From 8687b9533c67a551df928b28a776bfdbe6e3e84f Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 24 Aug 2018 11:11:29 -0700 Subject: Add getForwarderHelperForMakerAssetDataAsync method to forwarderHelperFactory --- packages/connect/src/http_client.ts | 2 +- packages/forwarder-helper/package.json | 5 +- .../src/forwarder_helper_factory.ts | 229 ++++++++++++++++++++- packages/forwarder-helper/src/types.ts | 5 + packages/forwarder-helper/src/utils/order_utils.ts | 16 ++ 5 files changed, 253 insertions(+), 4 deletions(-) create mode 100644 packages/forwarder-helper/src/utils/order_utils.ts diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index 87d5c30be..bdcfdd8d2 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -29,7 +29,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 v0 + * that implement the standard relayer API v2 */ export class HttpClient implements Client { private readonly _apiEndpointUrl: string; diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json index 410323f76..f849fb4ed 100644 --- a/packages/forwarder-helper/package.json +++ b/packages/forwarder-helper/package.json @@ -40,18 +40,21 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", "dependencies": { "@0xproject/assert": "^1.0.8", + "@0xproject/connect": "^2.0.0", + "@0xproject/contract-wrappers": "^1.0.1", "@0xproject/json-schemas": "^1.0.1", "@0xproject/order-utils": "^1.0.1", + "@0xproject/subproviders": "^2.0.2", "@0xproject/types": "^1.0.1", "@0xproject/typescript-typings": "^2.0.0", "@0xproject/utils": "^1.0.8", - "@types/node": "^8.0.53", "lodash": "^4.17.10" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "^4.14.116", "@types/mocha": "^2.2.42", + "@types/node": "^8.0.53", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index 95f11f555..e3ef59388 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -1,13 +1,22 @@ import { assert } from '@0xproject/assert'; +import { APIOrder, HttpClient } from '@0xproject/connect'; +import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; import { schemas } from '@0xproject/json-schemas'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; +import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; +import { constants } from './constants'; import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_helper_impl'; -import { ForwarderHelper } from './types'; +import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; +import { orderUtils } from './utils/order_utils'; export const forwarderHelperFactory = { /** - * Given an array of orders and an array of feeOrders + * Given an array of orders and an array of feeOrders, get a ForwarderHelper * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData * @return A ForwarderHelper, see type for definition @@ -22,4 +31,220 @@ export const forwarderHelperFactory = { const helper = new ForwarderHelperImpl(config); return helper; }, + /** + * Given a desired makerAsset and SRA url, get a ForwarderHelper + * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData + * @param sraUrl A url pointing to an SRA v2 compliant endpoint. + * @param rpcUrl A url pointing to an ethereum node. + * @param networkId The ethereum networkId, defaults to 1 (mainnet). + * @return A ForwarderHelper, see type for definition + */ + async getForwarderHelperForMakerAssetDataAsync( + makerAssetData: string, + takerAddress: string, + sraUrl: string, + rpcUrl?: string, + networkId: number = 1, + ): Promise { + assert.isHexString('makerAssetData', makerAssetData); + assert.isETHAddressHex('takerAddress', takerAddress); + assert.isWebUri('sraUrl', sraUrl); + if (!_.isUndefined(rpcUrl)) { + assert.isWebUri('rpcUrl', rpcUrl); + } + assert.isNumber('networkId', networkId); + // create provider + const providerEngine = new Web3ProviderEngine(); + if (!_.isUndefined(rpcUrl)) { + providerEngine.addProvider(new RPCSubprovider(rpcUrl)); + } + providerEngine.start(); + // create contract wrappers given provider and networkId + const contractWrappers = new ContractWrappers(providerEngine, { networkId }); + // find ether token asset data + const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); + if (_.isUndefined(etherTokenAddressIfExists)) { + throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); + } + const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); + // find zrx token asset data + let zrxTokenAssetData: string; + try { + zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); + } catch (err) { + throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); + } + // get orderbooks for makerAsset/WETH and ZRX/WETH + const sraClient = new HttpClient(sraUrl); + const orderbookRequests = [ + { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, + { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, + ]; + const requestOpts = { networkId }; + // TODO: try catch these requests and throw a more domain specific error + const [makerAssetOrderbook, zrxOrderbook] = await Promise.all( + _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), + ); + // validate orders and find remaining fillable from on chain state or sra api + let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; + let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; + if (!_.isUndefined(rpcUrl)) { + // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper + const ordersFromSra = _.map(makerAssetOrderbook.asks.records, apiOrder => apiOrder.order); + const feeOrdersFromSra = _.map(zrxOrderbook.asks.records, apiOrder => apiOrder.order); + // TODO: try catch these requests and throw a more domain specific error + const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( + _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { + const takerAddresses = _.map(ordersToBeValidated, () => takerAddress); + return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( + ordersToBeValidated, + takerAddresses, + ); + }), + ); + // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts + ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + ordersFromSra, + makerAssetOrdersAndTradersInfo, + zrxTokenAssetData, + ); + // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts + feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + feeOrdersFromSra, + feeOrdersAndTradersInfo, + zrxTokenAssetData, + ); + } else { + // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA + // if fill amounts are not available from the SRA, assume all orders are completely fillable + const apiOrdersFromSra = makerAssetOrderbook.asks.records; + const feeApiOrdersFromSra = zrxOrderbook.asks.records; + // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts + ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + apiOrdersFromSra, + ); + // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts + feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + feeApiOrdersFromSra, + ); + } + // compile final config + const config: ForwarderHelperImplConfig = { + orders: ordersAndRemainingFillableMakerAssetAmounts.orders, + feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, + remainingFillableMakerAssetAmounts: + ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts: + feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + }; + const helper = new ForwarderHelperImpl(config); + return helper; + }, }; + +interface OrdersAndRemainingFillableMakerAssetAmounts { + orders: SignedOrder[]; + remainingFillableMakerAssetAmounts: BigNumber[]; +} + +/** + * Given an array of APIOrder objects from a standard relayer api, return an array + * of fillable orders with their corresponding remainingFillableMakerAssetAmounts + */ +function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + apiOrders: APIOrder[], +): OrdersAndRemainingFillableMakerAssetAmounts { + const result = _.reduce( + apiOrders, + (acc, apiOrder, index) => { + // get current accumulations + const { orders, remainingFillableMakerAssetAmounts } = acc; + // get order and metadata + const { order, metaData } = apiOrder; + // if the order is expired, move on + if (orderUtils.isOrderExpired(order)) { + return acc; + } + // calculate remainingFillableMakerAssetAmount from api metadata + const remainingFillableTakerAssetAmount = _.get( + metaData, + 'remainingTakerAssetAmount', + order.takerAssetAmount, + ); + const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingFillableTakerAssetAmount, + ); + // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations + // if there is not any maker asset left to fill, do not add + if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { + return { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat( + remainingFillableMakerAssetAmounts, + remainingFillableMakerAssetAmount, + ), + }; + } else { + return acc; + } + }, + { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, + ); + return result; +} + +/** + * Given an array of orders and corresponding on-chain infos, return a subset of the orders + * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts + */ +function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + inputOrders: SignedOrder[], + ordersAndTradersInfo: OrderAndTraderInfo[], + zrxAssetData: string, +): OrdersAndRemainingFillableMakerAssetAmounts { + // iterate through the input orders and find the ones that are still fillable + // for the orders that are still fillable, calculate the remaining fillable maker asset amount + const result = _.reduce( + inputOrders, + (acc, order, index) => { + // get current accumulations + const { orders, remainingFillableMakerAssetAmounts } = acc; + // get corresponding on-chain state for the order + const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; + // if the order IS NOT fillable, do not add anything and continue iterating + if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { + return acc; + } + // if the order IS fillable, add the order and calculate the remaining fillable amount + const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); + const transferrableFeeAssetAmount = BigNumber.min([ + traderInfo.makerZrxAllowance, + traderInfo.makerZrxBalance, + ]); + const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); + const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingTakerAssetAmount, + ); + const remainingFillableCalculator = new RemainingFillableCalculator( + order.makerFee, + order.makerAssetAmount, + order.makerAssetData === zrxAssetData, + transferrableAssetAmount, + transferrableFeeAssetAmount, + remainingMakerAssetAmount, + ); + const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); + return { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat( + remainingFillableMakerAssetAmounts, + remainingFillableAmount, + ), + }; + }, + { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, + ); + return result; +} diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts index fb171cc90..5a8439257 100644 --- a/packages/forwarder-helper/src/types.ts +++ b/packages/forwarder-helper/src/types.ts @@ -1,6 +1,11 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +export enum ForwarderHelperFactoryError { + NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', + NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', +} + export interface ForwarderHelper { /** * Given a MarketBuyOrdersInfoRequest, returns a MarketBuyOrdersInfo containing all information relevant to fulfilling the request diff --git a/packages/forwarder-helper/src/utils/order_utils.ts b/packages/forwarder-helper/src/utils/order_utils.ts new file mode 100644 index 000000000..d14c6a6d7 --- /dev/null +++ b/packages/forwarder-helper/src/utils/order_utils.ts @@ -0,0 +1,16 @@ +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +export const orderUtils = { + isOrderExpired(order: SignedOrder): boolean { + const millisecondsInSecond = 1000; + const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round(); + return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec); + }, + calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { + const result = remainingTakerAssetAmount.eq(0) + ? new BigNumber(0) + : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); + return result; + }, +}; -- cgit From 8d6132736bfd57d08448cbde538c13072df80256 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 13 Sep 2018 14:39:06 +0200 Subject: Remove taker address as param and filter out non-open orders --- packages/forwarder-helper/src/constants.ts | 1 + .../forwarder-helper/src/forwarder_helper_factory.ts | 20 ++++++++++++-------- packages/forwarder-helper/src/utils/order_utils.ts | 5 +++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/forwarder-helper/src/constants.ts b/packages/forwarder-helper/src/constants.ts index 0ad30e4c0..c0a1b090e 100644 --- a/packages/forwarder-helper/src/constants.ts +++ b/packages/forwarder-helper/src/constants.ts @@ -2,4 +2,5 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { ZERO_AMOUNT: new BigNumber(0), + NULL_ADDRESS: '0x0000000000000000000000000000000000000000', }; diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index e3ef59388..ab8eaeeaf 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -1,5 +1,5 @@ import { assert } from '@0xproject/assert'; -import { APIOrder, HttpClient } from '@0xproject/connect'; +import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; import { schemas } from '@0xproject/json-schemas'; import { assetDataUtils } from '@0xproject/order-utils'; @@ -41,13 +41,11 @@ export const forwarderHelperFactory = { */ async getForwarderHelperForMakerAssetDataAsync( makerAssetData: string, - takerAddress: string, sraUrl: string, rpcUrl?: string, networkId: number = 1, ): Promise { assert.isHexString('makerAssetData', makerAssetData); - assert.isETHAddressHex('takerAddress', takerAddress); assert.isWebUri('sraUrl', sraUrl); if (!_.isUndefined(rpcUrl)) { assert.isWebUri('rpcUrl', rpcUrl); @@ -90,12 +88,12 @@ export const forwarderHelperFactory = { let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; if (!_.isUndefined(rpcUrl)) { // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper - const ordersFromSra = _.map(makerAssetOrderbook.asks.records, apiOrder => apiOrder.order); - const feeOrdersFromSra = _.map(zrxOrderbook.asks.records, apiOrder => apiOrder.order); + const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); + const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); // TODO: try catch these requests and throw a more domain specific error const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { - const takerAddresses = _.map(ordersToBeValidated, () => takerAddress); + const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( ordersToBeValidated, takerAddresses, @@ -161,8 +159,8 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( const { orders, remainingFillableMakerAssetAmounts } = acc; // get order and metadata const { order, metaData } = apiOrder; - // if the order is expired, move on - if (orderUtils.isOrderExpired(order)) { + // if the order is expired or not open, move on + if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { return acc; } // calculate remainingFillableMakerAssetAmount from api metadata @@ -248,3 +246,9 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( ); return result; } + +function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { + const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); + const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); + return result; +} diff --git a/packages/forwarder-helper/src/utils/order_utils.ts b/packages/forwarder-helper/src/utils/order_utils.ts index d14c6a6d7..482006bf1 100644 --- a/packages/forwarder-helper/src/utils/order_utils.ts +++ b/packages/forwarder-helper/src/utils/order_utils.ts @@ -1,6 +1,8 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +import { constants } from '../constants'; + export const orderUtils = { isOrderExpired(order: SignedOrder): boolean { const millisecondsInSecond = 1000; @@ -13,4 +15,7 @@ export const orderUtils = { : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); return result; }, + isOpenOrder(order: SignedOrder): boolean { + return order.takerAddress === constants.NULL_ADDRESS; + }, }; -- cgit From c0a14a4a4110f3fedea6624376eae4c86c02cda8 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 13 Sep 2018 14:44:53 +0200 Subject: Catch standard relayer api errors --- packages/forwarder-helper/src/forwarder_helper_factory.ts | 13 +++++++++---- packages/forwarder-helper/src/types.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index ab8eaeeaf..be38f2bd5 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -79,10 +79,15 @@ export const forwarderHelperFactory = { { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, ]; const requestOpts = { networkId }; - // TODO: try catch these requests and throw a more domain specific error - const [makerAssetOrderbook, zrxOrderbook] = await Promise.all( - _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), - ); + let makerAssetOrderbook: OrderbookResponse; + let zrxOrderbook: OrderbookResponse; + try { + [makerAssetOrderbook, zrxOrderbook] = await Promise.all( + _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), + ); + } catch (err) { + throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); + } // validate orders and find remaining fillable from on chain state or sra api let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts index 5a8439257..a7f02ff8d 100644 --- a/packages/forwarder-helper/src/types.ts +++ b/packages/forwarder-helper/src/types.ts @@ -4,6 +4,7 @@ import { BigNumber } from '@0xproject/utils'; export enum ForwarderHelperFactoryError { NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', + StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', } export interface ForwarderHelper { -- cgit From 90674d9038b45644e82545558d9937b9eec498f9 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 14 Sep 2018 13:42:37 +0200 Subject: Various clean up --- packages/forwarder-helper/src/forwarder_helper_factory.ts | 8 +++++--- packages/forwarder-helper/src/utils/order_utils.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index be38f2bd5..2b37ac98f 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -24,6 +24,7 @@ export const forwarderHelperFactory = { getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); + // TODO: Add assertion here for orders all having the same makerAsset and takerAsset const config: ForwarderHelperImplConfig = { orders, feeOrders, @@ -96,6 +97,7 @@ export const forwarderHelperFactory = { const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); // TODO: try catch these requests and throw a more domain specific error + // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); @@ -159,7 +161,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( ): OrdersAndRemainingFillableMakerAssetAmounts { const result = _.reduce( apiOrders, - (acc, apiOrder, index) => { + (acc, apiOrder) => { // get current accumulations const { orders, remainingFillableMakerAssetAmounts } = acc; // get order and metadata @@ -168,7 +170,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { return acc; } - // calculate remainingFillableMakerAssetAmount from api metadata + // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable const remainingFillableTakerAssetAmount = _.get( metaData, 'remainingTakerAssetAmount', @@ -215,7 +217,7 @@ function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( const { orders, remainingFillableMakerAssetAmounts } = acc; // get corresponding on-chain state for the order const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; - // if the order IS NOT fillable, do not add anything and continue iterating + // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { return acc; } diff --git a/packages/forwarder-helper/src/utils/order_utils.ts b/packages/forwarder-helper/src/utils/order_utils.ts index 482006bf1..bb0bdb80f 100644 --- a/packages/forwarder-helper/src/utils/order_utils.ts +++ b/packages/forwarder-helper/src/utils/order_utils.ts @@ -11,7 +11,7 @@ export const orderUtils = { }, calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { const result = remainingTakerAssetAmount.eq(0) - ? new BigNumber(0) + ? constants.ZERO_AMOUNT : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); return result; }, -- cgit From 91702bbae214f56e7ff66156fa799fcfb83f6e42 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 14 Sep 2018 13:45:14 +0200 Subject: Move packages/forwarder-helper into packages/asset-buyer --- packages/asset-buyer/.npmignore | 8 + packages/asset-buyer/CHANGELOG.json | 30 +++ packages/asset-buyer/CHANGELOG.md | 18 ++ packages/asset-buyer/README.md | 83 +++++++ packages/asset-buyer/package.json | 75 ++++++ packages/asset-buyer/src/constants.ts | 6 + .../asset-buyer/src/forwarder_helper_factory.ts | 261 +++++++++++++++++++++ packages/asset-buyer/src/forwarder_helper_impl.ts | 64 +++++ packages/asset-buyer/src/globals.d.ts | 6 + packages/asset-buyer/src/index.ts | 2 + packages/asset-buyer/src/types.ts | 49 ++++ .../utils/forwarder_helper_impl_config_utils.ts | 92 ++++++++ packages/asset-buyer/src/utils/order_utils.ts | 21 ++ .../asset-buyer/test/forwarder_helper_impl_test.ts | 136 +++++++++++ packages/asset-buyer/test/utils/chai_setup.ts | 13 + packages/asset-buyer/tsconfig.json | 8 + packages/asset-buyer/tslint.json | 3 + packages/asset-buyer/typedoc-tsconfig.json | 7 + packages/forwarder-helper/.npmignore | 8 - packages/forwarder-helper/CHANGELOG.json | 30 --- packages/forwarder-helper/CHANGELOG.md | 18 -- packages/forwarder-helper/README.md | 83 ------- packages/forwarder-helper/package.json | 75 ------ packages/forwarder-helper/src/constants.ts | 6 - .../src/forwarder_helper_factory.ts | 261 --------------------- .../forwarder-helper/src/forwarder_helper_impl.ts | 64 ----- packages/forwarder-helper/src/globals.d.ts | 6 - packages/forwarder-helper/src/index.ts | 2 - packages/forwarder-helper/src/types.ts | 49 ---- .../utils/forwarder_helper_impl_config_utils.ts | 92 -------- packages/forwarder-helper/src/utils/order_utils.ts | 21 -- .../test/forwarder_helper_impl_test.ts | 136 ----------- packages/forwarder-helper/test/utils/chai_setup.ts | 13 - packages/forwarder-helper/tsconfig.json | 8 - packages/forwarder-helper/tslint.json | 3 - packages/forwarder-helper/typedoc-tsconfig.json | 7 - 36 files changed, 882 insertions(+), 882 deletions(-) create mode 100644 packages/asset-buyer/.npmignore create mode 100644 packages/asset-buyer/CHANGELOG.json create mode 100644 packages/asset-buyer/CHANGELOG.md create mode 100644 packages/asset-buyer/README.md create mode 100644 packages/asset-buyer/package.json create mode 100644 packages/asset-buyer/src/constants.ts create mode 100644 packages/asset-buyer/src/forwarder_helper_factory.ts create mode 100644 packages/asset-buyer/src/forwarder_helper_impl.ts create mode 100644 packages/asset-buyer/src/globals.d.ts create mode 100644 packages/asset-buyer/src/index.ts create mode 100644 packages/asset-buyer/src/types.ts create mode 100644 packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts create mode 100644 packages/asset-buyer/src/utils/order_utils.ts create mode 100644 packages/asset-buyer/test/forwarder_helper_impl_test.ts create mode 100644 packages/asset-buyer/test/utils/chai_setup.ts create mode 100644 packages/asset-buyer/tsconfig.json create mode 100644 packages/asset-buyer/tslint.json create mode 100644 packages/asset-buyer/typedoc-tsconfig.json delete mode 100644 packages/forwarder-helper/.npmignore delete mode 100644 packages/forwarder-helper/CHANGELOG.json delete mode 100644 packages/forwarder-helper/CHANGELOG.md delete mode 100644 packages/forwarder-helper/README.md delete mode 100644 packages/forwarder-helper/package.json delete mode 100644 packages/forwarder-helper/src/constants.ts delete mode 100644 packages/forwarder-helper/src/forwarder_helper_factory.ts delete mode 100644 packages/forwarder-helper/src/forwarder_helper_impl.ts delete mode 100644 packages/forwarder-helper/src/globals.d.ts delete mode 100644 packages/forwarder-helper/src/index.ts delete mode 100644 packages/forwarder-helper/src/types.ts delete mode 100644 packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts delete mode 100644 packages/forwarder-helper/src/utils/order_utils.ts delete mode 100644 packages/forwarder-helper/test/forwarder_helper_impl_test.ts delete mode 100644 packages/forwarder-helper/test/utils/chai_setup.ts delete mode 100644 packages/forwarder-helper/tsconfig.json delete mode 100644 packages/forwarder-helper/tslint.json delete mode 100644 packages/forwarder-helper/typedoc-tsconfig.json diff --git a/packages/asset-buyer/.npmignore b/packages/asset-buyer/.npmignore new file mode 100644 index 000000000..5333847e7 --- /dev/null +++ b/packages/asset-buyer/.npmignore @@ -0,0 +1,8 @@ +.* +yarn-error.log +/src/ +/scripts/ +/schemas/ +test/ +tsconfig.json +/lib/src/monorepo_scripts/ diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json new file mode 100644 index 000000000..f0e646700 --- /dev/null +++ b/packages/asset-buyer/CHANGELOG.json @@ -0,0 +1,30 @@ +[ + { + "timestamp": 1536142250, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "1.0.1-rc.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1535377027 + }, + { + "version": "1.0.1-rc.1", + "changes": [ + { + "note": "Add initial forwarderHelperFactory", + "pr": 997 + } + ], + "timestamp": 1535133899 + } +] diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md new file mode 100644 index 000000000..d6b67aa1b --- /dev/null +++ b/packages/asset-buyer/CHANGELOG.md @@ -0,0 +1,18 @@ + + +CHANGELOG + +## v1.0.1 - _September 5, 2018_ + + * Dependencies updated + +## v1.0.1-rc.2 - _August 27, 2018_ + + * Dependencies updated + +## v1.0.1-rc.1 - _August 24, 2018_ + + * Add initial forwarderHelperFactory (#997) diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md new file mode 100644 index 000000000..c74526910 --- /dev/null +++ b/packages/asset-buyer/README.md @@ -0,0 +1,83 @@ +## @0xproject/forwarder-helper + +Provides convenience objects to help work with the Forwarder Contract + +### Read the [Documentation](https://0xproject.com/docs/forwarder-helper). + +## Installation + +```bash +yarn add @0xproject/forwarder-helper +``` + +**Import** + +```typescript +import { forwarderHelperFactory } from '@0xproject/forwarder-helper'; +``` + +or + +```javascript +var forwarderHelperFactory = require('@0xproject/forwarder-helper').forwarderHelperFactory; +``` + +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0xproject/forwarder-helper yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0xproject/forwarder-helper yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json new file mode 100644 index 000000000..f849fb4ed --- /dev/null +++ b/packages/asset-buyer/package.json @@ -0,0 +1,75 @@ +{ + "name": "@0xproject/forwarder-helper", + "version": "1.0.1", + "engines": { + "node": ">=6.12" + }, + "description": "Convenience object for working with the forwarder contract", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "watch_without_deps": "tsc -w", + "lint": "tslint --project .", + "test": "yarn run_mocha", + "rebuild_and_test": "run-s clean build test", + "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", + "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", + "test:circleci": "yarn test:coverage", + "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", + "clean": "shx rm -rf lib test_temp scripts", + "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", + "manual:postpublish": "yarn build; node ./scripts/postpublish.js", + "docs:stage": "node scripts/stage_docs.js", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --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" + }, + "config": { + "postpublish": { + "assets": [] + } + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "author": "", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", + "dependencies": { + "@0xproject/assert": "^1.0.8", + "@0xproject/connect": "^2.0.0", + "@0xproject/contract-wrappers": "^1.0.1", + "@0xproject/json-schemas": "^1.0.1", + "@0xproject/order-utils": "^1.0.1", + "@0xproject/subproviders": "^2.0.2", + "@0xproject/types": "^1.0.1", + "@0xproject/typescript-typings": "^2.0.0", + "@0xproject/utils": "^1.0.8", + "lodash": "^4.17.10" + }, + "devDependencies": { + "@0xproject/tslint-config": "^1.0.7", + "@types/lodash": "^4.14.116", + "@types/mocha": "^2.2.42", + "@types/node": "^8.0.53", + "chai": "^4.0.1", + "chai-as-promised": "^7.1.0", + "chai-bignumber": "^2.0.1", + "copyfiles": "^1.2.0", + "dirty-chai": "^2.0.1", + "make-promises-safe": "^1.1.0", + "mocha": "^4.1.0", + "npm-run-all": "^4.1.2", + "nyc": "^11.0.1", + "shx": "^0.2.2", + "tslint": "5.11.0", + "typedoc": "0.12.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts new file mode 100644 index 000000000..c0a1b090e --- /dev/null +++ b/packages/asset-buyer/src/constants.ts @@ -0,0 +1,6 @@ +import { BigNumber } from '@0xproject/utils'; + +export const constants = { + ZERO_AMOUNT: new BigNumber(0), + NULL_ADDRESS: '0x0000000000000000000000000000000000000000', +}; diff --git a/packages/asset-buyer/src/forwarder_helper_factory.ts b/packages/asset-buyer/src/forwarder_helper_factory.ts new file mode 100644 index 000000000..2b37ac98f --- /dev/null +++ b/packages/asset-buyer/src/forwarder_helper_factory.ts @@ -0,0 +1,261 @@ +import { assert } from '@0xproject/assert'; +import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; +import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; +import { schemas } from '@0xproject/json-schemas'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; +import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from './constants'; +import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_helper_impl'; +import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; +import { orderUtils } from './utils/order_utils'; + +export const forwarderHelperFactory = { + /** + * Given an array of orders and an array of feeOrders, get a ForwarderHelper + * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData + * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData + * @return A ForwarderHelper, see type for definition + */ + getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { + assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); + assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); + // TODO: Add assertion here for orders all having the same makerAsset and takerAsset + const config: ForwarderHelperImplConfig = { + orders, + feeOrders, + }; + const helper = new ForwarderHelperImpl(config); + return helper; + }, + /** + * Given a desired makerAsset and SRA url, get a ForwarderHelper + * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData + * @param sraUrl A url pointing to an SRA v2 compliant endpoint. + * @param rpcUrl A url pointing to an ethereum node. + * @param networkId The ethereum networkId, defaults to 1 (mainnet). + * @return A ForwarderHelper, see type for definition + */ + async getForwarderHelperForMakerAssetDataAsync( + makerAssetData: string, + sraUrl: string, + rpcUrl?: string, + networkId: number = 1, + ): Promise { + assert.isHexString('makerAssetData', makerAssetData); + assert.isWebUri('sraUrl', sraUrl); + if (!_.isUndefined(rpcUrl)) { + assert.isWebUri('rpcUrl', rpcUrl); + } + assert.isNumber('networkId', networkId); + // create provider + const providerEngine = new Web3ProviderEngine(); + if (!_.isUndefined(rpcUrl)) { + providerEngine.addProvider(new RPCSubprovider(rpcUrl)); + } + providerEngine.start(); + // create contract wrappers given provider and networkId + const contractWrappers = new ContractWrappers(providerEngine, { networkId }); + // find ether token asset data + const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); + if (_.isUndefined(etherTokenAddressIfExists)) { + throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); + } + const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); + // find zrx token asset data + let zrxTokenAssetData: string; + try { + zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); + } catch (err) { + throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); + } + // get orderbooks for makerAsset/WETH and ZRX/WETH + const sraClient = new HttpClient(sraUrl); + const orderbookRequests = [ + { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, + { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, + ]; + const requestOpts = { networkId }; + let makerAssetOrderbook: OrderbookResponse; + let zrxOrderbook: OrderbookResponse; + try { + [makerAssetOrderbook, zrxOrderbook] = await Promise.all( + _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), + ); + } catch (err) { + throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); + } + // validate orders and find remaining fillable from on chain state or sra api + let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; + let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; + if (!_.isUndefined(rpcUrl)) { + // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper + const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); + const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); + // TODO: try catch these requests and throw a more domain specific error + // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response + const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( + _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { + const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); + return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( + ordersToBeValidated, + takerAddresses, + ); + }), + ); + // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts + ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + ordersFromSra, + makerAssetOrdersAndTradersInfo, + zrxTokenAssetData, + ); + // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts + feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + feeOrdersFromSra, + feeOrdersAndTradersInfo, + zrxTokenAssetData, + ); + } else { + // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA + // if fill amounts are not available from the SRA, assume all orders are completely fillable + const apiOrdersFromSra = makerAssetOrderbook.asks.records; + const feeApiOrdersFromSra = zrxOrderbook.asks.records; + // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts + ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + apiOrdersFromSra, + ); + // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts + feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + feeApiOrdersFromSra, + ); + } + // compile final config + const config: ForwarderHelperImplConfig = { + orders: ordersAndRemainingFillableMakerAssetAmounts.orders, + feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, + remainingFillableMakerAssetAmounts: + ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts: + feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + }; + const helper = new ForwarderHelperImpl(config); + return helper; + }, +}; + +interface OrdersAndRemainingFillableMakerAssetAmounts { + orders: SignedOrder[]; + remainingFillableMakerAssetAmounts: BigNumber[]; +} + +/** + * Given an array of APIOrder objects from a standard relayer api, return an array + * of fillable orders with their corresponding remainingFillableMakerAssetAmounts + */ +function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( + apiOrders: APIOrder[], +): OrdersAndRemainingFillableMakerAssetAmounts { + const result = _.reduce( + apiOrders, + (acc, apiOrder) => { + // get current accumulations + const { orders, remainingFillableMakerAssetAmounts } = acc; + // get order and metadata + const { order, metaData } = apiOrder; + // if the order is expired or not open, move on + if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { + return acc; + } + // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable + const remainingFillableTakerAssetAmount = _.get( + metaData, + 'remainingTakerAssetAmount', + order.takerAssetAmount, + ); + const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingFillableTakerAssetAmount, + ); + // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations + // if there is not any maker asset left to fill, do not add + if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { + return { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat( + remainingFillableMakerAssetAmounts, + remainingFillableMakerAssetAmount, + ), + }; + } else { + return acc; + } + }, + { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, + ); + return result; +} + +/** + * Given an array of orders and corresponding on-chain infos, return a subset of the orders + * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts + */ +function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( + inputOrders: SignedOrder[], + ordersAndTradersInfo: OrderAndTraderInfo[], + zrxAssetData: string, +): OrdersAndRemainingFillableMakerAssetAmounts { + // iterate through the input orders and find the ones that are still fillable + // for the orders that are still fillable, calculate the remaining fillable maker asset amount + const result = _.reduce( + inputOrders, + (acc, order, index) => { + // get current accumulations + const { orders, remainingFillableMakerAssetAmounts } = acc; + // get corresponding on-chain state for the order + const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; + // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating + if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { + return acc; + } + // if the order IS fillable, add the order and calculate the remaining fillable amount + const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); + const transferrableFeeAssetAmount = BigNumber.min([ + traderInfo.makerZrxAllowance, + traderInfo.makerZrxBalance, + ]); + const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); + const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingTakerAssetAmount, + ); + const remainingFillableCalculator = new RemainingFillableCalculator( + order.makerFee, + order.makerAssetAmount, + order.makerAssetData === zrxAssetData, + transferrableAssetAmount, + transferrableFeeAssetAmount, + remainingMakerAssetAmount, + ); + const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); + return { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat( + remainingFillableMakerAssetAmounts, + remainingFillableAmount, + ), + }; + }, + { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, + ); + return result; +} + +function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { + const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); + const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); + return result; +} diff --git a/packages/asset-buyer/src/forwarder_helper_impl.ts b/packages/asset-buyer/src/forwarder_helper_impl.ts new file mode 100644 index 000000000..a90edb0bb --- /dev/null +++ b/packages/asset-buyer/src/forwarder_helper_impl.ts @@ -0,0 +1,64 @@ +import { marketUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from './constants'; +import { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfo, MarketBuyOrdersInfoRequest } from './types'; +import { forwarderHelperImplConfigUtils } from './utils/forwarder_helper_impl_config_utils'; + +const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface + +export interface ForwarderHelperImplConfig { + orders: SignedOrder[]; + feeOrders: SignedOrder[]; + remainingFillableMakerAssetAmounts?: BigNumber[]; + remainingFillableFeeAmounts?: BigNumber[]; +} + +export class ForwarderHelperImpl implements ForwarderHelper { + public readonly config: ForwarderHelperImplConfig; + constructor(config: ForwarderHelperImplConfig) { + this.config = forwarderHelperImplConfigUtils.sortedConfig(config); + } + public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo { + const { makerAssetFillAmount, feePercentage } = request; + const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config; + // TODO: make the slippage percentage customizable + const slippageBufferAmount = makerAssetFillAmount.mul(SLIPPAGE_PERCENTAGE).round(); + const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( + orders, + makerAssetFillAmount, + { + remainingFillableMakerAssetAmounts, + slippageBufferAmount, + }, + ); + if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(ForwarderHelperError.InsufficientMakerAssetLiquidity); + } + // TODO: update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to + // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage + const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( + resultOrders, + feeOrders, + { + remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts, + }, + ); + if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(ForwarderHelperError.InsufficientZrxLiquidity); + } + // TODO: calculate min and max eth usage + // TODO: optimize orders call data + return { + makerAssetFillAmount, + orders: resultOrders, + feeOrders: resultFeeOrders, + minEthAmount: constants.ZERO_AMOUNT, + maxEthAmount: constants.ZERO_AMOUNT, + feePercentage, + }; + } +} diff --git a/packages/asset-buyer/src/globals.d.ts b/packages/asset-buyer/src/globals.d.ts new file mode 100644 index 000000000..94e63a32d --- /dev/null +++ b/packages/asset-buyer/src/globals.d.ts @@ -0,0 +1,6 @@ +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts new file mode 100644 index 000000000..eb3a34bd5 --- /dev/null +++ b/packages/asset-buyer/src/index.ts @@ -0,0 +1,2 @@ +export { forwarderHelperFactory } from './forwarder_helper_factory'; +export { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfoRequest, MarketBuyOrdersInfo } from './types'; diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts new file mode 100644 index 000000000..a7f02ff8d --- /dev/null +++ b/packages/asset-buyer/src/types.ts @@ -0,0 +1,49 @@ +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +export enum ForwarderHelperFactoryError { + NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', + NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', + StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', +} + +export interface ForwarderHelper { + /** + * Given a MarketBuyOrdersInfoRequest, returns a MarketBuyOrdersInfo containing all information relevant to fulfilling the request + * using the ForwarderContract marketBuyOrdersWithEth function. + * @param request An object that conforms to MarketBuyOrdersInfoRequest. See type definition for more information. + * @return An object that conforms to MarketBuyOrdersInfo that satisfies the request. See type definition for more information. + */ + getMarketBuyOrdersInfo: (request: MarketBuyOrdersInfoRequest) => MarketBuyOrdersInfo; +} + +export enum ForwarderHelperError { + InsufficientMakerAssetLiquidity = 'INSUFFICIENT_MAKER_ASSET_LIQUIDITY', + InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', +} + +/** + * makerAssetFillAmount: The amount of makerAsset requesting to be filled + * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations + */ +export interface MarketBuyOrdersInfoRequest { + makerAssetFillAmount: BigNumber; + feePercentage?: BigNumber; +} + +/** + * makerAssetFillAmount: The amount of makerAsset requesting to be filled + * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested makerAssetFillAmount plus slippage + * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above + * minEthAmount: Amount of eth in wei to send with the tx for the most optimistic case + * maxEthAmount: Amount of eth in wei to send with the tx for the worst case + * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed thru directly from the request + */ +export interface MarketBuyOrdersInfo { + makerAssetFillAmount: BigNumber; + orders: SignedOrder[]; + feeOrders: SignedOrder[]; + minEthAmount: BigNumber; + maxEthAmount: BigNumber; + feePercentage?: BigNumber; +} diff --git a/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts b/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts new file mode 100644 index 000000000..253384f65 --- /dev/null +++ b/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts @@ -0,0 +1,92 @@ +import { sortingUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { ForwarderHelperImplConfig } from '../forwarder_helper_impl'; + +interface SignedOrderWithAmount extends SignedOrder { + remainingFillAmount: BigNumber; +} + +export const forwarderHelperImplConfigUtils = { + sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig { + const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config; + // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens + const orderSorter = (ordersToSort: SignedOrder[]) => { + return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort); + }; + const sortOrdersResult = sortOrdersAndRemainingFillAmounts( + orderSorter, + orders, + remainingFillableMakerAssetAmounts, + ); + const feeOrderSorter = (ordersToSort: SignedOrder[]) => { + return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort); + }; + const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts( + feeOrderSorter, + feeOrders, + remainingFillableFeeAmounts, + ); + return { + orders: sortOrdersResult.orders, + feeOrders: sortFeeOrdersResult.orders, + remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts, + remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts, + }; + }, +}; + +type OrderSorter = (orders: SignedOrder[]) => SignedOrder[]; + +function sortOrdersAndRemainingFillAmounts( + orderSorter: OrderSorter, + orders: SignedOrder[], + remainingFillAmounts?: BigNumber[], +): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } { + if (!_.isUndefined(remainingFillAmounts)) { + // Bundle orders together with their remainingFillAmounts so that we can sort them together + const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts); + // Sort + const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[]; + // Unbundle after sorting + const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts); + return { + orders: unbundledSortedOrderWithAmounts.orders, + remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts, + }; + } else { + const sortedOrders = orderSorter(orders); + return { + orders: sortedOrders, + }; + } +} + +function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] { + const ordersAndAmounts = _.map(orders, (order, index) => { + return { + ...order, + remainingFillAmount: amounts[index], + }; + }); + return ordersAndAmounts; +} + +function unbundleSignedOrderWithAmounts( + signedOrderWithAmounts: SignedOrderWithAmount[], +): { orders: SignedOrder[]; amounts: BigNumber[] } { + const orders = _.map(signedOrderWithAmounts, order => { + const { remainingFillAmount, ...rest } = order; + return rest; + }); + const amounts = _.map(signedOrderWithAmounts, order => { + const { remainingFillAmount } = order; + return remainingFillAmount; + }); + return { + orders, + amounts, + }; +} diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts new file mode 100644 index 000000000..bb0bdb80f --- /dev/null +++ b/packages/asset-buyer/src/utils/order_utils.ts @@ -0,0 +1,21 @@ +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +import { constants } from '../constants'; + +export const orderUtils = { + isOrderExpired(order: SignedOrder): boolean { + const millisecondsInSecond = 1000; + const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round(); + return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec); + }, + calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { + const result = remainingTakerAssetAmount.eq(0) + ? constants.ZERO_AMOUNT + : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); + return result; + }, + isOpenOrder(order: SignedOrder): boolean { + return order.takerAddress === constants.NULL_ADDRESS; + }, +}; diff --git a/packages/asset-buyer/test/forwarder_helper_impl_test.ts b/packages/asset-buyer/test/forwarder_helper_impl_test.ts new file mode 100644 index 000000000..3c3b6db92 --- /dev/null +++ b/packages/asset-buyer/test/forwarder_helper_impl_test.ts @@ -0,0 +1,136 @@ +import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory'; +import { BigNumber } from '@0xproject/utils'; +import * as chai from 'chai'; +import * as _ from 'lodash'; +import 'mocha'; + +import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '../src/forwarder_helper_impl'; +import { ForwarderHelperError } from '../src/types'; + +import { chaiSetup } from './utils/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +describe('ForwarderHelperImpl', () => { + // rate: 2 takerAsset / makerAsset + const testOrder1 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(200), + }); + // rate: 1 takerAsset / makerAsset + const testOrder2 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(100), + }); + // rate: 3 takerAsset / makerAsset + const testOrder3 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(300), + takerFee: new BigNumber(1), + }); + // rate: 3 WETH / ZRX + const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(300), + }); + // rate: 2 WETH / ZRX + const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(200), + }); + // rate: 1 WETH / ZRX + const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({ + makerAssetAmount: new BigNumber(100), + takerAssetAmount: new BigNumber(100), + }); + const inputForwarderHelperConfig: ForwarderHelperImplConfig = { + orders: [testOrder1, testOrder2, testOrder3], + feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], + remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)], + remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)], + }; + describe('#constructor', () => { + const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = { + orders: [testOrder1, testOrder2, testOrder3], + feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], + }; + it('sorts orders', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]); + }); + it('sorts fee orders', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]); + }); + it('sorts remainingFillableMakerAssetAmounts', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined(); + expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal( + new BigNumber(2), + ); + expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal( + new BigNumber(1), + ); + expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal( + new BigNumber(3), + ); + }); + it('sorts remainingFillableFeeAmounts', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined(); + expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6)); + expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5)); + expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4)); + }); + it('remainingFillableMakerAssetAmounts is undefined if none provided', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); + expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined(); + }); + it('remainingFillableFeeAmounts is undefined if none provided', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); + expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined(); + }); + }); + describe('#getMarketBuyOrdersInfo', () => { + it('throws if not enough makerAsset liquidity', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + expect(() => { + // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer + forwarderHelper.getMarketBuyOrdersInfo({ + makerAssetFillAmount: new BigNumber(6), + }); + }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity); + }); + it('throws if not enough ZRX liquidity', () => { + const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = { + orders: [testOrder1, testOrder2, testOrder3], + feeOrders: [], + }; + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees); + expect(() => { + // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw + forwarderHelper.getMarketBuyOrdersInfo({ + makerAssetFillAmount: new BigNumber(250), + }); + }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity); + }); + it('passes the makerAssetFillAmount from the request to the info response', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + const makerAssetFillAmount = new BigNumber(4); + const info = forwarderHelper.getMarketBuyOrdersInfo({ + makerAssetFillAmount, + }); + expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount); + }); + it('passes the feePercentage from the request to the info response', () => { + const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); + const feePercentage = new BigNumber(0.2); + const info = forwarderHelper.getMarketBuyOrdersInfo({ + makerAssetFillAmount: new BigNumber(4), + feePercentage, + }); + expect(info.feePercentage).to.bignumber.equal(feePercentage); + }); + }); +}); diff --git a/packages/asset-buyer/test/utils/chai_setup.ts b/packages/asset-buyer/test/utils/chai_setup.ts new file mode 100644 index 000000000..1a8733093 --- /dev/null +++ b/packages/asset-buyer/test/utils/chai_setup.ts @@ -0,0 +1,13 @@ +import * as chai from 'chai'; +import chaiAsPromised = require('chai-as-promised'); +import ChaiBigNumber = require('chai-bignumber'); +import * as dirtyChai from 'dirty-chai'; + +export const chaiSetup = { + configure(): void { + chai.config.includeStack = true; + chai.use(ChaiBigNumber()); + chai.use(dirtyChai); + chai.use(chaiAsPromised); + }, +}; diff --git a/packages/asset-buyer/tsconfig.json b/packages/asset-buyer/tsconfig.json new file mode 100644 index 000000000..2ee711adc --- /dev/null +++ b/packages/asset-buyer/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*", "./test/**/*"] +} diff --git a/packages/asset-buyer/tslint.json b/packages/asset-buyer/tslint.json new file mode 100644 index 000000000..ffaefe83a --- /dev/null +++ b/packages/asset-buyer/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0xproject/tslint-config"] +} diff --git a/packages/asset-buyer/typedoc-tsconfig.json b/packages/asset-buyer/typedoc-tsconfig.json new file mode 100644 index 000000000..c9b0af1ae --- /dev/null +++ b/packages/asset-buyer/typedoc-tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../typedoc-tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*", "./test/**/*"] +} diff --git a/packages/forwarder-helper/.npmignore b/packages/forwarder-helper/.npmignore deleted file mode 100644 index 5333847e7..000000000 --- a/packages/forwarder-helper/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -.* -yarn-error.log -/src/ -/scripts/ -/schemas/ -test/ -tsconfig.json -/lib/src/monorepo_scripts/ diff --git a/packages/forwarder-helper/CHANGELOG.json b/packages/forwarder-helper/CHANGELOG.json deleted file mode 100644 index f0e646700..000000000 --- a/packages/forwarder-helper/CHANGELOG.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "timestamp": 1536142250, - "version": "1.0.1", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "1.0.1-rc.2", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1535377027 - }, - { - "version": "1.0.1-rc.1", - "changes": [ - { - "note": "Add initial forwarderHelperFactory", - "pr": 997 - } - ], - "timestamp": 1535133899 - } -] diff --git a/packages/forwarder-helper/CHANGELOG.md b/packages/forwarder-helper/CHANGELOG.md deleted file mode 100644 index d6b67aa1b..000000000 --- a/packages/forwarder-helper/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ - - -CHANGELOG - -## v1.0.1 - _September 5, 2018_ - - * Dependencies updated - -## v1.0.1-rc.2 - _August 27, 2018_ - - * Dependencies updated - -## v1.0.1-rc.1 - _August 24, 2018_ - - * Add initial forwarderHelperFactory (#997) diff --git a/packages/forwarder-helper/README.md b/packages/forwarder-helper/README.md deleted file mode 100644 index c74526910..000000000 --- a/packages/forwarder-helper/README.md +++ /dev/null @@ -1,83 +0,0 @@ -## @0xproject/forwarder-helper - -Provides convenience objects to help work with the Forwarder Contract - -### Read the [Documentation](https://0xproject.com/docs/forwarder-helper). - -## Installation - -```bash -yarn add @0xproject/forwarder-helper -``` - -**Import** - -```typescript -import { forwarderHelperFactory } from '@0xproject/forwarder-helper'; -``` - -or - -```javascript -var forwarderHelperFactory = require('@0xproject/forwarder-helper').forwarderHelperFactory; -``` - -If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: - -```json -"compilerOptions": { - "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], -} -``` - -## Contributing - -We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. - -Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. - -### Install dependencies - -If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: - -```bash -yarn config set workspaces-experimental true -``` - -Then install dependencies - -```bash -yarn install -``` - -### Build - -To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: - -```bash -PKG=@0xproject/forwarder-helper yarn build -``` - -Or continuously rebuild on change: - -```bash -PKG=@0xproject/forwarder-helper yarn watch -``` - -### Clean - -```bash -yarn clean -``` - -### Lint - -```bash -yarn lint -``` - -### Run Tests - -```bash -yarn test -``` diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json deleted file mode 100644 index f849fb4ed..000000000 --- a/packages/forwarder-helper/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@0xproject/forwarder-helper", - "version": "1.0.1", - "engines": { - "node": ">=6.12" - }, - "description": "Convenience object for working with the forwarder contract", - "main": "lib/src/index.js", - "types": "lib/src/index.d.ts", - "scripts": { - "watch_without_deps": "tsc -w", - "lint": "tslint --project .", - "test": "yarn run_mocha", - "rebuild_and_test": "run-s clean build test", - "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", - "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", - "test:circleci": "yarn test:coverage", - "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", - "clean": "shx rm -rf lib test_temp scripts", - "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js", - "docs:stage": "node scripts/stage_docs.js", - "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --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" - }, - "config": { - "postpublish": { - "assets": [] - } - }, - "repository": { - "type": "git", - "url": "https://github.com/0xProject/0x-monorepo.git" - }, - "author": "", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", - "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/connect": "^2.0.0", - "@0xproject/contract-wrappers": "^1.0.1", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.1", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "lodash": "^4.17.10" - }, - "devDependencies": { - "@0xproject/tslint-config": "^1.0.7", - "@types/lodash": "^4.14.116", - "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", - "chai": "^4.0.1", - "chai-as-promised": "^7.1.0", - "chai-bignumber": "^2.0.1", - "copyfiles": "^1.2.0", - "dirty-chai": "^2.0.1", - "make-promises-safe": "^1.1.0", - "mocha": "^4.1.0", - "npm-run-all": "^4.1.2", - "nyc": "^11.0.1", - "shx": "^0.2.2", - "tslint": "5.11.0", - "typedoc": "0.12.0", - "typescript": "3.0.1" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/forwarder-helper/src/constants.ts b/packages/forwarder-helper/src/constants.ts deleted file mode 100644 index c0a1b090e..000000000 --- a/packages/forwarder-helper/src/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BigNumber } from '@0xproject/utils'; - -export const constants = { - ZERO_AMOUNT: new BigNumber(0), - NULL_ADDRESS: '0x0000000000000000000000000000000000000000', -}; diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts deleted file mode 100644 index 2b37ac98f..000000000 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ /dev/null @@ -1,261 +0,0 @@ -import { assert } from '@0xproject/assert'; -import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; -import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; -import { schemas } from '@0xproject/json-schemas'; -import { assetDataUtils } from '@0xproject/order-utils'; -import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; -import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { constants } from './constants'; -import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_helper_impl'; -import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; -import { orderUtils } from './utils/order_utils'; - -export const forwarderHelperFactory = { - /** - * Given an array of orders and an array of feeOrders, get a ForwarderHelper - * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData - * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData - * @return A ForwarderHelper, see type for definition - */ - getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { - assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); - assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); - // TODO: Add assertion here for orders all having the same makerAsset and takerAsset - const config: ForwarderHelperImplConfig = { - orders, - feeOrders, - }; - const helper = new ForwarderHelperImpl(config); - return helper; - }, - /** - * Given a desired makerAsset and SRA url, get a ForwarderHelper - * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData - * @param sraUrl A url pointing to an SRA v2 compliant endpoint. - * @param rpcUrl A url pointing to an ethereum node. - * @param networkId The ethereum networkId, defaults to 1 (mainnet). - * @return A ForwarderHelper, see type for definition - */ - async getForwarderHelperForMakerAssetDataAsync( - makerAssetData: string, - sraUrl: string, - rpcUrl?: string, - networkId: number = 1, - ): Promise { - assert.isHexString('makerAssetData', makerAssetData); - assert.isWebUri('sraUrl', sraUrl); - if (!_.isUndefined(rpcUrl)) { - assert.isWebUri('rpcUrl', rpcUrl); - } - assert.isNumber('networkId', networkId); - // create provider - const providerEngine = new Web3ProviderEngine(); - if (!_.isUndefined(rpcUrl)) { - providerEngine.addProvider(new RPCSubprovider(rpcUrl)); - } - providerEngine.start(); - // create contract wrappers given provider and networkId - const contractWrappers = new ContractWrappers(providerEngine, { networkId }); - // find ether token asset data - const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); - if (_.isUndefined(etherTokenAddressIfExists)) { - throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); - } - const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); - // find zrx token asset data - let zrxTokenAssetData: string; - try { - zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); - } catch (err) { - throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); - } - // get orderbooks for makerAsset/WETH and ZRX/WETH - const sraClient = new HttpClient(sraUrl); - const orderbookRequests = [ - { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, - { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, - ]; - const requestOpts = { networkId }; - let makerAssetOrderbook: OrderbookResponse; - let zrxOrderbook: OrderbookResponse; - try { - [makerAssetOrderbook, zrxOrderbook] = await Promise.all( - _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), - ); - } catch (err) { - throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); - } - // validate orders and find remaining fillable from on chain state or sra api - let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; - let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; - if (!_.isUndefined(rpcUrl)) { - // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper - const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); - const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); - // TODO: try catch these requests and throw a more domain specific error - // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response - const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( - _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { - const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); - return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( - ordersToBeValidated, - takerAddresses, - ); - }), - ); - // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts - ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - ordersFromSra, - makerAssetOrdersAndTradersInfo, - zrxTokenAssetData, - ); - // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts - feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - feeOrdersFromSra, - feeOrdersAndTradersInfo, - zrxTokenAssetData, - ); - } else { - // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA - // if fill amounts are not available from the SRA, assume all orders are completely fillable - const apiOrdersFromSra = makerAssetOrderbook.asks.records; - const feeApiOrdersFromSra = zrxOrderbook.asks.records; - // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts - ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - apiOrdersFromSra, - ); - // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts - feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - feeApiOrdersFromSra, - ); - } - // compile final config - const config: ForwarderHelperImplConfig = { - orders: ordersAndRemainingFillableMakerAssetAmounts.orders, - feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, - remainingFillableMakerAssetAmounts: - ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts: - feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - }; - const helper = new ForwarderHelperImpl(config); - return helper; - }, -}; - -interface OrdersAndRemainingFillableMakerAssetAmounts { - orders: SignedOrder[]; - remainingFillableMakerAssetAmounts: BigNumber[]; -} - -/** - * Given an array of APIOrder objects from a standard relayer api, return an array - * of fillable orders with their corresponding remainingFillableMakerAssetAmounts - */ -function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - apiOrders: APIOrder[], -): OrdersAndRemainingFillableMakerAssetAmounts { - const result = _.reduce( - apiOrders, - (acc, apiOrder) => { - // get current accumulations - const { orders, remainingFillableMakerAssetAmounts } = acc; - // get order and metadata - const { order, metaData } = apiOrder; - // if the order is expired or not open, move on - if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { - return acc; - } - // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable - const remainingFillableTakerAssetAmount = _.get( - metaData, - 'remainingTakerAssetAmount', - order.takerAssetAmount, - ); - const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingFillableTakerAssetAmount, - ); - // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations - // if there is not any maker asset left to fill, do not add - if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { - return { - orders: _.concat(orders, order), - remainingFillableMakerAssetAmounts: _.concat( - remainingFillableMakerAssetAmounts, - remainingFillableMakerAssetAmount, - ), - }; - } else { - return acc; - } - }, - { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, - ); - return result; -} - -/** - * Given an array of orders and corresponding on-chain infos, return a subset of the orders - * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts - */ -function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - inputOrders: SignedOrder[], - ordersAndTradersInfo: OrderAndTraderInfo[], - zrxAssetData: string, -): OrdersAndRemainingFillableMakerAssetAmounts { - // iterate through the input orders and find the ones that are still fillable - // for the orders that are still fillable, calculate the remaining fillable maker asset amount - const result = _.reduce( - inputOrders, - (acc, order, index) => { - // get current accumulations - const { orders, remainingFillableMakerAssetAmounts } = acc; - // get corresponding on-chain state for the order - const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; - // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating - if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { - return acc; - } - // if the order IS fillable, add the order and calculate the remaining fillable amount - const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); - const transferrableFeeAssetAmount = BigNumber.min([ - traderInfo.makerZrxAllowance, - traderInfo.makerZrxBalance, - ]); - const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); - const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingTakerAssetAmount, - ); - const remainingFillableCalculator = new RemainingFillableCalculator( - order.makerFee, - order.makerAssetAmount, - order.makerAssetData === zrxAssetData, - transferrableAssetAmount, - transferrableFeeAssetAmount, - remainingMakerAssetAmount, - ); - const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); - return { - orders: _.concat(orders, order), - remainingFillableMakerAssetAmounts: _.concat( - remainingFillableMakerAssetAmounts, - remainingFillableAmount, - ), - }; - }, - { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, - ); - return result; -} - -function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { - const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); - const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); - return result; -} diff --git a/packages/forwarder-helper/src/forwarder_helper_impl.ts b/packages/forwarder-helper/src/forwarder_helper_impl.ts deleted file mode 100644 index a90edb0bb..000000000 --- a/packages/forwarder-helper/src/forwarder_helper_impl.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { marketUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { constants } from './constants'; -import { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfo, MarketBuyOrdersInfoRequest } from './types'; -import { forwarderHelperImplConfigUtils } from './utils/forwarder_helper_impl_config_utils'; - -const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface - -export interface ForwarderHelperImplConfig { - orders: SignedOrder[]; - feeOrders: SignedOrder[]; - remainingFillableMakerAssetAmounts?: BigNumber[]; - remainingFillableFeeAmounts?: BigNumber[]; -} - -export class ForwarderHelperImpl implements ForwarderHelper { - public readonly config: ForwarderHelperImplConfig; - constructor(config: ForwarderHelperImplConfig) { - this.config = forwarderHelperImplConfigUtils.sortedConfig(config); - } - public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo { - const { makerAssetFillAmount, feePercentage } = request; - const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config; - // TODO: make the slippage percentage customizable - const slippageBufferAmount = makerAssetFillAmount.mul(SLIPPAGE_PERCENTAGE).round(); - const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( - orders, - makerAssetFillAmount, - { - remainingFillableMakerAssetAmounts, - slippageBufferAmount, - }, - ); - if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(ForwarderHelperError.InsufficientMakerAssetLiquidity); - } - // TODO: update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to - // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage - const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( - resultOrders, - feeOrders, - { - remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts, - }, - ); - if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(ForwarderHelperError.InsufficientZrxLiquidity); - } - // TODO: calculate min and max eth usage - // TODO: optimize orders call data - return { - makerAssetFillAmount, - orders: resultOrders, - feeOrders: resultFeeOrders, - minEthAmount: constants.ZERO_AMOUNT, - maxEthAmount: constants.ZERO_AMOUNT, - feePercentage, - }; - } -} diff --git a/packages/forwarder-helper/src/globals.d.ts b/packages/forwarder-helper/src/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/forwarder-helper/src/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/forwarder-helper/src/index.ts b/packages/forwarder-helper/src/index.ts deleted file mode 100644 index eb3a34bd5..000000000 --- a/packages/forwarder-helper/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { forwarderHelperFactory } from './forwarder_helper_factory'; -export { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfoRequest, MarketBuyOrdersInfo } from './types'; diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts deleted file mode 100644 index a7f02ff8d..000000000 --- a/packages/forwarder-helper/src/types.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; - -export enum ForwarderHelperFactoryError { - NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', - NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', - StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', -} - -export interface ForwarderHelper { - /** - * Given a MarketBuyOrdersInfoRequest, returns a MarketBuyOrdersInfo containing all information relevant to fulfilling the request - * using the ForwarderContract marketBuyOrdersWithEth function. - * @param request An object that conforms to MarketBuyOrdersInfoRequest. See type definition for more information. - * @return An object that conforms to MarketBuyOrdersInfo that satisfies the request. See type definition for more information. - */ - getMarketBuyOrdersInfo: (request: MarketBuyOrdersInfoRequest) => MarketBuyOrdersInfo; -} - -export enum ForwarderHelperError { - InsufficientMakerAssetLiquidity = 'INSUFFICIENT_MAKER_ASSET_LIQUIDITY', - InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', -} - -/** - * makerAssetFillAmount: The amount of makerAsset requesting to be filled - * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations - */ -export interface MarketBuyOrdersInfoRequest { - makerAssetFillAmount: BigNumber; - feePercentage?: BigNumber; -} - -/** - * makerAssetFillAmount: The amount of makerAsset requesting to be filled - * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested makerAssetFillAmount plus slippage - * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above - * minEthAmount: Amount of eth in wei to send with the tx for the most optimistic case - * maxEthAmount: Amount of eth in wei to send with the tx for the worst case - * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed thru directly from the request - */ -export interface MarketBuyOrdersInfo { - makerAssetFillAmount: BigNumber; - orders: SignedOrder[]; - feeOrders: SignedOrder[]; - minEthAmount: BigNumber; - maxEthAmount: BigNumber; - feePercentage?: BigNumber; -} diff --git a/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts b/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts deleted file mode 100644 index 253384f65..000000000 --- a/packages/forwarder-helper/src/utils/forwarder_helper_impl_config_utils.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { sortingUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { ForwarderHelperImplConfig } from '../forwarder_helper_impl'; - -interface SignedOrderWithAmount extends SignedOrder { - remainingFillAmount: BigNumber; -} - -export const forwarderHelperImplConfigUtils = { - sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig { - const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config; - // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens - const orderSorter = (ordersToSort: SignedOrder[]) => { - return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort); - }; - const sortOrdersResult = sortOrdersAndRemainingFillAmounts( - orderSorter, - orders, - remainingFillableMakerAssetAmounts, - ); - const feeOrderSorter = (ordersToSort: SignedOrder[]) => { - return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort); - }; - const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts( - feeOrderSorter, - feeOrders, - remainingFillableFeeAmounts, - ); - return { - orders: sortOrdersResult.orders, - feeOrders: sortFeeOrdersResult.orders, - remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts, - remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts, - }; - }, -}; - -type OrderSorter = (orders: SignedOrder[]) => SignedOrder[]; - -function sortOrdersAndRemainingFillAmounts( - orderSorter: OrderSorter, - orders: SignedOrder[], - remainingFillAmounts?: BigNumber[], -): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } { - if (!_.isUndefined(remainingFillAmounts)) { - // Bundle orders together with their remainingFillAmounts so that we can sort them together - const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts); - // Sort - const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[]; - // Unbundle after sorting - const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts); - return { - orders: unbundledSortedOrderWithAmounts.orders, - remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts, - }; - } else { - const sortedOrders = orderSorter(orders); - return { - orders: sortedOrders, - }; - } -} - -function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] { - const ordersAndAmounts = _.map(orders, (order, index) => { - return { - ...order, - remainingFillAmount: amounts[index], - }; - }); - return ordersAndAmounts; -} - -function unbundleSignedOrderWithAmounts( - signedOrderWithAmounts: SignedOrderWithAmount[], -): { orders: SignedOrder[]; amounts: BigNumber[] } { - const orders = _.map(signedOrderWithAmounts, order => { - const { remainingFillAmount, ...rest } = order; - return rest; - }); - const amounts = _.map(signedOrderWithAmounts, order => { - const { remainingFillAmount } = order; - return remainingFillAmount; - }); - return { - orders, - amounts, - }; -} diff --git a/packages/forwarder-helper/src/utils/order_utils.ts b/packages/forwarder-helper/src/utils/order_utils.ts deleted file mode 100644 index bb0bdb80f..000000000 --- a/packages/forwarder-helper/src/utils/order_utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; - -import { constants } from '../constants'; - -export const orderUtils = { - isOrderExpired(order: SignedOrder): boolean { - const millisecondsInSecond = 1000; - const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round(); - return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec); - }, - calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { - const result = remainingTakerAssetAmount.eq(0) - ? constants.ZERO_AMOUNT - : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); - return result; - }, - isOpenOrder(order: SignedOrder): boolean { - return order.takerAddress === constants.NULL_ADDRESS; - }, -}; diff --git a/packages/forwarder-helper/test/forwarder_helper_impl_test.ts b/packages/forwarder-helper/test/forwarder_helper_impl_test.ts deleted file mode 100644 index 3c3b6db92..000000000 --- a/packages/forwarder-helper/test/forwarder_helper_impl_test.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory'; -import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; -import * as _ from 'lodash'; -import 'mocha'; - -import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '../src/forwarder_helper_impl'; -import { ForwarderHelperError } from '../src/types'; - -import { chaiSetup } from './utils/chai_setup'; - -chaiSetup.configure(); -const expect = chai.expect; - -describe('ForwarderHelperImpl', () => { - // rate: 2 takerAsset / makerAsset - const testOrder1 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(200), - }); - // rate: 1 takerAsset / makerAsset - const testOrder2 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(100), - }); - // rate: 3 takerAsset / makerAsset - const testOrder3 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(300), - takerFee: new BigNumber(1), - }); - // rate: 3 WETH / ZRX - const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(300), - }); - // rate: 2 WETH / ZRX - const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(200), - }); - // rate: 1 WETH / ZRX - const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(100), - }); - const inputForwarderHelperConfig: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], - remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)], - remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)], - }; - describe('#constructor', () => { - const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], - }; - it('sorts orders', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]); - }); - it('sorts fee orders', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]); - }); - it('sorts remainingFillableMakerAssetAmounts', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined(); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal( - new BigNumber(2), - ); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal( - new BigNumber(1), - ); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal( - new BigNumber(3), - ); - }); - it('sorts remainingFillableFeeAmounts', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined(); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6)); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5)); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4)); - }); - it('remainingFillableMakerAssetAmounts is undefined if none provided', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); - expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined(); - }); - it('remainingFillableFeeAmounts is undefined if none provided', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); - expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined(); - }); - }); - describe('#getMarketBuyOrdersInfo', () => { - it('throws if not enough makerAsset liquidity', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(() => { - // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer - forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(6), - }); - }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity); - }); - it('throws if not enough ZRX liquidity', () => { - const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [], - }; - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees); - expect(() => { - // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw - forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(250), - }); - }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity); - }); - it('passes the makerAssetFillAmount from the request to the info response', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - const makerAssetFillAmount = new BigNumber(4); - const info = forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount, - }); - expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount); - }); - it('passes the feePercentage from the request to the info response', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - const feePercentage = new BigNumber(0.2); - const info = forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(4), - feePercentage, - }); - expect(info.feePercentage).to.bignumber.equal(feePercentage); - }); - }); -}); diff --git a/packages/forwarder-helper/test/utils/chai_setup.ts b/packages/forwarder-helper/test/utils/chai_setup.ts deleted file mode 100644 index 1a8733093..000000000 --- a/packages/forwarder-helper/test/utils/chai_setup.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as chai from 'chai'; -import chaiAsPromised = require('chai-as-promised'); -import ChaiBigNumber = require('chai-bignumber'); -import * as dirtyChai from 'dirty-chai'; - -export const chaiSetup = { - configure(): void { - chai.config.includeStack = true; - chai.use(ChaiBigNumber()); - chai.use(dirtyChai); - chai.use(chaiAsPromised); - }, -}; diff --git a/packages/forwarder-helper/tsconfig.json b/packages/forwarder-helper/tsconfig.json deleted file mode 100644 index 2ee711adc..000000000 --- a/packages/forwarder-helper/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": "." - }, - "include": ["./src/**/*", "./test/**/*"] -} diff --git a/packages/forwarder-helper/tslint.json b/packages/forwarder-helper/tslint.json deleted file mode 100644 index ffaefe83a..000000000 --- a/packages/forwarder-helper/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@0xproject/tslint-config"] -} diff --git a/packages/forwarder-helper/typedoc-tsconfig.json b/packages/forwarder-helper/typedoc-tsconfig.json deleted file mode 100644 index c9b0af1ae..000000000 --- a/packages/forwarder-helper/typedoc-tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../typedoc-tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./src/**/*", "./test/**/*"] -} -- cgit From 8da7d399981472ff9cbfa28fb0957a530de72b2d Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 14 Sep 2018 13:54:06 +0200 Subject: Update readme, changelog, and package.json with rename --- packages/asset-buyer/CHANGELOG.json | 24 ++---------------------- packages/asset-buyer/CHANGELOG.md | 17 ----------------- packages/asset-buyer/README.md | 16 ++++++++-------- packages/asset-buyer/package.json | 8 ++++---- 4 files changed, 14 insertions(+), 51 deletions(-) diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index f0e646700..2e4db1f6e 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -1,30 +1,10 @@ [ { - "timestamp": 1536142250, - "version": "1.0.1", + "version": "1.0.0-rc.1", "changes": [ { - "note": "Dependencies updated" + "note": "Init" } ] - }, - { - "version": "1.0.1-rc.2", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1535377027 - }, - { - "version": "1.0.1-rc.1", - "changes": [ - { - "note": "Add initial forwarderHelperFactory", - "pr": 997 - } - ], - "timestamp": 1535133899 } ] diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index d6b67aa1b..8b1378917 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -1,18 +1 @@ - -CHANGELOG - -## v1.0.1 - _September 5, 2018_ - - * Dependencies updated - -## v1.0.1-rc.2 - _August 27, 2018_ - - * Dependencies updated - -## v1.0.1-rc.1 - _August 24, 2018_ - - * Add initial forwarderHelperFactory (#997) diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md index c74526910..717849bf2 100644 --- a/packages/asset-buyer/README.md +++ b/packages/asset-buyer/README.md @@ -1,25 +1,25 @@ -## @0xproject/forwarder-helper +## @0xproject/asset-buyer -Provides convenience objects to help work with the Forwarder Contract +Convenience package for buying assets -### Read the [Documentation](https://0xproject.com/docs/forwarder-helper). +### Read the [Documentation](https://0xproject.com/docs/asset-buyer). ## Installation ```bash -yarn add @0xproject/forwarder-helper +yarn add @0xproject/asset-buyer ``` **Import** ```typescript -import { forwarderHelperFactory } from '@0xproject/forwarder-helper'; +import { AssetBuyer } from '@0xproject/asset-buyer'; ``` or ```javascript -var forwarderHelperFactory = require('@0xproject/forwarder-helper').forwarderHelperFactory; +var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer; ``` If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: @@ -55,13 +55,13 @@ yarn install To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -PKG=@0xproject/forwarder-helper yarn build +PKG=@0xproject/asset-buyer yarn build ``` Or continuously rebuild on change: ```bash -PKG=@0xproject/forwarder-helper yarn watch +PKG=@0xproject/asset-buyer yarn watch ``` ### Clean diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index f849fb4ed..e4d3d0701 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,10 +1,10 @@ { - "name": "@0xproject/forwarder-helper", - "version": "1.0.1", + "name": "@0xproject/asset-buyer", + "version": "1.0.0-rc.1", "engines": { "node": ">=6.12" }, - "description": "Convenience object for working with the forwarder contract", + "description": "Convenience package for buying assets", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", "scripts": { @@ -37,7 +37,7 @@ "bugs": { "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { "@0xproject/assert": "^1.0.8", "@0xproject/connect": "^2.0.0", -- cgit From 7b46cef83dca0a743bd598a70076004983cbf294 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 14 Sep 2018 16:18:16 +0200 Subject: Create initial AssetBuyer class --- packages/asset-buyer/package.json | 2 + .../asset-buyer/src/asset_buyers/asset_buyer.ts | 129 ++++++ packages/asset-buyer/src/constants.ts | 1 + .../asset-buyer/src/forwarder_helper_factory.ts | 510 ++++++++++----------- packages/asset-buyer/src/forwarder_helper_impl.ts | 64 --- packages/asset-buyer/src/index.ts | 4 +- packages/asset-buyer/src/types.ts | 63 ++- .../utils/forwarder_helper_impl_config_utils.ts | 170 +++---- .../asset-buyer/test/forwarder_helper_impl_test.ts | 264 +++++------ tsconfig.json | 2 +- 10 files changed, 635 insertions(+), 574 deletions(-) create mode 100644 packages/asset-buyer/src/asset_buyers/asset_buyer.ts delete mode 100644 packages/asset-buyer/src/forwarder_helper_impl.ts diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index e4d3d0701..0d6d1f52b 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -48,6 +48,8 @@ "@0xproject/types": "^1.0.1", "@0xproject/typescript-typings": "^2.0.0", "@0xproject/utils": "^1.0.8", + "@0xproject/web3-wrapper": "^2.0.2", + "ethereum-types": "^1.0.6", "lodash": "^4.17.10" }, "devDependencies": { diff --git a/packages/asset-buyer/src/asset_buyers/asset_buyer.ts b/packages/asset-buyer/src/asset_buyers/asset_buyer.ts new file mode 100644 index 000000000..eb7f85e2b --- /dev/null +++ b/packages/asset-buyer/src/asset_buyers/asset_buyer.ts @@ -0,0 +1,129 @@ +import { ContractWrappers } from '@0xproject/contract-wrappers'; +import { marketUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; +import { Provider } from 'ethereum-types'; + +import { constants } from '../constants'; +import { AssetBuyerError, BuyQuote, BuyQuoteRequest } from '../types'; + +const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface + +export interface AssetBuyerConfig { + orders: SignedOrder[]; + feeOrders: SignedOrder[]; + remainingFillableMakerAssetAmounts?: BigNumber[]; + remainingFillableFeeAmounts?: BigNumber[]; + networkId?: number; +} + +export class AssetBuyer { + public readonly provider: Provider; + public readonly config: AssetBuyerConfig; + private _contractWrappers: ContractWrappers; + constructor(provider: Provider, config: AssetBuyerConfig) { + this.provider = provider; + this.config = config; + const networkId = this.config.networkId || constants.MAINNET_NETWORK_ID; + this._contractWrappers = new ContractWrappers(this.provider, { + networkId, + }); + } + /** + * Given a BuyQuoteRequest, returns a BuyQuote containing all information relevant to fulfilling the buy. Pass the BuyQuote + * to executeBuyQuoteAsync to execute the buy. + * @param buyQuoteRequest An object that conforms to BuyQuoteRequest. See type definition for more information. + * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. + */ + public getBuyQuote(buyQuoteRequest: BuyQuoteRequest): BuyQuote { + const { assetBuyAmount, feePercentage } = buyQuoteRequest; + const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config; + // TODO: optimization + // make the slippage percentage customizable + const slippageBufferAmount = assetBuyAmount.mul(SLIPPAGE_PERCENTAGE).round(); + const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( + orders, + assetBuyAmount, + { + remainingFillableMakerAssetAmounts, + slippageBufferAmount, + }, + ); + if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(AssetBuyerError.InsufficientAssetLiquidity); + } + // TODO: optimization + // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to + // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage + const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( + resultOrders, + feeOrders, + { + remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts, + }, + ); + if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(AssetBuyerError.InsufficientZrxLiquidity); + } + const assetData = orders[0].makerAssetData; + // TODO: critical + // calculate minRate and maxRate by calculating min and max eth usage and then dividing into + // assetBuyAmount to get assetData / WETH + return { + assetData, + orders: resultOrders, + feeOrders: resultFeeOrders, + minRate: constants.ZERO_AMOUNT, + maxRate: constants.ZERO_AMOUNT, + assetBuyAmount, + feePercentage, + }; + } + /** + * Given a BuyQuote and desired rate, attempt to execute the buy. + * @param buyQuote An object that conforms to BuyQuote. See type definition for more information. + * @param rate The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate. + * @param takerAddress The address to perform the buy. Defaults to the first available address from the provider. + * @param feeRecipient The address where affiliate fees are sent. Defaults to null address (0x000...000). + * @return A promise of the txHash. + */ + public async executeBuyQuoteAsync( + buyQuote: BuyQuote, + rate?: BigNumber, + takerAddress?: string, + feeRecipient: string = constants.NULL_ADDRESS, + ): Promise { + const { orders, feeOrders, feePercentage, assetBuyAmount, maxRate } = buyQuote; + // if no takerAddress is provided, try to get one from the provider + let finalTakerAddress; + if (!_.isUndefined(takerAddress)) { + finalTakerAddress = takerAddress; + } else { + const web3Wrapper = new Web3Wrapper(this.provider); + const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); + const firstAvailableAddress = _.head(availableAddresses); + if (!_.isUndefined(firstAvailableAddress)) { + finalTakerAddress = firstAvailableAddress; + } else { + throw new Error(AssetBuyerError.NoAddressAvailable); + } + } + // if no rate is provided, default to the maxRate from buyQuote + const desiredRate = rate || maxRate; + // calculate how much eth is required to buy assetBuyAmount at the desired rate + const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate); + const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( + orders, + assetBuyAmount, + finalTakerAddress, + ethAmount, + feeOrders, + feePercentage, + feeRecipient, + ); + return txHash; + } +} diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index c0a1b090e..5785e705b 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -3,4 +3,5 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { ZERO_AMOUNT: new BigNumber(0), NULL_ADDRESS: '0x0000000000000000000000000000000000000000', + MAINNET_NETWORK_ID: 1, }; diff --git a/packages/asset-buyer/src/forwarder_helper_factory.ts b/packages/asset-buyer/src/forwarder_helper_factory.ts index 2b37ac98f..9a3832e81 100644 --- a/packages/asset-buyer/src/forwarder_helper_factory.ts +++ b/packages/asset-buyer/src/forwarder_helper_factory.ts @@ -1,261 +1,261 @@ -import { assert } from '@0xproject/assert'; -import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; -import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; -import { schemas } from '@0xproject/json-schemas'; -import { assetDataUtils } from '@0xproject/order-utils'; -import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; -import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; +// import { assert } from '@0xproject/assert'; +// import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; +// import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; +// import { schemas } from '@0xproject/json-schemas'; +// import { assetDataUtils } from '@0xproject/order-utils'; +// import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; +// import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; +// import { SignedOrder } from '@0xproject/types'; +// import { BigNumber } from '@0xproject/utils'; +// import * as _ from 'lodash'; -import { constants } from './constants'; -import { ForwarderHelperImpl, ForwarderHelperImplConfig } from './forwarder_helper_impl'; -import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; -import { orderUtils } from './utils/order_utils'; +// import { constants } from './constants'; +// import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; +// import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; +// import { orderUtils } from './utils/order_utils'; -export const forwarderHelperFactory = { - /** - * Given an array of orders and an array of feeOrders, get a ForwarderHelper - * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData - * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData - * @return A ForwarderHelper, see type for definition - */ - getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { - assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); - assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); - // TODO: Add assertion here for orders all having the same makerAsset and takerAsset - const config: ForwarderHelperImplConfig = { - orders, - feeOrders, - }; - const helper = new ForwarderHelperImpl(config); - return helper; - }, - /** - * Given a desired makerAsset and SRA url, get a ForwarderHelper - * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData - * @param sraUrl A url pointing to an SRA v2 compliant endpoint. - * @param rpcUrl A url pointing to an ethereum node. - * @param networkId The ethereum networkId, defaults to 1 (mainnet). - * @return A ForwarderHelper, see type for definition - */ - async getForwarderHelperForMakerAssetDataAsync( - makerAssetData: string, - sraUrl: string, - rpcUrl?: string, - networkId: number = 1, - ): Promise { - assert.isHexString('makerAssetData', makerAssetData); - assert.isWebUri('sraUrl', sraUrl); - if (!_.isUndefined(rpcUrl)) { - assert.isWebUri('rpcUrl', rpcUrl); - } - assert.isNumber('networkId', networkId); - // create provider - const providerEngine = new Web3ProviderEngine(); - if (!_.isUndefined(rpcUrl)) { - providerEngine.addProvider(new RPCSubprovider(rpcUrl)); - } - providerEngine.start(); - // create contract wrappers given provider and networkId - const contractWrappers = new ContractWrappers(providerEngine, { networkId }); - // find ether token asset data - const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); - if (_.isUndefined(etherTokenAddressIfExists)) { - throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); - } - const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); - // find zrx token asset data - let zrxTokenAssetData: string; - try { - zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); - } catch (err) { - throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); - } - // get orderbooks for makerAsset/WETH and ZRX/WETH - const sraClient = new HttpClient(sraUrl); - const orderbookRequests = [ - { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, - { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, - ]; - const requestOpts = { networkId }; - let makerAssetOrderbook: OrderbookResponse; - let zrxOrderbook: OrderbookResponse; - try { - [makerAssetOrderbook, zrxOrderbook] = await Promise.all( - _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), - ); - } catch (err) { - throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); - } - // validate orders and find remaining fillable from on chain state or sra api - let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; - let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; - if (!_.isUndefined(rpcUrl)) { - // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper - const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); - const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); - // TODO: try catch these requests and throw a more domain specific error - // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response - const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( - _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { - const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); - return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( - ordersToBeValidated, - takerAddresses, - ); - }), - ); - // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts - ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - ordersFromSra, - makerAssetOrdersAndTradersInfo, - zrxTokenAssetData, - ); - // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts - feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - feeOrdersFromSra, - feeOrdersAndTradersInfo, - zrxTokenAssetData, - ); - } else { - // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA - // if fill amounts are not available from the SRA, assume all orders are completely fillable - const apiOrdersFromSra = makerAssetOrderbook.asks.records; - const feeApiOrdersFromSra = zrxOrderbook.asks.records; - // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts - ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - apiOrdersFromSra, - ); - // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts - feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - feeApiOrdersFromSra, - ); - } - // compile final config - const config: ForwarderHelperImplConfig = { - orders: ordersAndRemainingFillableMakerAssetAmounts.orders, - feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, - remainingFillableMakerAssetAmounts: - ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts: - feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - }; - const helper = new ForwarderHelperImpl(config); - return helper; - }, -}; +// export const forwarderHelperFactory = { +// /** +// * Given an array of orders and an array of feeOrders, get a ForwarderHelper +// * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData +// * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData +// * @return A ForwarderHelper, see type for definition +// */ +// getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { +// assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); +// assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); +// // TODO: Add assertion here for orders all having the same makerAsset and takerAsset +// const config: ForwarderHelperImplConfig = { +// orders, +// feeOrders, +// }; +// const helper = new ForwarderHelperImpl(config); +// return helper; +// }, +// /** +// * Given a desired makerAsset and SRA url, get a ForwarderHelper +// * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData +// * @param sraUrl A url pointing to an SRA v2 compliant endpoint. +// * @param rpcUrl A url pointing to an ethereum node. +// * @param networkId The ethereum networkId, defaults to 1 (mainnet). +// * @return A ForwarderHelper, see type for definition +// */ +// async getForwarderHelperForMakerAssetDataAsync( +// makerAssetData: string, +// sraUrl: string, +// rpcUrl?: string, +// networkId: number = 1, +// ): Promise { +// assert.isHexString('makerAssetData', makerAssetData); +// assert.isWebUri('sraUrl', sraUrl); +// if (!_.isUndefined(rpcUrl)) { +// assert.isWebUri('rpcUrl', rpcUrl); +// } +// assert.isNumber('networkId', networkId); +// // create provider +// const providerEngine = new Web3ProviderEngine(); +// if (!_.isUndefined(rpcUrl)) { +// providerEngine.addProvider(new RPCSubprovider(rpcUrl)); +// } +// providerEngine.start(); +// // create contract wrappers given provider and networkId +// const contractWrappers = new ContractWrappers(providerEngine, { networkId }); +// // find ether token asset data +// const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); +// if (_.isUndefined(etherTokenAddressIfExists)) { +// throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); +// } +// const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); +// // find zrx token asset data +// let zrxTokenAssetData: string; +// try { +// zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); +// } catch (err) { +// throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); +// } +// // get orderbooks for makerAsset/WETH and ZRX/WETH +// const sraClient = new HttpClient(sraUrl); +// const orderbookRequests = [ +// { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, +// { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, +// ]; +// const requestOpts = { networkId }; +// let makerAssetOrderbook: OrderbookResponse; +// let zrxOrderbook: OrderbookResponse; +// try { +// [makerAssetOrderbook, zrxOrderbook] = await Promise.all( +// _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), +// ); +// } catch (err) { +// throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); +// } +// // validate orders and find remaining fillable from on chain state or sra api +// let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; +// let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; +// if (!_.isUndefined(rpcUrl)) { +// // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper +// const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); +// const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); +// // TODO: try catch these requests and throw a more domain specific error +// // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response +// const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( +// _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { +// const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); +// return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( +// ordersToBeValidated, +// takerAddresses, +// ); +// }), +// ); +// // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts +// ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( +// ordersFromSra, +// makerAssetOrdersAndTradersInfo, +// zrxTokenAssetData, +// ); +// // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts +// feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( +// feeOrdersFromSra, +// feeOrdersAndTradersInfo, +// zrxTokenAssetData, +// ); +// } else { +// // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA +// // if fill amounts are not available from the SRA, assume all orders are completely fillable +// const apiOrdersFromSra = makerAssetOrderbook.asks.records; +// const feeApiOrdersFromSra = zrxOrderbook.asks.records; +// // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts +// ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( +// apiOrdersFromSra, +// ); +// // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts +// feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( +// feeApiOrdersFromSra, +// ); +// } +// // compile final config +// const config: ForwarderHelperImplConfig = { +// orders: ordersAndRemainingFillableMakerAssetAmounts.orders, +// feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, +// remainingFillableMakerAssetAmounts: +// ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, +// remainingFillableFeeAmounts: +// feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, +// }; +// const helper = new ForwarderHelperImpl(config); +// return helper; +// }, +// }; -interface OrdersAndRemainingFillableMakerAssetAmounts { - orders: SignedOrder[]; - remainingFillableMakerAssetAmounts: BigNumber[]; -} +// interface OrdersAndRemainingFillableMakerAssetAmounts { +// orders: SignedOrder[]; +// remainingFillableMakerAssetAmounts: BigNumber[]; +// } -/** - * Given an array of APIOrder objects from a standard relayer api, return an array - * of fillable orders with their corresponding remainingFillableMakerAssetAmounts - */ -function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( - apiOrders: APIOrder[], -): OrdersAndRemainingFillableMakerAssetAmounts { - const result = _.reduce( - apiOrders, - (acc, apiOrder) => { - // get current accumulations - const { orders, remainingFillableMakerAssetAmounts } = acc; - // get order and metadata - const { order, metaData } = apiOrder; - // if the order is expired or not open, move on - if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { - return acc; - } - // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable - const remainingFillableTakerAssetAmount = _.get( - metaData, - 'remainingTakerAssetAmount', - order.takerAssetAmount, - ); - const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingFillableTakerAssetAmount, - ); - // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations - // if there is not any maker asset left to fill, do not add - if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { - return { - orders: _.concat(orders, order), - remainingFillableMakerAssetAmounts: _.concat( - remainingFillableMakerAssetAmounts, - remainingFillableMakerAssetAmount, - ), - }; - } else { - return acc; - } - }, - { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, - ); - return result; -} +// /** +// * Given an array of APIOrder objects from a standard relayer api, return an array +// * of fillable orders with their corresponding remainingFillableMakerAssetAmounts +// */ +// function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( +// apiOrders: APIOrder[], +// ): OrdersAndRemainingFillableMakerAssetAmounts { +// const result = _.reduce( +// apiOrders, +// (acc, apiOrder) => { +// // get current accumulations +// const { orders, remainingFillableMakerAssetAmounts } = acc; +// // get order and metadata +// const { order, metaData } = apiOrder; +// // if the order is expired or not open, move on +// if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { +// return acc; +// } +// // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable +// const remainingFillableTakerAssetAmount = _.get( +// metaData, +// 'remainingTakerAssetAmount', +// order.takerAssetAmount, +// ); +// const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( +// order, +// remainingFillableTakerAssetAmount, +// ); +// // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations +// // if there is not any maker asset left to fill, do not add +// if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { +// return { +// orders: _.concat(orders, order), +// remainingFillableMakerAssetAmounts: _.concat( +// remainingFillableMakerAssetAmounts, +// remainingFillableMakerAssetAmount, +// ), +// }; +// } else { +// return acc; +// } +// }, +// { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, +// ); +// return result; +// } -/** - * Given an array of orders and corresponding on-chain infos, return a subset of the orders - * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts - */ -function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( - inputOrders: SignedOrder[], - ordersAndTradersInfo: OrderAndTraderInfo[], - zrxAssetData: string, -): OrdersAndRemainingFillableMakerAssetAmounts { - // iterate through the input orders and find the ones that are still fillable - // for the orders that are still fillable, calculate the remaining fillable maker asset amount - const result = _.reduce( - inputOrders, - (acc, order, index) => { - // get current accumulations - const { orders, remainingFillableMakerAssetAmounts } = acc; - // get corresponding on-chain state for the order - const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; - // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating - if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { - return acc; - } - // if the order IS fillable, add the order and calculate the remaining fillable amount - const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); - const transferrableFeeAssetAmount = BigNumber.min([ - traderInfo.makerZrxAllowance, - traderInfo.makerZrxBalance, - ]); - const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); - const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingTakerAssetAmount, - ); - const remainingFillableCalculator = new RemainingFillableCalculator( - order.makerFee, - order.makerAssetAmount, - order.makerAssetData === zrxAssetData, - transferrableAssetAmount, - transferrableFeeAssetAmount, - remainingMakerAssetAmount, - ); - const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); - return { - orders: _.concat(orders, order), - remainingFillableMakerAssetAmounts: _.concat( - remainingFillableMakerAssetAmounts, - remainingFillableAmount, - ), - }; - }, - { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, - ); - return result; -} +// /** +// * Given an array of orders and corresponding on-chain infos, return a subset of the orders +// * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts +// */ +// function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( +// inputOrders: SignedOrder[], +// ordersAndTradersInfo: OrderAndTraderInfo[], +// zrxAssetData: string, +// ): OrdersAndRemainingFillableMakerAssetAmounts { +// // iterate through the input orders and find the ones that are still fillable +// // for the orders that are still fillable, calculate the remaining fillable maker asset amount +// const result = _.reduce( +// inputOrders, +// (acc, order, index) => { +// // get current accumulations +// const { orders, remainingFillableMakerAssetAmounts } = acc; +// // get corresponding on-chain state for the order +// const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; +// // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating +// if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { +// return acc; +// } +// // if the order IS fillable, add the order and calculate the remaining fillable amount +// const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); +// const transferrableFeeAssetAmount = BigNumber.min([ +// traderInfo.makerZrxAllowance, +// traderInfo.makerZrxBalance, +// ]); +// const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); +// const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( +// order, +// remainingTakerAssetAmount, +// ); +// const remainingFillableCalculator = new RemainingFillableCalculator( +// order.makerFee, +// order.makerAssetAmount, +// order.makerAssetData === zrxAssetData, +// transferrableAssetAmount, +// transferrableFeeAssetAmount, +// remainingMakerAssetAmount, +// ); +// const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); +// return { +// orders: _.concat(orders, order), +// remainingFillableMakerAssetAmounts: _.concat( +// remainingFillableMakerAssetAmounts, +// remainingFillableAmount, +// ), +// }; +// }, +// { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, +// ); +// return result; +// } -function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { - const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); - const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); - return result; -} +// function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { +// const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); +// const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); +// return result; +// } diff --git a/packages/asset-buyer/src/forwarder_helper_impl.ts b/packages/asset-buyer/src/forwarder_helper_impl.ts deleted file mode 100644 index a90edb0bb..000000000 --- a/packages/asset-buyer/src/forwarder_helper_impl.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { marketUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { constants } from './constants'; -import { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfo, MarketBuyOrdersInfoRequest } from './types'; -import { forwarderHelperImplConfigUtils } from './utils/forwarder_helper_impl_config_utils'; - -const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface - -export interface ForwarderHelperImplConfig { - orders: SignedOrder[]; - feeOrders: SignedOrder[]; - remainingFillableMakerAssetAmounts?: BigNumber[]; - remainingFillableFeeAmounts?: BigNumber[]; -} - -export class ForwarderHelperImpl implements ForwarderHelper { - public readonly config: ForwarderHelperImplConfig; - constructor(config: ForwarderHelperImplConfig) { - this.config = forwarderHelperImplConfigUtils.sortedConfig(config); - } - public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo { - const { makerAssetFillAmount, feePercentage } = request; - const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config; - // TODO: make the slippage percentage customizable - const slippageBufferAmount = makerAssetFillAmount.mul(SLIPPAGE_PERCENTAGE).round(); - const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( - orders, - makerAssetFillAmount, - { - remainingFillableMakerAssetAmounts, - slippageBufferAmount, - }, - ); - if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(ForwarderHelperError.InsufficientMakerAssetLiquidity); - } - // TODO: update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to - // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage - const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( - resultOrders, - feeOrders, - { - remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts, - }, - ); - if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(ForwarderHelperError.InsufficientZrxLiquidity); - } - // TODO: calculate min and max eth usage - // TODO: optimize orders call data - return { - makerAssetFillAmount, - orders: resultOrders, - feeOrders: resultFeeOrders, - minEthAmount: constants.ZERO_AMOUNT, - maxEthAmount: constants.ZERO_AMOUNT, - feePercentage, - }; - } -} diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index eb3a34bd5..299b32edd 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -1,2 +1,2 @@ -export { forwarderHelperFactory } from './forwarder_helper_factory'; -export { ForwarderHelper, ForwarderHelperError, MarketBuyOrdersInfoRequest, MarketBuyOrdersInfo } from './types'; +export { AssetBuyerError, BuyQuote, BuyQuoteRequest } from './types'; +export { AssetBuyer } from './asset_buyers/asset_buyer'; diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index a7f02ff8d..8a12d0cf8 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -1,49 +1,42 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; -export enum ForwarderHelperFactoryError { - NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', - NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', - StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', -} - -export interface ForwarderHelper { - /** - * Given a MarketBuyOrdersInfoRequest, returns a MarketBuyOrdersInfo containing all information relevant to fulfilling the request - * using the ForwarderContract marketBuyOrdersWithEth function. - * @param request An object that conforms to MarketBuyOrdersInfoRequest. See type definition for more information. - * @return An object that conforms to MarketBuyOrdersInfo that satisfies the request. See type definition for more information. - */ - getMarketBuyOrdersInfo: (request: MarketBuyOrdersInfoRequest) => MarketBuyOrdersInfo; -} - -export enum ForwarderHelperError { - InsufficientMakerAssetLiquidity = 'INSUFFICIENT_MAKER_ASSET_LIQUIDITY', - InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', -} - /** - * makerAssetFillAmount: The amount of makerAsset requesting to be filled - * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations + * assetBuyAmount: The amount of asset to buy. + * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations. */ -export interface MarketBuyOrdersInfoRequest { - makerAssetFillAmount: BigNumber; +export interface BuyQuoteRequest { + assetBuyAmount: BigNumber; feePercentage?: BigNumber; } /** - * makerAssetFillAmount: The amount of makerAsset requesting to be filled - * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested makerAssetFillAmount plus slippage - * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above - * minEthAmount: Amount of eth in wei to send with the tx for the most optimistic case - * maxEthAmount: Amount of eth in wei to send with the tx for the worst case - * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed thru directly from the request + * assetData: The asset information. + * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested assetBuyAmount plus slippage. + * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above. + * minRate: Min rate that needs to be paid in order to execute the buy. + * maxRate: Max rate that can be paid in order to execute the buy. + * assetBuyAmount: The amount of asset to buy. Passed through directly from the request. + * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed through directly from the request. */ -export interface MarketBuyOrdersInfo { - makerAssetFillAmount: BigNumber; +export interface BuyQuote { + assetData: string; orders: SignedOrder[]; feeOrders: SignedOrder[]; - minEthAmount: BigNumber; - maxEthAmount: BigNumber; + minRate: BigNumber; + maxRate: BigNumber; + assetBuyAmount: BigNumber; feePercentage?: BigNumber; } + +/** + * Possible errors thrown by an AssetBuyer instance or associated static methods + */ +export enum AssetBuyerError { + NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', + NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', + StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', + InsufficientAssetLiquidity = 'INSUFFICIENT_ASSET_LIQUIDITY', + InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', + NoAddressAvailable = 'NO_ADDRESS_AVAILABLE', +} diff --git a/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts b/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts index 253384f65..d3cbb651a 100644 --- a/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts +++ b/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts @@ -1,92 +1,92 @@ -import { sortingUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; +// import { sortingUtils } from '@0xproject/order-utils'; +// import { SignedOrder } from '@0xproject/types'; +// import { BigNumber } from '@0xproject/utils'; +// import * as _ from 'lodash'; -import { ForwarderHelperImplConfig } from '../forwarder_helper_impl'; +// import { ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; -interface SignedOrderWithAmount extends SignedOrder { - remainingFillAmount: BigNumber; -} +// interface SignedOrderWithAmount extends SignedOrder { +// remainingFillAmount: BigNumber; +// } -export const forwarderHelperImplConfigUtils = { - sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig { - const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config; - // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens - const orderSorter = (ordersToSort: SignedOrder[]) => { - return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort); - }; - const sortOrdersResult = sortOrdersAndRemainingFillAmounts( - orderSorter, - orders, - remainingFillableMakerAssetAmounts, - ); - const feeOrderSorter = (ordersToSort: SignedOrder[]) => { - return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort); - }; - const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts( - feeOrderSorter, - feeOrders, - remainingFillableFeeAmounts, - ); - return { - orders: sortOrdersResult.orders, - feeOrders: sortFeeOrdersResult.orders, - remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts, - remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts, - }; - }, -}; +// export const forwarderHelperImplConfigUtils = { +// sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig { +// const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config; +// // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens +// const orderSorter = (ordersToSort: SignedOrder[]) => { +// return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort); +// }; +// const sortOrdersResult = sortOrdersAndRemainingFillAmounts( +// orderSorter, +// orders, +// remainingFillableMakerAssetAmounts, +// ); +// const feeOrderSorter = (ordersToSort: SignedOrder[]) => { +// return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort); +// }; +// const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts( +// feeOrderSorter, +// feeOrders, +// remainingFillableFeeAmounts, +// ); +// return { +// orders: sortOrdersResult.orders, +// feeOrders: sortFeeOrdersResult.orders, +// remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts, +// remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts, +// }; +// }, +// }; -type OrderSorter = (orders: SignedOrder[]) => SignedOrder[]; +// type OrderSorter = (orders: SignedOrder[]) => SignedOrder[]; -function sortOrdersAndRemainingFillAmounts( - orderSorter: OrderSorter, - orders: SignedOrder[], - remainingFillAmounts?: BigNumber[], -): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } { - if (!_.isUndefined(remainingFillAmounts)) { - // Bundle orders together with their remainingFillAmounts so that we can sort them together - const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts); - // Sort - const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[]; - // Unbundle after sorting - const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts); - return { - orders: unbundledSortedOrderWithAmounts.orders, - remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts, - }; - } else { - const sortedOrders = orderSorter(orders); - return { - orders: sortedOrders, - }; - } -} +// function sortOrdersAndRemainingFillAmounts( +// orderSorter: OrderSorter, +// orders: SignedOrder[], +// remainingFillAmounts?: BigNumber[], +// ): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } { +// if (!_.isUndefined(remainingFillAmounts)) { +// // Bundle orders together with their remainingFillAmounts so that we can sort them together +// const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts); +// // Sort +// const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[]; +// // Unbundle after sorting +// const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts); +// return { +// orders: unbundledSortedOrderWithAmounts.orders, +// remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts, +// }; +// } else { +// const sortedOrders = orderSorter(orders); +// return { +// orders: sortedOrders, +// }; +// } +// } -function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] { - const ordersAndAmounts = _.map(orders, (order, index) => { - return { - ...order, - remainingFillAmount: amounts[index], - }; - }); - return ordersAndAmounts; -} +// function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] { +// const ordersAndAmounts = _.map(orders, (order, index) => { +// return { +// ...order, +// remainingFillAmount: amounts[index], +// }; +// }); +// return ordersAndAmounts; +// } -function unbundleSignedOrderWithAmounts( - signedOrderWithAmounts: SignedOrderWithAmount[], -): { orders: SignedOrder[]; amounts: BigNumber[] } { - const orders = _.map(signedOrderWithAmounts, order => { - const { remainingFillAmount, ...rest } = order; - return rest; - }); - const amounts = _.map(signedOrderWithAmounts, order => { - const { remainingFillAmount } = order; - return remainingFillAmount; - }); - return { - orders, - amounts, - }; -} +// function unbundleSignedOrderWithAmounts( +// signedOrderWithAmounts: SignedOrderWithAmount[], +// ): { orders: SignedOrder[]; amounts: BigNumber[] } { +// const orders = _.map(signedOrderWithAmounts, order => { +// const { remainingFillAmount, ...rest } = order; +// return rest; +// }); +// const amounts = _.map(signedOrderWithAmounts, order => { +// const { remainingFillAmount } = order; +// return remainingFillAmount; +// }); +// return { +// orders, +// amounts, +// }; +// } diff --git a/packages/asset-buyer/test/forwarder_helper_impl_test.ts b/packages/asset-buyer/test/forwarder_helper_impl_test.ts index 3c3b6db92..b7c014402 100644 --- a/packages/asset-buyer/test/forwarder_helper_impl_test.ts +++ b/packages/asset-buyer/test/forwarder_helper_impl_test.ts @@ -1,136 +1,136 @@ -import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory'; -import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; -import * as _ from 'lodash'; -import 'mocha'; +// import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory'; +// import { BigNumber } from '@0xproject/utils'; +// import * as chai from 'chai'; +// import * as _ from 'lodash'; +// import 'mocha'; -import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '../src/forwarder_helper_impl'; -import { ForwarderHelperError } from '../src/types'; +// import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; +// import { ForwarderHelperError } from '../src/types'; -import { chaiSetup } from './utils/chai_setup'; +// import { chaiSetup } from './utils/chai_setup'; -chaiSetup.configure(); -const expect = chai.expect; +// chaiSetup.configure(); +// const expect = chai.expect; -describe('ForwarderHelperImpl', () => { - // rate: 2 takerAsset / makerAsset - const testOrder1 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(200), - }); - // rate: 1 takerAsset / makerAsset - const testOrder2 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(100), - }); - // rate: 3 takerAsset / makerAsset - const testOrder3 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(300), - takerFee: new BigNumber(1), - }); - // rate: 3 WETH / ZRX - const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(300), - }); - // rate: 2 WETH / ZRX - const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(200), - }); - // rate: 1 WETH / ZRX - const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({ - makerAssetAmount: new BigNumber(100), - takerAssetAmount: new BigNumber(100), - }); - const inputForwarderHelperConfig: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], - remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)], - remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)], - }; - describe('#constructor', () => { - const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], - }; - it('sorts orders', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]); - }); - it('sorts fee orders', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]); - }); - it('sorts remainingFillableMakerAssetAmounts', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined(); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal( - new BigNumber(2), - ); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal( - new BigNumber(1), - ); - expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal( - new BigNumber(3), - ); - }); - it('sorts remainingFillableFeeAmounts', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined(); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6)); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5)); - expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4)); - }); - it('remainingFillableMakerAssetAmounts is undefined if none provided', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); - expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined(); - }); - it('remainingFillableFeeAmounts is undefined if none provided', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); - expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined(); - }); - }); - describe('#getMarketBuyOrdersInfo', () => { - it('throws if not enough makerAsset liquidity', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - expect(() => { - // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer - forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(6), - }); - }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity); - }); - it('throws if not enough ZRX liquidity', () => { - const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = { - orders: [testOrder1, testOrder2, testOrder3], - feeOrders: [], - }; - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees); - expect(() => { - // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw - forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(250), - }); - }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity); - }); - it('passes the makerAssetFillAmount from the request to the info response', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - const makerAssetFillAmount = new BigNumber(4); - const info = forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount, - }); - expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount); - }); - it('passes the feePercentage from the request to the info response', () => { - const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); - const feePercentage = new BigNumber(0.2); - const info = forwarderHelper.getMarketBuyOrdersInfo({ - makerAssetFillAmount: new BigNumber(4), - feePercentage, - }); - expect(info.feePercentage).to.bignumber.equal(feePercentage); - }); - }); -}); +// describe('ForwarderHelperImpl', () => { +// // rate: 2 takerAsset / makerAsset +// const testOrder1 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(200), +// }); +// // rate: 1 takerAsset / makerAsset +// const testOrder2 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(100), +// }); +// // rate: 3 takerAsset / makerAsset +// const testOrder3 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(300), +// takerFee: new BigNumber(1), +// }); +// // rate: 3 WETH / ZRX +// const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(300), +// }); +// // rate: 2 WETH / ZRX +// const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(200), +// }); +// // rate: 1 WETH / ZRX +// const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({ +// makerAssetAmount: new BigNumber(100), +// takerAssetAmount: new BigNumber(100), +// }); +// const inputForwarderHelperConfig: ForwarderHelperImplConfig = { +// orders: [testOrder1, testOrder2, testOrder3], +// feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], +// remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)], +// remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)], +// }; +// describe('#constructor', () => { +// const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = { +// orders: [testOrder1, testOrder2, testOrder3], +// feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], +// }; +// it('sorts orders', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]); +// }); +// it('sorts fee orders', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]); +// }); +// it('sorts remainingFillableMakerAssetAmounts', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined(); +// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal( +// new BigNumber(2), +// ); +// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal( +// new BigNumber(1), +// ); +// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal( +// new BigNumber(3), +// ); +// }); +// it('sorts remainingFillableFeeAmounts', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined(); +// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6)); +// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5)); +// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4)); +// }); +// it('remainingFillableMakerAssetAmounts is undefined if none provided', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); +// expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined(); +// }); +// it('remainingFillableFeeAmounts is undefined if none provided', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); +// expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined(); +// }); +// }); +// describe('#getMarketBuyOrdersInfo', () => { +// it('throws if not enough makerAsset liquidity', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// expect(() => { +// // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer +// forwarderHelper.getMarketBuyOrdersInfo({ +// makerAssetFillAmount: new BigNumber(6), +// }); +// }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity); +// }); +// it('throws if not enough ZRX liquidity', () => { +// const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = { +// orders: [testOrder1, testOrder2, testOrder3], +// feeOrders: [], +// }; +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees); +// expect(() => { +// // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw +// forwarderHelper.getMarketBuyOrdersInfo({ +// makerAssetFillAmount: new BigNumber(250), +// }); +// }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity); +// }); +// it('passes the makerAssetFillAmount from the request to the info response', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// const makerAssetFillAmount = new BigNumber(4); +// const info = forwarderHelper.getMarketBuyOrdersInfo({ +// makerAssetFillAmount, +// }); +// expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount); +// }); +// it('passes the feePercentage from the request to the info response', () => { +// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); +// const feePercentage = new BigNumber(0.2); +// const info = forwarderHelper.getMarketBuyOrdersInfo({ +// makerAssetFillAmount: new BigNumber(4), +// feePercentage, +// }); +// expect(info.feePercentage).to.bignumber.equal(feePercentage); +// }); +// }); +// }); diff --git a/tsconfig.json b/tsconfig.json index a931b28b9..bc71dfb70 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ { "path": "./packages/0x.js" }, { "path": "./packages/abi-gen" }, { "path": "./packages/assert" }, + { "path": "./packages/asset-buyer" }, { "path": "./packages/base-contract" }, { "path": "./packages/connect" }, { "path": "./packages/contract-wrappers" }, @@ -30,7 +31,6 @@ { "path": "./packages/dev-utils" }, { "path": "./packages/ethereum-types" }, { "path": "./packages/fill-scenarios" }, - { "path": "./packages/forwarder-helper" }, { "path": "./packages/json-schemas" }, { "path": "./packages/metacoin" }, { "path": "./packages/migrations" }, -- cgit From f1a22e9bd7943bc9cb8d8308daca0c60af6e0039 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 12:59:23 +0200 Subject: Flesh out the AssetBuyer class --- packages/asset-buyer/src/asset_buyer.ts | 227 +++++++++++++++++++++ .../asset-buyer/src/asset_buyers/asset_buyer.ts | 129 ------------ .../asset-buyer/src/forwarder_helper_factory.ts | 1 + packages/asset-buyer/src/index.ts | 15 +- packages/asset-buyer/src/types.ts | 50 ++++- packages/asset-buyer/src/utils/assert.ts | 23 +++ .../asset-buyer/src/utils/buy_quote_calculator.ts | 60 ++++++ .../utils/forwarder_helper_impl_config_utils.ts | 92 --------- .../src/utils/order_fetcher_response_processor.ts | 180 ++++++++++++++++ 9 files changed, 544 insertions(+), 233 deletions(-) create mode 100644 packages/asset-buyer/src/asset_buyer.ts delete mode 100644 packages/asset-buyer/src/asset_buyers/asset_buyer.ts create mode 100644 packages/asset-buyer/src/utils/assert.ts create mode 100644 packages/asset-buyer/src/utils/buy_quote_calculator.ts delete mode 100644 packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts create mode 100644 packages/asset-buyer/src/utils/order_fetcher_response_processor.ts diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts new file mode 100644 index 000000000..9cbdd8df6 --- /dev/null +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -0,0 +1,227 @@ +import { ContractWrappers } from '@0xproject/contract-wrappers'; +import { assetDataUtils, marketUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { constants } from './constants'; +import { + AssetBuyerError, + AssetBuyerOrdersAndFillableAmounts, + BuyQuote, + OrderFetcher, + OrderFetcherResponse, +} from './types'; +import { assert } from './utils/assert'; +import { buyQuoteCalculator } from './utils/buy_quote_calculator'; +import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; + +const SLIPPAGE_PERCENTAGE = 0.2; // 20% slippage protection, possibly move this into request interface +const DEFAULT_ORDER_REFRESH_INTERVAL_MS = 10000; // 10 seconds +const DEFAULT_FEE_PERCENTAGE = 0; +const ETHER_TOKEN_DECIMALS = 18; + +export class AssetBuyer { + public readonly provider: Provider; + public readonly assetData: string; + public readonly orderFetcher: OrderFetcher; + public readonly networkId: number; + public readonly orderRefreshIntervalMs: number; + private _contractWrappers: ContractWrappers; + private _lastRefreshTimeIfExists?: number; + private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; + /** + * Instantiates a new AssetBuyer instance + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). + * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An instance of AssetBuyer + */ + constructor( + provider: Provider, + assetData: string, + orderFetcher: OrderFetcher, + networkId: number = constants.MAINNET_NETWORK_ID, + orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + ) { + assert.isWeb3Provider('provider', provider); + assert.isString('assetData', assetData); + assert.isValidOrderFetcher('orderFetcher', orderFetcher); + assert.isNumber('networkId', networkId); + assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); + this.provider = provider; + this.assetData = assetData; + this.orderFetcher = orderFetcher; + this.networkId = networkId; + this.orderRefreshIntervalMs = orderRefreshIntervalMs; + this._contractWrappers = new ContractWrappers(this.provider, { + networkId, + }); + } + /** + * Get a BuyQuote containing all information relevant to fulfilling a buy. + * Pass the BuyQuote to executeBuyQuoteAsync to execute the buy. + * @param assetBuyAmount The amount of asset to buy. + * @param feePercentage The affiliate fee percentage. Defaults to 0. + * @param forceOrderRefresh If set to true, new orders and state will be fetched instead of waiting for + * the next orderRefreshIntervalMs. Defaults to false. + * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. + */ + public async getBuyQuoteAsync( + assetBuyAmount: BigNumber, + feePercentage: number = DEFAULT_FEE_PERCENTAGE, + forceOrderRefresh: boolean = false, + ): Promise { + assert.isBigNumber('assetBuyAmount', assetBuyAmount); + assert.isNumber('feePercentage', feePercentage); + assert.isBoolean('forceOrderRefresh', forceOrderRefresh); + // we should refresh if: + // we do not have any orders OR + // we are forced to OR + // we have some last refresh time AND that time was sufficiently long ago + const shouldRefresh = + _.isUndefined(this._currentOrdersAndFillableAmountsIfExists) || + forceOrderRefresh || + (!_.isUndefined(this._lastRefreshTimeIfExists) && + this._lastRefreshTimeIfExists + this.orderRefreshIntervalMs < Date.now()); + let ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts; + if (shouldRefresh) { + ordersAndFillableAmounts = await this._getLatestOrdersAndFillableAmountsAsync(); + this._lastRefreshTimeIfExists = Date.now(); + this._currentOrdersAndFillableAmountsIfExists = ordersAndFillableAmounts; + } else { + // it is safe to cast to AssetBuyerOrdersAndFillableAmounts because shouldRefresh catches the undefined case above + ordersAndFillableAmounts = this + ._currentOrdersAndFillableAmountsIfExists as AssetBuyerOrdersAndFillableAmounts; + } + // TODO: optimization + // make the slippage percentage customizable by integrator + const buyQuote = buyQuoteCalculator.calculate( + ordersAndFillableAmounts, + assetBuyAmount, + feePercentage, + SLIPPAGE_PERCENTAGE, + ); + return buyQuote; + } + /** + * Given a BuyQuote and desired rate, attempt to execute the buy. + * @param buyQuote An object that conforms to BuyQuote. See type definition for more information. + * @param rate The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate. + * @param takerAddress The address to perform the buy. Defaults to the first available address from the provider. + * @param feeRecipient The address where affiliate fees are sent. Defaults to null address (0x000...000). + * @return A promise of the txHash. + */ + public async executeBuyQuoteAsync( + buyQuote: BuyQuote, + rate?: BigNumber, + takerAddress?: string, + feeRecipient: string = constants.NULL_ADDRESS, + ): Promise { + assert.isValidBuyQuote('buyQuote', buyQuote); + if (!_.isUndefined(rate)) { + assert.isBigNumber('rate', rate); + } + if (!_.isUndefined(takerAddress)) { + assert.isETHAddressHex('takerAddress', takerAddress); + } + assert.isETHAddressHex('feeRecipient', feeRecipient); + const { orders, feeOrders, feePercentage, assetBuyAmount, maxRate } = buyQuote; + // if no takerAddress is provided, try to get one from the provider + let finalTakerAddress; + if (!_.isUndefined(takerAddress)) { + finalTakerAddress = takerAddress; + } else { + const web3Wrapper = new Web3Wrapper(this.provider); + const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); + const firstAvailableAddress = _.head(availableAddresses); + if (!_.isUndefined(firstAvailableAddress)) { + finalTakerAddress = firstAvailableAddress; + } else { + throw new Error(AssetBuyerError.NoAddressAvailable); + } + } + // if no rate is provided, default to the maxRate from buyQuote + const desiredRate = rate || maxRate; + // calculate how much eth is required to buy assetBuyAmount at the desired rate + const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate); + // TODO: critical + // update the forwarder wrapper to take in feePercentage as a number instead of a BigNumber, verify with Amir that this is being done correctly + const feePercentageBigNumber = !_.isUndefined(feePercentage) + ? Web3Wrapper.toBaseUnitAmount(new BigNumber(1), ETHER_TOKEN_DECIMALS).mul(feePercentage) + : constants.ZERO_AMOUNT; + const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( + orders, + assetBuyAmount, + finalTakerAddress, + ethAmount, + feeOrders, + feePercentageBigNumber, + feeRecipient, + ); + return txHash; + } + /** + * Ask the order fetcher for orders and process them. + */ + private async _getLatestOrdersAndFillableAmountsAsync(): Promise { + // find ether token asset data + const etherTokenAssetData = this._getEtherTokenAssetData(); + // find zrx token asset data + const zrxTokenAssetData = this._getZrxTokenAssetData(); + // construct order fetcher requests + const targetOrderFetcherRequest = { + makerAssetData: this.assetData, + takerAssetData: etherTokenAssetData, + networkId: this.networkId, + }; + const feeOrderFetcherRequest = { + makerAssetData: zrxTokenAssetData, + takerAssetData: etherTokenAssetData, + networkId: this.networkId, + }; + const requests = [targetOrderFetcherRequest, feeOrderFetcherRequest]; + // fetch orders and possible fillable amounts + const [targetOrderFetcherResponse, feeOrderFetcherResponse] = await Promise.all( + _.map(requests, request => this.orderFetcher.fetchOrdersAsync(request)), + ); + // process the responses into one object + const ordersAndFillableAmounts = await orderFetcherResponseProcessor.processAsync( + targetOrderFetcherResponse, + feeOrderFetcherResponse, + zrxTokenAssetData, + this._contractWrappers.orderValidator, + ); + return ordersAndFillableAmounts; + } + /** + * Get the assetData that represents the WETH token. + * Will throw if WETH does not exist for the current network. + */ + private _getEtherTokenAssetData(): string { + const etherTokenAddressIfExists = this._contractWrappers.etherToken.getContractAddressIfExists(); + if (_.isUndefined(etherTokenAddressIfExists)) { + throw new Error(AssetBuyerError.NoEtherTokenContractFound); + } + const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); + return etherTokenAssetData; + } + /** + * Get the assetData that represents the ZRX token. + * Will throw if ZRX does not exist for the current network. + */ + private _getZrxTokenAssetData(): string { + let zrxTokenAssetData: string; + try { + zrxTokenAssetData = this._contractWrappers.exchange.getZRXAssetData(); + } catch (err) { + throw new Error(AssetBuyerError.NoZrxTokenContractFound); + } + return zrxTokenAssetData; + } +} diff --git a/packages/asset-buyer/src/asset_buyers/asset_buyer.ts b/packages/asset-buyer/src/asset_buyers/asset_buyer.ts deleted file mode 100644 index eb7f85e2b..000000000 --- a/packages/asset-buyer/src/asset_buyers/asset_buyer.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { ContractWrappers } from '@0xproject/contract-wrappers'; -import { marketUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as _ from 'lodash'; -import { Provider } from 'ethereum-types'; - -import { constants } from '../constants'; -import { AssetBuyerError, BuyQuote, BuyQuoteRequest } from '../types'; - -const SLIPPAGE_PERCENTAGE = new BigNumber(0.2); // 20% slippage protection, possibly move this into request interface - -export interface AssetBuyerConfig { - orders: SignedOrder[]; - feeOrders: SignedOrder[]; - remainingFillableMakerAssetAmounts?: BigNumber[]; - remainingFillableFeeAmounts?: BigNumber[]; - networkId?: number; -} - -export class AssetBuyer { - public readonly provider: Provider; - public readonly config: AssetBuyerConfig; - private _contractWrappers: ContractWrappers; - constructor(provider: Provider, config: AssetBuyerConfig) { - this.provider = provider; - this.config = config; - const networkId = this.config.networkId || constants.MAINNET_NETWORK_ID; - this._contractWrappers = new ContractWrappers(this.provider, { - networkId, - }); - } - /** - * Given a BuyQuoteRequest, returns a BuyQuote containing all information relevant to fulfilling the buy. Pass the BuyQuote - * to executeBuyQuoteAsync to execute the buy. - * @param buyQuoteRequest An object that conforms to BuyQuoteRequest. See type definition for more information. - * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. - */ - public getBuyQuote(buyQuoteRequest: BuyQuoteRequest): BuyQuote { - const { assetBuyAmount, feePercentage } = buyQuoteRequest; - const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = this.config; - // TODO: optimization - // make the slippage percentage customizable - const slippageBufferAmount = assetBuyAmount.mul(SLIPPAGE_PERCENTAGE).round(); - const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( - orders, - assetBuyAmount, - { - remainingFillableMakerAssetAmounts, - slippageBufferAmount, - }, - ); - if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(AssetBuyerError.InsufficientAssetLiquidity); - } - // TODO: optimization - // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to - // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage - const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( - resultOrders, - feeOrders, - { - remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts, - }, - ); - if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { - throw new Error(AssetBuyerError.InsufficientZrxLiquidity); - } - const assetData = orders[0].makerAssetData; - // TODO: critical - // calculate minRate and maxRate by calculating min and max eth usage and then dividing into - // assetBuyAmount to get assetData / WETH - return { - assetData, - orders: resultOrders, - feeOrders: resultFeeOrders, - minRate: constants.ZERO_AMOUNT, - maxRate: constants.ZERO_AMOUNT, - assetBuyAmount, - feePercentage, - }; - } - /** - * Given a BuyQuote and desired rate, attempt to execute the buy. - * @param buyQuote An object that conforms to BuyQuote. See type definition for more information. - * @param rate The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate. - * @param takerAddress The address to perform the buy. Defaults to the first available address from the provider. - * @param feeRecipient The address where affiliate fees are sent. Defaults to null address (0x000...000). - * @return A promise of the txHash. - */ - public async executeBuyQuoteAsync( - buyQuote: BuyQuote, - rate?: BigNumber, - takerAddress?: string, - feeRecipient: string = constants.NULL_ADDRESS, - ): Promise { - const { orders, feeOrders, feePercentage, assetBuyAmount, maxRate } = buyQuote; - // if no takerAddress is provided, try to get one from the provider - let finalTakerAddress; - if (!_.isUndefined(takerAddress)) { - finalTakerAddress = takerAddress; - } else { - const web3Wrapper = new Web3Wrapper(this.provider); - const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); - const firstAvailableAddress = _.head(availableAddresses); - if (!_.isUndefined(firstAvailableAddress)) { - finalTakerAddress = firstAvailableAddress; - } else { - throw new Error(AssetBuyerError.NoAddressAvailable); - } - } - // if no rate is provided, default to the maxRate from buyQuote - const desiredRate = rate || maxRate; - // calculate how much eth is required to buy assetBuyAmount at the desired rate - const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate); - const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( - orders, - assetBuyAmount, - finalTakerAddress, - ethAmount, - feeOrders, - feePercentage, - feeRecipient, - ); - return txHash; - } -} diff --git a/packages/asset-buyer/src/forwarder_helper_factory.ts b/packages/asset-buyer/src/forwarder_helper_factory.ts index 9a3832e81..4c4adfda0 100644 --- a/packages/asset-buyer/src/forwarder_helper_factory.ts +++ b/packages/asset-buyer/src/forwarder_helper_factory.ts @@ -89,6 +89,7 @@ // } catch (err) { // throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); // } + // // validate orders and find remaining fillable from on chain state or sra api // let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; // let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 299b32edd..67ad06084 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -1,2 +1,13 @@ -export { AssetBuyerError, BuyQuote, BuyQuoteRequest } from './types'; -export { AssetBuyer } from './asset_buyers/asset_buyer'; +export { Provider } from 'ethereum-types'; +export { SignedOrder } from '@0xproject/types'; +export { BigNumber } from '@0xproject/utils'; + +export { AssetBuyer } from './asset_buyer'; +export { + AssetBuyerError, + BuyQuote, + OrderFetcher, + OrderFetcherRequest, + OrderFetcherResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from './types'; diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 8a12d0cf8..0da30f48d 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -2,22 +2,45 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; /** - * assetBuyAmount: The amount of asset to buy. - * feePercentage: Optional affiliate percentage amount factoring into eth amount calculations. + * makerAssetData: The assetData representing the desired makerAsset. + * takerAssetData: The assetData representing the desired takerAsset. + * networkId: The networkId that the desired orders should be for. */ -export interface BuyQuoteRequest { - assetBuyAmount: BigNumber; - feePercentage?: BigNumber; +export interface OrderFetcherRequest { + makerAssetData: string; + takerAssetData: string; + networkId: number; +} + +/** + * orders: An array of orders with optional remaining fillable makerAsset amounts. See type for more info. + */ +export interface OrderFetcherResponse { + orders: SignedOrderWithRemainingFillableMakerAssetAmount[]; +} + +/** + * A normal SignedOrder with one extra optional property `remainingFillableMakerAssetAmount` + * remainingFillableMakerAssetAmount: The amount of the makerAsset that is available to be filled + */ +export interface SignedOrderWithRemainingFillableMakerAssetAmount extends SignedOrder { + remainingFillableMakerAssetAmount?: BigNumber; +} +/** + * Given an OrderFetchRequest, get an OrderFetchResponse. + */ +export interface OrderFetcher { + fetchOrdersAsync: (orderFetchRequest: OrderFetcherRequest) => Promise; } /** - * assetData: The asset information. + * assetData: String that represents a specific asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested assetBuyAmount plus slippage. * feeOrders: An array of objects conforming to SignedOrder. These orders can be used to cover the fees for the orders param above. * minRate: Min rate that needs to be paid in order to execute the buy. * maxRate: Max rate that can be paid in order to execute the buy. - * assetBuyAmount: The amount of asset to buy. Passed through directly from the request. - * feePercentage: Affiliate fee percentage used to calculate the eth amounts above. Passed through directly from the request. + * assetBuyAmount: The amount of asset to buy. + * feePercentage: Optional affiliate fee percentage used to calculate the eth amounts above. */ export interface BuyQuote { assetData: string; @@ -26,11 +49,11 @@ export interface BuyQuote { minRate: BigNumber; maxRate: BigNumber; assetBuyAmount: BigNumber; - feePercentage?: BigNumber; + feePercentage?: number; } /** - * Possible errors thrown by an AssetBuyer instance or associated static methods + * Possible errors thrown by an AssetBuyer instance or associated static methods. */ export enum AssetBuyerError { NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', @@ -40,3 +63,10 @@ export enum AssetBuyerError { InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', NoAddressAvailable = 'NO_ADDRESS_AVAILABLE', } + +export interface AssetBuyerOrdersAndFillableAmounts { + orders: SignedOrderWithRemainingFillableMakerAssetAmount[]; + feeOrders: SignedOrderWithRemainingFillableMakerAssetAmount[]; + remainingFillableMakerAssetAmounts: BigNumber[]; + remainingFillableFeeAmounts: BigNumber[]; +} diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts new file mode 100644 index 000000000..c4d611477 --- /dev/null +++ b/packages/asset-buyer/src/utils/assert.ts @@ -0,0 +1,23 @@ +import { assert as sharedAssert } from '@0xproject/assert'; +import { schemas } from '@0xproject/json-schemas'; +import * as _ from 'lodash'; + +import { BuyQuote, OrderFetcher } from '../types'; + +export const assert = { + ...sharedAssert, + isValidBuyQuote(variableName: string, buyQuote: BuyQuote): void { + sharedAssert.isHexString(`${variableName}.assetData`, buyQuote.assetData); + sharedAssert.doesConformToSchema(`${variableName}.orders`, buyQuote.orders, schemas.signedOrdersSchema); + sharedAssert.doesConformToSchema(`${variableName}.feeOrders`, buyQuote.feeOrders, schemas.signedOrdersSchema); + sharedAssert.isBigNumber(`${variableName}.minRate`, buyQuote.minRate); + sharedAssert.isBigNumber(`${variableName}.maxRate`, buyQuote.maxRate); + sharedAssert.isBigNumber(`${variableName}.assetBuyAmount`, buyQuote.assetBuyAmount); + if (!_.isUndefined(buyQuote.feePercentage)) { + sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage); + } + }, + isValidOrderFetcher(variableName: string, orderFetcher: OrderFetcher): void { + sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.fetchOrdersAsync); + }, +}; diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts new file mode 100644 index 000000000..e05ab1e55 --- /dev/null +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -0,0 +1,60 @@ +import { marketUtils } from '@0xproject/order-utils'; +import { BigNumber } from '@0xproject/utils'; + +import { constants } from '../constants'; +import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types'; + +export const buyQuoteCalculator = { + calculate( + ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts, + assetBuyAmount: BigNumber, + feePercentage: number, + slippagePercentage: number, + ): BuyQuote { + const { + orders, + feeOrders, + remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts, + } = ordersAndFillableAmounts; + const slippageBufferAmount = assetBuyAmount.mul(slippagePercentage).round(); + const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( + orders, + assetBuyAmount, + { + remainingFillableMakerAssetAmounts, + slippageBufferAmount, + }, + ); + if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(AssetBuyerError.InsufficientAssetLiquidity); + } + // TODO: optimization + // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to + // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage + const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( + resultOrders, + feeOrders, + { + remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts, + }, + ); + if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { + throw new Error(AssetBuyerError.InsufficientZrxLiquidity); + } + const assetData = orders[0].makerAssetData; + // TODO: critical + // calculate minRate and maxRate by calculating min and max eth usage and then dividing into + // assetBuyAmount to get assetData / WETH, needs to take into account feePercentage as well + return { + assetData, + orders: resultOrders, + feeOrders: resultFeeOrders, + minRate: constants.ZERO_AMOUNT, + maxRate: constants.ZERO_AMOUNT, + assetBuyAmount, + feePercentage, + }; + }, +}; diff --git a/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts b/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts deleted file mode 100644 index d3cbb651a..000000000 --- a/packages/asset-buyer/src/utils/forwarder_helper_impl_config_utils.ts +++ /dev/null @@ -1,92 +0,0 @@ -// import { sortingUtils } from '@0xproject/order-utils'; -// import { SignedOrder } from '@0xproject/types'; -// import { BigNumber } from '@0xproject/utils'; -// import * as _ from 'lodash'; - -// import { ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; - -// interface SignedOrderWithAmount extends SignedOrder { -// remainingFillAmount: BigNumber; -// } - -// export const forwarderHelperImplConfigUtils = { -// sortedConfig(config: ForwarderHelperImplConfig): ForwarderHelperImplConfig { -// const { orders, feeOrders, remainingFillableMakerAssetAmounts, remainingFillableFeeAmounts } = config; -// // TODO: provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens -// const orderSorter = (ordersToSort: SignedOrder[]) => { -// return sortingUtils.sortOrdersByFeeAdjustedRate(ordersToSort); -// }; -// const sortOrdersResult = sortOrdersAndRemainingFillAmounts( -// orderSorter, -// orders, -// remainingFillableMakerAssetAmounts, -// ); -// const feeOrderSorter = (ordersToSort: SignedOrder[]) => { -// return sortingUtils.sortFeeOrdersByFeeAdjustedRate(ordersToSort); -// }; -// const sortFeeOrdersResult = sortOrdersAndRemainingFillAmounts( -// feeOrderSorter, -// feeOrders, -// remainingFillableFeeAmounts, -// ); -// return { -// orders: sortOrdersResult.orders, -// feeOrders: sortFeeOrdersResult.orders, -// remainingFillableMakerAssetAmounts: sortOrdersResult.remainingFillAmounts, -// remainingFillableFeeAmounts: sortFeeOrdersResult.remainingFillAmounts, -// }; -// }, -// }; - -// type OrderSorter = (orders: SignedOrder[]) => SignedOrder[]; - -// function sortOrdersAndRemainingFillAmounts( -// orderSorter: OrderSorter, -// orders: SignedOrder[], -// remainingFillAmounts?: BigNumber[], -// ): { orders: SignedOrder[]; remainingFillAmounts?: BigNumber[] } { -// if (!_.isUndefined(remainingFillAmounts)) { -// // Bundle orders together with their remainingFillAmounts so that we can sort them together -// const orderWithAmounts = bundleSignedOrderWithAmounts(orders, remainingFillAmounts); -// // Sort -// const sortedOrderWithAmounts = orderSorter(orderWithAmounts) as SignedOrderWithAmount[]; -// // Unbundle after sorting -// const unbundledSortedOrderWithAmounts = unbundleSignedOrderWithAmounts(sortedOrderWithAmounts); -// return { -// orders: unbundledSortedOrderWithAmounts.orders, -// remainingFillAmounts: unbundledSortedOrderWithAmounts.amounts, -// }; -// } else { -// const sortedOrders = orderSorter(orders); -// return { -// orders: sortedOrders, -// }; -// } -// } - -// function bundleSignedOrderWithAmounts(orders: SignedOrder[], amounts: BigNumber[]): SignedOrderWithAmount[] { -// const ordersAndAmounts = _.map(orders, (order, index) => { -// return { -// ...order, -// remainingFillAmount: amounts[index], -// }; -// }); -// return ordersAndAmounts; -// } - -// function unbundleSignedOrderWithAmounts( -// signedOrderWithAmounts: SignedOrderWithAmount[], -// ): { orders: SignedOrder[]; amounts: BigNumber[] } { -// const orders = _.map(signedOrderWithAmounts, order => { -// const { remainingFillAmount, ...rest } = order; -// return rest; -// }); -// const amounts = _.map(signedOrderWithAmounts, order => { -// const { remainingFillAmount } = order; -// return remainingFillAmount; -// }); -// return { -// orders, -// amounts, -// }; -// } diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts new file mode 100644 index 000000000..04c5355eb --- /dev/null +++ b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts @@ -0,0 +1,180 @@ +import { OrderAndTraderInfo, OrderStatus, OrderValidatorWrapper } from '@0xproject/contract-wrappers'; +import { sortingUtils } from '@0xproject/order-utils'; +import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from '../constants'; +import { + AssetBuyerOrdersAndFillableAmounts, + OrderFetcherResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from '../types'; + +import { orderUtils } from './order_utils'; + +interface OrdersAndRemainingFillableMakerAssetAmounts { + orders: SignedOrder[]; + remainingFillableMakerAssetAmounts: BigNumber[]; +} + +export const orderFetcherResponseProcessor = { + /** + * Take the responses for the target orders to buy and fee orders and process them. + * Processing includes: + * - Drop orders that are expired or not open orders (null taker address) + * - If shouldValidateOnChain, attempt to grab fillable amounts from on-chain otherwise assume completely fillable + * - Sort by rate + */ + async processAsync( + targetOrderFetcherResponse: OrderFetcherResponse, + feeOrderFetcherResponse: OrderFetcherResponse, + zrxTokenAssetData: string, + orderValidator?: OrderValidatorWrapper, + ): Promise { + // drop orders that are expired or not open + const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(targetOrderFetcherResponse.orders); + const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(feeOrderFetcherResponse.orders); + // set the orders to be sorted equal to the filtered orders + let unsortedTargetOrders = filteredTargetOrders; + let unsortedFeeOrders = filteredFeeOrders; + // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts + if (!_.isUndefined(orderValidator)) { + // TODO: critical + // try catch these requests and throw a more domain specific error + // TODO: optimization + // reduce this to once RPC call buy combining orders into one array and then splitting up the response + const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( + _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => { + const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); + return orderValidator.getOrdersAndTradersInfoAsync(ordersToBeValidated, takerAddresses); + }), + ); + // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts + unsortedTargetOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + filteredTargetOrders, + targetOrdersAndTradersInfo, + zrxTokenAssetData, + ); + // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts + unsortedFeeOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + filteredFeeOrders, + feeOrdersAndTradersInfo, + zrxTokenAssetData, + ); + } + // sort orders by rate + // TODO: optimization + // provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens + const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders); + const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders); + // unbundle orders and fillable amounts and compile final result + const targetOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedTargetOrders); + const feeOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedFeeOrders); + return { + orders: targetOrdersAndRemainingFillableMakerAssetAmounts.orders, + feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, + remainingFillableMakerAssetAmounts: + targetOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts: + feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + }; + }, +}; + +/** + * Given an array of orders, return a new array with expired and non open orders filtered out. + */ +function filterOutExpiredAndNonOpenOrders( + orders: SignedOrderWithRemainingFillableMakerAssetAmount[], +): SignedOrderWithRemainingFillableMakerAssetAmount[] { + const result = _.filter(orders, order => { + return orderUtils.isOpenOrder(order) && orderUtils.isOrderExpired(order); + }); + return result; +} + +/** + * Given an array of orders and corresponding on-chain infos, return a subset of the orders + * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts. + */ +function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + inputOrders: SignedOrder[], + ordersAndTradersInfo: OrderAndTraderInfo[], + zrxAssetData: string, +): SignedOrderWithRemainingFillableMakerAssetAmount[] { + // iterate through the input orders and find the ones that are still fillable + // for the orders that are still fillable, calculate the remaining fillable maker asset amount + const result = _.reduce( + inputOrders, + (accOrders, order, index) => { + // get corresponding on-chain state for the order + const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; + // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating + if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { + return accOrders; + } + // if the order IS fillable, add the order and calculate the remaining fillable amount + const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); + const transferrableFeeAssetAmount = BigNumber.min([ + traderInfo.makerZrxAllowance, + traderInfo.makerZrxBalance, + ]); + const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); + const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingTakerAssetAmount, + ); + const remainingFillableCalculator = new RemainingFillableCalculator( + order.makerFee, + order.makerAssetAmount, + order.makerAssetData === zrxAssetData, + transferrableAssetAmount, + transferrableFeeAssetAmount, + remainingMakerAssetAmount, + ); + const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); + // if the order does not have any remaining fillable makerAsset, do not add anything to the accumulations and continue iterating + if (remainingFillableAmount.lte(constants.ZERO_AMOUNT)) { + return accOrders; + } + const orderWithRemainingFillableMakerAssetAmount = { + ...order, + remainingFillableMakerAssetAmount: remainingFillableAmount, + }; + const newAccOrders = _.concat(accOrders, orderWithRemainingFillableMakerAssetAmount); + return newAccOrders; + }, + [] as SignedOrderWithRemainingFillableMakerAssetAmount[], + ); + return result; +} + +/** + * Given an array of orders with remaining fillable maker asset amounts. Unbundle into an instance of OrdersAndRemainingFillableMakerAssetAmounts. + * If an order is missing a corresponding remainingFillableMakerAssetAmount, assume it is completely fillable. + */ +function unbundleOrdersWithAmounts( + ordersWithAmounts: SignedOrderWithRemainingFillableMakerAssetAmount[], +): OrdersAndRemainingFillableMakerAssetAmounts { + const result = _.reduce( + ordersWithAmounts, + (acc, orderWithAmount) => { + const { orders, remainingFillableMakerAssetAmounts } = acc; + const { remainingFillableMakerAssetAmount, ...order } = orderWithAmount; + // if we are still missing a remainingFillableMakerAssetAmount, assume the order is completely fillable + const newRemainingAmount = remainingFillableMakerAssetAmount || order.makerAssetAmount; + const newAcc = { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat(remainingFillableMakerAssetAmounts, newRemainingAmount), + }; + return newAcc; + }, + { + orders: [] as SignedOrder[], + remainingFillableMakerAssetAmounts: [] as BigNumber[], + }, + ); + return result; +} -- cgit From 190bf2599c1327fffd03d8a9d50bc7568190cf33 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 13:56:20 +0200 Subject: Implement StandardRelayerAPIOrderFetcher --- .../asset-buyer/src/forwarder_helper_factory.ts | 262 --------------------- .../standard_relayer_api_order_fetcher.ts | 80 +++++++ .../src/utils/order_fetcher_response_processor.ts | 4 + 3 files changed, 84 insertions(+), 262 deletions(-) delete mode 100644 packages/asset-buyer/src/forwarder_helper_factory.ts create mode 100644 packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts diff --git a/packages/asset-buyer/src/forwarder_helper_factory.ts b/packages/asset-buyer/src/forwarder_helper_factory.ts deleted file mode 100644 index 4c4adfda0..000000000 --- a/packages/asset-buyer/src/forwarder_helper_factory.ts +++ /dev/null @@ -1,262 +0,0 @@ -// import { assert } from '@0xproject/assert'; -// import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; -// import { ContractWrappers, OrderAndTraderInfo, OrderStatus } from '@0xproject/contract-wrappers'; -// import { schemas } from '@0xproject/json-schemas'; -// import { assetDataUtils } from '@0xproject/order-utils'; -// import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; -// import { RPCSubprovider, Web3ProviderEngine } from '@0xproject/subproviders'; -// import { SignedOrder } from '@0xproject/types'; -// import { BigNumber } from '@0xproject/utils'; -// import * as _ from 'lodash'; - -// import { constants } from './constants'; -// import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; -// import { ForwarderHelper, ForwarderHelperFactoryError } from './types'; -// import { orderUtils } from './utils/order_utils'; - -// export const forwarderHelperFactory = { -// /** -// * Given an array of orders and an array of feeOrders, get a ForwarderHelper -// * @param orders An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData -// * @param feeOrders An array of objects conforming to SignedOrder. Each order should specify ZRX as makerAssetData WETH as takerAssetData -// * @return A ForwarderHelper, see type for definition -// */ -// getForwarderHelperForOrders(orders: SignedOrder[], feeOrders: SignedOrder[] = []): ForwarderHelper { -// assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); -// assert.doesConformToSchema('feeOrders', orders, schemas.signedOrdersSchema); -// // TODO: Add assertion here for orders all having the same makerAsset and takerAsset -// const config: ForwarderHelperImplConfig = { -// orders, -// feeOrders, -// }; -// const helper = new ForwarderHelperImpl(config); -// return helper; -// }, -// /** -// * Given a desired makerAsset and SRA url, get a ForwarderHelper -// * @param makerAssetData An array of objects conforming to SignedOrder. Each order should specify the same makerAssetData and takerAssetData -// * @param sraUrl A url pointing to an SRA v2 compliant endpoint. -// * @param rpcUrl A url pointing to an ethereum node. -// * @param networkId The ethereum networkId, defaults to 1 (mainnet). -// * @return A ForwarderHelper, see type for definition -// */ -// async getForwarderHelperForMakerAssetDataAsync( -// makerAssetData: string, -// sraUrl: string, -// rpcUrl?: string, -// networkId: number = 1, -// ): Promise { -// assert.isHexString('makerAssetData', makerAssetData); -// assert.isWebUri('sraUrl', sraUrl); -// if (!_.isUndefined(rpcUrl)) { -// assert.isWebUri('rpcUrl', rpcUrl); -// } -// assert.isNumber('networkId', networkId); -// // create provider -// const providerEngine = new Web3ProviderEngine(); -// if (!_.isUndefined(rpcUrl)) { -// providerEngine.addProvider(new RPCSubprovider(rpcUrl)); -// } -// providerEngine.start(); -// // create contract wrappers given provider and networkId -// const contractWrappers = new ContractWrappers(providerEngine, { networkId }); -// // find ether token asset data -// const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); -// if (_.isUndefined(etherTokenAddressIfExists)) { -// throw new Error(ForwarderHelperFactoryError.NoEtherTokenContractFound); -// } -// const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); -// // find zrx token asset data -// let zrxTokenAssetData: string; -// try { -// zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); -// } catch (err) { -// throw new Error(ForwarderHelperFactoryError.NoZrxTokenContractFound); -// } -// // get orderbooks for makerAsset/WETH and ZRX/WETH -// const sraClient = new HttpClient(sraUrl); -// const orderbookRequests = [ -// { baseAssetData: makerAssetData, quoteAssetData: etherTokenAssetData }, -// { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, -// ]; -// const requestOpts = { networkId }; -// let makerAssetOrderbook: OrderbookResponse; -// let zrxOrderbook: OrderbookResponse; -// try { -// [makerAssetOrderbook, zrxOrderbook] = await Promise.all( -// _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), -// ); -// } catch (err) { -// throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); -// } - -// // validate orders and find remaining fillable from on chain state or sra api -// let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; -// let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; -// if (!_.isUndefined(rpcUrl)) { -// // if we do have an rpc url, get on-chain orders and traders info via the OrderValidatorWrapper -// const ordersFromSra = getOpenAsksFromOrderbook(makerAssetOrderbook); -// const feeOrdersFromSra = getOpenAsksFromOrderbook(zrxOrderbook); -// // TODO: try catch these requests and throw a more domain specific error -// // TODO: optimization, reduce this to once RPC call buy combining orders into one array and then splitting up the response -// const [makerAssetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( -// _.map([ordersFromSra, feeOrdersFromSra], ordersToBeValidated => { -// const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); -// return contractWrappers.orderValidator.getOrdersAndTradersInfoAsync( -// ordersToBeValidated, -// takerAddresses, -// ); -// }), -// ); -// // take maker asset orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts -// ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( -// ordersFromSra, -// makerAssetOrdersAndTradersInfo, -// zrxTokenAssetData, -// ); -// // take fee orders from SRA + on chain information and find the valid orders and remaining fillable maker asset amounts -// feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( -// feeOrdersFromSra, -// feeOrdersAndTradersInfo, -// zrxTokenAssetData, -// ); -// } else { -// // if we don't have an rpc url, assume all orders are valid and fallback to optional fill amounts from SRA -// // if fill amounts are not available from the SRA, assume all orders are completely fillable -// const apiOrdersFromSra = makerAssetOrderbook.asks.records; -// const feeApiOrdersFromSra = zrxOrderbook.asks.records; -// // take maker asset orders from SRA and the valid orders and remaining fillable maker asset amounts -// ordersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( -// apiOrdersFromSra, -// ); -// // take fee orders from SRA and find the valid orders and remaining fillable maker asset amounts -// feeOrdersAndRemainingFillableMakerAssetAmounts = getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( -// feeApiOrdersFromSra, -// ); -// } -// // compile final config -// const config: ForwarderHelperImplConfig = { -// orders: ordersAndRemainingFillableMakerAssetAmounts.orders, -// feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, -// remainingFillableMakerAssetAmounts: -// ordersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, -// remainingFillableFeeAmounts: -// feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, -// }; -// const helper = new ForwarderHelperImpl(config); -// return helper; -// }, -// }; - -// interface OrdersAndRemainingFillableMakerAssetAmounts { -// orders: SignedOrder[]; -// remainingFillableMakerAssetAmounts: BigNumber[]; -// } - -// /** -// * Given an array of APIOrder objects from a standard relayer api, return an array -// * of fillable orders with their corresponding remainingFillableMakerAssetAmounts -// */ -// function getValidOrdersAndRemainingFillableMakerAssetAmountsFromApi( -// apiOrders: APIOrder[], -// ): OrdersAndRemainingFillableMakerAssetAmounts { -// const result = _.reduce( -// apiOrders, -// (acc, apiOrder) => { -// // get current accumulations -// const { orders, remainingFillableMakerAssetAmounts } = acc; -// // get order and metadata -// const { order, metaData } = apiOrder; -// // if the order is expired or not open, move on -// if (orderUtils.isOrderExpired(order) || !orderUtils.isOpenOrder(order)) { -// return acc; -// } -// // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable -// const remainingFillableTakerAssetAmount = _.get( -// metaData, -// 'remainingTakerAssetAmount', -// order.takerAssetAmount, -// ); -// const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( -// order, -// remainingFillableTakerAssetAmount, -// ); -// // if there is some amount of maker asset left to fill and add the order and remaining amount to the accumulations -// // if there is not any maker asset left to fill, do not add -// if (remainingFillableMakerAssetAmount.gt(constants.ZERO_AMOUNT)) { -// return { -// orders: _.concat(orders, order), -// remainingFillableMakerAssetAmounts: _.concat( -// remainingFillableMakerAssetAmounts, -// remainingFillableMakerAssetAmount, -// ), -// }; -// } else { -// return acc; -// } -// }, -// { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, -// ); -// return result; -// } - -// /** -// * Given an array of orders and corresponding on-chain infos, return a subset of the orders -// * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts -// */ -// function getValidOrdersAndRemainingFillableMakerAssetAmountsFromOnChain( -// inputOrders: SignedOrder[], -// ordersAndTradersInfo: OrderAndTraderInfo[], -// zrxAssetData: string, -// ): OrdersAndRemainingFillableMakerAssetAmounts { -// // iterate through the input orders and find the ones that are still fillable -// // for the orders that are still fillable, calculate the remaining fillable maker asset amount -// const result = _.reduce( -// inputOrders, -// (acc, order, index) => { -// // get current accumulations -// const { orders, remainingFillableMakerAssetAmounts } = acc; -// // get corresponding on-chain state for the order -// const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; -// // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating -// if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { -// return acc; -// } -// // if the order IS fillable, add the order and calculate the remaining fillable amount -// const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); -// const transferrableFeeAssetAmount = BigNumber.min([ -// traderInfo.makerZrxAllowance, -// traderInfo.makerZrxBalance, -// ]); -// const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); -// const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( -// order, -// remainingTakerAssetAmount, -// ); -// const remainingFillableCalculator = new RemainingFillableCalculator( -// order.makerFee, -// order.makerAssetAmount, -// order.makerAssetData === zrxAssetData, -// transferrableAssetAmount, -// transferrableFeeAssetAmount, -// remainingMakerAssetAmount, -// ); -// const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); -// return { -// orders: _.concat(orders, order), -// remainingFillableMakerAssetAmounts: _.concat( -// remainingFillableMakerAssetAmounts, -// remainingFillableAmount, -// ), -// }; -// }, -// { orders: [] as SignedOrder[], remainingFillableMakerAssetAmounts: [] as BigNumber[] }, -// ); -// return result; -// } - -// function getOpenAsksFromOrderbook(orderbookResponse: OrderbookResponse): SignedOrder[] { -// const asks = _.map(orderbookResponse.asks.records, apiOrder => apiOrder.order); -// const result = _.filter(asks, ask => orderUtils.isOpenOrder(ask)); -// return result; -// } diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts new file mode 100644 index 000000000..bf177b93b --- /dev/null +++ b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts @@ -0,0 +1,80 @@ +import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from '../constants'; +import { + AssetBuyerError, + OrderFetcher, + OrderFetcherRequest, + OrderFetcherResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from '../types'; +import { assert } from '../utils/assert'; +import { orderUtils } from '../utils/order_utils'; + +export class StandardRelayerAPIOrderFetcher implements OrderFetcher { + public readonly apiUrl: string; + private _sraClient: HttpClient; + /** + * Given an array of APIOrder objects from a standard relayer api, return an array + * of SignedOrderWithRemainingFillableMakerAssetAmounts + */ + private static _getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( + apiOrders: APIOrder[], + ): SignedOrderWithRemainingFillableMakerAssetAmount[] { + const result = _.map(apiOrders, apiOrder => { + const { order, metaData } = apiOrder; + // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable + const remainingFillableTakerAssetAmount = _.get( + metaData, + 'remainingTakerAssetAmount', + order.takerAssetAmount, + ); + const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingFillableTakerAssetAmount, + ); + const newOrder = { + ...order, + remainingFillableMakerAssetAmount, + }; + return newOrder; + }); + return result; + } + /** + * Instantiates a new StandardRelayerAPIOrderFetcher instance + * @param apiUrl The relayer API base HTTP url you would like to interact with. + * @return An instance of StandardRelayerAPIOrderFetcher + */ + constructor(apiUrl: string) { + assert.isWebUri('apiUrl', apiUrl); + this.apiUrl = apiUrl; + this._sraClient = new HttpClient(apiUrl); + } + /** + * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderFetcherResponse that satisfies the request. + * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. + * @return An instance of OrderFetcherResponse. See type for more information. + */ + public async fetchOrdersAsync(orderFetchRequest: OrderFetcherRequest): Promise { + const { makerAssetData, takerAssetData, networkId } = orderFetchRequest; + const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData }; + const requestOpts = { networkId }; + let orderbook: OrderbookResponse; + try { + orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest, requestOpts); + } catch (err) { + throw new Error(AssetBuyerError.StandardRelayerApiError); + } + const apiOrders = orderbook.asks.records; + const orders = StandardRelayerAPIOrderFetcher._getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( + apiOrders, + ); + return { + orders, + }; + } +} diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts index 04c5355eb..f1116a80f 100644 --- a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts @@ -165,6 +165,10 @@ function unbundleOrdersWithAmounts( const { remainingFillableMakerAssetAmount, ...order } = orderWithAmount; // if we are still missing a remainingFillableMakerAssetAmount, assume the order is completely fillable const newRemainingAmount = remainingFillableMakerAssetAmount || order.makerAssetAmount; + // if remaining amount is less than or equal to zero, do not add it + if (newRemainingAmount.lte(constants.ZERO_AMOUNT)) { + return acc; + } const newAcc = { orders: _.concat(orders, order), remainingFillableMakerAssetAmounts: _.concat(remainingFillableMakerAssetAmounts, newRemainingAmount), -- cgit From 4e59be9afce49fca8b396c305d5271c8299c85c1 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:08:19 +0200 Subject: Implement ProvidedOrderFetcher --- .../src/order_fetchers/provided_order_fetcher.ts | 41 ++++++++++++++++++++++ .../standard_relayer_api_order_fetcher.ts | 1 + packages/asset-buyer/src/utils/assert.ts | 7 +++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts diff --git a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts new file mode 100644 index 000000000..29b03f1c4 --- /dev/null +++ b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts @@ -0,0 +1,41 @@ +import { schemas } from '@0xproject/json-schemas'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from '../constants'; +import { + AssetBuyerError, + OrderFetcher, + OrderFetcherRequest, + OrderFetcherResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from '../types'; +import { assert } from '../utils/assert'; +import { orderUtils } from '../utils/order_utils'; + +export class ProvidedOrderFetcher implements OrderFetcher { + public readonly providedOrders: SignedOrder[]; + /** + * Instantiates a new ProvidedOrderFetcher instance + * @param providedOrders An array of objects that conform to SignedOrder to fetch from. + * @return An instance of ProvidedOrderFetcher + */ + constructor(providedOrders: SignedOrder[]) { + assert.doesConformToSchema('providedOrders', providedOrders, schemas.signedOrdersSchema); + this.providedOrders = providedOrders; + } + /** + * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderFetcherResponse that satisfies the request. + * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. + * @return An instance of OrderFetcherResponse. See type for more information. + */ + public async fetchOrdersAsync(orderFetchRequest: OrderFetcherRequest): Promise { + assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); + const { makerAssetData, takerAssetData } = orderFetchRequest; + const orders = _.filter(this.providedOrders, order => { + return order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData; + }); + return { orders }; + } +} diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts index bf177b93b..5688daf69 100644 --- a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts @@ -60,6 +60,7 @@ export class StandardRelayerAPIOrderFetcher implements OrderFetcher { * @return An instance of OrderFetcherResponse. See type for more information. */ public async fetchOrdersAsync(orderFetchRequest: OrderFetcherRequest): Promise { + assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); const { makerAssetData, takerAssetData, networkId } = orderFetchRequest; const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData }; const requestOpts = { networkId }; diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index c4d611477..0085ca41e 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -2,7 +2,7 @@ import { assert as sharedAssert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -import { BuyQuote, OrderFetcher } from '../types'; +import { BuyQuote, OrderFetcher, OrderFetcherRequest } from '../types'; export const assert = { ...sharedAssert, @@ -20,4 +20,9 @@ export const assert = { isValidOrderFetcher(variableName: string, orderFetcher: OrderFetcher): void { sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.fetchOrdersAsync); }, + isValidOrderFetcherRequest(variableName: string, orderFetcherRequest: OrderFetcherRequest): void { + sharedAssert.isHexString(`${variableName}.makerAssetData`, orderFetcherRequest.makerAssetData); + sharedAssert.isHexString(`${variableName}.takerAssetData`, orderFetcherRequest.takerAssetData); + sharedAssert.isNumber(`${variableName}.networkId`, orderFetcherRequest.networkId); + }, }; -- cgit From dfe58e4975e0ad3edf08fdc6d3441e83171096a9 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:08:34 +0200 Subject: Delete old test --- .../asset-buyer/test/forwarder_helper_impl_test.ts | 136 --------------------- 1 file changed, 136 deletions(-) delete mode 100644 packages/asset-buyer/test/forwarder_helper_impl_test.ts diff --git a/packages/asset-buyer/test/forwarder_helper_impl_test.ts b/packages/asset-buyer/test/forwarder_helper_impl_test.ts deleted file mode 100644 index b7c014402..000000000 --- a/packages/asset-buyer/test/forwarder_helper_impl_test.ts +++ /dev/null @@ -1,136 +0,0 @@ -// import { testOrderFactory } from '@0xproject/order-utils/lib/test/utils/test_order_factory'; -// import { BigNumber } from '@0xproject/utils'; -// import * as chai from 'chai'; -// import * as _ from 'lodash'; -// import 'mocha'; - -// import { ForwarderHelperImpl, ForwarderHelperImplConfig } from '@0xproject/asset-buyer/src/asset_buyer'; -// import { ForwarderHelperError } from '../src/types'; - -// import { chaiSetup } from './utils/chai_setup'; - -// chaiSetup.configure(); -// const expect = chai.expect; - -// describe('ForwarderHelperImpl', () => { -// // rate: 2 takerAsset / makerAsset -// const testOrder1 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(200), -// }); -// // rate: 1 takerAsset / makerAsset -// const testOrder2 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(100), -// }); -// // rate: 3 takerAsset / makerAsset -// const testOrder3 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(300), -// takerFee: new BigNumber(1), -// }); -// // rate: 3 WETH / ZRX -// const testFeeOrder1 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(300), -// }); -// // rate: 2 WETH / ZRX -// const testFeeOrder2 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(200), -// }); -// // rate: 1 WETH / ZRX -// const testFeeOrder3 = testOrderFactory.generateTestSignedOrder({ -// makerAssetAmount: new BigNumber(100), -// takerAssetAmount: new BigNumber(100), -// }); -// const inputForwarderHelperConfig: ForwarderHelperImplConfig = { -// orders: [testOrder1, testOrder2, testOrder3], -// feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], -// remainingFillableMakerAssetAmounts: [new BigNumber(1), new BigNumber(2), new BigNumber(3)], -// remainingFillableFeeAmounts: [new BigNumber(4), new BigNumber(5), new BigNumber(6)], -// }; -// describe('#constructor', () => { -// const inputForwarderHelperConfigNoRemainingAmounts: ForwarderHelperImplConfig = { -// orders: [testOrder1, testOrder2, testOrder3], -// feeOrders: [testFeeOrder1, testFeeOrder2, testFeeOrder3], -// }; -// it('sorts orders', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// expect(forwarderHelper.config.orders).deep.equals([testOrder2, testOrder1, testOrder3]); -// }); -// it('sorts fee orders', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// expect(forwarderHelper.config.feeOrders).deep.equals([testFeeOrder3, testFeeOrder2, testFeeOrder1]); -// }); -// it('sorts remainingFillableMakerAssetAmounts', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.not.undefined(); -// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 0)).to.bignumber.equal( -// new BigNumber(2), -// ); -// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 1)).to.bignumber.equal( -// new BigNumber(1), -// ); -// expect(_.nth(forwarderHelper.config.remainingFillableMakerAssetAmounts, 2)).to.bignumber.equal( -// new BigNumber(3), -// ); -// }); -// it('sorts remainingFillableFeeAmounts', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.not.undefined(); -// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 0)).to.bignumber.equal(new BigNumber(6)); -// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 1)).to.bignumber.equal(new BigNumber(5)); -// expect(_.nth(forwarderHelper.config.remainingFillableFeeAmounts, 2)).to.bignumber.equal(new BigNumber(4)); -// }); -// it('remainingFillableMakerAssetAmounts is undefined if none provided', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); -// expect(forwarderHelper.config.remainingFillableMakerAssetAmounts).to.be.undefined(); -// }); -// it('remainingFillableFeeAmounts is undefined if none provided', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoRemainingAmounts); -// expect(forwarderHelper.config.remainingFillableFeeAmounts).to.be.undefined(); -// }); -// }); -// describe('#getMarketBuyOrdersInfo', () => { -// it('throws if not enough makerAsset liquidity', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// expect(() => { -// // request for 6 makerAsset units, because we have exactly 6 available we should throw because there is a built in slippage buffer -// forwarderHelper.getMarketBuyOrdersInfo({ -// makerAssetFillAmount: new BigNumber(6), -// }); -// }).to.throw(ForwarderHelperError.InsufficientMakerAssetLiquidity); -// }); -// it('throws if not enough ZRX liquidity', () => { -// const inputForwarderHelperConfigNoFees: ForwarderHelperImplConfig = { -// orders: [testOrder1, testOrder2, testOrder3], -// feeOrders: [], -// }; -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfigNoFees); -// expect(() => { -// // request for 4 makerAsset units, we need fees but no fee orders exist, show we should throw -// forwarderHelper.getMarketBuyOrdersInfo({ -// makerAssetFillAmount: new BigNumber(250), -// }); -// }).to.throw(ForwarderHelperError.InsufficientZrxLiquidity); -// }); -// it('passes the makerAssetFillAmount from the request to the info response', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// const makerAssetFillAmount = new BigNumber(4); -// const info = forwarderHelper.getMarketBuyOrdersInfo({ -// makerAssetFillAmount, -// }); -// expect(info.makerAssetFillAmount).to.bignumber.equal(makerAssetFillAmount); -// }); -// it('passes the feePercentage from the request to the info response', () => { -// const forwarderHelper = new ForwarderHelperImpl(inputForwarderHelperConfig); -// const feePercentage = new BigNumber(0.2); -// const info = forwarderHelper.getMarketBuyOrdersInfo({ -// makerAssetFillAmount: new BigNumber(4), -// feePercentage, -// }); -// expect(info.feePercentage).to.bignumber.equal(feePercentage); -// }); -// }); -// }); -- cgit From c692115cdcbc761c0c4074db79f8c127b92da7e0 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:14:19 +0200 Subject: Fix lint errors --- packages/asset-buyer/src/asset_buyer.ts | 7 +++---- .../asset-buyer/src/order_fetchers/provided_order_fetcher.ts | 11 +---------- .../src/order_fetchers/standard_relayer_api_order_fetcher.ts | 5 +---- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 9cbdd8df6..3b603d929 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -1,6 +1,5 @@ import { ContractWrappers } from '@0xproject/contract-wrappers'; -import { assetDataUtils, marketUtils } from '@0xproject/order-utils'; -import { SignedOrder } from '@0xproject/types'; +import { assetDataUtils } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider } from 'ethereum-types'; @@ -29,7 +28,7 @@ export class AssetBuyer { public readonly orderFetcher: OrderFetcher; public readonly networkId: number; public readonly orderRefreshIntervalMs: number; - private _contractWrappers: ContractWrappers; + private readonly _contractWrappers: ContractWrappers; private _lastRefreshTimeIfExists?: number; private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; /** @@ -188,7 +187,7 @@ export class AssetBuyer { const requests = [targetOrderFetcherRequest, feeOrderFetcherRequest]; // fetch orders and possible fillable amounts const [targetOrderFetcherResponse, feeOrderFetcherResponse] = await Promise.all( - _.map(requests, request => this.orderFetcher.fetchOrdersAsync(request)), + _.map(requests, async request => this.orderFetcher.fetchOrdersAsync(request)), ); // process the responses into one object const ordersAndFillableAmounts = await orderFetcherResponseProcessor.processAsync( diff --git a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts index 29b03f1c4..7a7ffcdfe 100644 --- a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts @@ -1,18 +1,9 @@ import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import { constants } from '../constants'; -import { - AssetBuyerError, - OrderFetcher, - OrderFetcherRequest, - OrderFetcherResponse, - SignedOrderWithRemainingFillableMakerAssetAmount, -} from '../types'; +import { OrderFetcher, OrderFetcherRequest, OrderFetcherResponse } from '../types'; import { assert } from '../utils/assert'; -import { orderUtils } from '../utils/order_utils'; export class ProvidedOrderFetcher implements OrderFetcher { public readonly providedOrders: SignedOrder[]; diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts index 5688daf69..9fcd16ca1 100644 --- a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts @@ -1,9 +1,6 @@ import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import { constants } from '../constants'; import { AssetBuyerError, OrderFetcher, @@ -16,7 +13,7 @@ import { orderUtils } from '../utils/order_utils'; export class StandardRelayerAPIOrderFetcher implements OrderFetcher { public readonly apiUrl: string; - private _sraClient: HttpClient; + private readonly _sraClient: HttpClient; /** * Given an array of APIOrder objects from a standard relayer api, return an array * of SignedOrderWithRemainingFillableMakerAssetAmounts -- cgit From d57619b5db8d4b5a8d31f095d8dfef04faef44c9 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:16:08 +0200 Subject: Export the order fetchers --- packages/asset-buyer/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 67ad06084..efd3523fd 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -3,6 +3,8 @@ export { SignedOrder } from '@0xproject/types'; export { BigNumber } from '@0xproject/utils'; export { AssetBuyer } from './asset_buyer'; +export { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; +export { StandardRelayerAPIOrderFetcher } from './order_fetchers/standard_relayer_api_order_fetcher'; export { AssetBuyerError, BuyQuote, -- cgit From af40989f5f6b606172370d8e878c51ce2e7382eb Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:47:44 +0200 Subject: Add factory method on AssetBuyer for provided orders --- packages/asset-buyer/src/asset_buyer.ts | 24 +++++++++++++++++++++++- packages/asset-buyer/src/utils/assert.ts | 16 ++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 3b603d929..a68658d22 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -1,5 +1,6 @@ import { ContractWrappers } from '@0xproject/contract-wrappers'; -import { assetDataUtils } from '@0xproject/order-utils'; +import { schemas } from '@0xproject/json-schemas'; +import { assetDataUtils, SignedOrder } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider } from 'ethereum-types'; @@ -13,6 +14,7 @@ import { OrderFetcher, OrderFetcherResponse, } from './types'; +import { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; import { assert } from './utils/assert'; import { buyQuoteCalculator } from './utils/buy_quote_calculator'; import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; @@ -31,6 +33,26 @@ export class AssetBuyer { private readonly _contractWrappers: ContractWrappers; private _lastRefreshTimeIfExists?: number; private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; + public static getAssetBuyerForProvidedOrders( + provider: Provider, + orders: SignedOrder[], + feeOrders: SignedOrder[] = [], + networkId: number = constants.MAINNET_NETWORK_ID, + orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + ): AssetBuyer { + assert.isWeb3Provider('provider', provider); + assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); + assert.doesConformToSchema('feeOrders', feeOrders, schemas.signedOrdersSchema); + assert.isNumber('networkId', networkId); + assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); + assert.areValidProvidedOrders('orders', orders); + assert.areValidProvidedOrders('feeOrders', feeOrders); + assert.assert(orders.length !== 0, `Expected orders to contain at least one order`); + const assetData = orders[0].makerAssetData; + const orderFetcher = new ProvidedOrderFetcher(_.concat(orders, feeOrders)); + const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + return assetBuyer; + } /** * Instantiates a new AssetBuyer instance * @param provider The Provider instance you would like to use for interacting with the Ethereum network. diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index 0085ca41e..edc90608c 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -1,5 +1,6 @@ import { assert as sharedAssert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; +import { SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; import { BuyQuote, OrderFetcher, OrderFetcherRequest } from '../types'; @@ -25,4 +26,19 @@ export const assert = { sharedAssert.isHexString(`${variableName}.takerAssetData`, orderFetcherRequest.takerAssetData); sharedAssert.isNumber(`${variableName}.networkId`, orderFetcherRequest.networkId); }, + areValidProvidedOrders(variableName: string, orders: SignedOrder[]): void { + if (orders.length === 0) { + return; + } + const makerAssetData = orders[0].makerAssetData; + const takerAssetData = orders[0].takerAssetData; + const filteredOrders = _.filter( + orders, + order => order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData, + ); + sharedAssert.assert( + orders.length === filteredOrders.length, + `Expected all orders in ${variableName} to have the same makerAssetData and takerAssetData.`, + ); + }, }; -- cgit From 9ec2b5a2d53bad2820b297f90bd16528f87537eb Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 14:53:04 +0200 Subject: Add factory method on AssetBuyer for specific token address --- packages/asset-buyer/src/asset_buyer.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index a68658d22..bb3d6d77c 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -7,6 +7,8 @@ import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; import { constants } from './constants'; +import { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; +import { StandardRelayerAPIOrderFetcher } from './order_fetchers/standard_relayer_api_order_fetcher'; import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, @@ -14,7 +16,7 @@ import { OrderFetcher, OrderFetcherResponse, } from './types'; -import { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; + import { assert } from './utils/assert'; import { buyQuoteCalculator } from './utils/buy_quote_calculator'; import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; @@ -53,6 +55,23 @@ export class AssetBuyer { const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); return assetBuyer; } + public static getAssetBuyerForERC20TokenAddress( + provider: Provider, + tokenAddress: string, + sraApiUrl: string, + networkId: number = constants.MAINNET_NETWORK_ID, + orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + ): AssetBuyer { + assert.isWeb3Provider('provider', provider); + assert.isETHAddressHex('tokenAddress', tokenAddress); + assert.isWebUri('sraApiUrl', sraApiUrl); + assert.isNumber('networkId', networkId); + assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); + const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress); + const orderFetcher = new StandardRelayerAPIOrderFetcher(sraApiUrl); + const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + return assetBuyer; + } /** * Instantiates a new AssetBuyer instance * @param provider The Provider instance you would like to use for interacting with the Ethereum network. -- cgit From a22d2dc7ee3a1f354074009f3ff117b14050f5c6 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Sat, 15 Sep 2018 15:05:27 +0200 Subject: Add factory method for specific assetData to buy and add comments --- packages/asset-buyer/src/asset_buyer.ts | 55 +++++++++++++++++++++- .../standard_relayer_api_order_fetcher.ts | 2 +- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index bb3d6d77c..fa1118e18 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -35,6 +35,16 @@ export class AssetBuyer { private readonly _contractWrappers: ContractWrappers; private _lastRefreshTimeIfExists?: number; private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; + /** + * Instantiates a new AssetBuyer instance + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param orders A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH). + * @param feeOrders A array of objects that conform to SignedOrder. All orders must have the same makerAssetData (ZRX) and takerAssetData (WETH). Defaults to an empty array. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An instance of AssetBuyer + */ public static getAssetBuyerForProvidedOrders( provider: Provider, orders: SignedOrder[], @@ -55,6 +65,42 @@ export class AssetBuyer { const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); return assetBuyer; } + /** + * Instantiates a new AssetBuyer instance + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param assetData The assetData that identifies the desired asset to buy. + * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An instance of AssetBuyer + */ + public static getAssetBuyerForAssetData( + provider: Provider, + assetData: string, + sraApiUrl: string, + networkId: number = constants.MAINNET_NETWORK_ID, + orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + ): AssetBuyer { + assert.isWeb3Provider('provider', provider); + assert.isHexString('assetData', assetData); + assert.isWebUri('sraApiUrl', sraApiUrl); + assert.isNumber('networkId', networkId); + assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); + const orderFetcher = new StandardRelayerAPIOrderFetcher(sraApiUrl); + const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + return assetBuyer; + } + /** + * Instantiates a new AssetBuyer instance + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param tokenAddress The ERC20 token address that identifies the desired asset to buy. + * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An instance of AssetBuyer + */ public static getAssetBuyerForERC20TokenAddress( provider: Provider, tokenAddress: string, @@ -68,8 +114,13 @@ export class AssetBuyer { assert.isNumber('networkId', networkId); assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress); - const orderFetcher = new StandardRelayerAPIOrderFetcher(sraApiUrl); - const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + const assetBuyer = AssetBuyer.getAssetBuyerForAssetData( + provider, + assetData, + sraApiUrl, + networkId, + orderRefreshIntervalMs, + ); return assetBuyer; } /** diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts index 9fcd16ca1..3b082b68d 100644 --- a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts @@ -43,7 +43,7 @@ export class StandardRelayerAPIOrderFetcher implements OrderFetcher { } /** * Instantiates a new StandardRelayerAPIOrderFetcher instance - * @param apiUrl The relayer API base HTTP url you would like to interact with. + * @param apiUrl The standard relayer API base HTTP url you would like to source orders from. * @return An instance of StandardRelayerAPIOrderFetcher */ constructor(apiUrl: string) { -- cgit From e46807c28b0c915130b1b5e49d1c9f39f12751ae Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 13:55:31 +0200 Subject: Fix order creation and fill flow in Portal --- packages/website/package.json | 1 + packages/website/ts/blockchain.ts | 2 +- packages/website/ts/components/inputs/token_amount_input.tsx | 2 +- yarn.lock | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/website/package.json b/packages/website/package.json index b602a3116..f0a44b97b 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -20,6 +20,7 @@ "dependencies": { "0x.js": "^0.38.6", "@0xproject/contract-wrappers": "^1.0.1", + "@0xproject/json-schemas": "^1.0.1", "@0xproject/order-utils": "^1.0.1", "@0xproject/react-docs": "^1.0.8", "@0xproject/react-shared": "^1.0.9", diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index d3f2f3f7b..632a63016 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -228,7 +228,7 @@ export class Blockchain { const tokenSymbolToAddressOverrides = tokenAddressOverrides[this.networkId]; let isTokenAddressInOverrides = false; if (!_.isUndefined(tokenSymbolToAddressOverrides)) { - isTokenAddressInOverrides = _.keys(tokenSymbolToAddressOverrides).includes(tokenAddress); + isTokenAddressInOverrides = _.values(tokenSymbolToAddressOverrides).includes(tokenAddress); } return !_.isUndefined(tokenIfExists) || isTokenAddressInOverrides; } diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx index 93ef516cf..db093fb68 100644 --- a/packages/website/ts/components/inputs/token_amount_input.tsx +++ b/packages/website/ts/components/inputs/token_amount_input.tsx @@ -111,7 +111,7 @@ export class TokenAmountInput extends React.Component Insufficient allowance.{' '} Set allowance diff --git a/yarn.lock b/yarn.lock index aa30946a8..7464a9c5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5296,9 +5296,9 @@ ethereumjs-wallet@~0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: - version "3.0.18" - resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447" +ethers@3.0.22: + version "3.0.22" + resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" dependencies: aes-js "3.0.0" bn.js "^4.4.0" -- cgit From f6e1bf78c8c73221e06b3356c37a269265221275 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 14:33:47 +0200 Subject: Add yarn.lock --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7464a9c5d..aa30946a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5296,9 +5296,9 @@ ethereumjs-wallet@~0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@3.0.22: - version "3.0.22" - resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" +ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: + version "3.0.18" + resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447" dependencies: aes-js "3.0.0" bn.js "^4.4.0" -- cgit From 65f709d50ae559ec1b17f3c44f3d87e5d3cc4da7 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 16:07:08 +0200 Subject: Move all constants to own file --- packages/asset-buyer/src/asset_buyer.ts | 19 +++++++------------ packages/asset-buyer/src/constants.ts | 4 ++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index fa1118e18..76b96427e 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -21,11 +21,6 @@ import { assert } from './utils/assert'; import { buyQuoteCalculator } from './utils/buy_quote_calculator'; import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; -const SLIPPAGE_PERCENTAGE = 0.2; // 20% slippage protection, possibly move this into request interface -const DEFAULT_ORDER_REFRESH_INTERVAL_MS = 10000; // 10 seconds -const DEFAULT_FEE_PERCENTAGE = 0; -const ETHER_TOKEN_DECIMALS = 18; - export class AssetBuyer { public readonly provider: Provider; public readonly assetData: string; @@ -50,7 +45,7 @@ export class AssetBuyer { orders: SignedOrder[], feeOrders: SignedOrder[] = [], networkId: number = constants.MAINNET_NETWORK_ID, - orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); @@ -80,7 +75,7 @@ export class AssetBuyer { assetData: string, sraApiUrl: string, networkId: number = constants.MAINNET_NETWORK_ID, - orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.isHexString('assetData', assetData); @@ -106,7 +101,7 @@ export class AssetBuyer { tokenAddress: string, sraApiUrl: string, networkId: number = constants.MAINNET_NETWORK_ID, - orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -138,7 +133,7 @@ export class AssetBuyer { assetData: string, orderFetcher: OrderFetcher, networkId: number = constants.MAINNET_NETWORK_ID, - orderRefreshIntervalMs: number = DEFAULT_ORDER_REFRESH_INTERVAL_MS, + orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ) { assert.isWeb3Provider('provider', provider); assert.isString('assetData', assetData); @@ -165,7 +160,7 @@ export class AssetBuyer { */ public async getBuyQuoteAsync( assetBuyAmount: BigNumber, - feePercentage: number = DEFAULT_FEE_PERCENTAGE, + feePercentage: number = constants.DEFAULT_FEE_PERCENTAGE, forceOrderRefresh: boolean = false, ): Promise { assert.isBigNumber('assetBuyAmount', assetBuyAmount); @@ -196,7 +191,7 @@ export class AssetBuyer { ordersAndFillableAmounts, assetBuyAmount, feePercentage, - SLIPPAGE_PERCENTAGE, + constants.DEFAULT_SLIPPAGE_PERCENTAGE, ); return buyQuote; } @@ -244,7 +239,7 @@ export class AssetBuyer { // TODO: critical // update the forwarder wrapper to take in feePercentage as a number instead of a BigNumber, verify with Amir that this is being done correctly const feePercentageBigNumber = !_.isUndefined(feePercentage) - ? Web3Wrapper.toBaseUnitAmount(new BigNumber(1), ETHER_TOKEN_DECIMALS).mul(feePercentage) + ? Web3Wrapper.toBaseUnitAmount(new BigNumber(1), constants.ETHER_TOKEN_DECIMALS).mul(feePercentage) : constants.ZERO_AMOUNT; const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( orders, diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index 5785e705b..e20bcc6ed 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -4,4 +4,8 @@ export const constants = { ZERO_AMOUNT: new BigNumber(0), NULL_ADDRESS: '0x0000000000000000000000000000000000000000', MAINNET_NETWORK_ID: 1, + DEFAULT_SLIPPAGE_PERCENTAGE: 0.2, // 20% slippage protection + DEFAULT_ORDER_REFRESH_INTERVAL_MS: 10000, // 10 seconds + DEFAULT_FEE_PERCENTAGE: 0, + ETHER_TOKEN_DECIMALS: 18, }; -- cgit From 38afd108f8e1dbb56655260a415050f44754c630 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 16:07:47 +0200 Subject: Fix order expired bug --- packages/asset-buyer/src/utils/order_fetcher_response_processor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts index f1116a80f..f700cadf9 100644 --- a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts @@ -90,7 +90,7 @@ function filterOutExpiredAndNonOpenOrders( orders: SignedOrderWithRemainingFillableMakerAssetAmount[], ): SignedOrderWithRemainingFillableMakerAssetAmount[] { const result = _.filter(orders, order => { - return orderUtils.isOpenOrder(order) && orderUtils.isOrderExpired(order); + return orderUtils.isOpenOrder(order) && !orderUtils.isOrderExpired(order); }); return result; } -- cgit From b947609ff18f518ac36435083a97604b983a3081 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 16:26:50 +0200 Subject: Restrict orders field of AssetBuyerOrdersAndFillableAmounts to SignedOrder for consistency --- packages/asset-buyer/src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 0da30f48d..75773f0e8 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -65,8 +65,8 @@ export enum AssetBuyerError { } export interface AssetBuyerOrdersAndFillableAmounts { - orders: SignedOrderWithRemainingFillableMakerAssetAmount[]; - feeOrders: SignedOrderWithRemainingFillableMakerAssetAmount[]; + orders: SignedOrder[]; + feeOrders: SignedOrder[]; remainingFillableMakerAssetAmounts: BigNumber[]; remainingFillableFeeAmounts: BigNumber[]; } -- cgit From 0003666050c4991623cb36ec994d536e4703b4fe Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 16:42:52 +0200 Subject: make the slippage percentage customizable by integrator --- packages/asset-buyer/src/asset_buyer.ts | 10 +++++----- packages/asset-buyer/src/constants.ts | 11 +++++++++-- packages/asset-buyer/src/types.ts | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 76b96427e..a2c0f37c9 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -13,6 +13,7 @@ import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote, + BuyQuoteRequestOpts, OrderFetcher, OrderFetcherResponse, } from './types'; @@ -160,12 +161,13 @@ export class AssetBuyer { */ public async getBuyQuoteAsync( assetBuyAmount: BigNumber, - feePercentage: number = constants.DEFAULT_FEE_PERCENTAGE, - forceOrderRefresh: boolean = false, + options: Partial, ): Promise { + const { feePercentage, forceOrderRefresh, slippagePercentage } = { ...options, ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS }; assert.isBigNumber('assetBuyAmount', assetBuyAmount); assert.isNumber('feePercentage', feePercentage); assert.isBoolean('forceOrderRefresh', forceOrderRefresh); + assert.isNumber('feePercentage', slippagePercentage); // we should refresh if: // we do not have any orders OR // we are forced to OR @@ -185,13 +187,11 @@ export class AssetBuyer { ordersAndFillableAmounts = this ._currentOrdersAndFillableAmountsIfExists as AssetBuyerOrdersAndFillableAmounts; } - // TODO: optimization - // make the slippage percentage customizable by integrator const buyQuote = buyQuoteCalculator.calculate( ordersAndFillableAmounts, assetBuyAmount, feePercentage, - constants.DEFAULT_SLIPPAGE_PERCENTAGE, + slippagePercentage, ); return buyQuote; } diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index e20bcc6ed..53fe89160 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -1,11 +1,18 @@ import { BigNumber } from '@0xproject/utils'; +import { BuyQuoteRequestOpts } from './types'; + +const DEFAULT_BUY_QUOTE_REQUEST_OPTS: BuyQuoteRequestOpts = { + feePercentage: 0, + forceOrderRefresh: false, + slippagePercentage: 0.2, // 20% slippage protection +}; + export const constants = { ZERO_AMOUNT: new BigNumber(0), NULL_ADDRESS: '0x0000000000000000000000000000000000000000', MAINNET_NETWORK_ID: 1, - DEFAULT_SLIPPAGE_PERCENTAGE: 0.2, // 20% slippage protection DEFAULT_ORDER_REFRESH_INTERVAL_MS: 10000, // 10 seconds - DEFAULT_FEE_PERCENTAGE: 0, ETHER_TOKEN_DECIMALS: 18, + DEFAULT_BUY_QUOTE_REQUEST_OPTS, }; diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 75773f0e8..fb4aecd77 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -52,6 +52,12 @@ export interface BuyQuote { feePercentage?: number; } +export interface BuyQuoteRequestOpts { + feePercentage: number; + forceOrderRefresh: boolean; + slippagePercentage: number; +} + /** * Possible errors thrown by an AssetBuyer instance or associated static methods. */ -- cgit From fd4b4f8f8289d1e5a873ff5aa0aa9f7ac6a2ba08 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 18 Sep 2018 23:56:07 +0200 Subject: Make ForwaderWrapper take in a number for feePercentage instead of BigNumber --- .../src/contract_wrappers/forwarder_wrapper.ts | 17 +++++++++++------ packages/contract-wrappers/src/utils/constants.ts | 2 ++ packages/contract-wrappers/src/utils/utils.ts | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts index 13ef0fe01..906222731 100644 --- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts @@ -12,6 +12,7 @@ import { TransactionOpts } from '../types'; import { assert } from '../utils/assert'; import { calldataOptimizationUtils } from '../utils/calldata_optimization_utils'; import { constants } from '../utils/constants'; +import { utils } from '../utils/utils'; import { ContractWrapper } from './contract_wrapper'; import { ForwarderContract } from './generated/forwarder'; @@ -57,7 +58,7 @@ export class ForwarderWrapper extends ContractWrapper { takerAddress: string, ethAmount: BigNumber, signedFeeOrders: SignedOrder[] = [], - feePercentage: BigNumber = constants.ZERO_AMOUNT, + feePercentage: number = 0, feeRecipientAddress: string = constants.NULL_ADDRESS, txOpts: TransactionOpts = {}, ): Promise { @@ -66,7 +67,7 @@ export class ForwarderWrapper extends ContractWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); assert.isBigNumber('ethAmount', ethAmount); assert.doesConformToSchema('signedFeeOrders', signedFeeOrders, schemas.signedOrdersSchema); - assert.isBigNumber('feePercentage', feePercentage); + assert.isNumber('feePercentage', feePercentage); assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress); assert.doesConformToSchema('txOpts', txOpts, txOptsSchema); // other assertions @@ -76,6 +77,8 @@ export class ForwarderWrapper extends ContractWrapper { this.getZRXTokenAddress(), this.getEtherTokenAddress(), ); + // format feePercentage + const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage); // lowercase input addresses const normalizedTakerAddress = takerAddress.toLowerCase(); const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase(); @@ -89,7 +92,7 @@ export class ForwarderWrapper extends ContractWrapper { _.map(optimizedMarketOrders, order => order.signature), optimizedFeeOrders, _.map(optimizedFeeOrders, order => order.signature), - feePercentage, + formattedFeePercentage, feeRecipientAddress, { value: ethAmount, @@ -124,7 +127,7 @@ export class ForwarderWrapper extends ContractWrapper { takerAddress: string, ethAmount: BigNumber, signedFeeOrders: SignedOrder[] = [], - feePercentage: BigNumber = constants.ZERO_AMOUNT, + feePercentage: number = 0, feeRecipientAddress: string = constants.NULL_ADDRESS, txOpts: TransactionOpts = {}, ): Promise { @@ -134,7 +137,7 @@ export class ForwarderWrapper extends ContractWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); assert.isBigNumber('ethAmount', ethAmount); assert.doesConformToSchema('signedFeeOrders', signedFeeOrders, schemas.signedOrdersSchema); - assert.isBigNumber('feePercentage', feePercentage); + assert.isNumber('feePercentage', feePercentage); assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress); assert.doesConformToSchema('txOpts', txOpts, txOptsSchema); // other assertions @@ -144,6 +147,8 @@ export class ForwarderWrapper extends ContractWrapper { this.getZRXTokenAddress(), this.getEtherTokenAddress(), ); + // format feePercentage + const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage); // lowercase input addresses const normalizedTakerAddress = takerAddress.toLowerCase(); const normalizedFeeRecipientAddress = feeRecipientAddress.toLowerCase(); @@ -158,7 +163,7 @@ export class ForwarderWrapper extends ContractWrapper { _.map(optimizedMarketOrders, order => order.signature), optimizedFeeOrders, _.map(optimizedFeeOrders, order => order.signature), - feePercentage, + formattedFeePercentage, feeRecipientAddress, { value: ethAmount, diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts index 2df11538c..78441decf 100644 --- a/packages/contract-wrappers/src/utils/constants.ts +++ b/packages/contract-wrappers/src/utils/constants.ts @@ -12,4 +12,6 @@ export const constants = { UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1), DEFAULT_BLOCK_POLLING_INTERVAL: 1000, ZERO_AMOUNT: new BigNumber(0), + ONE_AMOUNT: new BigNumber(1), + ETHER_TOKEN_DECIMALS: 18, }; diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts index 689a7ee0a..f7949ec34 100644 --- a/packages/contract-wrappers/src/utils/utils.ts +++ b/packages/contract-wrappers/src/utils/utils.ts @@ -1,4 +1,7 @@ import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; + +import { constants } from './constants'; export const utils = { getCurrentUnixTimestampSec(): BigNumber { @@ -8,4 +11,7 @@ export const utils = { getCurrentUnixTimestampMs(): BigNumber { return new BigNumber(Date.now()); }, + numberPercentageToEtherTokenAmountPercentage(percentage: number): BigNumber { + return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).mul(percentage); + }, }; -- cgit From 93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 19 Sep 2018 00:57:05 +0200 Subject: Add isValidPercentage assert --- packages/asset-buyer/src/asset_buyer.ts | 20 +++++++------------- packages/asset-buyer/src/utils/assert.ts | 7 +++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index a2c0f37c9..7becb8285 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -159,15 +159,14 @@ export class AssetBuyer { * the next orderRefreshIntervalMs. Defaults to false. * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. */ - public async getBuyQuoteAsync( - assetBuyAmount: BigNumber, - options: Partial, - ): Promise { - const { feePercentage, forceOrderRefresh, slippagePercentage } = { ...options, ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS }; + public async getBuyQuoteAsync(assetBuyAmount: BigNumber, options: Partial): Promise { + const { feePercentage, forceOrderRefresh, slippagePercentage } = { + ...options, + ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS, + }; assert.isBigNumber('assetBuyAmount', assetBuyAmount); - assert.isNumber('feePercentage', feePercentage); + assert.isValidPercentage('feePercentage', feePercentage); assert.isBoolean('forceOrderRefresh', forceOrderRefresh); - assert.isNumber('feePercentage', slippagePercentage); // we should refresh if: // we do not have any orders OR // we are forced to OR @@ -236,18 +235,13 @@ export class AssetBuyer { const desiredRate = rate || maxRate; // calculate how much eth is required to buy assetBuyAmount at the desired rate const ethAmount = assetBuyAmount.dividedToIntegerBy(desiredRate); - // TODO: critical - // update the forwarder wrapper to take in feePercentage as a number instead of a BigNumber, verify with Amir that this is being done correctly - const feePercentageBigNumber = !_.isUndefined(feePercentage) - ? Web3Wrapper.toBaseUnitAmount(new BigNumber(1), constants.ETHER_TOKEN_DECIMALS).mul(feePercentage) - : constants.ZERO_AMOUNT; const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEthAsync( orders, assetBuyAmount, finalTakerAddress, ethAmount, feeOrders, - feePercentageBigNumber, + feePercentage, feeRecipient, ); return txHash; diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index edc90608c..745ba726f 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -41,4 +41,11 @@ export const assert = { `Expected all orders in ${variableName} to have the same makerAssetData and takerAssetData.`, ); }, + isValidPercentage(variableName: string, percentage: number): void { + assert.isNumber(variableName, percentage); + assert.assert( + percentage >= 0 && percentage <= 1, + `Expected ${variableName} to be between 0 and 1, but is ${percentage}`, + ); + }, }; -- cgit From 60e2dfdbda1e089ee4d4419243167eaeb769ff6a Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 19 Sep 2018 15:58:30 +0200 Subject: Calculate min and max rates in buy quote --- .../asset-buyer/src/utils/buy_quote_calculator.ts | 62 +++++++++++++++------- packages/order-utils/src/market_utils.ts | 39 +++++++++----- packages/order-utils/src/types.ts | 2 + 3 files changed, 70 insertions(+), 33 deletions(-) diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index e05ab1e55..52cecf8ad 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -1,5 +1,6 @@ import { marketUtils } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; import { constants } from '../constants'; import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types'; @@ -18,41 +19,64 @@ export const buyQuoteCalculator = { remainingFillableFeeAmounts, } = ordersAndFillableAmounts; const slippageBufferAmount = assetBuyAmount.mul(slippagePercentage).round(); - const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( - orders, - assetBuyAmount, - { - remainingFillableMakerAssetAmounts, - slippageBufferAmount, - }, - ); + const { + resultOrders, + remainingFillAmount, + ordersRemainingFillableMakerAssetAmounts, + } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(orders, assetBuyAmount, { + remainingFillableMakerAssetAmounts, + slippageBufferAmount, + }); if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { throw new Error(AssetBuyerError.InsufficientAssetLiquidity); } // TODO: optimization // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage - const { resultFeeOrders, remainingFeeAmount } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders( - resultOrders, - feeOrders, - { - remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts, - }, - ); + const { + resultFeeOrders, + remainingFeeAmount, + feeOrdersRemainingFillableMakerAssetAmounts, + } = marketUtils.findFeeOrdersThatCoverFeesForTargetOrders(resultOrders, feeOrders, { + remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts, + }); if (remainingFeeAmount.gt(constants.ZERO_AMOUNT)) { throw new Error(AssetBuyerError.InsufficientZrxLiquidity); } const assetData = orders[0].makerAssetData; - // TODO: critical + // calculate minRate and maxRate by calculating min and max eth usage and then dividing into // assetBuyAmount to get assetData / WETH, needs to take into account feePercentage as well + // minEthAmount = (sum(takerAssetAmount[i]) until sum(makerAssetAmount[i]) >= assetBuyAmount ) * (1 + feePercentage) + // maxEthAmount = (sum(takerAssetAmount[i]) until i == orders.length) * (1 + feePercentage) + const allOrders = _.concat(resultOrders, resultFeeOrders); + const allRemainingAmounts = _.concat( + ordersRemainingFillableMakerAssetAmounts, + feeOrdersRemainingFillableMakerAssetAmounts, + ); + let minEthAmount = constants.ZERO_AMOUNT; + let maxEthAmount = constants.ZERO_AMOUNT; + let cumulativeMakerAmount = constants.ZERO_AMOUNT; + _.forEach(allOrders, (order, index) => { + const remainingFillableMakerAssetAmount = allRemainingAmounts[index]; + const orderRate = order.takerAssetAmount.div(order.makerAssetAmount); + const claimableTakerAssetAmount = orderRate.mul(remainingFillableMakerAssetAmount); + // taker asset is always assumed to be WETH + maxEthAmount = maxEthAmount.plus(claimableTakerAssetAmount); + if (cumulativeMakerAmount.lessThan(assetBuyAmount)) { + minEthAmount = minEthAmount.plus(claimableTakerAssetAmount); + } + cumulativeMakerAmount = cumulativeMakerAmount.plus(remainingFillableMakerAssetAmount); + }); + const feeAdjustedMinRate = minEthAmount.mul(feePercentage + 1).div(assetBuyAmount); + const feeAdjustedMaxRate = minEthAmount.mul(feePercentage + 1).div(assetBuyAmount); return { assetData, orders: resultOrders, feeOrders: resultFeeOrders, - minRate: constants.ZERO_AMOUNT, - maxRate: constants.ZERO_AMOUNT, + minRate: feeAdjustedMinRate, + maxRate: feeAdjustedMaxRate, assetBuyAmount, feePercentage, }; diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index 4a664cb14..ed6af7d85 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -51,17 +51,23 @@ export const marketUtils = { // iterate through the orders input from left to right until we have enough makerAsset to fill totalFillAmount const result = _.reduce( orders, - ({ resultOrders, remainingFillAmount }, order, index) => { + ({ resultOrders, remainingFillAmount, ordersRemainingFillableMakerAssetAmounts }, order, index) => { if (remainingFillAmount.lessThanOrEqualTo(constants.ZERO_AMOUNT)) { - return { resultOrders, remainingFillAmount: constants.ZERO_AMOUNT }; + return { + resultOrders, + remainingFillAmount: constants.ZERO_AMOUNT, + ordersRemainingFillableMakerAssetAmounts, + }; } else { const makerAssetAmountAvailable = remainingFillableMakerAssetAmounts[index]; + const shouldIncludeOrder = makerAssetAmountAvailable.gt(constants.ZERO_AMOUNT); // if there is no makerAssetAmountAvailable do not append order to resultOrders // if we have exceeded the total amount we want to fill set remainingFillAmount to 0 return { - resultOrders: makerAssetAmountAvailable.gt(constants.ZERO_AMOUNT) - ? _.concat(resultOrders, order) - : resultOrders, + resultOrders: shouldIncludeOrder ? _.concat(resultOrders, order) : resultOrders, + ordersRemainingFillableMakerAssetAmounts: shouldIncludeOrder + ? _.concat(ordersRemainingFillableMakerAssetAmounts, makerAssetAmountAvailable) + : ordersRemainingFillableMakerAssetAmounts, remainingFillAmount: BigNumber.max( constants.ZERO_AMOUNT, remainingFillAmount.minus(makerAssetAmountAvailable), @@ -69,7 +75,11 @@ export const marketUtils = { }; } }, - { resultOrders: [] as T[], remainingFillAmount: totalFillAmount }, + { + resultOrders: [] as T[], + remainingFillAmount: totalFillAmount, + ordersRemainingFillableMakerAssetAmounts: [] as BigNumber[], + }, ); return result; }, @@ -133,17 +143,18 @@ export const marketUtils = { }, constants.ZERO_AMOUNT, ); - const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( - feeOrders, - totalFeeAmount, - { - remainingFillableMakerAssetAmounts: remainingFillableFeeAmounts, - slippageBufferAmount, - }, - ); + const { + resultOrders, + remainingFillAmount, + ordersRemainingFillableMakerAssetAmounts, + } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(feeOrders, totalFeeAmount, { + remainingFillableMakerAssetAmounts: remainingFillableFeeAmounts, + slippageBufferAmount, + }); return { resultFeeOrders: resultOrders, remainingFeeAmount: remainingFillAmount, + feeOrdersRemainingFillableMakerAssetAmounts: ordersRemainingFillableMakerAssetAmounts, }; // TODO: add more orders here to cover rounding // https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarding-contract-specification.md#over-buying-zrx diff --git a/packages/order-utils/src/types.ts b/packages/order-utils/src/types.ts index 09292e557..a843efaa4 100644 --- a/packages/order-utils/src/types.ts +++ b/packages/order-utils/src/types.ts @@ -72,10 +72,12 @@ export interface FindFeeOrdersThatCoverFeesForTargetOrdersOpts { export interface FeeOrdersAndRemainingFeeAmount { resultFeeOrders: T[]; + feeOrdersRemainingFillableMakerAssetAmounts: BigNumber[]; remainingFeeAmount: BigNumber; } export interface OrdersAndRemainingFillAmount { resultOrders: T[]; + ordersRemainingFillableMakerAssetAmounts: BigNumber[]; remainingFillAmount: BigNumber; } -- cgit From 14345ab24e0cd8db7bd2804b169acfaf18040ea4 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 19 Sep 2018 16:02:52 +0200 Subject: Rename forceOrderRefresh to shouldForceOrderRefresh --- packages/asset-buyer/src/asset_buyer.ts | 6 +++--- packages/asset-buyer/src/constants.ts | 2 +- packages/asset-buyer/src/types.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 7becb8285..81b46d89a 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -160,20 +160,20 @@ export class AssetBuyer { * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information. */ public async getBuyQuoteAsync(assetBuyAmount: BigNumber, options: Partial): Promise { - const { feePercentage, forceOrderRefresh, slippagePercentage } = { + const { feePercentage, shouldForceOrderRefresh, slippagePercentage } = { ...options, ...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS, }; assert.isBigNumber('assetBuyAmount', assetBuyAmount); assert.isValidPercentage('feePercentage', feePercentage); - assert.isBoolean('forceOrderRefresh', forceOrderRefresh); + assert.isBoolean('shouldForceOrderRefresh', shouldForceOrderRefresh); // we should refresh if: // we do not have any orders OR // we are forced to OR // we have some last refresh time AND that time was sufficiently long ago const shouldRefresh = _.isUndefined(this._currentOrdersAndFillableAmountsIfExists) || - forceOrderRefresh || + shouldForceOrderRefresh || (!_.isUndefined(this._lastRefreshTimeIfExists) && this._lastRefreshTimeIfExists + this.orderRefreshIntervalMs < Date.now()); let ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts; diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index 53fe89160..701832fd4 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -4,7 +4,7 @@ import { BuyQuoteRequestOpts } from './types'; const DEFAULT_BUY_QUOTE_REQUEST_OPTS: BuyQuoteRequestOpts = { feePercentage: 0, - forceOrderRefresh: false, + shouldForceOrderRefresh: false, slippagePercentage: 0.2, // 20% slippage protection }; diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index fb4aecd77..339bce52c 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -54,7 +54,7 @@ export interface BuyQuote { export interface BuyQuoteRequestOpts { feePercentage: number; - forceOrderRefresh: boolean; + shouldForceOrderRefresh: boolean; slippagePercentage: number; } -- cgit From a03b1d4d6cc5548f4c2f07a933a4c2cc6be3b053 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 19 Sep 2018 16:48:57 +0200 Subject: Move ObjectMap to shared types --- packages/types/CHANGELOG.json | 9 +++++++++ packages/types/src/index.ts | 4 ++++ packages/website/ts/types.ts | 6 +----- packages/website/ts/utils/analytics.ts | 3 ++- packages/website/ts/utils/token_address_overrides.ts | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 008ff8ff4..8448f4ae6 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "1.1.0", + "changes": [ + { + "note": "Add ObjectMap type", + "pr": 1037 + } + ] + }, { "version": "1.0.1", "changes": [ diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 48a9e23d1..25803e8c8 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -239,3 +239,7 @@ export enum StatusCodes { MethodNotAllowed = 405, GatewayTimeout = 504, } + +export interface ObjectMap { + [key: string]: T; +} diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 5fe9eef99..3c6d3df4d 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -1,4 +1,4 @@ -import { SignedOrder } from '@0xproject/types'; +import { ObjectMap, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Provider } from 'ethereum-types'; import * as React from 'react'; @@ -519,10 +519,6 @@ export interface OutdatedWrappedEtherByNetworkId { export type ItemByAddress = ObjectMap; -export interface ObjectMap { - [key: string]: T; -} - export type TokenStateByAddress = ItemByAddress; export interface TokenState { diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts index 62dbff2b9..3aae317b0 100644 --- a/packages/website/ts/utils/analytics.ts +++ b/packages/website/ts/utils/analytics.ts @@ -1,6 +1,7 @@ import { assetDataUtils } from '@0xproject/order-utils'; +import { ObjectMap } from '@0xproject/types'; import * as _ from 'lodash'; -import { ObjectMap, PortalOrder } from 'ts/types'; +import { PortalOrder } from 'ts/types'; import { utils } from 'ts/utils/utils'; export interface HeapAnalytics { diff --git a/packages/website/ts/utils/token_address_overrides.ts b/packages/website/ts/utils/token_address_overrides.ts index 8353358bc..e7e916273 100644 --- a/packages/website/ts/utils/token_address_overrides.ts +++ b/packages/website/ts/utils/token_address_overrides.ts @@ -1,4 +1,4 @@ -import { ObjectMap } from 'ts/types'; +import { ObjectMap } from '@0xproject/types'; import { constants } from 'ts/utils/constants'; // Map of networkId -> tokenSymbol -> tokenAddress -- cgit From a44f77a83811146ad68ee6f56bcda94e56d6a634 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 19 Sep 2018 18:38:50 +0200 Subject: Implement StandardRelayerAPIAssetBuyerManager --- packages/asset-buyer/src/asset_buyer.ts | 18 +-- packages/asset-buyer/src/constants.ts | 1 + packages/asset-buyer/src/index.ts | 2 + .../standard_relayer_api_asset_buyer_manager.ts | 125 +++++++++++++++++++++ packages/asset-buyer/src/types.ts | 7 ++ packages/asset-buyer/src/utils/asset_data_utils.ts | 26 +++++ .../asset-buyer/src/utils/buy_quote_calculator.ts | 1 + 7 files changed, 166 insertions(+), 14 deletions(-) create mode 100644 packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts create mode 100644 packages/asset-buyer/src/utils/asset_data_utils.ts diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 81b46d89a..5f57e3d7f 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -1,6 +1,6 @@ import { ContractWrappers } from '@0xproject/contract-wrappers'; import { schemas } from '@0xproject/json-schemas'; -import { assetDataUtils, SignedOrder } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider } from 'ethereum-types'; @@ -19,6 +19,7 @@ import { } from './types'; import { assert } from './utils/assert'; +import { assetDataUtils } from './utils/asset_data_utils'; import { buyQuoteCalculator } from './utils/buy_quote_calculator'; import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; @@ -284,24 +285,13 @@ export class AssetBuyer { * Will throw if WETH does not exist for the current network. */ private _getEtherTokenAssetData(): string { - const etherTokenAddressIfExists = this._contractWrappers.etherToken.getContractAddressIfExists(); - if (_.isUndefined(etherTokenAddressIfExists)) { - throw new Error(AssetBuyerError.NoEtherTokenContractFound); - } - const etherTokenAssetData = assetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); - return etherTokenAssetData; + return assetDataUtils.getEtherTokenAssetData(this._contractWrappers); } /** * Get the assetData that represents the ZRX token. * Will throw if ZRX does not exist for the current network. */ private _getZrxTokenAssetData(): string { - let zrxTokenAssetData: string; - try { - zrxTokenAssetData = this._contractWrappers.exchange.getZRXAssetData(); - } catch (err) { - throw new Error(AssetBuyerError.NoZrxTokenContractFound); - } - return zrxTokenAssetData; + return assetDataUtils.getZrxTokenAssetData(this._contractWrappers); } } diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index 701832fd4..0ebe0f8e2 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -15,4 +15,5 @@ export const constants = { DEFAULT_ORDER_REFRESH_INTERVAL_MS: 10000, // 10 seconds ETHER_TOKEN_DECIMALS: 18, DEFAULT_BUY_QUOTE_REQUEST_OPTS, + MAX_PER_PAGE: 10000, }; diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index efd3523fd..2156b7e96 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -5,6 +5,7 @@ export { BigNumber } from '@0xproject/utils'; export { AssetBuyer } from './asset_buyer'; export { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; export { StandardRelayerAPIOrderFetcher } from './order_fetchers/standard_relayer_api_order_fetcher'; +export { StandardRelayerAPIAssetBuyerManager } from './standard_relayer_api_asset_buyer_manager'; export { AssetBuyerError, BuyQuote, @@ -12,4 +13,5 @@ export { OrderFetcherRequest, OrderFetcherResponse, SignedOrderWithRemainingFillableMakerAssetAmount, + StandardRelayerApiAssetBuyerManagerError, } from './types'; diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts new file mode 100644 index 000000000..6cd96fab2 --- /dev/null +++ b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts @@ -0,0 +1,125 @@ +import { HttpClient } from '@0xproject/connect'; +import { ContractWrappers } from '@0xproject/contract-wrappers'; +import { ObjectMap } from '@0xproject/types'; +import { Provider } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { AssetBuyer } from './asset_buyer'; +import { constants } from './constants'; +import { assert } from './utils/assert'; +import { assetDataUtils } from './utils/asset_data_utils'; + +import { OrderFetcher, StandardRelayerApiAssetBuyerManagerError } from './types'; + +export class StandardRelayerAPIAssetBuyerManager { + // Map of assetData to AssetBuyer for that assetData + public readonly assetBuyerMap: ObjectMap; + /** + * Returns an array of all assetDatas available at the provided sraApiUrl + * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. + * @param pairedWithAssetData Optional filter argument to return assetDatas that only pair with this assetData value. + * + * @return An array of all assetDatas available at the provider sraApiUrl + */ + public static async getAllAvailableAssetDatasAsync( + sraApiUrl: string, + pairedWithAssetData?: string, + ): Promise { + const client = new HttpClient(sraApiUrl); + const params = { + assetDataA: pairedWithAssetData, + perPage: constants.MAX_PER_PAGE, + }; + const assetPairsResponse = await client.getAssetPairsAsync(params); + return _.uniq(_.map(assetPairsResponse.records, pairsItem => pairsItem.assetDataB.assetData)); + } + /** + * Instantiates a new StandardRelayerAPIAssetBuyerManager instance with all available assetDatas at the provided sraApiUrl + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. + * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An promise of an instance of StandardRelayerAPIAssetBuyerManager + */ + public static async getAssetBuyerManagerWithAllAvailableAssetDatasAsync( + provider: Provider, + sraApiUrl: string, + orderFetcher: OrderFetcher, + networkId: number = constants.MAINNET_NETWORK_ID, + orderRefreshIntervalMs?: number, + ): Promise { + const contractWrappers = new ContractWrappers(provider, { networkId }); + const etherTokenAssetData = assetDataUtils.getEtherTokenAssetData(contractWrappers); + const assetDatas = await StandardRelayerAPIAssetBuyerManager.getAllAvailableAssetDatasAsync( + sraApiUrl, + etherTokenAssetData, + ); + return new StandardRelayerAPIAssetBuyerManager( + provider, + assetDatas, + orderFetcher, + networkId, + orderRefreshIntervalMs, + ); + } + /** + * Instantiates a new StandardRelayerAPIAssetBuyerManager instance + * @param provider The Provider instance you would like to use for interacting with the Ethereum network. + * @param assetDatas The assetDatas of the desired assets to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). + * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param networkId The ethereum network id. Defaults to 1 (mainnet). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. + * Defaults to 10000ms (10s). + * @return An instance of StandardRelayerAPIAssetBuyerManager + */ + constructor( + provider: Provider, + assetDatas: string[], + orderFetcher: OrderFetcher, + networkId?: number, + orderRefreshIntervalMs?: number, + ) { + assert.assert(assetDatas.length > 0, `Expected 'assetDatas' to be a non-empty array.`); + this.assetBuyerMap = _.reduce( + assetDatas, + (accAssetBuyerMap: ObjectMap, assetData: string) => { + accAssetBuyerMap[assetData] = new AssetBuyer( + provider, + assetData, + orderFetcher, + networkId, + orderRefreshIntervalMs, + ); + return accAssetBuyerMap; + }, + {}, + ); + } + /** + * Get a AssetBuyer for the provided assetData + * @param assetData The desired assetData. + * + * @return An instance of AssetBuyer + */ + public getAssetBuyerFromAssetData(assetData: string): AssetBuyer { + const assetBuyer = this.assetBuyerMap[assetData]; + if (_.isUndefined(assetBuyer)) { + throw new Error( + `${StandardRelayerApiAssetBuyerManagerError.AssetBuyerNotFound}: For assetData ${assetData}`, + ); + } + return assetBuyer; + } + /** + * Get a AssetBuyer for the provided ERC20 tokenAddress + * @param tokenAddress The desired tokenAddress. + * + * @return An instance of AssetBuyer + */ + public getAssetBuyerFromERC20TokenAddress(tokenAddress: string): AssetBuyer { + const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress); + return this.getAssetBuyerFromAssetData(assetData); + } +} diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 339bce52c..c30bdf4bb 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -70,6 +70,13 @@ export enum AssetBuyerError { NoAddressAvailable = 'NO_ADDRESS_AVAILABLE', } +/** + * Possible errors thrown by an StandardRelayerApiAssetBuyerManager instance or associated static methods. + */ +export enum StandardRelayerApiAssetBuyerManagerError { + AssetBuyerNotFound = 'ASSET_BUYER_NOT_FOUND', +} + export interface AssetBuyerOrdersAndFillableAmounts { orders: SignedOrder[]; feeOrders: SignedOrder[]; diff --git a/packages/asset-buyer/src/utils/asset_data_utils.ts b/packages/asset-buyer/src/utils/asset_data_utils.ts new file mode 100644 index 000000000..10ff31057 --- /dev/null +++ b/packages/asset-buyer/src/utils/asset_data_utils.ts @@ -0,0 +1,26 @@ +import { ContractWrappers } from '@0xproject/contract-wrappers'; +import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils'; +import * as _ from 'lodash'; + +import { AssetBuyerError } from '../types'; + +export const assetDataUtils = { + ...sharedAssetDataUtils, + getEtherTokenAssetData(contractWrappers: ContractWrappers): string { + const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); + if (_.isUndefined(etherTokenAddressIfExists)) { + throw new Error(AssetBuyerError.NoEtherTokenContractFound); + } + const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); + return etherTokenAssetData; + }, + getZrxTokenAssetData(contractWrappers: ContractWrappers): string { + let zrxTokenAssetData: string; + try { + zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); + } catch (err) { + throw new Error(AssetBuyerError.NoZrxTokenContractFound); + } + return zrxTokenAssetData; + }, +}; diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index 52cecf8ad..31823cc02 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -59,6 +59,7 @@ export const buyQuoteCalculator = { let maxEthAmount = constants.ZERO_AMOUNT; let cumulativeMakerAmount = constants.ZERO_AMOUNT; _.forEach(allOrders, (order, index) => { + // TODO: Move this logic to order_utils const remainingFillableMakerAssetAmount = allRemainingAmounts[index]; const orderRate = order.takerAssetAmount.div(order.makerAssetAmount); const claimableTakerAssetAmount = orderRate.mul(remainingFillableMakerAssetAmount); -- cgit From abd308455abb1eb1bdb739e0b4c86887c573dc45 Mon Sep 17 00:00:00 2001 From: Philippe Castonguay Date: Wed, 19 Sep 2018 20:17:00 -0400 Subject: Add BigNumber[] support in ContractEventArg Currently, my contract has events that take a BigNumber array and typescript complains that ContractEventArg does not support this. --- packages/ethereum-types/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index 3b6fdc77b..f57d4d6e6 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -238,7 +238,7 @@ export enum AbiType { Fallback = 'fallback', } -export type ContractEventArg = string | BigNumber | number | boolean; +export type ContractEventArg = string | BigNumber | BigNumber[] |number | boolean; export interface DecodedLogArgs { [argName: string]: ContractEventArg; -- cgit From 3238925aa4e13750e5a8e45b3130ce9e148efae8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Sep 2018 14:09:11 +0200 Subject: Add better description to README --- packages/asset-buyer/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md index 717849bf2..f615b93e1 100644 --- a/packages/asset-buyer/README.md +++ b/packages/asset-buyer/README.md @@ -1,6 +1,8 @@ ## @0xproject/asset-buyer -Convenience package for buying assets +Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute Wrapped Ether based 0x orders without having to set allowances, wrap Ether or buy ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset. + +In its more advanced and useful form, it integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone. ### Read the [Documentation](https://0xproject.com/docs/asset-buyer). -- cgit From d23487bda9fa918d31bb940fffb74f8be0859be5 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Sep 2018 14:27:20 +0200 Subject: Update descriptions for methods on AssetBuyer --- packages/asset-buyer/src/asset_buyer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 5f57e3d7f..2b25c681c 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -33,7 +33,7 @@ export class AssetBuyer { private _lastRefreshTimeIfExists?: number; private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; /** - * Instantiates a new AssetBuyer instance + * Instantiates a new AssetBuyer instance given existing liquidity in the form of orders and feeOrders. * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param orders A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH). * @param feeOrders A array of objects that conform to SignedOrder. All orders must have the same makerAssetData (ZRX) and takerAssetData (WETH). Defaults to an empty array. @@ -63,7 +63,7 @@ export class AssetBuyer { return assetBuyer; } /** - * Instantiates a new AssetBuyer instance + * Instantiates a new AssetBuyer instance given the desired assetData and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param assetData The assetData that identifies the desired asset to buy. * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. @@ -89,7 +89,7 @@ export class AssetBuyer { return assetBuyer; } /** - * Instantiates a new AssetBuyer instance + * Instantiates a new AssetBuyer instance given the desired ERC20 token address and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param tokenAddress The ERC20 token address that identifies the desired asset to buy. * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. -- cgit From 03e18ff7c60749fd33228b25077891da26e81d41 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Sep 2018 15:10:15 +0200 Subject: Rename OrderFetcher to OrderProvider and other small improvements --- packages/asset-buyer/src/asset_buyer.ts | 28 ++++++++++------------ packages/asset-buyer/src/index.ts | 6 ++--- .../src/order_fetchers/provided_order_fetcher.ts | 6 ++--- .../standard_relayer_api_order_fetcher.ts | 10 ++++---- .../standard_relayer_api_asset_buyer_manager.ts | 21 ++++++++-------- packages/asset-buyer/src/types.ts | 8 +++---- packages/asset-buyer/src/utils/assert.ts | 8 +++---- packages/asset-buyer/src/utils/asset_data_utils.ts | 4 ++-- .../src/utils/order_fetcher_response_processor.ts | 6 ++--- 9 files changed, 48 insertions(+), 49 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 2b25c681c..e74b8eac1 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -14,8 +14,8 @@ import { AssetBuyerOrdersAndFillableAmounts, BuyQuote, BuyQuoteRequestOpts, - OrderFetcher, - OrderFetcherResponse, + OrderProvider, + OrderProviderResponse, } from './types'; import { assert } from './utils/assert'; @@ -26,7 +26,7 @@ import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_pr export class AssetBuyer { public readonly provider: Provider; public readonly assetData: string; - public readonly orderFetcher: OrderFetcher; + public readonly orderFetcher: OrderProvider; public readonly networkId: number; public readonly orderRefreshIntervalMs: number; private readonly _contractWrappers: ContractWrappers; @@ -133,7 +133,7 @@ export class AssetBuyer { constructor( provider: Provider, assetData: string, - orderFetcher: OrderFetcher, + orderFetcher: OrderProvider, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ) { @@ -152,8 +152,8 @@ export class AssetBuyer { }); } /** - * Get a BuyQuote containing all information relevant to fulfilling a buy. - * Pass the BuyQuote to executeBuyQuoteAsync to execute the buy. + * Get a `BuyQuote` containing all information relevant to fulfilling a buy. + * You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy. * @param assetBuyAmount The amount of asset to buy. * @param feePercentage The affiliate fee percentage. Defaults to 0. * @param forceOrderRefresh If set to true, new orders and state will be fetched instead of waiting for @@ -251,10 +251,8 @@ export class AssetBuyer { * Ask the order fetcher for orders and process them. */ private async _getLatestOrdersAndFillableAmountsAsync(): Promise { - // find ether token asset data - const etherTokenAssetData = this._getEtherTokenAssetData(); - // find zrx token asset data - const zrxTokenAssetData = this._getZrxTokenAssetData(); + const etherTokenAssetData = this._getEtherTokenAssetDataOrThrow(); + const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow(); // construct order fetcher requests const targetOrderFetcherRequest = { makerAssetData: this.assetData, @@ -269,7 +267,7 @@ export class AssetBuyer { const requests = [targetOrderFetcherRequest, feeOrderFetcherRequest]; // fetch orders and possible fillable amounts const [targetOrderFetcherResponse, feeOrderFetcherResponse] = await Promise.all( - _.map(requests, async request => this.orderFetcher.fetchOrdersAsync(request)), + _.map(requests, async request => this.orderFetcher.getOrdersAsync(request)), ); // process the responses into one object const ordersAndFillableAmounts = await orderFetcherResponseProcessor.processAsync( @@ -284,14 +282,14 @@ export class AssetBuyer { * Get the assetData that represents the WETH token. * Will throw if WETH does not exist for the current network. */ - private _getEtherTokenAssetData(): string { - return assetDataUtils.getEtherTokenAssetData(this._contractWrappers); + private _getEtherTokenAssetDataOrThrow(): string { + return assetDataUtils.getEtherTokenAssetDataOrThrow(this._contractWrappers); } /** * Get the assetData that represents the ZRX token. * Will throw if ZRX does not exist for the current network. */ - private _getZrxTokenAssetData(): string { - return assetDataUtils.getZrxTokenAssetData(this._contractWrappers); + private _getZrxTokenAssetDataOrThrow(): string { + return assetDataUtils.getZrxTokenAssetDataOrThrow(this._contractWrappers); } } diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 2156b7e96..aa10c3af2 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -9,9 +9,9 @@ export { StandardRelayerAPIAssetBuyerManager } from './standard_relayer_api_asse export { AssetBuyerError, BuyQuote, - OrderFetcher, - OrderFetcherRequest, - OrderFetcherResponse, + OrderProvider, + OrderProviderRequest, + OrderProviderResponse, SignedOrderWithRemainingFillableMakerAssetAmount, StandardRelayerApiAssetBuyerManagerError, } from './types'; diff --git a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts index 7a7ffcdfe..397f296d7 100644 --- a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts @@ -2,10 +2,10 @@ import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; -import { OrderFetcher, OrderFetcherRequest, OrderFetcherResponse } from '../types'; +import { OrderProvider, OrderProviderRequest, OrderProviderResponse } from '../types'; import { assert } from '../utils/assert'; -export class ProvidedOrderFetcher implements OrderFetcher { +export class ProvidedOrderFetcher implements OrderProvider { public readonly providedOrders: SignedOrder[]; /** * Instantiates a new ProvidedOrderFetcher instance @@ -21,7 +21,7 @@ export class ProvidedOrderFetcher implements OrderFetcher { * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. * @return An instance of OrderFetcherResponse. See type for more information. */ - public async fetchOrdersAsync(orderFetchRequest: OrderFetcherRequest): Promise { + public async getOrdersAsync(orderFetchRequest: OrderProviderRequest): Promise { assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); const { makerAssetData, takerAssetData } = orderFetchRequest; const orders = _.filter(this.providedOrders, order => { diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts index 3b082b68d..730eaf4e0 100644 --- a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts +++ b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts @@ -3,15 +3,15 @@ import * as _ from 'lodash'; import { AssetBuyerError, - OrderFetcher, - OrderFetcherRequest, - OrderFetcherResponse, + OrderProvider, + OrderProviderRequest, + OrderProviderResponse, SignedOrderWithRemainingFillableMakerAssetAmount, } from '../types'; import { assert } from '../utils/assert'; import { orderUtils } from '../utils/order_utils'; -export class StandardRelayerAPIOrderFetcher implements OrderFetcher { +export class StandardRelayerAPIOrderFetcher implements OrderProvider { public readonly apiUrl: string; private readonly _sraClient: HttpClient; /** @@ -56,7 +56,7 @@ export class StandardRelayerAPIOrderFetcher implements OrderFetcher { * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. * @return An instance of OrderFetcherResponse. See type for more information. */ - public async fetchOrdersAsync(orderFetchRequest: OrderFetcherRequest): Promise { + public async getOrdersAsync(orderFetchRequest: OrderProviderRequest): Promise { assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); const { makerAssetData, takerAssetData, networkId } = orderFetchRequest; const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData }; diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts index 6cd96fab2..866bee46e 100644 --- a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts +++ b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts @@ -9,8 +9,9 @@ import { constants } from './constants'; import { assert } from './utils/assert'; import { assetDataUtils } from './utils/asset_data_utils'; -import { OrderFetcher, StandardRelayerApiAssetBuyerManagerError } from './types'; +import { OrderProvider, StandardRelayerApiAssetBuyerManagerError } from './types'; +// TODO: Read-only list of available assetDatas export class StandardRelayerAPIAssetBuyerManager { // Map of assetData to AssetBuyer for that assetData public readonly assetBuyerMap: ObjectMap; @@ -37,7 +38,7 @@ export class StandardRelayerAPIAssetBuyerManager { * Instantiates a new StandardRelayerAPIAssetBuyerManager instance with all available assetDatas at the provided sraApiUrl * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. - * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param orderProvider An object that conforms to OrderProvider, see type for definition. * @param networkId The ethereum network id. Defaults to 1 (mainnet). * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. * Defaults to 10000ms (10s). @@ -46,12 +47,12 @@ export class StandardRelayerAPIAssetBuyerManager { public static async getAssetBuyerManagerWithAllAvailableAssetDatasAsync( provider: Provider, sraApiUrl: string, - orderFetcher: OrderFetcher, + orderProvider: OrderProvider, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs?: number, ): Promise { const contractWrappers = new ContractWrappers(provider, { networkId }); - const etherTokenAssetData = assetDataUtils.getEtherTokenAssetData(contractWrappers); + const etherTokenAssetData = assetDataUtils.getEtherTokenAssetDataOrThrow(contractWrappers); const assetDatas = await StandardRelayerAPIAssetBuyerManager.getAllAvailableAssetDatasAsync( sraApiUrl, etherTokenAssetData, @@ -59,7 +60,7 @@ export class StandardRelayerAPIAssetBuyerManager { return new StandardRelayerAPIAssetBuyerManager( provider, assetDatas, - orderFetcher, + orderProvider, networkId, orderRefreshIntervalMs, ); @@ -68,7 +69,7 @@ export class StandardRelayerAPIAssetBuyerManager { * Instantiates a new StandardRelayerAPIAssetBuyerManager instance * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param assetDatas The assetDatas of the desired assets to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). - * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param orderProvider An object that conforms to OrderProvider, see type for definition. * @param networkId The ethereum network id. Defaults to 1 (mainnet). * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. * Defaults to 10000ms (10s). @@ -77,7 +78,7 @@ export class StandardRelayerAPIAssetBuyerManager { constructor( provider: Provider, assetDatas: string[], - orderFetcher: OrderFetcher, + orderProvider: OrderProvider, networkId?: number, orderRefreshIntervalMs?: number, ) { @@ -88,7 +89,7 @@ export class StandardRelayerAPIAssetBuyerManager { accAssetBuyerMap[assetData] = new AssetBuyer( provider, assetData, - orderFetcher, + orderProvider, networkId, orderRefreshIntervalMs, ); @@ -98,7 +99,7 @@ export class StandardRelayerAPIAssetBuyerManager { ); } /** - * Get a AssetBuyer for the provided assetData + * Get an AssetBuyer for the provided assetData * @param assetData The desired assetData. * * @return An instance of AssetBuyer @@ -113,7 +114,7 @@ export class StandardRelayerAPIAssetBuyerManager { return assetBuyer; } /** - * Get a AssetBuyer for the provided ERC20 tokenAddress + * Get an AssetBuyer for the provided ERC20 tokenAddress * @param tokenAddress The desired tokenAddress. * * @return An instance of AssetBuyer diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index c30bdf4bb..09319fca4 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -6,7 +6,7 @@ import { BigNumber } from '@0xproject/utils'; * takerAssetData: The assetData representing the desired takerAsset. * networkId: The networkId that the desired orders should be for. */ -export interface OrderFetcherRequest { +export interface OrderProviderRequest { makerAssetData: string; takerAssetData: string; networkId: number; @@ -15,7 +15,7 @@ export interface OrderFetcherRequest { /** * orders: An array of orders with optional remaining fillable makerAsset amounts. See type for more info. */ -export interface OrderFetcherResponse { +export interface OrderProviderResponse { orders: SignedOrderWithRemainingFillableMakerAssetAmount[]; } @@ -29,8 +29,8 @@ export interface SignedOrderWithRemainingFillableMakerAssetAmount extends Signed /** * Given an OrderFetchRequest, get an OrderFetchResponse. */ -export interface OrderFetcher { - fetchOrdersAsync: (orderFetchRequest: OrderFetcherRequest) => Promise; +export interface OrderProvider { + getOrdersAsync: (orderProviderRequest: OrderProviderRequest) => Promise; } /** diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index 745ba726f..1d57ae9b8 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -3,7 +3,7 @@ import { schemas } from '@0xproject/json-schemas'; import { SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; -import { BuyQuote, OrderFetcher, OrderFetcherRequest } from '../types'; +import { BuyQuote, OrderProvider, OrderProviderRequest } from '../types'; export const assert = { ...sharedAssert, @@ -18,10 +18,10 @@ export const assert = { sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage); } }, - isValidOrderFetcher(variableName: string, orderFetcher: OrderFetcher): void { - sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.fetchOrdersAsync); + isValidOrderFetcher(variableName: string, orderFetcher: OrderProvider): void { + sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.getOrdersAsync); }, - isValidOrderFetcherRequest(variableName: string, orderFetcherRequest: OrderFetcherRequest): void { + isValidOrderFetcherRequest(variableName: string, orderFetcherRequest: OrderProviderRequest): void { sharedAssert.isHexString(`${variableName}.makerAssetData`, orderFetcherRequest.makerAssetData); sharedAssert.isHexString(`${variableName}.takerAssetData`, orderFetcherRequest.takerAssetData); sharedAssert.isNumber(`${variableName}.networkId`, orderFetcherRequest.networkId); diff --git a/packages/asset-buyer/src/utils/asset_data_utils.ts b/packages/asset-buyer/src/utils/asset_data_utils.ts index 10ff31057..d05ff2504 100644 --- a/packages/asset-buyer/src/utils/asset_data_utils.ts +++ b/packages/asset-buyer/src/utils/asset_data_utils.ts @@ -6,7 +6,7 @@ import { AssetBuyerError } from '../types'; export const assetDataUtils = { ...sharedAssetDataUtils, - getEtherTokenAssetData(contractWrappers: ContractWrappers): string { + getEtherTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string { const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists(); if (_.isUndefined(etherTokenAddressIfExists)) { throw new Error(AssetBuyerError.NoEtherTokenContractFound); @@ -14,7 +14,7 @@ export const assetDataUtils = { const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists); return etherTokenAssetData; }, - getZrxTokenAssetData(contractWrappers: ContractWrappers): string { + getZrxTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string { let zrxTokenAssetData: string; try { zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData(); diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts index f700cadf9..98ab6b9d1 100644 --- a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts @@ -8,7 +8,7 @@ import * as _ from 'lodash'; import { constants } from '../constants'; import { AssetBuyerOrdersAndFillableAmounts, - OrderFetcherResponse, + OrderProviderResponse, SignedOrderWithRemainingFillableMakerAssetAmount, } from '../types'; @@ -28,8 +28,8 @@ export const orderFetcherResponseProcessor = { * - Sort by rate */ async processAsync( - targetOrderFetcherResponse: OrderFetcherResponse, - feeOrderFetcherResponse: OrderFetcherResponse, + targetOrderFetcherResponse: OrderProviderResponse, + feeOrderFetcherResponse: OrderProviderResponse, zrxTokenAssetData: string, orderValidator?: OrderValidatorWrapper, ): Promise { -- cgit From 35c324f67c8022f3a71bc723bf69763bf651cb05 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Sep 2018 19:00:23 +0200 Subject: Add utility to get assetDatas --- .../asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts index 866bee46e..207713110 100644 --- a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts +++ b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts @@ -11,7 +11,6 @@ import { assetDataUtils } from './utils/asset_data_utils'; import { OrderProvider, StandardRelayerApiAssetBuyerManagerError } from './types'; -// TODO: Read-only list of available assetDatas export class StandardRelayerAPIAssetBuyerManager { // Map of assetData to AssetBuyer for that assetData public readonly assetBuyerMap: ObjectMap; @@ -123,4 +122,12 @@ export class StandardRelayerAPIAssetBuyerManager { const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress); return this.getAssetBuyerFromAssetData(assetData); } + /** + * Get a list of all the assetDatas that the instance supports + * + * @return An array of assetData strings + */ + public getAssetDatas(): string[] { + return _.keys(this.assetBuyerMap); + } } -- cgit From 90e28220fafe3912e86502a5d8af50972680900f Mon Sep 17 00:00:00 2001 From: Philippe Castonguay Date: Thu, 20 Sep 2018 16:19:08 -0400 Subject: Set ContractEventArg type definition to `any` --- packages/ethereum-types/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index f57d4d6e6..8f8f4b7e6 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -238,7 +238,7 @@ export enum AbiType { Fallback = 'fallback', } -export type ContractEventArg = string | BigNumber | BigNumber[] |number | boolean; +export type ContractEventArg = any; export interface DecodedLogArgs { [argName: string]: ContractEventArg; -- cgit From fcca63a2dc17f7745304d02dfaffe60f0d6785c4 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Sep 2018 23:39:55 +0200 Subject: Move some logic to order utils --- packages/asset-buyer/src/utils/buy_quote_calculator.ts | 10 ++++++---- packages/asset-buyer/src/utils/order_utils.ts | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index 31823cc02..aa7159e6c 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -3,6 +3,7 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { constants } from '../constants'; +import { orderUtils } from './order_utils'; import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types'; export const buyQuoteCalculator = { @@ -30,7 +31,7 @@ export const buyQuoteCalculator = { if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) { throw new Error(AssetBuyerError.InsufficientAssetLiquidity); } - // TODO: optimization + // TODO(bmillman): optimization // update this logic to find the minimum amount of feeOrders to cover the worst case as opposed to // finding order that cover all fees, this will help with estimating ETH and minimizing gas usage const { @@ -59,10 +60,11 @@ export const buyQuoteCalculator = { let maxEthAmount = constants.ZERO_AMOUNT; let cumulativeMakerAmount = constants.ZERO_AMOUNT; _.forEach(allOrders, (order, index) => { - // TODO: Move this logic to order_utils const remainingFillableMakerAssetAmount = allRemainingAmounts[index]; - const orderRate = order.takerAssetAmount.div(order.makerAssetAmount); - const claimableTakerAssetAmount = orderRate.mul(remainingFillableMakerAssetAmount); + const claimableTakerAssetAmount = orderUtils.calculateRemainingTakerAssetAmount( + order, + remainingFillableMakerAssetAmount, + ); // taker asset is always assumed to be WETH maxEthAmount = maxEthAmount.plus(claimableTakerAssetAmount); if (cumulativeMakerAmount.lessThan(assetBuyAmount)) { diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts index bb0bdb80f..27db73257 100644 --- a/packages/asset-buyer/src/utils/order_utils.ts +++ b/packages/asset-buyer/src/utils/order_utils.ts @@ -10,10 +10,16 @@ export const orderUtils = { return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec); }, calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { - const result = remainingTakerAssetAmount.eq(0) - ? constants.ZERO_AMOUNT - : remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); - return result; + if (remainingTakerAssetAmount.eq(0)) { + return constants.ZERO_AMOUNT; + } + return remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount); + }, + calculateRemainingTakerAssetAmount(order: SignedOrder, remainingMakerAssetAmount: BigNumber): BigNumber { + if (remainingMakerAssetAmount.eq(0)) { + return constants.ZERO_AMOUNT; + } + return remainingMakerAssetAmount.times(order.takerAssetAmount).dividedToIntegerBy(order.makerAssetAmount); }, isOpenOrder(order: SignedOrder): boolean { return order.takerAddress === constants.NULL_ADDRESS; -- cgit From 4e8ec2359d0f3842411d752fcfe966d540b10178 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 10:56:31 +0100 Subject: Also make sure the transactionReceipt contains a blockNumber when checking if a transaction has been mined. --- packages/web3-wrapper/CHANGELOG.json | 9 +++++++++ packages/web3-wrapper/src/web3_wrapper.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 57e6f7689..e1fdede0e 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.0.3", + "changes": [ + { + "note": + "Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined." + } + ] + }, { "timestamp": 1536142250, "version": "2.0.2", diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index ea78f8801..af0fe3a72 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -539,7 +539,7 @@ export class Web3Wrapper { } // Immediately check if the transaction has already been mined. let transactionReceipt = await this.getTransactionReceiptAsync(txHash); - if (!_.isNull(transactionReceipt)) { + if (!_.isNull(transactionReceipt) && !_.isNull(transactionReceipt.blockNumber)) { const logsWithDecodedArgs = _.map( transactionReceipt.logs, this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder), -- cgit From c10807c4e35a76a314f1c2e492a5c1410d30777e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 11:04:30 +0100 Subject: Add PR number --- packages/web3-wrapper/CHANGELOG.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index e1fdede0e..2b3c09ebc 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -4,7 +4,8 @@ "changes": [ { "note": - "Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined." + "Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined.", + "pr": 1079 } ] }, -- cgit From e6840c60c7a1528accb3aeb9c3aa4e94ff652dc3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 13:43:06 +0100 Subject: Add assertion that one cannot specify both blockHash & fromBlock/toBlock to getLogsAsync --- packages/web3-wrapper/src/web3_wrapper.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index af0fe3a72..e6944d4bb 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -438,6 +438,10 @@ export class Web3Wrapper { * @returns The corresponding log entries */ public async getLogsAsync(filter: FilterObject): Promise { + if (!_.isUndefined(filter.blockHash) && (!_.isUndefined(filter.fromBlock) || !_.isUndefined(filter.toBlock))) { + throw new Error(`Cannot specify 'blockHash' as well as 'fromBlock'/'toBlock' in the filter supplied to 'getLogsAsync'`); + } + let fromBlock = filter.fromBlock; if (_.isNumber(fromBlock)) { fromBlock = utils.numberToHex(fromBlock); -- cgit From 1b799e98e8505ff0195944b9987a938b9645b665 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 13:45:06 +0100 Subject: Add blockHash to FilterObject now that EIP234 is supported --- packages/ethereum-types/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index 8f8f4b7e6..a3ff2fddb 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -181,6 +181,7 @@ export interface CallData extends CallTxDataBase { export interface FilterObject { fromBlock?: number | string; toBlock?: number | string; + blockHash?: string; address?: string; topics?: LogTopic[]; } -- cgit From b0484eafe3ca6c66f3c5109721ced7b199f11823 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 13:46:10 +0100 Subject: Upgrade blockstream to version that supports fetching logs by blockHash, fixing reliability issues --- packages/contract-wrappers/package.json | 2 +- packages/order-watcher/package.json | 2 +- yarn.lock | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index ece5c9649..4ec93928c 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -82,7 +82,7 @@ "@0xproject/utils": "^1.0.8", "@0xproject/web3-wrapper": "^2.0.2", "ethereum-types": "^1.0.6", - "ethereumjs-blockstream": "5.0.0", + "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "js-sha3": "^0.7.0", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index a07e0f795..bc86a651f 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -82,7 +82,7 @@ "@0xproject/web3-wrapper": "^2.0.2", "bintrees": "^1.0.2", "ethereum-types": "^1.0.6", - "ethereumjs-blockstream": "5.0.0", + "ethereumjs-blockstream": "6.0.0", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/yarn.lock b/yarn.lock index aa30946a8..950b39fd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5203,6 +5203,14 @@ ethereumjs-blockstream@5.0.0: source-map-support "0.5.6" uuid "3.2.1" +ethereumjs-blockstream@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/ethereumjs-blockstream/-/ethereumjs-blockstream-6.0.0.tgz#79d726d1f358935eb65195e91d40344c31e87eff" + dependencies: + immutable "3.8.2" + source-map-support "0.5.6" + uuid "3.2.1" + ethereumjs-tx@0xProject/ethereumjs-tx#fake-tx-include-signature-by-default: version "1.3.4" resolved "https://codeload.github.com/0xProject/ethereumjs-tx/tar.gz/29d1153889c389591f74b2401da8a0c6ad40f9a7" @@ -6053,7 +6061,7 @@ ganache-core@0xProject/ganache-core#monorepo-dep: ethereumjs-tx "0xProject/ethereumjs-tx#fake-tx-include-signature-by-default" ethereumjs-util "^5.2.0" ethereumjs-vm "2.3.5" - ethereumjs-wallet "~0.6.0" + ethereumjs-wallet "0.6.0" fake-merkle-patricia-tree "~1.0.1" heap "~0.2.6" js-scrypt "^0.2.0" -- cgit From 97150cf55f472ca5c77b28d064976d84df9f2436 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 14:56:54 +0200 Subject: Add labels to TODOs --- packages/asset-buyer/src/utils/buy_quote_calculator.ts | 3 ++- packages/asset-buyer/src/utils/order_fetcher_response_processor.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index aa7159e6c..3d90a6ead 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -3,9 +3,10 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { constants } from '../constants'; -import { orderUtils } from './order_utils'; import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types'; +import { orderUtils } from './order_utils'; + export const buyQuoteCalculator = { calculate( ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts, diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts index 98ab6b9d1..ec4a6ce7e 100644 --- a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts @@ -41,9 +41,9 @@ export const orderFetcherResponseProcessor = { let unsortedFeeOrders = filteredFeeOrders; // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts if (!_.isUndefined(orderValidator)) { - // TODO: critical + // TODO(bmillman): improvement // try catch these requests and throw a more domain specific error - // TODO: optimization + // TODO(bmillman): optimization // reduce this to once RPC call buy combining orders into one array and then splitting up the response const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => { @@ -65,7 +65,7 @@ export const orderFetcherResponseProcessor = { ); } // sort orders by rate - // TODO: optimization + // TODO(bmillman): optimization // provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders); const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders); -- cgit From 8dea48ebeff775f7437c45f5a6d39dfc7dbf704e Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 15:21:44 +0200 Subject: Renamed orderFetcherResponseProcessor to orderProviderResponseProcessoer --- packages/asset-buyer/src/asset_buyer.ts | 4 +- .../src/utils/order_fetcher_response_processor.ts | 184 --------------------- .../src/utils/order_provider_response_processor.ts | 184 +++++++++++++++++++++ 3 files changed, 186 insertions(+), 186 deletions(-) delete mode 100644 packages/asset-buyer/src/utils/order_fetcher_response_processor.ts create mode 100644 packages/asset-buyer/src/utils/order_provider_response_processor.ts diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index e74b8eac1..74ced0e51 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -21,7 +21,7 @@ import { import { assert } from './utils/assert'; import { assetDataUtils } from './utils/asset_data_utils'; import { buyQuoteCalculator } from './utils/buy_quote_calculator'; -import { orderFetcherResponseProcessor } from './utils/order_fetcher_response_processor'; +import { orderProviderResponseProcessor } from './utils/order_provider_response_processor'; export class AssetBuyer { public readonly provider: Provider; @@ -270,7 +270,7 @@ export class AssetBuyer { _.map(requests, async request => this.orderFetcher.getOrdersAsync(request)), ); // process the responses into one object - const ordersAndFillableAmounts = await orderFetcherResponseProcessor.processAsync( + const ordersAndFillableAmounts = await orderProviderResponseProcessor.processAsync( targetOrderFetcherResponse, feeOrderFetcherResponse, zrxTokenAssetData, diff --git a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts b/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts deleted file mode 100644 index ec4a6ce7e..000000000 --- a/packages/asset-buyer/src/utils/order_fetcher_response_processor.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { OrderAndTraderInfo, OrderStatus, OrderValidatorWrapper } from '@0xproject/contract-wrappers'; -import { sortingUtils } from '@0xproject/order-utils'; -import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { constants } from '../constants'; -import { - AssetBuyerOrdersAndFillableAmounts, - OrderProviderResponse, - SignedOrderWithRemainingFillableMakerAssetAmount, -} from '../types'; - -import { orderUtils } from './order_utils'; - -interface OrdersAndRemainingFillableMakerAssetAmounts { - orders: SignedOrder[]; - remainingFillableMakerAssetAmounts: BigNumber[]; -} - -export const orderFetcherResponseProcessor = { - /** - * Take the responses for the target orders to buy and fee orders and process them. - * Processing includes: - * - Drop orders that are expired or not open orders (null taker address) - * - If shouldValidateOnChain, attempt to grab fillable amounts from on-chain otherwise assume completely fillable - * - Sort by rate - */ - async processAsync( - targetOrderFetcherResponse: OrderProviderResponse, - feeOrderFetcherResponse: OrderProviderResponse, - zrxTokenAssetData: string, - orderValidator?: OrderValidatorWrapper, - ): Promise { - // drop orders that are expired or not open - const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(targetOrderFetcherResponse.orders); - const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(feeOrderFetcherResponse.orders); - // set the orders to be sorted equal to the filtered orders - let unsortedTargetOrders = filteredTargetOrders; - let unsortedFeeOrders = filteredFeeOrders; - // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts - if (!_.isUndefined(orderValidator)) { - // TODO(bmillman): improvement - // try catch these requests and throw a more domain specific error - // TODO(bmillman): optimization - // reduce this to once RPC call buy combining orders into one array and then splitting up the response - const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( - _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => { - const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); - return orderValidator.getOrdersAndTradersInfoAsync(ordersToBeValidated, takerAddresses); - }), - ); - // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts - unsortedTargetOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( - filteredTargetOrders, - targetOrdersAndTradersInfo, - zrxTokenAssetData, - ); - // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts - unsortedFeeOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( - filteredFeeOrders, - feeOrdersAndTradersInfo, - zrxTokenAssetData, - ); - } - // sort orders by rate - // TODO(bmillman): optimization - // provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens - const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders); - const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders); - // unbundle orders and fillable amounts and compile final result - const targetOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedTargetOrders); - const feeOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedFeeOrders); - return { - orders: targetOrdersAndRemainingFillableMakerAssetAmounts.orders, - feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, - remainingFillableMakerAssetAmounts: - targetOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - remainingFillableFeeAmounts: - feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, - }; - }, -}; - -/** - * Given an array of orders, return a new array with expired and non open orders filtered out. - */ -function filterOutExpiredAndNonOpenOrders( - orders: SignedOrderWithRemainingFillableMakerAssetAmount[], -): SignedOrderWithRemainingFillableMakerAssetAmount[] { - const result = _.filter(orders, order => { - return orderUtils.isOpenOrder(order) && !orderUtils.isOrderExpired(order); - }); - return result; -} - -/** - * Given an array of orders and corresponding on-chain infos, return a subset of the orders - * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts. - */ -function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( - inputOrders: SignedOrder[], - ordersAndTradersInfo: OrderAndTraderInfo[], - zrxAssetData: string, -): SignedOrderWithRemainingFillableMakerAssetAmount[] { - // iterate through the input orders and find the ones that are still fillable - // for the orders that are still fillable, calculate the remaining fillable maker asset amount - const result = _.reduce( - inputOrders, - (accOrders, order, index) => { - // get corresponding on-chain state for the order - const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; - // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating - if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { - return accOrders; - } - // if the order IS fillable, add the order and calculate the remaining fillable amount - const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); - const transferrableFeeAssetAmount = BigNumber.min([ - traderInfo.makerZrxAllowance, - traderInfo.makerZrxBalance, - ]); - const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); - const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingTakerAssetAmount, - ); - const remainingFillableCalculator = new RemainingFillableCalculator( - order.makerFee, - order.makerAssetAmount, - order.makerAssetData === zrxAssetData, - transferrableAssetAmount, - transferrableFeeAssetAmount, - remainingMakerAssetAmount, - ); - const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); - // if the order does not have any remaining fillable makerAsset, do not add anything to the accumulations and continue iterating - if (remainingFillableAmount.lte(constants.ZERO_AMOUNT)) { - return accOrders; - } - const orderWithRemainingFillableMakerAssetAmount = { - ...order, - remainingFillableMakerAssetAmount: remainingFillableAmount, - }; - const newAccOrders = _.concat(accOrders, orderWithRemainingFillableMakerAssetAmount); - return newAccOrders; - }, - [] as SignedOrderWithRemainingFillableMakerAssetAmount[], - ); - return result; -} - -/** - * Given an array of orders with remaining fillable maker asset amounts. Unbundle into an instance of OrdersAndRemainingFillableMakerAssetAmounts. - * If an order is missing a corresponding remainingFillableMakerAssetAmount, assume it is completely fillable. - */ -function unbundleOrdersWithAmounts( - ordersWithAmounts: SignedOrderWithRemainingFillableMakerAssetAmount[], -): OrdersAndRemainingFillableMakerAssetAmounts { - const result = _.reduce( - ordersWithAmounts, - (acc, orderWithAmount) => { - const { orders, remainingFillableMakerAssetAmounts } = acc; - const { remainingFillableMakerAssetAmount, ...order } = orderWithAmount; - // if we are still missing a remainingFillableMakerAssetAmount, assume the order is completely fillable - const newRemainingAmount = remainingFillableMakerAssetAmount || order.makerAssetAmount; - // if remaining amount is less than or equal to zero, do not add it - if (newRemainingAmount.lte(constants.ZERO_AMOUNT)) { - return acc; - } - const newAcc = { - orders: _.concat(orders, order), - remainingFillableMakerAssetAmounts: _.concat(remainingFillableMakerAssetAmounts, newRemainingAmount), - }; - return newAcc; - }, - { - orders: [] as SignedOrder[], - remainingFillableMakerAssetAmounts: [] as BigNumber[], - }, - ); - return result; -} diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts new file mode 100644 index 000000000..79e15c3d8 --- /dev/null +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -0,0 +1,184 @@ +import { OrderAndTraderInfo, OrderStatus, OrderValidatorWrapper } from '@0xproject/contract-wrappers'; +import { sortingUtils } from '@0xproject/order-utils'; +import { RemainingFillableCalculator } from '@0xproject/order-utils/lib/src/remaining_fillable_calculator'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { constants } from '../constants'; +import { + AssetBuyerOrdersAndFillableAmounts, + OrderProviderResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from '../types'; + +import { orderUtils } from './order_utils'; + +interface OrdersAndRemainingFillableMakerAssetAmounts { + orders: SignedOrder[]; + remainingFillableMakerAssetAmounts: BigNumber[]; +} + +export const orderProviderResponseProcessor = { + /** + * Take the responses for the target orders to buy and fee orders and process them. + * Processing includes: + * - Drop orders that are expired or not open orders (null taker address) + * - If shouldValidateOnChain, attempt to grab fillable amounts from on-chain otherwise assume completely fillable + * - Sort by rate + */ + async processAsync( + targetOrderProviderResponse: OrderProviderResponse, + feeOrderProviderResponse: OrderProviderResponse, + zrxTokenAssetData: string, + orderValidator?: OrderValidatorWrapper, + ): Promise { + // drop orders that are expired or not open + const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(targetOrderProviderResponse.orders); + const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(feeOrderProviderResponse.orders); + // set the orders to be sorted equal to the filtered orders + let unsortedTargetOrders = filteredTargetOrders; + let unsortedFeeOrders = filteredFeeOrders; + // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts + if (!_.isUndefined(orderValidator)) { + // TODO(bmillman): improvement + // try catch these requests and throw a more domain specific error + // TODO(bmillman): optimization + // reduce this to once RPC call buy combining orders into one array and then splitting up the response + const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( + _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => { + const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS); + return orderValidator.getOrdersAndTradersInfoAsync(ordersToBeValidated, takerAddresses); + }), + ); + // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts + unsortedTargetOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + filteredTargetOrders, + targetOrdersAndTradersInfo, + zrxTokenAssetData, + ); + // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts + unsortedFeeOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + filteredFeeOrders, + feeOrdersAndTradersInfo, + zrxTokenAssetData, + ); + } + // sort orders by rate + // TODO(bmillman): optimization + // provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens + const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders); + const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders); + // unbundle orders and fillable amounts and compile final result + const targetOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedTargetOrders); + const feeOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedFeeOrders); + return { + orders: targetOrdersAndRemainingFillableMakerAssetAmounts.orders, + feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders, + remainingFillableMakerAssetAmounts: + targetOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + remainingFillableFeeAmounts: + feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts, + }; + }, +}; + +/** + * Given an array of orders, return a new array with expired and non open orders filtered out. + */ +function filterOutExpiredAndNonOpenOrders( + orders: SignedOrderWithRemainingFillableMakerAssetAmount[], +): SignedOrderWithRemainingFillableMakerAssetAmount[] { + const result = _.filter(orders, order => { + return orderUtils.isOpenOrder(order) && !orderUtils.isOrderExpired(order); + }); + return result; +} + +/** + * Given an array of orders and corresponding on-chain infos, return a subset of the orders + * that are still fillable orders with their corresponding remainingFillableMakerAssetAmounts. + */ +function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain( + inputOrders: SignedOrder[], + ordersAndTradersInfo: OrderAndTraderInfo[], + zrxAssetData: string, +): SignedOrderWithRemainingFillableMakerAssetAmount[] { + // iterate through the input orders and find the ones that are still fillable + // for the orders that are still fillable, calculate the remaining fillable maker asset amount + const result = _.reduce( + inputOrders, + (accOrders, order, index) => { + // get corresponding on-chain state for the order + const { orderInfo, traderInfo } = ordersAndTradersInfo[index]; + // if the order IS NOT fillable, do not add anything to the accumulations and continue iterating + if (orderInfo.orderStatus !== OrderStatus.FILLABLE) { + return accOrders; + } + // if the order IS fillable, add the order and calculate the remaining fillable amount + const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]); + const transferrableFeeAssetAmount = BigNumber.min([ + traderInfo.makerZrxAllowance, + traderInfo.makerZrxBalance, + ]); + const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount); + const remainingMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingTakerAssetAmount, + ); + const remainingFillableCalculator = new RemainingFillableCalculator( + order.makerFee, + order.makerAssetAmount, + order.makerAssetData === zrxAssetData, + transferrableAssetAmount, + transferrableFeeAssetAmount, + remainingMakerAssetAmount, + ); + const remainingFillableAmount = remainingFillableCalculator.computeRemainingFillable(); + // if the order does not have any remaining fillable makerAsset, do not add anything to the accumulations and continue iterating + if (remainingFillableAmount.lte(constants.ZERO_AMOUNT)) { + return accOrders; + } + const orderWithRemainingFillableMakerAssetAmount = { + ...order, + remainingFillableMakerAssetAmount: remainingFillableAmount, + }; + const newAccOrders = _.concat(accOrders, orderWithRemainingFillableMakerAssetAmount); + return newAccOrders; + }, + [] as SignedOrderWithRemainingFillableMakerAssetAmount[], + ); + return result; +} + +/** + * Given an array of orders with remaining fillable maker asset amounts. Unbundle into an instance of OrdersAndRemainingFillableMakerAssetAmounts. + * If an order is missing a corresponding remainingFillableMakerAssetAmount, assume it is completely fillable. + */ +function unbundleOrdersWithAmounts( + ordersWithAmounts: SignedOrderWithRemainingFillableMakerAssetAmount[], +): OrdersAndRemainingFillableMakerAssetAmounts { + const result = _.reduce( + ordersWithAmounts, + (acc, orderWithAmount) => { + const { orders, remainingFillableMakerAssetAmounts } = acc; + const { remainingFillableMakerAssetAmount, ...order } = orderWithAmount; + // if we are still missing a remainingFillableMakerAssetAmount, assume the order is completely fillable + const newRemainingAmount = remainingFillableMakerAssetAmount || order.makerAssetAmount; + // if remaining amount is less than or equal to zero, do not add it + if (newRemainingAmount.lte(constants.ZERO_AMOUNT)) { + return acc; + } + const newAcc = { + orders: _.concat(orders, order), + remainingFillableMakerAssetAmounts: _.concat(remainingFillableMakerAssetAmounts, newRemainingAmount), + }; + return newAcc; + }, + { + orders: [] as SignedOrder[], + remainingFillableMakerAssetAmounts: [] as BigNumber[], + }, + ); + return result; +} -- cgit From 31f6fc065f743efd0c6961ed2d71ae1ad04e3289 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 14:24:50 +0100 Subject: Add changelog entries --- packages/contract-wrappers/CHANGELOG.json | 8 ++++++++ packages/order-watcher/CHANGELOG.json | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index a9e631157..0d941d756 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "2.0.0", + "changes": [ + { + "note": "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + } + ] + }, { "version": "1.0.3", "changes": [ diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 8d8aaf702..a85fddf7d 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "2.0.0", + "changes": [ + { + "note": "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + } + ] + }, { "version": "1.0.3", "changes": [ -- cgit From 45dc2be0832eefbf6f009b07abb7b7a435b19279 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 14:53:25 +0100 Subject: Fix prettier --- packages/contract-wrappers/CHANGELOG.json | 3 ++- packages/order-watcher/CHANGELOG.json | 3 ++- packages/web3-wrapper/src/web3_wrapper.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 0d941d756..a8572e968 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -3,7 +3,8 @@ "version": "2.0.0", "changes": [ { - "note": "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + "note": + "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." } ] }, diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index a85fddf7d..d6be772e2 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -3,7 +3,8 @@ "version": "2.0.0", "changes": [ { - "note": "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + "note": + "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." } ] }, diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index e6944d4bb..3764b4593 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -439,7 +439,9 @@ export class Web3Wrapper { */ public async getLogsAsync(filter: FilterObject): Promise { if (!_.isUndefined(filter.blockHash) && (!_.isUndefined(filter.fromBlock) || !_.isUndefined(filter.toBlock))) { - throw new Error(`Cannot specify 'blockHash' as well as 'fromBlock'/'toBlock' in the filter supplied to 'getLogsAsync'`); + throw new Error( + `Cannot specify 'blockHash' as well as 'fromBlock'/'toBlock' in the filter supplied to 'getLogsAsync'`, + ); } let fromBlock = filter.fromBlock; -- cgit From c64dcec772d8f5bfa7a32c5e60bfe808229d4d5e Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 15:58:04 +0200 Subject: More renaming --- packages/asset-buyer/src/asset_buyer.ts | 40 +++++------ packages/asset-buyer/src/index.ts | 4 +- .../src/order_fetchers/provided_order_fetcher.ts | 32 --------- .../standard_relayer_api_order_fetcher.ts | 78 ---------------------- .../src/order_providers/basic_order_provider.ts | 32 +++++++++ .../standard_relayer_api_order_provider.ts | 78 ++++++++++++++++++++++ packages/asset-buyer/src/types.ts | 2 +- packages/asset-buyer/src/utils/assert.ts | 4 +- .../asset-buyer/src/utils/buy_quote_calculator.ts | 1 + 9 files changed, 136 insertions(+), 135 deletions(-) delete mode 100644 packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts delete mode 100644 packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts create mode 100644 packages/asset-buyer/src/order_providers/basic_order_provider.ts create mode 100644 packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 74ced0e51..9774a8d39 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -7,8 +7,8 @@ import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; import { constants } from './constants'; -import { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; -import { StandardRelayerAPIOrderFetcher } from './order_fetchers/standard_relayer_api_order_fetcher'; +import { BasicOrderProvider } from './order_providers/basic_order_provider'; +import { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider'; import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, @@ -26,7 +26,7 @@ import { orderProviderResponseProcessor } from './utils/order_provider_response_ export class AssetBuyer { public readonly provider: Provider; public readonly assetData: string; - public readonly orderFetcher: OrderProvider; + public readonly orderProvider: OrderProvider; public readonly networkId: number; public readonly orderRefreshIntervalMs: number; private readonly _contractWrappers: ContractWrappers; @@ -58,8 +58,8 @@ export class AssetBuyer { assert.areValidProvidedOrders('feeOrders', feeOrders); assert.assert(orders.length !== 0, `Expected orders to contain at least one order`); const assetData = orders[0].makerAssetData; - const orderFetcher = new ProvidedOrderFetcher(_.concat(orders, feeOrders)); - const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + const orderProvider = new BasicOrderProvider(_.concat(orders, feeOrders)); + const assetBuyer = new AssetBuyer(provider, assetData, orderProvider, networkId, orderRefreshIntervalMs); return assetBuyer; } /** @@ -84,8 +84,8 @@ export class AssetBuyer { assert.isWebUri('sraApiUrl', sraApiUrl); assert.isNumber('networkId', networkId); assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); - const orderFetcher = new StandardRelayerAPIOrderFetcher(sraApiUrl); - const assetBuyer = new AssetBuyer(provider, assetData, orderFetcher, networkId, orderRefreshIntervalMs); + const orderProvider = new StandardRelayerAPIOrderProvider(sraApiUrl); + const assetBuyer = new AssetBuyer(provider, assetData, orderProvider, networkId, orderRefreshIntervalMs); return assetBuyer; } /** @@ -124,7 +124,7 @@ export class AssetBuyer { * Instantiates a new AssetBuyer instance * @param provider The Provider instance you would like to use for interacting with the Ethereum network. * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). - * @param orderFetcher An object that conforms to OrderFetcher, see type for definition. + * @param orderProvider An object that conforms to OrderProvider, see type for definition. * @param networkId The ethereum network id. Defaults to 1 (mainnet). * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. * Defaults to 10000ms (10s). @@ -133,18 +133,18 @@ export class AssetBuyer { constructor( provider: Provider, assetData: string, - orderFetcher: OrderProvider, + orderProvider: OrderProvider, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, ) { assert.isWeb3Provider('provider', provider); assert.isString('assetData', assetData); - assert.isValidOrderFetcher('orderFetcher', orderFetcher); + assert.isValidOrderProvider('orderProvider', orderProvider); assert.isNumber('networkId', networkId); assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); this.provider = provider; this.assetData = assetData; - this.orderFetcher = orderFetcher; + this.orderProvider = orderProvider; this.networkId = networkId; this.orderRefreshIntervalMs = orderRefreshIntervalMs; this._contractWrappers = new ContractWrappers(this.provider, { @@ -248,31 +248,31 @@ export class AssetBuyer { return txHash; } /** - * Ask the order fetcher for orders and process them. + * Ask the order Provider for orders and process them. */ private async _getLatestOrdersAndFillableAmountsAsync(): Promise { const etherTokenAssetData = this._getEtherTokenAssetDataOrThrow(); const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow(); - // construct order fetcher requests - const targetOrderFetcherRequest = { + // construct order Provider requests + const targetOrderProviderRequest = { makerAssetData: this.assetData, takerAssetData: etherTokenAssetData, networkId: this.networkId, }; - const feeOrderFetcherRequest = { + const feeOrderProviderRequest = { makerAssetData: zrxTokenAssetData, takerAssetData: etherTokenAssetData, networkId: this.networkId, }; - const requests = [targetOrderFetcherRequest, feeOrderFetcherRequest]; + const requests = [targetOrderProviderRequest, feeOrderProviderRequest]; // fetch orders and possible fillable amounts - const [targetOrderFetcherResponse, feeOrderFetcherResponse] = await Promise.all( - _.map(requests, async request => this.orderFetcher.getOrdersAsync(request)), + const [targetOrderProviderResponse, feeOrderProviderResponse] = await Promise.all( + _.map(requests, async request => this.orderProvider.getOrdersAsync(request)), ); // process the responses into one object const ordersAndFillableAmounts = await orderProviderResponseProcessor.processAsync( - targetOrderFetcherResponse, - feeOrderFetcherResponse, + targetOrderProviderResponse, + feeOrderProviderResponse, zrxTokenAssetData, this._contractWrappers.orderValidator, ); diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index aa10c3af2..8ef529ac0 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -3,8 +3,8 @@ export { SignedOrder } from '@0xproject/types'; export { BigNumber } from '@0xproject/utils'; export { AssetBuyer } from './asset_buyer'; -export { ProvidedOrderFetcher } from './order_fetchers/provided_order_fetcher'; -export { StandardRelayerAPIOrderFetcher } from './order_fetchers/standard_relayer_api_order_fetcher'; +export { BasicOrderProvider } from './order_providers/basic_order_provider'; +export { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider'; export { StandardRelayerAPIAssetBuyerManager } from './standard_relayer_api_asset_buyer_manager'; export { AssetBuyerError, diff --git a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts deleted file mode 100644 index 397f296d7..000000000 --- a/packages/asset-buyer/src/order_fetchers/provided_order_fetcher.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { schemas } from '@0xproject/json-schemas'; -import { SignedOrder } from '@0xproject/types'; -import * as _ from 'lodash'; - -import { OrderProvider, OrderProviderRequest, OrderProviderResponse } from '../types'; -import { assert } from '../utils/assert'; - -export class ProvidedOrderFetcher implements OrderProvider { - public readonly providedOrders: SignedOrder[]; - /** - * Instantiates a new ProvidedOrderFetcher instance - * @param providedOrders An array of objects that conform to SignedOrder to fetch from. - * @return An instance of ProvidedOrderFetcher - */ - constructor(providedOrders: SignedOrder[]) { - assert.doesConformToSchema('providedOrders', providedOrders, schemas.signedOrdersSchema); - this.providedOrders = providedOrders; - } - /** - * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderFetcherResponse that satisfies the request. - * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. - * @return An instance of OrderFetcherResponse. See type for more information. - */ - public async getOrdersAsync(orderFetchRequest: OrderProviderRequest): Promise { - assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); - const { makerAssetData, takerAssetData } = orderFetchRequest; - const orders = _.filter(this.providedOrders, order => { - return order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData; - }); - return { orders }; - } -} diff --git a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts b/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts deleted file mode 100644 index 730eaf4e0..000000000 --- a/packages/asset-buyer/src/order_fetchers/standard_relayer_api_order_fetcher.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; -import * as _ from 'lodash'; - -import { - AssetBuyerError, - OrderProvider, - OrderProviderRequest, - OrderProviderResponse, - SignedOrderWithRemainingFillableMakerAssetAmount, -} from '../types'; -import { assert } from '../utils/assert'; -import { orderUtils } from '../utils/order_utils'; - -export class StandardRelayerAPIOrderFetcher implements OrderProvider { - public readonly apiUrl: string; - private readonly _sraClient: HttpClient; - /** - * Given an array of APIOrder objects from a standard relayer api, return an array - * of SignedOrderWithRemainingFillableMakerAssetAmounts - */ - private static _getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( - apiOrders: APIOrder[], - ): SignedOrderWithRemainingFillableMakerAssetAmount[] { - const result = _.map(apiOrders, apiOrder => { - const { order, metaData } = apiOrder; - // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable - const remainingFillableTakerAssetAmount = _.get( - metaData, - 'remainingTakerAssetAmount', - order.takerAssetAmount, - ); - const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( - order, - remainingFillableTakerAssetAmount, - ); - const newOrder = { - ...order, - remainingFillableMakerAssetAmount, - }; - return newOrder; - }); - return result; - } - /** - * Instantiates a new StandardRelayerAPIOrderFetcher instance - * @param apiUrl The standard relayer API base HTTP url you would like to source orders from. - * @return An instance of StandardRelayerAPIOrderFetcher - */ - constructor(apiUrl: string) { - assert.isWebUri('apiUrl', apiUrl); - this.apiUrl = apiUrl; - this._sraClient = new HttpClient(apiUrl); - } - /** - * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderFetcherResponse that satisfies the request. - * @param orderFetchRequest An instance of OrderFetcherRequest. See type for more information. - * @return An instance of OrderFetcherResponse. See type for more information. - */ - public async getOrdersAsync(orderFetchRequest: OrderProviderRequest): Promise { - assert.isValidOrderFetcherRequest('orderFetchRequest', orderFetchRequest); - const { makerAssetData, takerAssetData, networkId } = orderFetchRequest; - const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData }; - const requestOpts = { networkId }; - let orderbook: OrderbookResponse; - try { - orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest, requestOpts); - } catch (err) { - throw new Error(AssetBuyerError.StandardRelayerApiError); - } - const apiOrders = orderbook.asks.records; - const orders = StandardRelayerAPIOrderFetcher._getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( - apiOrders, - ); - return { - orders, - }; - } -} diff --git a/packages/asset-buyer/src/order_providers/basic_order_provider.ts b/packages/asset-buyer/src/order_providers/basic_order_provider.ts new file mode 100644 index 000000000..9bb2d90ac --- /dev/null +++ b/packages/asset-buyer/src/order_providers/basic_order_provider.ts @@ -0,0 +1,32 @@ +import { schemas } from '@0xproject/json-schemas'; +import { SignedOrder } from '@0xproject/types'; +import * as _ from 'lodash'; + +import { OrderProvider, OrderProviderRequest, OrderProviderResponse } from '../types'; +import { assert } from '../utils/assert'; + +export class BasicOrderProvider implements OrderProvider { + public readonly orders: SignedOrder[]; + /** + * Instantiates a new BasicOrderProvider instance + * @param orders An array of objects that conform to SignedOrder to fetch from. + * @return An instance of BasicOrderProvider + */ + constructor(orders: SignedOrder[]) { + assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); + this.orders = orders; + } + /** + * Given an object that conforms to OrderFetcherRequest, return the corresponding OrderProviderResponse that satisfies the request. + * @param orderProviderRequest An instance of OrderFetcherRequest. See type for more information. + * @return An instance of OrderProviderResponse. See type for more information. + */ + public async getOrdersAsync(orderProviderRequest: OrderProviderRequest): Promise { + assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest); + const { makerAssetData, takerAssetData } = orderProviderRequest; + const orders = _.filter(this.orders, order => { + return order.makerAssetData === makerAssetData && order.takerAssetData === takerAssetData; + }); + return { orders }; + } +} diff --git a/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts new file mode 100644 index 000000000..be3e9da50 --- /dev/null +++ b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts @@ -0,0 +1,78 @@ +import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; +import * as _ from 'lodash'; + +import { + AssetBuyerError, + OrderProvider, + OrderProviderRequest, + OrderProviderResponse, + SignedOrderWithRemainingFillableMakerAssetAmount, +} from '../types'; +import { assert } from '../utils/assert'; +import { orderUtils } from '../utils/order_utils'; + +export class StandardRelayerAPIOrderProvider implements OrderProvider { + public readonly apiUrl: string; + private readonly _sraClient: HttpClient; + /** + * Given an array of APIOrder objects from a standard relayer api, return an array + * of SignedOrderWithRemainingFillableMakerAssetAmounts + */ + private static _getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( + apiOrders: APIOrder[], + ): SignedOrderWithRemainingFillableMakerAssetAmount[] { + const result = _.map(apiOrders, apiOrder => { + const { order, metaData } = apiOrder; + // calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable + const remainingFillableTakerAssetAmount = _.get( + metaData, + 'remainingTakerAssetAmount', + order.takerAssetAmount, + ); + const remainingFillableMakerAssetAmount = orderUtils.calculateRemainingMakerAssetAmount( + order, + remainingFillableTakerAssetAmount, + ); + const newOrder = { + ...order, + remainingFillableMakerAssetAmount, + }; + return newOrder; + }); + return result; + } + /** + * Instantiates a new StandardRelayerAPIOrderProvider instance + * @param apiUrl The standard relayer API base HTTP url you would like to source orders from. + * @return An instance of StandardRelayerAPIOrderProvider + */ + constructor(apiUrl: string) { + assert.isWebUri('apiUrl', apiUrl); + this.apiUrl = apiUrl; + this._sraClient = new HttpClient(apiUrl); + } + /** + * Given an object that conforms to OrderProviderRequest, return the corresponding OrderProviderResponse that satisfies the request. + * @param orderProviderRequest An instance of OrderProviderRequest. See type for more information. + * @return An instance of OrderProviderResponse. See type for more information. + */ + public async getOrdersAsync(orderProviderRequest: OrderProviderRequest): Promise { + assert.isValidOrderProviderRequest('orderProviderRequest', orderProviderRequest); + const { makerAssetData, takerAssetData, networkId } = orderProviderRequest; + const orderbookRequest = { baseAssetData: makerAssetData, quoteAssetData: takerAssetData }; + const requestOpts = { networkId }; + let orderbook: OrderbookResponse; + try { + orderbook = await this._sraClient.getOrderbookAsync(orderbookRequest, requestOpts); + } catch (err) { + throw new Error(AssetBuyerError.StandardRelayerApiError); + } + const apiOrders = orderbook.asks.records; + const orders = StandardRelayerAPIOrderProvider._getSignedOrderWithRemainingFillableMakerAssetAmountFromApi( + apiOrders, + ); + return { + orders, + }; + } +} diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 09319fca4..5df8e632a 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -27,7 +27,7 @@ export interface SignedOrderWithRemainingFillableMakerAssetAmount extends Signed remainingFillableMakerAssetAmount?: BigNumber; } /** - * Given an OrderFetchRequest, get an OrderFetchResponse. + * Given an OrderProviderRequest, get an OrderProviderResponse. */ export interface OrderProvider { getOrdersAsync: (orderProviderRequest: OrderProviderRequest) => Promise; diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index 1d57ae9b8..2c3426894 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -18,10 +18,10 @@ export const assert = { sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage); } }, - isValidOrderFetcher(variableName: string, orderFetcher: OrderProvider): void { + isValidOrderProvider(variableName: string, orderFetcher: OrderProvider): void { sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.getOrdersAsync); }, - isValidOrderFetcherRequest(variableName: string, orderFetcherRequest: OrderProviderRequest): void { + isValidOrderProviderRequest(variableName: string, orderFetcherRequest: OrderProviderRequest): void { sharedAssert.isHexString(`${variableName}.makerAssetData`, orderFetcherRequest.makerAssetData); sharedAssert.isHexString(`${variableName}.takerAssetData`, orderFetcherRequest.takerAssetData); sharedAssert.isNumber(`${variableName}.networkId`, orderFetcherRequest.networkId); diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index 3d90a6ead..9946924ef 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -7,6 +7,7 @@ import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '. import { orderUtils } from './order_utils'; +// Calculates a buy quote for orders that have WETH as the takerAsset export const buyQuoteCalculator = { calculate( ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts, -- cgit From c48cf3ab3b74a9082eb30540115534c7432667ac Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 16:03:47 +0200 Subject: Make asset buyer map private --- .../asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts index 207713110..947c738a1 100644 --- a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts +++ b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts @@ -13,7 +13,7 @@ import { OrderProvider, StandardRelayerApiAssetBuyerManagerError } from './types export class StandardRelayerAPIAssetBuyerManager { // Map of assetData to AssetBuyer for that assetData - public readonly assetBuyerMap: ObjectMap; + private readonly _assetBuyerMap: ObjectMap; /** * Returns an array of all assetDatas available at the provided sraApiUrl * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. @@ -82,7 +82,7 @@ export class StandardRelayerAPIAssetBuyerManager { orderRefreshIntervalMs?: number, ) { assert.assert(assetDatas.length > 0, `Expected 'assetDatas' to be a non-empty array.`); - this.assetBuyerMap = _.reduce( + this._assetBuyerMap = _.reduce( assetDatas, (accAssetBuyerMap: ObjectMap, assetData: string) => { accAssetBuyerMap[assetData] = new AssetBuyer( @@ -104,7 +104,7 @@ export class StandardRelayerAPIAssetBuyerManager { * @return An instance of AssetBuyer */ public getAssetBuyerFromAssetData(assetData: string): AssetBuyer { - const assetBuyer = this.assetBuyerMap[assetData]; + const assetBuyer = this._assetBuyerMap[assetData]; if (_.isUndefined(assetBuyer)) { throw new Error( `${StandardRelayerApiAssetBuyerManagerError.AssetBuyerNotFound}: For assetData ${assetData}`, @@ -128,6 +128,6 @@ export class StandardRelayerAPIAssetBuyerManager { * @return An array of assetData strings */ public getAssetDatas(): string[] { - return _.keys(this.assetBuyerMap); + return _.keys(this._assetBuyerMap); } } -- cgit From 1bfaefb240d08eb0a8a5d6743d529604383f6e43 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 16:24:45 +0200 Subject: Add order provider response validation --- packages/asset-buyer/src/asset_buyer.ts | 4 ++++ packages/asset-buyer/src/types.ts | 1 + .../asset-buyer/src/utils/order_provider_response_processor.ts | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 9774a8d39..03f9b5a2b 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -269,6 +269,10 @@ export class AssetBuyer { const [targetOrderProviderResponse, feeOrderProviderResponse] = await Promise.all( _.map(requests, async request => this.orderProvider.getOrdersAsync(request)), ); + // since the order provider is an injected dependency, validate that it respects the API + // ie. it should only return maker/taker assetDatas that are specified + orderProviderResponseProcessor.throwIfInvalidResponse(targetOrderProviderResponse, targetOrderProviderRequest); + orderProviderResponseProcessor.throwIfInvalidResponse(feeOrderProviderResponse, feeOrderProviderRequest); // process the responses into one object const ordersAndFillableAmounts = await orderProviderResponseProcessor.processAsync( targetOrderProviderResponse, diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts index 5df8e632a..ee6858525 100644 --- a/packages/asset-buyer/src/types.ts +++ b/packages/asset-buyer/src/types.ts @@ -68,6 +68,7 @@ export enum AssetBuyerError { InsufficientAssetLiquidity = 'INSUFFICIENT_ASSET_LIQUIDITY', InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY', NoAddressAvailable = 'NO_ADDRESS_AVAILABLE', + InvalidOrderProviderResponse = 'INVALID_ORDER_PROVIDER_RESPONSE', } /** diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index 79e15c3d8..2f3208a55 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -7,7 +7,9 @@ import * as _ from 'lodash'; import { constants } from '../constants'; import { + AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, + OrderProviderRequest, OrderProviderResponse, SignedOrderWithRemainingFillableMakerAssetAmount, } from '../types'; @@ -20,6 +22,14 @@ interface OrdersAndRemainingFillableMakerAssetAmounts { } export const orderProviderResponseProcessor = { + throwIfInvalidResponse(response: OrderProviderResponse, request: OrderProviderRequest): void { + const { makerAssetData, takerAssetData } = request; + _.forEach(response.orders, order => { + if (order.makerAssetData !== makerAssetData || order.takerAssetData !== takerAssetData) { + throw new Error(AssetBuyerError.InvalidOrderProviderResponse); + } + }); + }, /** * Take the responses for the target orders to buy and fee orders and process them. * Processing includes: -- cgit From 7dd28d6fab1d47a287422a0f51d63ba69d1c4dbc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 21 Sep 2018 16:37:20 +0200 Subject: Don't depend on a specific version of node types --- packages/0x.js/package.json | 2 +- packages/abi-gen/package.json | 2 +- packages/contract-wrappers/package.json | 2 +- packages/contracts/package.json | 2 +- packages/ethereum-types/package.json | 2 +- packages/forwarder-helper/package.json | 2 +- packages/json-schemas/package.json | 2 +- packages/monorepo-scripts/package.json | 2 +- packages/order-utils/package.json | 2 +- packages/order-watcher/package.json | 2 +- packages/react-docs/package.json | 2 +- packages/react-shared/package.json | 2 +- packages/sol-cov/package.json | 2 +- packages/sra-report/package.json | 2 +- packages/subproviders/package.json | 2 +- packages/types/package.json | 2 +- packages/utils/package.json | 2 +- packages/website/package.json | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index bf929a835..020d03942 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -48,7 +48,7 @@ "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "@types/web3-provider-engine": "^14.0.0", "awesome-typescript-loader": "^3.1.3", diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 79c550a33..cb2545ead 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -48,7 +48,7 @@ "@types/glob": "5.0.35", "@types/handlebars": "^4.0.36", "@types/mkdirp": "^0.5.1", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sleep": "^0.0.7", "@types/tmp": "^0.0.33", "@types/yargs": "^10.0.0", diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index ece5c9649..1c98a7ddc 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -48,7 +48,7 @@ "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "@types/uuid": "^3.4.2", "@types/web3-provider-engine": "^14.0.0", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 1c912d3a7..8c8920951 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -54,7 +54,7 @@ "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", "@types/lodash": "4.14.104", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index afe480916..7f1746b30 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -36,7 +36,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@types/node": "^8.0.53", + "@types/node": "*", "bignumber.js": "~4.1.0" }, "publishConfig": { diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json index 305b3f6a7..4b74a444b 100644 --- a/packages/forwarder-helper/package.json +++ b/packages/forwarder-helper/package.json @@ -42,7 +42,7 @@ "@0xproject/types": "^1.0.1", "@0xproject/typescript-typings": "^2.0.0", "@0xproject/utils": "^1.0.8", - "@types/node": "^8.0.53", + "@types/node": "*", "lodash": "^4.17.10" }, "devDependencies": { diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 776f26664..61a992bc3 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -39,7 +39,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { "@0xproject/typescript-typings": "^2.0.0", - "@types/node": "^8.0.53", + "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index cddb6ec3d..571865a90 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -33,7 +33,7 @@ "devDependencies": { "@types/glob": "^5.0.33", "@types/mkdirp": "^0.5.2", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/opn": "^5.1.0", "@types/rimraf": "^2.0.2", "@types/semver": "5.5.0", diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index b3f93ff2e..a10f0a905 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -64,7 +64,7 @@ "@0xproject/typescript-typings": "^2.0.0", "@0xproject/utils": "^1.0.8", "@0xproject/web3-wrapper": "^2.0.2", - "@types/node": "^8.0.53", + "@types/node": "*", "bn.js": "^4.11.8", "ethereum-types": "^1.0.6", "ethereumjs-abi": "0.6.5", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index a07e0f795..53ef64306 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -49,7 +49,7 @@ "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "awesome-typescript-loader": "^3.1.3", "chai": "^4.0.1", diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 345522074..ca3e98ce2 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -37,7 +37,7 @@ "@0xproject/utils": "^1.0.8", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/react": "*", "@types/react-dom": "*", "@types/react-scroll": "1.5.3", diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 49b3a4ac3..9249707ed 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -37,7 +37,7 @@ "@types/is-mobile": "0.3.0", "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/react": "*", "@types/react-dom": "*", "@types/react-scroll": "1.5.3", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index f51a76155..079c52b72 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -64,7 +64,7 @@ "@types/loglevel": "^1.5.3", "@types/mkdirp": "^0.5.1", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/rimraf": "^2.0.2", "@types/solidity-parser-antlr": "^0.2.0", "chai": "^4.0.1", diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 98d10be07..7e4bb00a8 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -51,7 +51,7 @@ "@types/mocha": "^2.2.48", "@types/newman": "^3.9.0", "@types/nock": "^9.1.2", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index b96166d37..6882e77f9 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -59,7 +59,7 @@ "@types/hdkey": "^0.7.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "@types/web3-provider-engine": "^14.0.0", "chai": "^4.0.1", diff --git a/packages/types/package.json b/packages/types/package.json index 15f0a54b4..04577621a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -30,7 +30,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@types/node": "^8.0.53", + "@types/node": "*", "bignumber.js": "~4.1.0", "ethereum-types": "^1.0.6" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index 831b6c819..588f45708 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -43,7 +43,7 @@ "dependencies": { "@0xproject/types": "^1.0.1", "@0xproject/typescript-typings": "^2.0.0", - "@types/node": "^8.0.53", + "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", "bignumber.js": "~4.1.0", "detect-node": "2.0.3", diff --git a/packages/website/package.json b/packages/website/package.json index 911a4ccba..051ac27e0 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -72,7 +72,7 @@ "@types/jsonschema": "^1.1.1", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/numeral": "^0.0.22", "@types/query-string": "^5.1.0", "@types/react": "^16.4.2", -- cgit From 5e84e9689f0899a39dbfaffe13b80fa07fec5ba8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 21 Sep 2018 16:53:18 +0200 Subject: Small typos --- packages/asset-buyer/src/utils/assert.ts | 2 +- packages/asset-buyer/src/utils/order_provider_response_processor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index 2c3426894..04f425237 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -19,7 +19,7 @@ export const assert = { } }, isValidOrderProvider(variableName: string, orderFetcher: OrderProvider): void { - sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.getOrdersAsync); + sharedAssert.isFunction(`${variableName}.getOrdersAsync`, orderFetcher.getOrdersAsync); }, isValidOrderProviderRequest(variableName: string, orderFetcherRequest: OrderProviderRequest): void { sharedAssert.isHexString(`${variableName}.makerAssetData`, orderFetcherRequest.makerAssetData); diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index 2f3208a55..9e54300b3 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -52,7 +52,7 @@ export const orderProviderResponseProcessor = { // if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts if (!_.isUndefined(orderValidator)) { // TODO(bmillman): improvement - // try catch these requests and throw a more domain specific error + // try/catch these requests and throw a more domain specific error // TODO(bmillman): optimization // reduce this to once RPC call buy combining orders into one array and then splitting up the response const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all( -- cgit From 5446de630886422f1795e06d638a200ab62763ef Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 21 Sep 2018 16:59:16 +0200 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 9 +++++++++ packages/0x.js/CHANGELOG.md | 4 ++++ packages/abi-gen/CHANGELOG.json | 9 +++++++++ packages/abi-gen/CHANGELOG.md | 4 ++++ packages/assert/CHANGELOG.json | 9 +++++++++ packages/assert/CHANGELOG.md | 4 ++++ packages/base-contract/CHANGELOG.json | 9 +++++++++ packages/base-contract/CHANGELOG.md | 4 ++++ packages/connect/CHANGELOG.json | 9 +++++++++ packages/connect/CHANGELOG.md | 4 ++++ packages/contract-wrappers/CHANGELOG.json | 9 +++++++++ packages/contract-wrappers/CHANGELOG.md | 4 ++++ packages/dev-utils/CHANGELOG.json | 9 +++++++++ packages/dev-utils/CHANGELOG.md | 4 ++++ packages/ethereum-types/CHANGELOG.json | 9 +++++++++ packages/ethereum-types/CHANGELOG.md | 4 ++++ packages/fill-scenarios/CHANGELOG.json | 9 +++++++++ packages/fill-scenarios/CHANGELOG.md | 4 ++++ packages/forwarder-helper/CHANGELOG.json | 9 +++++++++ packages/forwarder-helper/CHANGELOG.md | 4 ++++ packages/json-schemas/CHANGELOG.json | 9 +++++++++ packages/json-schemas/CHANGELOG.md | 4 ++++ packages/migrations/CHANGELOG.json | 9 +++++++++ packages/migrations/CHANGELOG.md | 4 ++++ packages/order-utils/CHANGELOG.json | 9 +++++++++ packages/order-utils/CHANGELOG.md | 4 ++++ packages/order-watcher/CHANGELOG.json | 9 +++++++++ packages/order-watcher/CHANGELOG.md | 4 ++++ packages/react-docs/CHANGELOG.json | 9 +++++++++ packages/react-docs/CHANGELOG.md | 4 ++++ packages/react-shared/CHANGELOG.json | 9 +++++++++ packages/react-shared/CHANGELOG.md | 4 ++++ packages/sol-compiler/CHANGELOG.json | 9 +++++++++ packages/sol-compiler/CHANGELOG.md | 4 ++++ packages/sol-cov/CHANGELOG.json | 9 +++++++++ packages/sol-cov/CHANGELOG.md | 4 ++++ packages/sol-resolver/CHANGELOG.json | 9 +++++++++ packages/sol-resolver/CHANGELOG.md | 4 ++++ packages/sra-report/CHANGELOG.json | 9 +++++++++ packages/sra-report/CHANGELOG.md | 4 ++++ packages/sra-spec/CHANGELOG.json | 9 +++++++++ packages/sra-spec/CHANGELOG.md | 4 ++++ packages/subproviders/CHANGELOG.json | 9 +++++++++ packages/subproviders/CHANGELOG.md | 4 ++++ packages/types/CHANGELOG.json | 9 +++++++++ packages/types/CHANGELOG.md | 4 ++++ packages/typescript-typings/CHANGELOG.json | 9 +++++++++ packages/typescript-typings/CHANGELOG.md | 4 ++++ packages/utils/CHANGELOG.json | 9 +++++++++ packages/utils/CHANGELOG.md | 4 ++++ packages/web3-wrapper/CHANGELOG.json | 3 ++- packages/web3-wrapper/CHANGELOG.md | 4 ++++ 52 files changed, 331 insertions(+), 1 deletion(-) diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 86cf7a916..391c5fa17 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.3", "changes": [ diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index a6f23e620..7031425ab 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 640f76f07..2ecacb05d 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 3c65739c0..88ab42864 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 53c892ef5..8a9b6afd6 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index 8b1437350..d39441338 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 89580ca90..723963f87 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "2.0.2", diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index a81f7a3a7..c4ba59e26 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _September 21, 2018_ + + * Dependencies updated + ## v2.0.2 - _September 5, 2018_ * Dependencies updated diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index c6e753261..f5ca80279 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537369748, "version": "2.0.1", diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index 8e9ebe3e0..1f8116f88 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _September 21, 2018_ + + * Dependencies updated + ## v2.0.1 - _September 19, 2018_ * Dependencies updated diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index a9e631157..2f8a02a1a 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.3", "changes": [ diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 69561213e..3757bd6ba 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index 839af99ac..e834eb1a3 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.8", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.7", diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index c1737c884..34f29418b 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.8 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.7 - _September 5, 2018_ * Dependencies updated diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json index 5bb6965ee..20d33ea38 100644 --- a/packages/ethereum-types/CHANGELOG.json +++ b/packages/ethereum-types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.6", diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md index 0131f6319..0de27c2fb 100644 --- a/packages/ethereum-types/CHANGELOG.md +++ b/packages/ethereum-types/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.7 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.6 - _September 5, 2018_ * Dependencies updated diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index dbcabe632..e378c7cf0 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.2", "changes": [ diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index 409e5035c..16fbb4f34 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.2 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/forwarder-helper/CHANGELOG.json b/packages/forwarder-helper/CHANGELOG.json index aef30e4d0..084811c26 100644 --- a/packages/forwarder-helper/CHANGELOG.json +++ b/packages/forwarder-helper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537369748, "version": "1.0.3", diff --git a/packages/forwarder-helper/CHANGELOG.md b/packages/forwarder-helper/CHANGELOG.md index 4c26e6980..338d03d54 100644 --- a/packages/forwarder-helper/CHANGELOG.md +++ b/packages/forwarder-helper/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Dependencies updated diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index 09d7fb932..e3308f98b 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.1", diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index b68c1a1f9..0817874ba 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.2 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.1 - _September 5, 2018_ * Dependencies updated diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 84ec503bf..a25de1a77 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537369748, "version": "1.0.9", diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index aff23b0cf..2a6aeb96d 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 19, 2018_ * Dependencies updated diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index d202d779c..5bf538c1f 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.2", "changes": [ diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index 077f017db..e35867fa6 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.2 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 8d8aaf702..dec154f0f 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.3", "changes": [ diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index e79bf638e..a4e1cc79f 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index d1e846bb1..c8a44aa9e 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index 679f00097..595b0cf98 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index 7f88a4db2..898ab26aa 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.9", diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index bc524322c..f6878e43f 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 5, 2018_ * Dependencies updated diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index 8c5c84ce8..9a1961b79 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.1.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.1.2", diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index 8b0e12441..a5d1332f8 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.3 - _September 21, 2018_ + + * Dependencies updated + ## v1.1.2 - _September 5, 2018_ * Dependencies updated diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index e57939f4f..5f49e0443 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "2.1.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "2.1.2", diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index b41dc00e6..e1b898b19 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.3 - _September 21, 2018_ + + * Dependencies updated + ## v2.1.2 - _September 5, 2018_ * Dependencies updated diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index e7f5177f8..bfc7cb93b 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index c14ef9336..5bed9f43c 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json index 4d9dc80f7..ee12caf34 100644 --- a/packages/sra-report/CHANGELOG.json +++ b/packages/sra-report/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md index d3c9251f3..5e75625df 100644 --- a/packages/sra-report/CHANGELOG.md +++ b/packages/sra-report/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index 715f1a2f1..e0b373191 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.1", diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index 52b99f538..59f397bc6 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.2 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.1 - _September 5, 2018_ * Dependencies updated diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index 0df16acf2..2d3c37615 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "2.0.2", diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index db75710d7..6e268d7ec 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _September 21, 2018_ + + * Dependencies updated + ## v2.0.2 - _September 5, 2018_ * Dependencies updated diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 008ff8ff4..a1fc1dcd0 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.1", "changes": [ diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 759a93fb0..d89416fd6 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.2 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.1 - _September 5, 2018_ * Add AssetProxyOwner revert reasons (#1041) diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index cef518859..f0b1a6c40 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "2.0.0", "changes": [ diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md index e19e01509..67e86bb82 100644 --- a/packages/typescript-typings/CHANGELOG.md +++ b/packages/typescript-typings/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.1 - _September 21, 2018_ + + * Dependencies updated + ## v2.0.0 - _September 5, 2018_ * Remove types for web3-provider-engine, newman, ganache-core, detect-node, eth-lightwallet (#1052) diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index c1b7db100..7449355ce 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537541580, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1536142250, "version": "1.0.8", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 2452cf42e..aa2c08940 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 5, 2018_ * Dependencies updated diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 2b3c09ebc..1653f388c 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -7,7 +7,8 @@ "Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined.", "pr": 1079 } - ] + ], + "timestamp": 1537541580 }, { "timestamp": 1536142250, diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 17f2b9f48..72aff4a95 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _September 21, 2018_ + + * Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined. (#1079) + ## v2.0.2 - _September 5, 2018_ * Dependencies updated -- cgit From 29f6adc2ed57720d2c2aab7b760a4bcfec5d7b37 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 21 Sep 2018 16:59:27 +0200 Subject: Publish - 0x.js@1.0.4 - @0xproject/abi-gen@1.0.9 - @0xproject/assert@1.0.9 - @0xproject/base-contract@2.0.3 - @0xproject/connect@2.0.2 - @0xproject/contract-wrappers@1.0.4 - contracts@2.1.45 - @0xproject/dev-utils@1.0.8 - ethereum-types@1.0.7 - @0xproject/fill-scenarios@1.0.3 - @0xproject/forwarder-helper@1.0.4 - @0xproject/json-schemas@1.0.2 - @0xproject/metacoin@0.0.19 - @0xproject/migrations@1.0.10 - @0xproject/monorepo-scripts@1.0.9 - @0xproject/order-utils@1.0.3 - @0xproject/order-watcher@1.0.4 - @0xproject/react-docs@1.0.9 - @0xproject/react-shared@1.0.10 - @0xproject/sol-compiler@1.1.3 - @0xproject/sol-cov@2.1.3 - @0xproject/sol-resolver@1.0.9 - @0xproject/sra-report@1.0.9 - @0xproject/sra-spec@1.0.2 - @0xproject/subproviders@2.0.3 - @0xproject/testnet-faucets@1.0.47 - @0xproject/types@1.0.2 - @0xproject/typescript-typings@2.0.1 - @0xproject/utils@1.0.9 - @0xproject/web3-wrapper@2.0.3 - @0xproject/website@0.0.50 --- packages/0x.js/package.json | 32 ++++++++++++++++---------------- packages/abi-gen/package.json | 8 ++++---- packages/assert/package.json | 8 ++++---- packages/base-contract/package.json | 10 +++++----- packages/connect/package.json | 14 +++++++------- packages/contract-wrappers/package.json | 30 +++++++++++++++--------------- packages/contracts/package.json | 26 +++++++++++++------------- packages/dev-utils/package.json | 14 +++++++------- packages/ethereum-types/package.json | 2 +- packages/fill-scenarios/package.json | 18 +++++++++--------- packages/forwarder-helper/package.json | 14 +++++++------- packages/json-schemas/package.json | 6 +++--- packages/metacoin/package.json | 24 ++++++++++++------------ packages/migrations/package.json | 24 ++++++++++++------------ packages/monorepo-scripts/package.json | 2 +- packages/order-utils/package.json | 20 ++++++++++---------- packages/order-watcher/package.json | 30 +++++++++++++++--------------- packages/react-docs/package.json | 8 ++++---- packages/react-shared/package.json | 4 ++-- packages/sol-compiler/package.json | 20 ++++++++++---------- packages/sol-cov/package.json | 16 ++++++++-------- packages/sol-resolver/package.json | 6 +++--- packages/sra-report/package.json | 8 ++++---- packages/sra-spec/package.json | 4 ++-- packages/subproviders/package.json | 14 +++++++------- packages/testnet-faucets/package.json | 14 +++++++------- packages/types/package.json | 4 ++-- packages/typescript-typings/package.json | 4 ++-- packages/utils/package.json | 8 ++++---- packages/web3-wrapper/package.json | 12 ++++++------ packages/website/package.json | 22 +++++++++++----------- 31 files changed, 213 insertions(+), 213 deletions(-) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 020d03942..c92e24c52 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -41,10 +41,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/migrations": "^1.0.9", - "@0xproject/monorepo-scripts": "^1.0.8", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/migrations": "^1.0.10", + "@0xproject/monorepo-scripts": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -73,17 +73,17 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/contract-wrappers": "^1.0.3", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/order-watcher": "^1.0.3", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/contract-wrappers": "^1.0.4", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/order-watcher": "^1.0.4", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5", "web3-provider-engine": "14.0.6" diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index cb2545ead..6b8581ef3 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/abi-gen", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -30,10 +30,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", "chalk": "^2.3.0", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "glob": "^7.1.2", "handlebars": "^4.0.11", "lodash": "^4.17.5", diff --git a/packages/assert/package.json b/packages/assert/package.json index 23357dc99..629cb23e5 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/assert", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -44,9 +44,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", "lodash": "^4.17.5", "valid-url": "^1.0.9" }, diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 6542f48df..44b0807ba 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/base-contract", - "version": "2.0.2", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -40,10 +40,10 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/connect/package.json b/packages/connect/package.json index 1308aa5b2..1575afe01 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/connect", - "version": "2.0.1", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -43,12 +43,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", + "@0xproject/assert": "^1.0.9", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", "lodash": "^4.17.5", "query-string": "^5.0.1", "sinon": "^4.0.0", diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 1c98a7ddc..331ff1701 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/contract-wrappers", - "version": "1.0.3", + "version": "1.0.4", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -41,10 +41,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/migrations": "^1.0.9", - "@0xproject/subproviders": "^2.0.2", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/migrations": "^1.0.10", + "@0xproject/subproviders": "^2.0.3", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -72,16 +72,16 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/fill-scenarios": "^1.0.2", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/fill-scenarios": "^1.0.3", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "5.0.0", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 8c8920951..63de510b1 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "contracts", - "version": "2.1.44", + "version": "2.1.45", "engines": { "node": ">=6.12" }, @@ -45,11 +45,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/sol-compiler": "^1.1.2", - "@0xproject/sol-cov": "^2.1.2", - "@0xproject/subproviders": "^2.0.2", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/sol-compiler": "^1.1.3", + "@0xproject/sol-cov": "^2.1.3", + "@0xproject/subproviders": "^2.0.3", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", @@ -72,15 +72,15 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.2", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index ff8bb3534..3ded87c05 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/dev-utils", - "version": "1.0.7", + "version": "1.0.8", "engines": { "node": ">=6.12" }, @@ -42,12 +42,12 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index 7f1746b30..c1abfb79b 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-types", - "version": "1.0.6", + "version": "1.0.7", "engines": { "node": ">=6.12" }, diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 4592ca091..474618a14 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/fill-scenarios", - "version": "1.0.2", + "version": "1.0.3", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", + "@0xproject/abi-gen": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "copyfiles": "^2.0.0", @@ -37,13 +37,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/base-contract": "^2.0.2", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/forwarder-helper/package.json b/packages/forwarder-helper/package.json index 4b74a444b..a76e5c990 100644 --- a/packages/forwarder-helper/package.json +++ b/packages/forwarder-helper/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/forwarder-helper", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -36,12 +36,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/forwarder-helper/README.md", "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", + "@0xproject/assert": "^1.0.9", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", "@types/node": "*", "lodash": "^4.17.10" }, diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 61a992bc3..3d5399d2a 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/json-schemas", - "version": "1.0.1", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -38,14 +38,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.0", + "@0xproject/typescript-typings": "^2.0.1", "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", - "@0xproject/utils": "^1.0.8", + "@0xproject/utils": "^1.0.9", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 9246c1961..9824da332 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/metacoin", - "version": "0.0.18", + "version": "0.0.19", "engines": { "node": ">=6.12" }, @@ -28,25 +28,25 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/sol-cov": "^2.1.2", - "@0xproject/subproviders": "^2.0.2", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/sol-cov": "^2.1.3", + "@0xproject/subproviders": "^2.0.3", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@types/mocha": "^5.2.2", "copyfiles": "^2.0.0", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5", "run-s": "^0.0.0" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/sol-compiler": "^1.1.2", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/sol-compiler": "^1.1.3", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 5938ac224..1229c78dc 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/migrations", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -30,10 +30,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.0.1", + "@0xproject/types": "^1.0.2", "@types/yargs": "^10.0.0", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", @@ -44,15 +44,15 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.2", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/sol-compiler": "^1.1.2", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/sol-compiler": "^1.1.3", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@ledgerhq/hw-app-eth": "^4.3.0", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 571865a90..e776569b1 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/monorepo-scripts", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index a10f0a905..c9620bffa 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-utils", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -38,7 +38,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.7", + "@0xproject/dev-utils": "^1.0.8", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -57,16 +57,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@types/node": "*", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 53ef64306..8ce57364f 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-watcher", - "version": "1.0.3", + "version": "1.0.4", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -42,9 +42,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/migrations": "^1.0.9", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/migrations": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -70,18 +70,18 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/contract-wrappers": "^1.0.3", - "@0xproject/fill-scenarios": "^1.0.2", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/contract-wrappers": "^1.0.4", + "@0xproject/fill-scenarios": "^1.0.3", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "bintrees": "^1.0.2", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "5.0.0", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index ca3e98ce2..0efe7dbc9 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-docs", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -23,7 +23,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.7", + "@0xproject/dev-utils": "^1.0.8", "@0xproject/tslint-config": "^1.0.7", "@types/compare-versions": "^3.0.0", "copyfiles": "^2.0.0", @@ -33,8 +33,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/react-shared": "^1.0.9", - "@0xproject/utils": "^1.0.8", + "@0xproject/react-shared": "^1.0.10", + "@0xproject/utils": "^1.0.9", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 9249707ed..458968c39 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-shared", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -24,7 +24,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.7", + "@0xproject/dev-utils": "^1.0.8", "@0xproject/tslint-config": "^1.0.7", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 8395eccb5..2ad0f9f09 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-compiler", - "version": "1.1.2", + "version": "1.1.3", "engines": { "node": ">=6.12" }, @@ -41,7 +41,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.7", + "@0xproject/dev-utils": "^1.0.8", "@0xproject/tslint-config": "^1.0.7", "@types/mkdirp": "^0.5.2", "@types/require-from-string": "^1.2.0", @@ -64,16 +64,16 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/sol-resolver": "^1.0.8", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/assert": "^1.0.9", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/sol-resolver": "^1.0.9", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 079c52b72..f80ae78e0 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "2.1.2", + "version": "2.1.3", "engines": { "node": ">=6.12" }, @@ -41,13 +41,13 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/sol-compiler": "^1.1.2", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/sol-compiler": "^1.1.3", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index 2e0ce319c..da3f18788 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-resolver", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -30,8 +30,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 7e4bb00a8..eebf0cc0b 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-report", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -33,13 +33,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { - "@0xproject/assert": "^1.0.8", + "@0xproject/assert": "^1.0.9", "@0xproject/connect": "1.0.4", "@0xproject/json-schemas": "^0.8.3", "@0xproject/order-utils": "^0.0.9", "@0xproject/types": "^0.8.2", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", "chalk": "^2.3.0", "lodash": "^4.17.5", "newman": "^3.9.3", diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index 82559a089..3da886e34 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-spec", - "version": "1.0.1", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -34,7 +34,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0xproject/json-schemas": "^1.0.1" + "@0xproject/json-schemas": "^1.0.2" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 6882e77f9..347c71726 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/subproviders", - "version": "2.0.2", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -28,11 +28,11 @@ } }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/assert": "^1.0.9", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", "@types/eth-lightwallet": "^3.0.0", @@ -41,7 +41,7 @@ "bip39": "^2.5.0", "bn.js": "^4.11.8", "eth-lightwallet": "^3.0.1", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "ganache-core": "0xProject/ganache-core#monorepo-dep", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index d4e68559f..448186b34 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/testnet-faucets", - "version": "1.0.46", + "version": "1.0.47", "engines": { "node": ">=6.12" }, @@ -17,13 +17,13 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^1.0.3", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "0x.js": "^1.0.4", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "body-parser": "^1.17.1", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "express": "^4.15.2", diff --git a/packages/types/package.json b/packages/types/package.json index 04577621a..f1c04b39b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/types", - "version": "1.0.1", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -32,7 +32,7 @@ "dependencies": { "@types/node": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.6" + "ethereum-types": "^1.0.7" }, "publishConfig": { "access": "public" diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index 4b521d6d0..6f8b7e256 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/typescript-typings", - "version": "2.0.0", + "version": "2.0.1", "engines": { "node": ">=6.12" }, @@ -26,7 +26,7 @@ "@types/bn.js": "^4.11.0", "@types/react": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "popper.js": "1.14.3" }, "devDependencies": { diff --git a/packages/utils/package.json b/packages/utils/package.json index 588f45708..a3977cef6 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/utils", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -41,13 +41,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", "bignumber.js": "~4.1.0", "detect-node": "2.0.3", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "isomorphic-fetch": "^2.2.1", diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 05ea4da17..bcd640839 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/web3-wrapper", - "version": "2.0.2", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -53,11 +53,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.9", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/website/package.json b/packages/website/package.json index 051ac27e0..54ec1c84b 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/website", - "version": "0.0.49", + "version": "0.0.50", "engines": { "node": ">=6.12" }, @@ -19,21 +19,21 @@ "license": "Apache-2.0", "dependencies": { "0x.js": "^0.38.6", - "@0xproject/contract-wrappers": "^1.0.3", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/react-docs": "^1.0.8", - "@0xproject/react-shared": "^1.0.9", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/contract-wrappers": "^1.0.4", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/react-docs": "^1.0.9", + "@0xproject/react-shared": "^1.0.10", + "@0xproject/subproviders": "^2.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "accounting": "^0.4.1", "basscss": "^8.0.3", "blockies": "^0.0.2", "bowser": "^1.9.3", "deep-equal": "^1.0.1", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "find-versions": "^2.0.0", "jsonschema": "^1.2.0", -- cgit From 8bce407aec414fbaf80a7132bdf43c5b9f66247b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 21 Sep 2018 17:36:05 +0100 Subject: Add order-utils to README list --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0962d36fb..6e697ee78 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,16 @@ If you're developing on 0x now or are interested in using 0x infrastructure in t | [`@0xproject/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0xproject/assert.svg)](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages | | [`@0xproject/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0xproject/base-contract.svg)](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts | | [`@0xproject/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0xproject/connect.svg)](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API | -| [`@0xproject/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0xproject/sol-compiler.svg)](https://www.npmjs.com/package/@0xproject/sol-compiler) | A thin wrapper around Solc.js that outputs artifacts, resolves imports, only re-compiles when needed, and other niceties. | | [`@0xproject/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0xproject/dev-utils.svg)](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages | | [`@0xproject/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0xproject/json-schemas.svg)](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas | | [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | [![npm](https://img.shields.io/npm/v/@0xproject/monorepo-scripts.svg)](https://www.npmjs.com/package/@0xproject/monorepo-scripts) | Monorepo scripts | +| [`@0xproject/order-utils`](/packages/order-utils) | [![npm](https://img.shields.io/npm/v/@0xproject/order-utils.svg)](https://www.npmjs.com/package/@0xproject/order-utils) | A set of utilities for generating, parsing, signing and validating 0x orders. | | [`@0xproject/react-docs`](/packages/react-docs) | [![npm](https://img.shields.io/npm/v/@0xproject/react-docs.svg)](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON | | [`@0xproject/react-shared`](/packages/react-shared) | [![npm](https://img.shields.io/npm/v/@0xproject/react-shared.svg)](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components | +| [`@0xproject/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0xproject/sol-compiler.svg)](https://www.npmjs.com/package/@0xproject/sol-compiler) | A thin wrapper around Solc.js that outputs artifacts, resolves imports, only re-compiles when needed, and other niceties. | +| [`@0xproject/sol-cov`](/packages/sol-cov) | [![npm](https://img.shields.io/npm/v/@0xproject/sol-cov.svg)](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool | | [`@0xproject/sra-spec`](/packages/sra-spec) | [![npm](https://img.shields.io/npm/v/@0xproject/sra-spec.svg)](https://www.npmjs.com/package/@0xproject/sra-spec) | OpenAPI specification for the standard relayer API | | [`@0xproject/sra-report`](/packages/sra-report) | [![npm](https://img.shields.io/npm/v/@0xproject/sra-report.svg)](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance | -| [`@0xproject/sol-cov`](/packages/sol-cov) | [![npm](https://img.shields.io/npm/v/@0xproject/sol-cov.svg)](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool | | [`@0xproject/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0xproject/subproviders.svg)](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) | | [`@0xproject/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0xproject/tslint-config.svg)](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules | | [`@0xproject/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0xproject/types.svg)](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations | -- cgit From e4b664bafa24c2ee788a343edecd0124f784780d Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 24 Sep 2018 13:17:38 +0200 Subject: Add expiry buffer --- packages/asset-buyer/src/asset_buyer.ts | 45 +++++++++++++++++----- packages/asset-buyer/src/constants.ts | 1 + .../src/utils/order_provider_response_processor.ts | 14 +++++-- packages/asset-buyer/src/utils/order_utils.ts | 5 ++- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 03f9b5a2b..409e34e74 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -29,6 +29,7 @@ export class AssetBuyer { public readonly orderProvider: OrderProvider; public readonly networkId: number; public readonly orderRefreshIntervalMs: number; + public readonly expiryBufferSeconds: number; private readonly _contractWrappers: ContractWrappers; private _lastRefreshTimeIfExists?: number; private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts; @@ -38,8 +39,9 @@ export class AssetBuyer { * @param orders A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH). * @param feeOrders A array of objects that conform to SignedOrder. All orders must have the same makerAssetData (ZRX) and takerAssetData (WETH). Defaults to an empty array. * @param networkId The ethereum network id. Defaults to 1 (mainnet). - * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. - * Defaults to 10000ms (10s). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s). + * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s. + * * @return An instance of AssetBuyer */ public static getAssetBuyerForProvidedOrders( @@ -48,6 +50,7 @@ export class AssetBuyer { feeOrders: SignedOrder[] = [], networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, + expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); @@ -59,7 +62,14 @@ export class AssetBuyer { assert.assert(orders.length !== 0, `Expected orders to contain at least one order`); const assetData = orders[0].makerAssetData; const orderProvider = new BasicOrderProvider(_.concat(orders, feeOrders)); - const assetBuyer = new AssetBuyer(provider, assetData, orderProvider, networkId, orderRefreshIntervalMs); + const assetBuyer = new AssetBuyer( + provider, + assetData, + orderProvider, + networkId, + orderRefreshIntervalMs, + expiryBufferSeconds, + ); return assetBuyer; } /** @@ -68,8 +78,9 @@ export class AssetBuyer { * @param assetData The assetData that identifies the desired asset to buy. * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. * @param networkId The ethereum network id. Defaults to 1 (mainnet). - * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. - * Defaults to 10000ms (10s). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s). + * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s. + * * @return An instance of AssetBuyer */ public static getAssetBuyerForAssetData( @@ -78,6 +89,7 @@ export class AssetBuyer { sraApiUrl: string, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, + expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.isHexString('assetData', assetData); @@ -85,7 +97,14 @@ export class AssetBuyer { assert.isNumber('networkId', networkId); assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs); const orderProvider = new StandardRelayerAPIOrderProvider(sraApiUrl); - const assetBuyer = new AssetBuyer(provider, assetData, orderProvider, networkId, orderRefreshIntervalMs); + const assetBuyer = new AssetBuyer( + provider, + assetData, + orderProvider, + networkId, + orderRefreshIntervalMs, + expiryBufferSeconds, + ); return assetBuyer; } /** @@ -94,8 +113,8 @@ export class AssetBuyer { * @param tokenAddress The ERC20 token address that identifies the desired asset to buy. * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from. * @param networkId The ethereum network id. Defaults to 1 (mainnet). - * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. - * Defaults to 10000ms (10s). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s). + * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s. * @return An instance of AssetBuyer */ public static getAssetBuyerForERC20TokenAddress( @@ -104,6 +123,7 @@ export class AssetBuyer { sraApiUrl: string, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, + expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS, ): AssetBuyer { assert.isWeb3Provider('provider', provider); assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -117,6 +137,7 @@ export class AssetBuyer { sraApiUrl, networkId, orderRefreshIntervalMs, + expiryBufferSeconds, ); return assetBuyer; } @@ -126,8 +147,9 @@ export class AssetBuyer { * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). * @param orderProvider An object that conforms to OrderProvider, see type for definition. * @param networkId The ethereum network id. Defaults to 1 (mainnet). - * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. - * Defaults to 10000ms (10s). + * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s). + * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s. + * * @return An instance of AssetBuyer */ constructor( @@ -136,6 +158,7 @@ export class AssetBuyer { orderProvider: OrderProvider, networkId: number = constants.MAINNET_NETWORK_ID, orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS, + expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS, ) { assert.isWeb3Provider('provider', provider); assert.isString('assetData', assetData); @@ -146,6 +169,7 @@ export class AssetBuyer { this.assetData = assetData; this.orderProvider = orderProvider; this.networkId = networkId; + this.expiryBufferSeconds = expiryBufferSeconds; this.orderRefreshIntervalMs = orderRefreshIntervalMs; this._contractWrappers = new ContractWrappers(this.provider, { networkId, @@ -278,6 +302,7 @@ export class AssetBuyer { targetOrderProviderResponse, feeOrderProviderResponse, zrxTokenAssetData, + this.expiryBufferSeconds, this._contractWrappers.orderValidator, ); return ordersAndFillableAmounts; diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts index 0ebe0f8e2..79b5d9052 100644 --- a/packages/asset-buyer/src/constants.ts +++ b/packages/asset-buyer/src/constants.ts @@ -16,4 +16,5 @@ export const constants = { ETHER_TOKEN_DECIMALS: 18, DEFAULT_BUY_QUOTE_REQUEST_OPTS, MAX_PER_PAGE: 10000, + DEFAULT_EXPIRY_BUFFER_SECONDS: 15, }; diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts index 9e54300b3..31fdcc182 100644 --- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts +++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts @@ -41,11 +41,18 @@ export const orderProviderResponseProcessor = { targetOrderProviderResponse: OrderProviderResponse, feeOrderProviderResponse: OrderProviderResponse, zrxTokenAssetData: string, + expiryBufferSeconds: number, orderValidator?: OrderValidatorWrapper, ): Promise { // drop orders that are expired or not open - const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(targetOrderProviderResponse.orders); - const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(feeOrderProviderResponse.orders); + const filteredTargetOrders = filterOutExpiredAndNonOpenOrders( + targetOrderProviderResponse.orders, + expiryBufferSeconds, + ); + const filteredFeeOrders = filterOutExpiredAndNonOpenOrders( + feeOrderProviderResponse.orders, + expiryBufferSeconds, + ); // set the orders to be sorted equal to the filtered orders let unsortedTargetOrders = filteredTargetOrders; let unsortedFeeOrders = filteredFeeOrders; @@ -98,9 +105,10 @@ export const orderProviderResponseProcessor = { */ function filterOutExpiredAndNonOpenOrders( orders: SignedOrderWithRemainingFillableMakerAssetAmount[], + expiryBufferSeconds: number, ): SignedOrderWithRemainingFillableMakerAssetAmount[] { const result = _.filter(orders, order => { - return orderUtils.isOpenOrder(order) && !orderUtils.isOrderExpired(order); + return orderUtils.isOpenOrder(order) && !orderUtils.willOrderExpire(order, expiryBufferSeconds); }); return result; } diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts index 27db73257..62166eb76 100644 --- a/packages/asset-buyer/src/utils/order_utils.ts +++ b/packages/asset-buyer/src/utils/order_utils.ts @@ -5,9 +5,12 @@ import { constants } from '../constants'; export const orderUtils = { isOrderExpired(order: SignedOrder): boolean { + return orderUtils.willOrderExpire(order, 0); + }, + willOrderExpire(order: SignedOrder, secondsFromNow: number): boolean { const millisecondsInSecond = 1000; const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round(); - return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec); + return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec.minus(secondsFromNow)); }, calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber { if (remainingTakerAssetAmount.eq(0)) { -- cgit From 7a43e1911615d4f59a2cecdb2a98cac95f205f86 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 24 Sep 2018 15:43:02 +0200 Subject: Improve README --- packages/asset-buyer/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md index f615b93e1..5f7f26f30 100644 --- a/packages/asset-buyer/README.md +++ b/packages/asset-buyer/README.md @@ -1,11 +1,9 @@ ## @0xproject/asset-buyer -Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute Wrapped Ether based 0x orders without having to set allowances, wrap Ether or buy ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset. +Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or buy ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset. In its more advanced and useful form, it integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone. -### Read the [Documentation](https://0xproject.com/docs/asset-buyer). - ## Installation ```bash -- cgit From d8d1c98a40f5cc895329f73af4d8d000c6a5195b Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 24 Sep 2018 15:53:34 +0200 Subject: Upgrade all deps --- packages/asset-buyer/package.json | 16 ++++++++-------- yarn.lock | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index f80f8db7e..2b5136e31 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -36,16 +36,16 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/connect": "^2.0.0", - "@0xproject/contract-wrappers": "^1.0.1", - "@0xproject/json-schemas": "^1.0.1", + "@0xproject/assert": "^1.0.9", + "@0xproject/connect": "^2.0.2", + "@0xproject/contract-wrappers": "^1.0.4", + "@0xproject/json-schemas": "^1.0.2", "@0xproject/order-utils": "^1.0.1", "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "ethereum-types": "^1.0.6", "lodash": "^4.17.10" }, diff --git a/yarn.lock b/yarn.lock index aa30946a8..7464a9c5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5296,9 +5296,9 @@ ethereumjs-wallet@~0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: - version "3.0.18" - resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447" +ethers@3.0.22: + version "3.0.22" + resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" dependencies: aes-js "3.0.0" bn.js "^4.4.0" -- cgit From d0448c2bbd90c6c103f07b201886670dc4675a43 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 24 Sep 2018 15:02:06 +0100 Subject: Fix bug where if block wasn't found, getBlockAsync would throw. Now it returns `undefined` --- .../src/contract_wrappers/contract_wrapper.ts | 17 +++++++++-- .../contract-wrappers/test/subscription_test.ts | 2 +- .../test/multisig/multi_sig_with_time_lock.ts | 5 +++- packages/contracts/test/utils/block_timestamp.ts | 7 +++-- .../src/order_watcher/event_watcher.ts | 18 +++++++++--- packages/web3-wrapper/src/web3_wrapper.ts | 26 +++++++++++------ packages/web3-wrapper/test/web3_wrapper_test.ts | 34 +++++++++++++++------- 7 files changed, 78 insertions(+), 31 deletions(-) diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 19de17c0a..4a1d6258b 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -2,6 +2,7 @@ import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { BlockParamLiteral, + BlockWithoutTransactionData, ContractAbi, ContractArtifact, FilterObject, @@ -174,7 +175,7 @@ export abstract class ContractWrapper { throw new Error(ContractWrappersError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper), + this._getBlockOrNullAsync.bind(this), this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose), ); @@ -194,6 +195,13 @@ export abstract class ContractWrapper { this._onLogStateChanged.bind(this, isRemoved), ); } + private async _getBlockOrNullAsync(): Promise { + const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); + if (_.isUndefined(blockIfExists)) { + return null; + } + return blockIfExists; + } // HACK: This should be a package-scoped method (which doesn't exist in TS) // We don't want this method available in the public interface for all classes // who inherit from ContractWrapper, and it is only used by the internal implementation @@ -212,11 +220,14 @@ export abstract class ContractWrapper { delete this._blockAndLogStreamerIfExists; } private async _reconcileBlockAsync(): Promise { - const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest); + const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest); + if (_.isUndefined(latestBlockIfExists)) { + return; // noop + } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); } } } diff --git a/packages/contract-wrappers/test/subscription_test.ts b/packages/contract-wrappers/test/subscription_test.ts index 81b9012bd..68ef7225e 100644 --- a/packages/contract-wrappers/test/subscription_test.ts +++ b/packages/contract-wrappers/test/subscription_test.ts @@ -61,7 +61,7 @@ describe('SubscriptionTest', () => { callback, ); stubs = [ - Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockAsync').throws( + Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockIfExistsAsync').throws( new Error('JSON RPC error'), ), ]; diff --git a/packages/contracts/test/multisig/multi_sig_with_time_lock.ts b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts index 05d8bbb36..0b17c298b 100644 --- a/packages/contracts/test/multisig/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts @@ -269,7 +269,10 @@ describe('MultiSigWalletWithTimeLock', () => { expect(confirmRes.logs).to.have.length(2); const blockNum = await web3Wrapper.getBlockNumberAsync(); - const blockInfo = await web3Wrapper.getBlockAsync(blockNum); + const blockInfo = await web3Wrapper.getBlockIfExistsAsync(blockNum); + if (_.isUndefined(blockInfo)) { + throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`); + } const timestamp = new BigNumber(blockInfo.timestamp); const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId)); diff --git a/packages/contracts/test/utils/block_timestamp.ts b/packages/contracts/test/utils/block_timestamp.ts index 1159792c4..66c13eed1 100644 --- a/packages/contracts/test/utils/block_timestamp.ts +++ b/packages/contracts/test/utils/block_timestamp.ts @@ -35,6 +35,9 @@ export async function increaseTimeAndMineBlockAsync(seconds: number): Promise { - const currentBlock = await web3Wrapper.getBlockAsync('latest'); - return currentBlock.timestamp; + const currentBlockIfExists = await web3Wrapper.getBlockIfExistsAsync('latest'); + if (_.isUndefined(currentBlockIfExists)) { + throw new Error(`Unable to fetch latest block.`); + } + return currentBlockIfExists.timestamp; } diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index 9509c75de..fc8dd471d 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ import { intervalUtils, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { BlockParamLiteral, LogEntry, Provider } from 'ethereum-types'; +import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -62,7 +62,7 @@ export class EventWatcher { throw new Error(OrderWatcherError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper), + this._getBlockOrNullAsync.bind(this), this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), this._onBlockAndLogStreamerError.bind(this), ); @@ -82,6 +82,13 @@ export class EventWatcher { this._onLogStateChangedAsync.bind(this, callback, isRemoved), ); } + private async _getBlockOrNullAsync(): Promise { + const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); + if (_.isUndefined(blockIfExists)) { + return null; + } + return blockIfExists; + } private _stopBlockAndLogStream(): void { if (_.isUndefined(this._blockAndLogStreamerIfExists)) { throw new Error(OrderWatcherError.SubscriptionNotFound); @@ -100,11 +107,14 @@ export class EventWatcher { await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); } private async _reconcileBlockAsync(): Promise { - const latestBlock = await this._web3Wrapper.getBlockAsync(this._stateLayer); + const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer); + if (_.isUndefined(latestBlockIfExists)) { + return; // noop + } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); } } private async _emitDifferencesAsync( diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index af0fe3a72..40e0a73f0 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -329,23 +329,28 @@ export class Web3Wrapper { /** * Fetch a specific Ethereum block without transaction data * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) - * @returns The requested block without transaction data + * @returns The requested block without transaction data, or undefined if block was not found */ - public async getBlockAsync(blockParam: string | BlockParam): Promise { + public async getBlockIfExistsAsync( + blockParam: string | BlockParam, + ): Promise { Web3Wrapper._assertBlockParamOrString(blockParam); const encodedBlockParam = marshaller.marshalBlockParam(blockParam); const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber'; const shouldIncludeTransactionData = false; - const blockWithoutTransactionDataWithHexValues = await this._sendRawPayloadAsync< + const blockWithoutTransactionDataWithHexValuesOrNull = await this._sendRawPayloadAsync< BlockWithoutTransactionDataRPC >({ method, params: [encodedBlockParam, shouldIncludeTransactionData], }); - const blockWithoutTransactionData = marshaller.unmarshalIntoBlockWithoutTransactionData( - blockWithoutTransactionDataWithHexValues, - ); - return blockWithoutTransactionData; + let blockWithoutTransactionDataIfExists; + if (!_.isNull(blockWithoutTransactionDataWithHexValuesOrNull)) { + blockWithoutTransactionDataIfExists = marshaller.unmarshalIntoBlockWithoutTransactionData( + blockWithoutTransactionDataWithHexValuesOrNull, + ); + } + return blockWithoutTransactionDataIfExists; } /** * Fetch a specific Ethereum block with transaction data @@ -376,8 +381,11 @@ export class Web3Wrapper { */ public async getBlockTimestampAsync(blockParam: string | BlockParam): Promise { Web3Wrapper._assertBlockParamOrString(blockParam); - const { timestamp } = await this.getBlockAsync(blockParam); - return timestamp; + const blockIfExists = await this.getBlockIfExistsAsync(blockParam); + if (_.isUndefined(blockIfExists)) { + throw new Error(`Failed to fetch block with blockParam: ${JSON.stringify(blockParam)}`); + } + return blockIfExists.timestamp; } /** * Retrieve the user addresses available through the backing provider diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts index b4fd8bb44..385c469bf 100644 --- a/packages/web3-wrapper/test/web3_wrapper_test.ts +++ b/packages/web3-wrapper/test/web3_wrapper_test.ts @@ -85,28 +85,40 @@ describe('Web3Wrapper tests', () => { expect(typeof blockNumber).to.be.equal('number'); }); }); - describe('#getBlockAsync', () => { + describe('#getBlockIfExistsAsync', () => { it('gets block when supplied a valid BlockParamLiteral value', async () => { const blockParamLiteral = BlockParamLiteral.Earliest; - const block = await web3Wrapper.getBlockAsync(blockParamLiteral); - expect(block.number).to.be.equal(0); - expect(utils.isBigNumber(block.difficulty)).to.equal(true); - expect(_.isNumber(block.gasLimit)).to.equal(true); + const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral); + if (_.isUndefined(blockIfExists)) { + throw new Error('Expected block to exist'); + } + expect(blockIfExists.number).to.be.equal(0); + expect(utils.isBigNumber(blockIfExists.difficulty)).to.equal(true); + expect(_.isNumber(blockIfExists.gasLimit)).to.equal(true); }); it('gets block when supplied a block number', async () => { const blockParamLiteral = 0; - const block = await web3Wrapper.getBlockAsync(blockParamLiteral); - expect(block.number).to.be.equal(0); + const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral); + if (_.isUndefined(blockIfExists)) { + throw new Error('Expected block to exist'); + } + expect(blockIfExists.number).to.be.equal(0); }); it('gets block when supplied a block hash', async () => { const blockParamLiteral = 0; - const block = await web3Wrapper.getBlockAsync(blockParamLiteral); - const sameBlock = await web3Wrapper.getBlockAsync(block.hash as string); - expect(sameBlock.number).to.be.equal(0); + const blockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockParamLiteral); + if (_.isUndefined(blockIfExists)) { + throw new Error('Expected block to exist'); + } + const sameBlockIfExists = await web3Wrapper.getBlockIfExistsAsync(blockIfExists.hash as string); + if (_.isUndefined(sameBlockIfExists)) { + throw new Error('Expected block to exist'); + } + expect(sameBlockIfExists.number).to.be.equal(0); }); it('should throw if supplied invalid blockParam value', async () => { const invalidBlockParam = 'deadbeef'; - expect(web3Wrapper.getBlockAsync(invalidBlockParam)).to.eventually.to.be.rejected(); + expect(web3Wrapper.getBlockIfExistsAsync(invalidBlockParam)).to.eventually.to.be.rejected(); }); }); describe('#getBlockWithTransactionDataAsync', () => { -- cgit From ebddf82819a9fe9eb8550e939ea946248718beef Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 24 Sep 2018 15:02:47 +0100 Subject: Add CHANGELOG entry for change to getBlockAsync --- packages/web3-wrapper/CHANGELOG.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 1653f388c..eb21dc3dc 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.0.0", + "changes": [ + { + "note": + "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined." + } + ] + }, { "version": "2.0.3", "changes": [ -- cgit From 5d88a56452d9f953e36a91991573ff0f3efa0da4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 24 Sep 2018 15:11:29 +0100 Subject: Add PR nr --- packages/web3-wrapper/CHANGELOG.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index eb21dc3dc..ce3f5e3be 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -4,7 +4,8 @@ "changes": [ { "note": - "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined." + "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined.", + "pr": 1082 } ] }, -- cgit From 311b92591955e9b6eaaaffe6b92b9f33a05d38b4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 24 Sep 2018 15:14:07 +0100 Subject: Add to doc comment why a block might not be returned to the caller --- packages/web3-wrapper/src/web3_wrapper.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index 40e0a73f0..dc634a57f 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -330,6 +330,7 @@ export class Web3Wrapper { * Fetch a specific Ethereum block without transaction data * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) * @returns The requested block without transaction data, or undefined if block was not found + * (e.g the node isn't fully synced, there was a block re-org and the requested block was uncles, etc...) */ public async getBlockIfExistsAsync( blockParam: string | BlockParam, -- cgit From 7516959c9f733c0ee73c2551db185a7751d9f94c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 24 Sep 2018 15:14:14 +0100 Subject: Add comments for clarity --- packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts | 1 + packages/order-watcher/src/order_watcher/event_watcher.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 4a1d6258b..19a882712 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -195,6 +195,7 @@ export abstract class ContractWrapper { this._onLogStateChanged.bind(this, isRemoved), ); } + // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _getBlockOrNullAsync(): Promise { const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); if (_.isUndefined(blockIfExists)) { diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index fc8dd471d..eca235e26 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -82,6 +82,7 @@ export class EventWatcher { this._onLogStateChangedAsync.bind(this, callback, isRemoved), ); } + // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _getBlockOrNullAsync(): Promise { const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); if (_.isUndefined(blockIfExists)) { -- cgit From 6f2ab23bd028ea460540e1519376bb2dd4e23c72 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Mon, 24 Sep 2018 13:54:25 -0700 Subject: Feature/custom verdaccio dockerfile (#1083) Create custom verdaccio docker image --- .circleci/config.yml | 2 +- packages/migrations/.gitignore | 1 + packages/verdaccio/Dockerfile | 3 ++ packages/verdaccio/README.md | 18 +++++++++++ packages/verdaccio/conf.yaml | 71 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 packages/migrations/.gitignore create mode 100644 packages/verdaccio/Dockerfile create mode 100644 packages/verdaccio/README.md create mode 100644 packages/verdaccio/conf.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index d5ae2c2fc..446ef499d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,7 +64,7 @@ jobs: resource_class: medium+ docker: - image: circleci/node:9 - - image: verdaccio/verdaccio + - image: albrow/0x-verdaccio working_directory: ~/repo steps: - restore_cache: diff --git a/packages/migrations/.gitignore b/packages/migrations/.gitignore new file mode 100644 index 000000000..dc4af7ced --- /dev/null +++ b/packages/migrations/.gitignore @@ -0,0 +1 @@ +artifacts/development diff --git a/packages/verdaccio/Dockerfile b/packages/verdaccio/Dockerfile new file mode 100644 index 000000000..6a6a64abf --- /dev/null +++ b/packages/verdaccio/Dockerfile @@ -0,0 +1,3 @@ +FROM verdaccio/verdaccio + +ADD conf.yaml /verdaccio/conf/config.yaml diff --git a/packages/verdaccio/README.md b/packages/verdaccio/README.md new file mode 100644 index 000000000..340cd5512 --- /dev/null +++ b/packages/verdaccio/README.md @@ -0,0 +1,18 @@ +## 0x Verdaccio + +This package contains a Dockerfile and conf.yaml file for configuring our own +Docker image for Verdaccio. + +See https://verdaccio.org/docs/en/configuration for more information. + +## Build + +In the root directory for _this package_, run: + +`sudo docker build . -t 0x-verdaccio` + +## Run + +To start Verdaccio run: + +`sudo docker run --rm -i -p 4873:4873 0x-verdaccio` diff --git a/packages/verdaccio/conf.yaml b/packages/verdaccio/conf.yaml new file mode 100644 index 000000000..24e036932 --- /dev/null +++ b/packages/verdaccio/conf.yaml @@ -0,0 +1,71 @@ +# +# Copied from https://github.com/verdaccio/verdaccio/blob/90fc216649ecd8df31d3706b5c17555fa0a35e4a/conf/docker.yaml +# Only the uplinks section has been modified. +# +# This is the config file used for the docker images. +# It allows all users to do anything, so don't use it on production systems. +# +# Do not configure host and port under `listen` in this file +# as it will be ignored when using docker. +# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration +# +# Look here for more config file examples: +# https://github.com/verdaccio/verdaccio/tree/master/conf +# + +# path to a directory with all packages +storage: /verdaccio/storage +# path to a directory with plugins to include +plugins: /verdaccio/plugins + +web: + # WebUI is enabled as default, if you want disable it, just uncomment this line + enable: false + +auth: + htpasswd: + file: /verdaccio/conf/htpasswd + # Maximum amount of users allowed to register, defaults to "+infinity". + # You can set this to -1 to disable registration. + #max_users: 1000 + +# a list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ + cache: true + max_fails: 5 + +packages: + '@*/*': + # scoped packages + access: $all + publish: $authenticated + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + # + # you can specify usernames/groupnames (depending on your auth plugin) + # and three keywords: "$all", "$anonymous", "$authenticated" + access: $all + + # allow all known users to publish packages + # (anyone can register by default, remember?) + publish: $authenticated + + # if package is not available locally, proxy requests to 'npmjs' registry + proxy: npmjs + +# To use `npm audit` uncomment the following section +# middlewares: +# audit: +# enabled: true + +# log settings +logs: + - {type: stdout, format: pretty, level: http} + #- {type: file, path: verdaccio.log, level: info} + +max_body_size: 100mb -- cgit From 408f5731880d61877964275301ad10d522aad6a7 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Mon, 24 Sep 2018 14:31:26 -0700 Subject: Use the 0xorg DockerHub account instead of albrow (#1084) --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 446ef499d..537b19348 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,7 @@ jobs: test-contracts-geth: docker: - image: circleci/node:9 - - image: albrow/0x-devnet + - image: 0xorg/devnet working_directory: ~/repo steps: - restore_cache: @@ -64,7 +64,7 @@ jobs: resource_class: medium+ docker: - image: circleci/node:9 - - image: albrow/0x-verdaccio + - image: 0xorg/verdaccio working_directory: ~/repo steps: - restore_cache: -- cgit From 9c89d1e99b5a285eee74b53fa6f2595789fafb11 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 10:45:11 +0100 Subject: Expose method to send raw JSON RPC payloads --- packages/web3-wrapper/src/web3_wrapper.ts | 73 +++++++++++++++++-------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index 2f574b76a..d52c1cb6e 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -193,7 +193,7 @@ export class Web3Wrapper { * @returns Ethereum node's version string */ public async getNodeVersionAsync(): Promise { - const nodeVersion = await this._sendRawPayloadAsync({ method: 'web3_clientVersion' }); + const nodeVersion = await this.sendRawPayloadAsync({ method: 'web3_clientVersion' }); return nodeVersion; } /** @@ -201,7 +201,7 @@ export class Web3Wrapper { * @returns The network id */ public async getNetworkIdAsync(): Promise { - const networkIdStr = await this._sendRawPayloadAsync({ method: 'net_version' }); + const networkIdStr = await this.sendRawPayloadAsync({ method: 'net_version' }); const networkId = _.parseInt(networkIdStr); return networkId; } @@ -212,7 +212,7 @@ export class Web3Wrapper { */ public async getTransactionReceiptAsync(txHash: string): Promise { assert.isHexString('txHash', txHash); - const transactionReceipt = await this._sendRawPayloadAsync({ + const transactionReceipt = await this.sendRawPayloadAsync({ method: 'eth_getTransactionReceipt', params: [txHash], }); @@ -228,7 +228,7 @@ export class Web3Wrapper { */ public async getTransactionByHashAsync(txHash: string): Promise { assert.isHexString('txHash', txHash); - const transaction = await this._sendRawPayloadAsync({ + const transaction = await this.sendRawPayloadAsync({ method: 'eth_getTransactionByHash', params: [txHash], }); @@ -247,7 +247,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const encodedOwner = marshaller.marshalAddress(owner); - const balanceInWei = await this._sendRawPayloadAsync({ + const balanceInWei = await this.sendRawPayloadAsync({ method: 'eth_getBalance', params: [encodedOwner, marshalledDefaultBlock], }); @@ -279,7 +279,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const encodedAddress = marshaller.marshalAddress(address); - const code = await this._sendRawPayloadAsync({ + const code = await this.sendRawPayloadAsync({ method: 'eth_getCode', params: [encodedAddress, marshalledDefaultBlock], }); @@ -293,7 +293,7 @@ export class Web3Wrapper { */ public async getTransactionTraceAsync(txHash: string, traceParams: TraceParams): Promise { assert.isHexString('txHash', txHash); - const trace = await this._sendRawPayloadAsync({ + const trace = await this.sendRawPayloadAsync({ method: 'debug_traceTransaction', params: [txHash, traceParams], }); @@ -308,7 +308,7 @@ export class Web3Wrapper { public async signMessageAsync(address: string, message: string): Promise { assert.isETHAddressHex('address', address); assert.isString('message', message); // TODO: Should this be stricter? Hex string? - const signData = await this._sendRawPayloadAsync({ + const signData = await this.sendRawPayloadAsync({ method: 'eth_sign', params: [address, message], }); @@ -319,7 +319,7 @@ export class Web3Wrapper { * @returns Block number */ public async getBlockNumberAsync(): Promise { - const blockNumberHex = await this._sendRawPayloadAsync({ + const blockNumberHex = await this.sendRawPayloadAsync({ method: 'eth_blockNumber', params: [], }); @@ -339,7 +339,7 @@ export class Web3Wrapper { const encodedBlockParam = marshaller.marshalBlockParam(blockParam); const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber'; const shouldIncludeTransactionData = false; - const blockWithoutTransactionDataWithHexValuesOrNull = await this._sendRawPayloadAsync< + const blockWithoutTransactionDataWithHexValuesOrNull = await this.sendRawPayloadAsync< BlockWithoutTransactionDataRPC >({ method, @@ -366,7 +366,7 @@ export class Web3Wrapper { } const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber'; const shouldIncludeTransactionData = true; - const blockWithTransactionDataWithHexValues = await this._sendRawPayloadAsync({ + const blockWithTransactionDataWithHexValues = await this.sendRawPayloadAsync({ method, params: [encodedBlockParam, shouldIncludeTransactionData], }); @@ -393,7 +393,7 @@ export class Web3Wrapper { * @returns Available user addresses */ public async getAvailableAddressesAsync(): Promise { - const addresses = await this._sendRawPayloadAsync({ + const addresses = await this.sendRawPayloadAsync({ method: 'eth_accounts', params: [], }); @@ -405,7 +405,7 @@ export class Web3Wrapper { * @returns The snapshot id. This can be used to revert to this snapshot */ public async takeSnapshotAsync(): Promise { - const snapshotId = Number(await this._sendRawPayloadAsync({ method: 'evm_snapshot', params: [] })); + const snapshotId = Number(await this.sendRawPayloadAsync({ method: 'evm_snapshot', params: [] })); return snapshotId; } /** @@ -415,14 +415,14 @@ export class Web3Wrapper { */ public async revertSnapshotAsync(snapshotId: number): Promise { assert.isNumber('snapshotId', snapshotId); - const didRevert = await this._sendRawPayloadAsync({ method: 'evm_revert', params: [snapshotId] }); + const didRevert = await this.sendRawPayloadAsync({ method: 'evm_revert', params: [snapshotId] }); return didRevert; } /** * Mine a block on a TestRPC/Ganache local node */ public async mineBlockAsync(): Promise { - await this._sendRawPayloadAsync({ method: 'evm_mine', params: [] }); + await this.sendRawPayloadAsync({ method: 'evm_mine', params: [] }); } /** * Increase the next blocks timestamp on TestRPC/Ganache or Geth local node. @@ -434,9 +434,9 @@ export class Web3Wrapper { // Detect Geth vs. Ganache and use appropriate endpoint. const version = await this.getNodeVersionAsync(); if (_.includes(version, uniqueVersionIds.geth)) { - return this._sendRawPayloadAsync({ method: 'debug_increaseTime', params: [timeDelta] }); + return this.sendRawPayloadAsync({ method: 'debug_increaseTime', params: [timeDelta] }); } else if (_.includes(version, uniqueVersionIds.ganache)) { - return this._sendRawPayloadAsync({ method: 'evm_increaseTime', params: [timeDelta] }); + return this.sendRawPayloadAsync({ method: 'evm_increaseTime', params: [timeDelta] }); } else { throw new Error(`Unknown client version: ${version}`); } @@ -470,7 +470,7 @@ export class Web3Wrapper { method: 'eth_getLogs', params: [serializedFilter], }; - const rawLogs = await this._sendRawPayloadAsync(payload); + const rawLogs = await this.sendRawPayloadAsync(payload); const formattedLogs = _.map(rawLogs, marshaller.unmarshalLog.bind(marshaller)); return formattedLogs; } @@ -486,7 +486,7 @@ export class Web3Wrapper { schemas.jsNumber, ]); const txDataHex = marshaller.marshalTxData(txData); - const gasHex = await this._sendRawPayloadAsync({ method: 'eth_estimateGas', params: [txDataHex] }); + const gasHex = await this.sendRawPayloadAsync({ method: 'eth_estimateGas', params: [txDataHex] }); const gas = utils.convertHexToNumber(gasHex); return gas; } @@ -507,7 +507,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const callDataHex = marshaller.marshalCallData(callData); - const rawCallResult = await this._sendRawPayloadAsync({ + const rawCallResult = await this.sendRawPayloadAsync({ method: 'eth_call', params: [callDataHex, marshalledDefaultBlock], }); @@ -528,7 +528,7 @@ export class Web3Wrapper { schemas.jsNumber, ]); const txDataHex = marshaller.marshalTxData(txData); - const txHash = await this._sendRawPayloadAsync({ method: 'eth_sendTransaction', params: [txDataHex] }); + const txHash = await this.sendRawPayloadAsync({ method: 'eth_sendTransaction', params: [txDataHex] }); return txHash; } /** @@ -638,7 +638,24 @@ export class Web3Wrapper { */ public async setHeadAsync(blockNumber: number): Promise { assert.isNumber('blockNumber', blockNumber); - await this._sendRawPayloadAsync({ method: 'debug_setHead', params: [utils.numberToHex(blockNumber)] }); + await this.sendRawPayloadAsync({ method: 'debug_setHead', params: [utils.numberToHex(blockNumber)] }); + } + /** + * Sends a raw Ethereum JSON RPC payload and returns the response's `result` key + * @param payload A partial JSON RPC payload. No need to include version, id, params (if none needed) + * @return The contents nested under the result key of the response body + */ + public async sendRawPayloadAsync(payload: Partial): Promise { + const sendAsync = this._provider.sendAsync.bind(this._provider); + const payloadWithDefaults = { + id: this._jsonRpcRequestId++, + params: [], + jsonrpc: '2.0', + ...payload, + }; + const response = await promisify(sendAsync)(payloadWithDefaults); + const result = response.result; + return result; } /** * Returns either NodeType.Geth or NodeType.Ganache depending on the type of @@ -654,16 +671,4 @@ export class Web3Wrapper { throw new Error(`Unknown client version: ${version}`); } } - private async _sendRawPayloadAsync(payload: Partial): Promise { - const sendAsync = this._provider.sendAsync.bind(this._provider); - const payloadWithDefaults = { - id: this._jsonRpcRequestId++, - params: [], - jsonrpc: '2.0', - ...payload, - }; - const response = await promisify(sendAsync)(payloadWithDefaults); - const result = response.result; - return result; - } } // tslint:disable-line:max-file-line-count -- cgit From 21910a712965e5f992f540d94620be2b45384d8f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 11:02:49 +0100 Subject: Add entry about newly exposed method --- packages/web3-wrapper/CHANGELOG.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index ce3f5e3be..8ef544d26 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -6,6 +6,10 @@ "note": "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined.", "pr": 1082 + }, + { + "note": "Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls", + "pr": 1080 } ] }, -- cgit From 0afe55f2ff028d03e3a9f110819806f68446dee9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 11:20:09 +0100 Subject: Refactor blockstream integration to use the proper callback method interface --- .../src/contract_wrappers/contract_wrapper.ts | 40 ++++++++++++++++------ .../src/order_watcher/event_watcher.ts | 40 ++++++++++++++++------ 2 files changed, 58 insertions(+), 22 deletions(-) diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 19a882712..660f2d122 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -175,8 +175,8 @@ export abstract class ContractWrapper { throw new Error(ContractWrappersError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._getBlockOrNullAsync.bind(this), - this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), + this._blockstreamGetBlockOrNullAsync.bind(this), + this._blockstreamGetLogsAsync.bind(this), ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose), ); const catchAllLogFilter = {}; @@ -196,12 +196,30 @@ export abstract class ContractWrapper { ); } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _getBlockOrNullAsync(): Promise { - const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); - if (_.isUndefined(blockIfExists)) { - return null; - } - return blockIfExists; + private async _blockstreamGetBlockOrNullAsync(hash: string): Promise { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getBlockByHash', + params: [hash, shouldIncludeTransactionData], + }); + return blockOrNull as Block; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLatestBlockOrNullAsync(): Promise { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getBlockByNumber', + params: ['latest', shouldIncludeTransactionData], + }); + return blockOrNull as Block; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { + const logs = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getLogs', + params: [filterOptions], + }); + return logs as Log[]; } // HACK: This should be a package-scoped method (which doesn't exist in TS) // We don't want this method available in the public interface for all classes @@ -221,14 +239,14 @@ export abstract class ContractWrapper { delete this._blockAndLogStreamerIfExists; } private async _reconcileBlockAsync(): Promise { - const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest); - if (_.isUndefined(latestBlockIfExists)) { + const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync(); + if (_.isNull(latestBlockOrNull)) { return; // noop } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockOrNull as any) as Block); } } } diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index eca235e26..c3de86f4e 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -62,8 +62,8 @@ export class EventWatcher { throw new Error(OrderWatcherError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._getBlockOrNullAsync.bind(this), - this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), + this._blockstreamGetBlockOrNullAsync.bind(this), + this._blockstreamGetLogsAsync.bind(this), this._onBlockAndLogStreamerError.bind(this), ); const catchAllLogFilter = {}; @@ -82,13 +82,31 @@ export class EventWatcher { this._onLogStateChangedAsync.bind(this, callback, isRemoved), ); } + /// This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetBlockOrNullAsync(hash: string): Promise { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getBlockByHash', + params: [hash, shouldIncludeTransactionData], + }); + return blockOrNull as Block; + } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _getBlockOrNullAsync(): Promise { - const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); - if (_.isUndefined(blockIfExists)) { - return null; - } - return blockIfExists; + private async _blockstreamGetLatestBlockOrNullAsync(): Promise { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getBlockByNumber', + params: ['latest', shouldIncludeTransactionData], + }); + return blockOrNull as Block; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { + const logs = await this._web3Wrapper.sendRawPayloadAsync({ + method: 'eth_getLogs', + params: [filterOptions], + }); + return logs as Log[]; } private _stopBlockAndLogStream(): void { if (_.isUndefined(this._blockAndLogStreamerIfExists)) { @@ -108,14 +126,14 @@ export class EventWatcher { await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); } private async _reconcileBlockAsync(): Promise { - const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer); - if (_.isUndefined(latestBlockIfExists)) { + const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync(); + if (_.isNull(latestBlockOrNull)) { return; // noop } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockOrNull as any) as Block); } } private async _emitDifferencesAsync( -- cgit From 902691e289ab6e7daae18f42ec8601807f3a7c0a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 11:29:36 +0100 Subject: Update changelogs --- packages/contract-wrappers/CHANGELOG.json | 7 ++++++- packages/order-watcher/CHANGELOG.json | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 1c9af4971..468ddc3bc 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -4,7 +4,12 @@ "changes": [ { "note": - "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", + "pr": 1080 + }, + { + "note": "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "pr": 1080 } ] }, diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 1b19a4cdd..a70d91654 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -4,7 +4,12 @@ "changes": [ { "note": - "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too." + "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", + "pr": 1080 + }, + { + "note": "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "pr": 1080 } ] }, -- cgit From 284930eb58c95c03f1a73b7c1f127701068e41e9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 11:30:27 +0100 Subject: Add missing type --- packages/order-watcher/src/order_watcher/event_watcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index c3de86f4e..d23052613 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ import { intervalUtils, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types'; +import { BlockParamLiteral, FilterObject, LogEntry, Provider } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; -- cgit From 55ca971186fd9318c1be9cc9e8c125f55c653cd9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 12:05:44 +0100 Subject: Decode logs received from blockstream --- .../contract-wrappers/src/contract_wrappers/contract_wrapper.ts | 9 +++++---- packages/order-watcher/src/order_watcher/event_watcher.ts | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 660f2d122..58c5bce6d 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -1,14 +1,14 @@ import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper'; import { BlockParamLiteral, - BlockWithoutTransactionData, ContractAbi, ContractArtifact, FilterObject, LogEntry, LogWithDecodedArgs, RawLog, + RawLogEntry, } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -158,7 +158,8 @@ export abstract class ContractWrapper { return addressIfExists; } } - private _onLogStateChanged(isRemoved: boolean, log: LogEntry): void { + private _onLogStateChanged(isRemoved: boolean, rawLog: RawLogEntry): void { + const log: LogEntry = marshaller.unmarshalLog(rawLog); _.forEach(this._filters, (filter: FilterObject, filterToken: string) => { if (filterUtils.matchesFilter(log, filter)) { const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs; @@ -209,7 +210,7 @@ export abstract class ContractWrapper { const shouldIncludeTransactionData = false; const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByNumber', - params: ['latest', shouldIncludeTransactionData], + params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], }); return blockOrNull as Block; } diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index d23052613..e73e1f9f9 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ import { intervalUtils, logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { BlockParamLiteral, FilterObject, LogEntry, Provider } from 'ethereum-types'; +import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper'; +import { BlockParamLiteral, FilterObject, LogEntry, Provider, RawLogEntry } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -96,7 +96,7 @@ export class EventWatcher { const shouldIncludeTransactionData = false; const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByNumber', - params: ['latest', shouldIncludeTransactionData], + params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], }); return blockOrNull as Block; } @@ -121,8 +121,9 @@ export class EventWatcher { private async _onLogStateChangedAsync( callback: EventWatcherCallback, isRemoved: boolean, - log: LogEntry, + rawLog: RawLogEntry, ): Promise { + const log: LogEntry = marshaller.unmarshalLog(rawLog); await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); } private async _reconcileBlockAsync(): Promise { -- cgit From 173b36c54cc51c9b42c3f96f5a313d9e271b087c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 12:06:28 +0100 Subject: Fix prettier --- packages/contract-wrappers/CHANGELOG.json | 5 +++-- packages/order-watcher/CHANGELOG.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 468ddc3bc..9ee812426 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -4,11 +4,12 @@ "changes": [ { "note": - "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", + "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", "pr": 1080 }, { - "note": "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "note": + "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", "pr": 1080 } ] diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index a70d91654..eded891d6 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -5,10 +5,11 @@ { "note": "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", - "pr": 1080 + "pr": 1080 }, { - "note": "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "note": + "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", "pr": 1080 } ] -- cgit From a05530f821b2550ff14a0e359c27650d4ba03130 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 12:06:37 +0100 Subject: Fix prettier --- packages/web3-wrapper/CHANGELOG.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 8ef544d26..18ce5acd5 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -8,7 +8,8 @@ "pr": 1082 }, { - "note": "Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls", + "note": + "Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls", "pr": 1080 } ] -- cgit From b85db17e75e818b5b554cc2b8068aba980d95804 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 25 Sep 2018 12:47:31 +0200 Subject: Move SRA types from @0xproject/connect to @0xproject/sra-types --- .../standard_relayer_api_order_provider.ts | 3 +- packages/connect/CHANGELOG.json | 9 ++ packages/connect/src/http_client.ts | 18 ++- packages/connect/src/index.ts | 25 ++-- packages/connect/src/types.ts | 145 +++------------------ .../src/utils/orders_channel_message_parser.ts | 2 +- .../src/utils/relayer_response_json_parsers.ts | 2 +- packages/connect/src/utils/type_converters.ts | 2 +- packages/connect/src/ws_orders_channel.ts | 3 +- .../fixtures/standard_relayer_api/asset_pairs.ts | 2 +- .../standard_relayer_api/fee_recipients.ts | 2 +- .../fixtures/standard_relayer_api/order_config.ts | 2 +- .../fixtures/standard_relayer_api/orderbook.ts | 2 +- .../test/fixtures/standard_relayer_api/orders.ts | 2 +- packages/types/CHANGELOG.json | 4 + packages/types/src/index.ts | 128 ++++++++++++++++++ yarn.lock | 6 +- 17 files changed, 190 insertions(+), 167 deletions(-) diff --git a/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts index be3e9da50..31942c25b 100644 --- a/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts +++ b/packages/asset-buyer/src/order_providers/standard_relayer_api_order_provider.ts @@ -1,4 +1,5 @@ -import { APIOrder, HttpClient, OrderbookResponse } from '@0xproject/connect'; +import { HttpClient } from '@0xproject/connect'; +import { APIOrder, OrderbookResponse } from '@0xproject/types'; import * as _ from 'lodash'; import { diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index f5ca80279..b39c8d272 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.0.3", + "changes": [ + { + "note": "Import SRA-related types from @0xproject/types", + "pr": 1085 + } + ] + }, { "timestamp": 1537541580, "version": "2.0.2", diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index bdcfdd8d2..8a68d6c23 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -1,19 +1,10 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; -import { SignedOrder } from '@0xproject/types'; -import { fetchAsync } from '@0xproject/utils'; -import * as _ from 'lodash'; -import * as queryString from 'query-string'; - -import { schemas as clientSchemas } from './schemas/schemas'; import { APIOrder, AssetPairsRequestOpts, AssetPairsResponse, - Client, FeeRecipientsResponse, - HttpRequestOptions, - HttpRequestType, OrderbookRequest, OrderbookResponse, OrderConfigRequest, @@ -22,7 +13,14 @@ import { OrdersResponse, PagedRequestOpts, RequestOpts, -} from './types'; + SignedOrder, +} from '@0xproject/types'; +import { fetchAsync } from '@0xproject/utils'; +import * as _ from 'lodash'; +import * as queryString from 'query-string'; + +import { schemas as clientSchemas } from './schemas/schemas'; +import { Client, HttpRequestOptions, HttpRequestType } from './types'; import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers'; const TRAILING_SLASHES_REGEX = /\/+$/; diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts index 0b9cad038..0ec5a0f68 100644 --- a/packages/connect/src/index.ts +++ b/packages/connect/src/index.ts @@ -1,23 +1,20 @@ export { HttpClient } from './http_client'; export { ordersChannelFactory } from './orders_channel_factory'; +export { Client, OrdersChannel, OrdersChannelHandler } from './types'; export { - Client, + APIOrder, + AssetPairsRequestOpts, + AssetPairsResponse, + FeeRecipientsResponse, + OrderbookRequest, + OrderbookResponse, OrderConfigRequest, OrderConfigResponse, - OrdersChannel, - OrdersChannelHandler, OrdersChannelSubscriptionOpts, - OrderbookRequest, - OrderbookResponse, OrdersRequestOpts, - PagedRequestOpts, - AssetPairsRequestOpts, - RequestOpts, - AssetPairsResponse, - FeeRecipientsResponse, - APIOrder, OrdersResponse, + PagedRequestOpts, PaginatedCollection, -} from './types'; - -export { SignedOrder } from '@0xproject/types'; + RequestOpts, + SignedOrder, +} from '@0xproject/types'; diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index b76af081c..4bb0ae534 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -1,5 +1,18 @@ -import { SignedOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; +import { + APIOrder, + AssetPairsItem, + AssetPairsRequestOpts, + FeeRecipientsResponse, + OrderbookRequest, + OrderbookResponse, + OrderConfigRequest, + OrderConfigResponse, + OrdersChannelSubscriptionOpts, + OrdersRequestOpts, + PagedRequestOpts, + PaginatedCollection, + SignedOrder, +} from '@0xproject/types'; export interface Client { getAssetPairsAsync: ( @@ -18,140 +31,12 @@ export interface OrdersChannel { close: () => void; } -/** - * 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 OrdersChannelSubscriptionOpts { - baseAssetData: string; - quoteAssetData: string; - limit: number; -} - export interface OrdersChannelHandler { onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void; onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void; onClose: (channel: OrdersChannel) => void; } -export type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage; - -export enum OrdersChannelMessageTypes { - Update = 'update', - Unknown = 'unknown', -} - -export interface UpdateOrdersChannelMessage { - type: OrdersChannelMessageTypes.Update; - requestId: string; - payload: APIOrder[]; -} - -export interface UnknownOrdersChannelMessage { - type: OrdersChannelMessageTypes.Unknown; - requestId: string; - payload: undefined; -} - -export enum WebsocketConnectionEventType { - Close = 'close', - Error = 'error', - Message = 'message', -} - -export enum WebsocketClientEventType { - Connect = 'connect', - ConnectFailed = 'connectFailed', -} - -export type OrdersResponse = PaginatedCollection; - -export interface APIOrder { - order: SignedOrder; - metaData: object; -} - -export interface AssetPairsRequestOpts { - assetDataA?: string; - assetDataB?: string; -} - -export type AssetPairsResponse = PaginatedCollection; - -export interface AssetPairsItem { - assetDataA: Asset; - assetDataB: Asset; -} - -export interface Asset { - assetData: string; - minAmount: BigNumber; - maxAmount: BigNumber; - precision: number; -} - -export interface OrdersRequestOpts { - 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 { - baseAssetData: string; - quoteAssetData: string; -} - -export interface OrderbookResponse { - bids: PaginatedCollection; - asks: PaginatedCollection; -} - -export interface PaginatedCollection { - total: number; - page: number; - perPage: number; - records: T[]; -} - -export interface OrderConfigRequest { - makerAddress: string; - takerAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerAssetData: string; - takerAssetData: string; - exchangeAddress: string; - expirationTimeSeconds: BigNumber; -} - -export interface OrderConfigResponse { - makerFee: BigNumber; - takerFee: BigNumber; - feeRecipientAddress: string; - senderAddress: string; -} - -export type FeeRecipientsResponse = PaginatedCollection; - -export interface RequestOpts { - networkId?: number; -} - -export interface PagedRequestOpts { - page?: number; - perPage?: number; -} - export interface HttpRequestOptions { params?: object; payload?: object; diff --git a/packages/connect/src/utils/orders_channel_message_parser.ts b/packages/connect/src/utils/orders_channel_message_parser.ts index 1b6cda17b..943d7802e 100644 --- a/packages/connect/src/utils/orders_channel_message_parser.ts +++ b/packages/connect/src/utils/orders_channel_message_parser.ts @@ -2,7 +2,7 @@ import { assert } from '@0xproject/assert'; import { schemas } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -import { OrdersChannelMessage, OrdersChannelMessageTypes } from '../types'; +import { OrdersChannelMessage, OrdersChannelMessageTypes } from '@0xproject/types'; import { relayerResponseJsonParsers } from './relayer_response_json_parsers'; diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index bc31f231d..356e2dde6 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -9,7 +9,7 @@ import { OrderbookResponse, OrderConfigResponse, OrdersResponse, -} from '../types'; +} from '@0xproject/types'; import { typeConverters } from './type_converters'; diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts index d57ea00e5..99760cf74 100644 --- a/packages/connect/src/utils/type_converters.ts +++ b/packages/connect/src/utils/type_converters.ts @@ -1,7 +1,7 @@ import { orderParsingUtils } from '@0xproject/order-utils'; import * as _ from 'lodash'; -import { APIOrder } from '../types'; +import { APIOrder } from '@0xproject/types'; export const typeConverters = { convertOrderbookStringFieldsToBigNumber(orderbook: any): any { diff --git a/packages/connect/src/ws_orders_channel.ts b/packages/connect/src/ws_orders_channel.ts index cde4acbc3..bf5e8508d 100644 --- a/packages/connect/src/ws_orders_channel.ts +++ b/packages/connect/src/ws_orders_channel.ts @@ -1,8 +1,9 @@ +import { OrdersChannelMessageTypes, OrdersChannelSubscriptionOpts } from '@0xproject/types'; import * as _ from 'lodash'; import { v4 as uuid } from 'uuid'; import * as WebSocket from 'websocket'; -import { OrdersChannel, OrdersChannelHandler, OrdersChannelMessageTypes, OrdersChannelSubscriptionOpts } from './types'; +import { OrdersChannel, OrdersChannelHandler } from './types'; import { assert } from './utils/assert'; import { ordersChannelMessageParser } from './utils/orders_channel_message_parser'; diff --git a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts index 5ce703317..27216e421 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -import { AssetPairsResponse } from '../../../src/types'; +import { AssetPairsResponse } from '@0xproject/types'; export const assetDataPairsResponse: AssetPairsResponse = { total: 43, diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts index e17ffe7a8..6f544e9d3 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts @@ -1,4 +1,4 @@ -import { FeeRecipientsResponse } from '../../../src/types'; +import { FeeRecipientsResponse } from '@0xproject/types'; export const feeRecipientsResponse: FeeRecipientsResponse = { total: 3, diff --git a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts b/packages/connect/test/fixtures/standard_relayer_api/order_config.ts index 36f01a009..56a4ac550 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/order_config.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -import { OrderConfigResponse } from '../../../src/types'; +import { OrderConfigResponse } from '@0xproject/types'; export const orderConfigResponse: OrderConfigResponse = { senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts index d5f39a51f..21d51da74 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -import { OrderbookResponse } from '../../../src/types'; +import { OrderbookResponse } from '@0xproject/types'; export const orderbookResponse: OrderbookResponse = { bids: { diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.ts b/packages/connect/test/fixtures/standard_relayer_api/orders.ts index 01f8974b8..fb85990d0 100644 --- a/packages/connect/test/fixtures/standard_relayer_api/orders.ts +++ b/packages/connect/test/fixtures/standard_relayer_api/orders.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; -import { OrdersResponse } from '../../../src/types'; +import { OrdersResponse } from '@0xproject/types'; export const ordersResponse: OrdersResponse = { total: 984, diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 8b1346347..9cdb3bc1f 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -5,6 +5,10 @@ { "note": "Add ObjectMap type", "pr": 1037 + }, + { + "note": "Add SRA types from connect", + "pr": 1085 } ] }, diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 25803e8c8..d27060ee5 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -243,3 +243,131 @@ export enum StatusCodes { export interface ObjectMap { [key: string]: T; } + +/** + * 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 OrdersChannelSubscriptionOpts { + baseAssetData: string; + quoteAssetData: string; + limit: number; +} + +export type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage; + +export enum OrdersChannelMessageTypes { + Update = 'update', + Unknown = 'unknown', +} + +export interface UpdateOrdersChannelMessage { + type: OrdersChannelMessageTypes.Update; + requestId: string; + payload: APIOrder[]; +} + +export interface UnknownOrdersChannelMessage { + type: OrdersChannelMessageTypes.Unknown; + requestId: string; + payload: undefined; +} + +export enum WebsocketConnectionEventType { + Close = 'close', + Error = 'error', + Message = 'message', +} + +export enum WebsocketClientEventType { + Connect = 'connect', + ConnectFailed = 'connectFailed', +} + +export type OrdersResponse = PaginatedCollection; + +export interface APIOrder { + order: SignedOrder; + metaData: object; +} + +export interface AssetPairsRequestOpts { + assetDataA?: string; + assetDataB?: string; +} + +export type AssetPairsResponse = PaginatedCollection; + +export interface AssetPairsItem { + assetDataA: Asset; + assetDataB: Asset; +} + +export interface Asset { + assetData: string; + minAmount: BigNumber; + maxAmount: BigNumber; + precision: number; +} + +export interface OrdersRequestOpts { + 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 { + baseAssetData: string; + quoteAssetData: string; +} + +export interface OrderbookResponse { + bids: PaginatedCollection; + asks: PaginatedCollection; +} + +export interface PaginatedCollection { + total: number; + page: number; + perPage: number; + records: T[]; +} + +export interface OrderConfigRequest { + makerAddress: string; + takerAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerAssetData: string; + takerAssetData: string; + exchangeAddress: string; + expirationTimeSeconds: BigNumber; +} + +export interface OrderConfigResponse { + makerFee: BigNumber; + takerFee: BigNumber; + feeRecipientAddress: string; + senderAddress: string; +} + +export type FeeRecipientsResponse = PaginatedCollection; + +export interface RequestOpts { + networkId?: number; +} + +export interface PagedRequestOpts { + page?: number; + perPage?: number; +} diff --git a/yarn.lock b/yarn.lock index 7464a9c5d..aa30946a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5296,9 +5296,9 @@ ethereumjs-wallet@~0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@3.0.22: - version "3.0.22" - resolved "https://registry.npmjs.org/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" +ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: + version "3.0.18" + resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447" dependencies: aes-js "3.0.0" bn.js "^4.4.0" -- cgit From fc3acec669f21b8c5bcb5e3d4f712c2adaf2cf64 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 12:32:20 +0100 Subject: Fix lint issues --- .../src/contract_wrappers/contract_wrapper.ts | 16 ++++++++-------- .../order-watcher/src/order_watcher/event_watcher.ts | 20 +++++++++----------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 58c5bce6d..f7a89e3be 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -199,28 +199,28 @@ export abstract class ContractWrapper { // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _blockstreamGetBlockOrNullAsync(hash: string): Promise { const shouldIncludeTransactionData = false; - const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByHash', params: [hash, shouldIncludeTransactionData], }); - return blockOrNull as Block; + return blockOrNull; } // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _blockstreamGetLatestBlockOrNullAsync(): Promise { const shouldIncludeTransactionData = false; - const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByNumber', params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], }); - return blockOrNull as Block; + return blockOrNull; } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { - const logs = await this._web3Wrapper.sendRawPayloadAsync({ + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { + const logs = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getLogs', params: [filterOptions], }); - return logs as Log[]; + return logs as RawLogEntry[]; } // HACK: This should be a package-scoped method (which doesn't exist in TS) // We don't want this method available in the public interface for all classes @@ -247,7 +247,7 @@ export abstract class ContractWrapper { // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockOrNull as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull); } } } diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index e73e1f9f9..9ea301815 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -20,7 +20,6 @@ enum LogEventState { */ export class EventWatcher { private readonly _web3Wrapper: Web3Wrapper; - private readonly _stateLayer: BlockParamLiteral; private readonly _isVerbose: boolean; private _blockAndLogStreamerIfExists: BlockAndLogStreamer | undefined; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; @@ -35,7 +34,6 @@ export class EventWatcher { ) { this._isVerbose = isVerbose; this._web3Wrapper = new Web3Wrapper(provider); - this._stateLayer = stateLayer; this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) ? DEFAULT_EVENT_POLLING_INTERVAL_MS : pollingIntervalIfExistsMs; @@ -82,31 +80,31 @@ export class EventWatcher { this._onLogStateChangedAsync.bind(this, callback, isRemoved), ); } - /// This method only exists in order to comply with the expected interface of Blockstream's constructor + // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _blockstreamGetBlockOrNullAsync(hash: string): Promise { const shouldIncludeTransactionData = false; - const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByHash', params: [hash, shouldIncludeTransactionData], }); - return blockOrNull as Block; + return blockOrNull; } // This method only exists in order to comply with the expected interface of Blockstream's constructor private async _blockstreamGetLatestBlockOrNullAsync(): Promise { const shouldIncludeTransactionData = false; - const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getBlockByNumber', params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], }); - return blockOrNull as Block; + return blockOrNull; } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { - const logs = await this._web3Wrapper.sendRawPayloadAsync({ + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise { + const logs = await this._web3Wrapper.sendRawPayloadAsync({ method: 'eth_getLogs', params: [filterOptions], }); - return logs as Log[]; + return logs as RawLogEntry[]; } private _stopBlockAndLogStream(): void { if (_.isUndefined(this._blockAndLogStreamerIfExists)) { @@ -134,7 +132,7 @@ export class EventWatcher { // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockOrNull as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull); } } private async _emitDifferencesAsync( -- cgit From 411813d8d9f23d535f10dd3fdd9e824b244bf187 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 25 Sep 2018 13:48:44 +0200 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 9 +++++++++ packages/0x.js/CHANGELOG.md | 4 ++++ packages/abi-gen/CHANGELOG.json | 9 +++++++++ packages/abi-gen/CHANGELOG.md | 4 ++++ packages/assert/CHANGELOG.json | 9 +++++++++ packages/assert/CHANGELOG.md | 4 ++++ packages/asset-buyer/CHANGELOG.json | 9 +++++++++ packages/asset-buyer/CHANGELOG.md | 13 +++++++++++++ packages/base-contract/CHANGELOG.json | 9 +++++++++ packages/base-contract/CHANGELOG.md | 4 ++++ packages/connect/CHANGELOG.json | 3 ++- packages/connect/CHANGELOG.md | 4 ++++ packages/contract-wrappers/CHANGELOG.json | 9 +++++++++ packages/contract-wrappers/CHANGELOG.md | 4 ++++ packages/dev-utils/CHANGELOG.json | 9 +++++++++ packages/dev-utils/CHANGELOG.md | 4 ++++ packages/fill-scenarios/CHANGELOG.json | 9 +++++++++ packages/fill-scenarios/CHANGELOG.md | 4 ++++ packages/json-schemas/CHANGELOG.json | 9 +++++++++ packages/json-schemas/CHANGELOG.md | 4 ++++ packages/migrations/CHANGELOG.json | 9 +++++++++ packages/migrations/CHANGELOG.md | 4 ++++ packages/order-utils/CHANGELOG.json | 9 +++++++++ packages/order-utils/CHANGELOG.md | 4 ++++ packages/order-watcher/CHANGELOG.json | 9 +++++++++ packages/order-watcher/CHANGELOG.md | 4 ++++ packages/react-docs/CHANGELOG.json | 9 +++++++++ packages/react-docs/CHANGELOG.md | 4 ++++ packages/react-shared/CHANGELOG.json | 9 +++++++++ packages/react-shared/CHANGELOG.md | 4 ++++ packages/sol-compiler/CHANGELOG.json | 9 +++++++++ packages/sol-compiler/CHANGELOG.md | 4 ++++ packages/sol-cov/CHANGELOG.json | 9 +++++++++ packages/sol-cov/CHANGELOG.md | 4 ++++ packages/sol-resolver/CHANGELOG.json | 9 +++++++++ packages/sol-resolver/CHANGELOG.md | 4 ++++ packages/sra-report/CHANGELOG.json | 9 +++++++++ packages/sra-report/CHANGELOG.md | 4 ++++ packages/sra-spec/CHANGELOG.json | 9 +++++++++ packages/sra-spec/CHANGELOG.md | 4 ++++ packages/subproviders/CHANGELOG.json | 9 +++++++++ packages/subproviders/CHANGELOG.md | 4 ++++ packages/types/CHANGELOG.json | 3 ++- packages/types/CHANGELOG.md | 5 +++++ packages/utils/CHANGELOG.json | 9 +++++++++ packages/utils/CHANGELOG.md | 4 ++++ packages/web3-wrapper/CHANGELOG.json | 3 ++- packages/web3-wrapper/CHANGELOG.md | 4 ++++ 48 files changed, 301 insertions(+), 3 deletions(-) diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 391c5fa17..38966a0b7 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.4", diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 7031425ab..d881cd825 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 21, 2018_ * Dependencies updated diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 2ecacb05d..18aed8716 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 88ab42864..99fc44f0c 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 8a9b6afd6..851ba6c04 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index d39441338..26760306e 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index 2e4db1f6e..50b965f2d 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.0", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.0.0-rc.1", "changes": [ diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index 8b1378917..b27795d18 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -1 +1,14 @@ + +CHANGELOG + +## v1.0.0 - _September 25, 2018_ + + * Dependencies updated + +## v1.0.0-rc.1 - _Invalid date_ + + * Init diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 723963f87..5f94afa43 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "2.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "2.0.3", diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index c4ba59e26..b3f3b5619 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index b39c8d272..d4c501eb1 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -6,7 +6,8 @@ "note": "Import SRA-related types from @0xproject/types", "pr": 1085 } - ] + ], + "timestamp": 1537875740 }, { "timestamp": 1537541580, diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index 1f8116f88..2c2483cb6 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _September 25, 2018_ + + * Import SRA-related types from @0xproject/types (#1085) + ## v2.0.2 - _September 21, 2018_ * Dependencies updated diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 2f8a02a1a..65aaf15c7 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.4", diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 3757bd6ba..98de9c7f2 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 21, 2018_ * Dependencies updated diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index e834eb1a3..bd4f280ba 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.8", diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index 34f29418b..a362330c2 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.9 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.8 - _September 21, 2018_ * Dependencies updated diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index e378c7cf0..3023a43c5 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.3", diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index 16fbb4f34..4fb3f3c54 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index e3308f98b..afe8c6f55 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.2", diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index 0817874ba..dc9a69a3c 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.2 - _September 21, 2018_ * Dependencies updated diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index a25de1a77..1c8418818 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.10", diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index 2a6aeb96d..80038bebb 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 21, 2018_ * Dependencies updated diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 5bf538c1f..d6742df2e 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.3", diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index e35867fa6..67e5a54a6 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index dec154f0f..d4b0e6607 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.4", diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index a4e1cc79f..d179b2e1a 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 21, 2018_ * Dependencies updated diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index c8a44aa9e..4e3dfed99 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index 595b0cf98..ca96d479d 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index 898ab26aa..96e2a92f9 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.10", diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index f6878e43f..09f6066cd 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 21, 2018_ * Dependencies updated diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index 9a1961b79..af6897b40 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.1.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.1.3", diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index a5d1332f8..02058b378 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.1.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index 5f49e0443..ef009b586 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "2.1.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "2.1.3", diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index e1b898b19..5dddb1c4d 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.4 - _September 25, 2018_ + + * Dependencies updated + ## v2.1.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index bfc7cb93b..ee439c2d0 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index 5bed9f43c..53354f4ef 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json index ee12caf34..006965b01 100644 --- a/packages/sra-report/CHANGELOG.json +++ b/packages/sra-report/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md index 5e75625df..298ea66ec 100644 --- a/packages/sra-report/CHANGELOG.md +++ b/packages/sra-report/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index e0b373191..a4a1fe8ff 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.2", diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index 59f397bc6..e279d517f 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.2 - _September 21, 2018_ * Dependencies updated diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index 2d3c37615..8b6b87d2a 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "2.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "2.0.3", diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index 6e268d7ec..708a94b21 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.3 - _September 21, 2018_ * Dependencies updated diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 9cdb3bc1f..f9479f789 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -10,7 +10,8 @@ "note": "Add SRA types from connect", "pr": 1085 } - ] + ], + "timestamp": 1537875740 }, { "timestamp": 1537541580, diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d89416fd6..9841aa301 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,11 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.0 - _September 25, 2018_ + + * Add ObjectMap type (#1037) + * Add SRA types from connect (#1085) + ## v1.0.2 - _September 21, 2018_ * Dependencies updated diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 7449355ce..1536c1960 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537875740, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.9", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index aa2c08940..ff26a0900 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 21, 2018_ * Dependencies updated diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index ce3f5e3be..b1ea2fe2e 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -7,7 +7,8 @@ "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined.", "pr": 1082 } - ] + ], + "timestamp": 1537875740 }, { "version": "2.0.3", diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 72aff4a95..cafbe1340 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.0 - _September 25, 2018_ + + * Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined. (#1082) + ## v2.0.3 - _September 21, 2018_ * Fixes issue #1076 where Parity now returns a placeholder transactionReceipt before the transaction is mined. (#1079) -- cgit From 78ef98c27ce954f7e46b261b0809ff9d8d70519b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 25 Sep 2018 13:48:55 +0200 Subject: Publish - 0x.js@1.0.5 - @0xproject/abi-gen@1.0.10 - @0xproject/assert@1.0.10 - @0xproject/asset-buyer@1.0.0 - @0xproject/base-contract@2.0.4 - @0xproject/connect@2.0.3 - @0xproject/contract-wrappers@1.0.5 - contracts@2.1.46 - @0xproject/dev-utils@1.0.9 - @0xproject/fill-scenarios@1.0.4 - @0xproject/json-schemas@1.0.3 - @0xproject/metacoin@0.0.20 - @0xproject/migrations@1.0.11 - @0xproject/order-utils@1.0.4 - @0xproject/order-watcher@1.0.5 - @0xproject/react-docs@1.0.10 - @0xproject/react-shared@1.0.11 - @0xproject/sol-compiler@1.1.4 - @0xproject/sol-cov@2.1.4 - @0xproject/sol-resolver@1.0.10 - @0xproject/sra-report@1.0.10 - @0xproject/sra-spec@1.0.3 - @0xproject/subproviders@2.0.4 - @0xproject/testnet-faucets@1.0.48 - @0xproject/types@1.1.0 - @0xproject/utils@1.0.10 - @0xproject/web3-wrapper@3.0.0 - @0xproject/website@0.0.51 --- packages/0x.js/package.json | 26 +++++++++++++------------- packages/abi-gen/package.json | 4 ++-- packages/assert/package.json | 6 +++--- packages/asset-buyer/package.json | 20 ++++++++++---------- packages/base-contract/package.json | 6 +++--- packages/connect/package.json | 12 ++++++------ packages/contract-wrappers/package.json | 26 +++++++++++++------------- packages/contracts/package.json | 22 +++++++++++----------- packages/dev-utils/package.json | 10 +++++----- packages/fill-scenarios/package.json | 14 +++++++------- packages/json-schemas/package.json | 4 ++-- packages/metacoin/package.json | 20 ++++++++++---------- packages/migrations/package.json | 20 ++++++++++---------- packages/order-utils/package.json | 16 ++++++++-------- packages/order-watcher/package.json | 26 +++++++++++++------------- packages/react-docs/package.json | 8 ++++---- packages/react-shared/package.json | 4 ++-- packages/sol-compiler/package.json | 16 ++++++++-------- packages/sol-cov/package.json | 12 ++++++------ packages/sol-resolver/package.json | 4 ++-- packages/sra-report/package.json | 6 +++--- packages/sra-spec/package.json | 4 ++-- packages/subproviders/package.json | 10 +++++----- packages/testnet-faucets/package.json | 10 +++++----- packages/types/package.json | 2 +- packages/utils/package.json | 4 ++-- packages/web3-wrapper/package.json | 8 ++++---- packages/website/package.json | 20 ++++++++++---------- 28 files changed, 170 insertions(+), 170 deletions(-) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index c92e24c52..d53571dbf 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "1.0.4", + "version": "1.0.5", "engines": { "node": ">=6.12" }, @@ -41,9 +41,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/migrations": "^1.0.10", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/migrations": "^1.0.11", "@0xproject/monorepo-scripts": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", @@ -73,16 +73,16 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/base-contract": "^2.0.3", - "@0xproject/contract-wrappers": "^1.0.4", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/order-watcher": "^1.0.4", - "@0xproject/subproviders": "^2.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/contract-wrappers": "^1.0.5", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/order-watcher": "^1.0.5", + "@0xproject/subproviders": "^2.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5", diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 6b8581ef3..1fb697299 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/abi-gen", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -31,7 +31,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "chalk": "^2.3.0", "ethereum-types": "^1.0.7", "glob": "^7.1.2", diff --git a/packages/assert/package.json b/packages/assert/package.json index 629cb23e5..ee510d14f 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/assert", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -44,9 +44,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/json-schemas": "^1.0.2", + "@0xproject/json-schemas": "^1.0.3", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "lodash": "^4.17.5", "valid-url": "^1.0.9" }, diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 2b5136e31..d15213e0b 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/asset-buyer", - "version": "1.0.0-rc.1", + "version": "1.0.0", "engines": { "node": ">=6.12" }, @@ -36,16 +36,16 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/connect": "^2.0.2", - "@0xproject/contract-wrappers": "^1.0.4", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/order-utils": "^1.0.1", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/connect": "^2.0.3", + "@0xproject/contract-wrappers": "^1.0.5", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/subproviders": "^2.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.6", "lodash": "^4.17.10" }, diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 44b0807ba..cd7f29114 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/base-contract", - "version": "2.0.3", + "version": "2.0.4", "engines": { "node": ">=6.12" }, @@ -41,8 +41,8 @@ }, "dependencies": { "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/connect/package.json b/packages/connect/package.json index 1575afe01..075089fd2 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/connect", - "version": "2.0.2", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -43,12 +43,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "lodash": "^4.17.5", "query-string": "^5.0.1", "sinon": "^4.0.0", diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 331ff1701..544d667c6 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/contract-wrappers", - "version": "1.0.4", + "version": "1.0.5", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -41,10 +41,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/migrations": "^1.0.10", - "@0xproject/subproviders": "^2.0.3", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/migrations": "^1.0.11", + "@0xproject/subproviders": "^2.0.4", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -72,15 +72,15 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/base-contract": "^2.0.3", - "@0xproject/fill-scenarios": "^1.0.3", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/fill-scenarios": "^1.0.4", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "5.0.0", "ethereumjs-util": "^5.1.1", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 63de510b1..6a7a7c208 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "contracts", - "version": "2.1.45", + "version": "2.1.46", "engines": { "node": ">=6.12" }, @@ -45,11 +45,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/sol-compiler": "^1.1.3", - "@0xproject/sol-cov": "^2.1.3", - "@0xproject/subproviders": "^2.0.3", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/sol-compiler": "^1.1.4", + "@0xproject/sol-cov": "^2.1.4", + "@0xproject/subproviders": "^2.0.4", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", @@ -72,12 +72,12 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.3", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.0.7", diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index 3ded87c05..c45581e45 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/dev-utils", - "version": "1.0.8", + "version": "1.0.9", "engines": { "node": ">=6.12" }, @@ -42,11 +42,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/subproviders": "^2.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/subproviders": "^2.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "lodash": "^4.17.5" }, diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 474618a14..857ec496f 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/fill-scenarios", - "version": "1.0.3", + "version": "1.0.4", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", + "@0xproject/abi-gen": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "copyfiles": "^2.0.0", @@ -37,12 +37,12 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/base-contract": "^2.0.3", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 3d5399d2a..7dfdb1066 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/json-schemas", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -45,7 +45,7 @@ }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 9824da332..924408d53 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/metacoin", - "version": "0.0.19", + "version": "0.0.20", "engines": { "node": ">=6.12" }, @@ -28,15 +28,15 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/base-contract": "^2.0.3", - "@0xproject/sol-cov": "^2.1.3", - "@0xproject/subproviders": "^2.0.3", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/sol-cov": "^2.1.4", + "@0xproject/subproviders": "^2.0.4", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.0.2", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@types/mocha": "^5.2.2", "copyfiles": "^2.0.0", "ethereum-types": "^1.0.7", @@ -45,8 +45,8 @@ "run-s": "^0.0.0" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/sol-compiler": "^1.1.3", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/sol-compiler": "^1.1.4", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 1229c78dc..f44a254ed 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/migrations", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -30,10 +30,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/dev-utils": "^1.0.8", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/dev-utils": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.0.2", + "@0xproject/types": "^1.1.0", "@types/yargs": "^10.0.0", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", @@ -44,13 +44,13 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.3", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/sol-compiler": "^1.1.3", - "@0xproject/subproviders": "^2.0.3", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/sol-compiler": "^1.1.4", + "@0xproject/subproviders": "^2.0.4", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@ledgerhq/hw-app-eth": "^4.3.0", "ethereum-types": "^1.0.7", "ethers": "3.0.22", diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index c9620bffa..167d32608 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-utils", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -38,7 +38,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.8", + "@0xproject/dev-utils": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -57,13 +57,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/base-contract": "^2.0.3", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@types/node": "*", "bn.js": "^4.11.8", "ethereum-types": "^1.0.7", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 8ce57364f..d383211a8 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-watcher", - "version": "1.0.4", + "version": "1.0.5", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -42,9 +42,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.9", - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/migrations": "^1.0.10", + "@0xproject/abi-gen": "^1.0.10", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/migrations": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -70,16 +70,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/base-contract": "^2.0.3", - "@0xproject/contract-wrappers": "^1.0.4", - "@0xproject/fill-scenarios": "^1.0.3", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/base-contract": "^2.0.4", + "@0xproject/contract-wrappers": "^1.0.5", + "@0xproject/fill-scenarios": "^1.0.4", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "bintrees": "^1.0.2", "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "5.0.0", diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 0efe7dbc9..d933489b7 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-docs", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -23,7 +23,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.8", + "@0xproject/dev-utils": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/compare-versions": "^3.0.0", "copyfiles": "^2.0.0", @@ -33,8 +33,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/react-shared": "^1.0.10", - "@0xproject/utils": "^1.0.9", + "@0xproject/react-shared": "^1.0.11", + "@0xproject/utils": "^1.0.10", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 458968c39..9154c2bb6 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-shared", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -24,7 +24,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.8", + "@0xproject/dev-utils": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 2ad0f9f09..841e2960c 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-compiler", - "version": "1.1.3", + "version": "1.1.4", "engines": { "node": ">=6.12" }, @@ -41,7 +41,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.8", + "@0xproject/dev-utils": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/mkdirp": "^0.5.2", "@types/require-from-string": "^1.2.0", @@ -64,13 +64,13 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/json-schemas": "^1.0.2", - "@0xproject/sol-resolver": "^1.0.9", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/sol-resolver": "^1.0.10", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", "ethereum-types": "^1.0.7", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index f80ae78e0..63b8f06d5 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "2.1.3", + "version": "2.1.4", "engines": { "node": ">=6.12" }, @@ -41,12 +41,12 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/dev-utils": "^1.0.8", - "@0xproject/sol-compiler": "^1.1.3", - "@0xproject/subproviders": "^2.0.3", + "@0xproject/dev-utils": "^1.0.9", + "@0xproject/sol-compiler": "^1.1.4", + "@0xproject/subproviders": "^2.0.4", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index da3f18788..caf7df3aa 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-resolver", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -30,7 +30,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.0.2", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", "lodash": "^4.17.5" }, diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index eebf0cc0b..c916765e2 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-report", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -33,13 +33,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { - "@0xproject/assert": "^1.0.9", + "@0xproject/assert": "^1.0.10", "@0xproject/connect": "1.0.4", "@0xproject/json-schemas": "^0.8.3", "@0xproject/order-utils": "^0.0.9", "@0xproject/types": "^0.8.2", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "chalk": "^2.3.0", "lodash": "^4.17.5", "newman": "^3.9.3", diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index 3da886e34..0c5131848 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-spec", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -34,7 +34,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0xproject/json-schemas": "^1.0.2" + "@0xproject/json-schemas": "^1.0.3" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 347c71726..6740a0743 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/subproviders", - "version": "2.0.3", + "version": "2.0.4", "engines": { "node": ">=6.12" }, @@ -28,11 +28,11 @@ } }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/types": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", "@types/eth-lightwallet": "^3.0.0", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index 448186b34..cfac1b018 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/testnet-faucets", - "version": "1.0.47", + "version": "1.0.48", "engines": { "node": ">=6.12" }, @@ -17,11 +17,11 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^1.0.4", - "@0xproject/subproviders": "^2.0.3", + "0x.js": "^1.0.5", + "@0xproject/subproviders": "^2.0.4", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "body-parser": "^1.17.1", "ethereum-types": "^1.0.7", "ethereumjs-tx": "^1.3.5", diff --git a/packages/types/package.json b/packages/types/package.json index f1c04b39b..f78368198 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/types", - "version": "1.0.2", + "version": "1.1.0", "engines": { "node": ">=6.12" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index a3977cef6..77d11c41c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/utils", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -41,7 +41,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.0.2", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index bcd640839..f895296e9 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/web3-wrapper", - "version": "2.0.3", + "version": "3.0.0", "engines": { "node": ">=6.12" }, @@ -53,10 +53,10 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.9", - "@0xproject/json-schemas": "^1.0.2", + "@0xproject/assert": "^1.0.10", + "@0xproject/json-schemas": "^1.0.3", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", + "@0xproject/utils": "^1.0.10", "ethereum-types": "^1.0.7", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/website/package.json b/packages/website/package.json index 65a0d4c10..67b2fb4ec 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/website", - "version": "0.0.50", + "version": "0.0.51", "engines": { "node": ">=6.12" }, @@ -19,16 +19,16 @@ "license": "Apache-2.0", "dependencies": { "0x.js": "^0.38.6", - "@0xproject/contract-wrappers": "^1.0.4", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.3", - "@0xproject/react-docs": "^1.0.9", - "@0xproject/react-shared": "^1.0.10", - "@0xproject/subproviders": "^2.0.3", - "@0xproject/types": "^1.0.2", + "@0xproject/contract-wrappers": "^1.0.5", + "@0xproject/json-schemas": "^1.0.3", + "@0xproject/order-utils": "^1.0.4", + "@0xproject/react-docs": "^1.0.10", + "@0xproject/react-shared": "^1.0.11", + "@0xproject/subproviders": "^2.0.4", + "@0xproject/types": "^1.1.0", "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.9", - "@0xproject/web3-wrapper": "^2.0.3", + "@0xproject/utils": "^1.0.10", + "@0xproject/web3-wrapper": "^3.0.0", "accounting": "^0.4.1", "basscss": "^8.0.3", "blockies": "^0.0.2", -- cgit From 9eecf3683b674f0753e508476c4c21eb32625f18 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 16:10:13 +0100 Subject: Add transactionHash to OrderState and emit it from OrderWatcher subscription --- packages/order-utils/src/order_state_utils.ts | 4 +++- .../order-utils/test/order_state_utils_test.ts | 20 +++++++++++++++++ .../src/order_watcher/order_watcher.ts | 25 +++++++++++---------- packages/order-watcher/test/order_watcher_test.ts | 26 ++++++++++++++++++++++ packages/types/src/index.ts | 2 ++ 5 files changed, 64 insertions(+), 13 deletions(-) diff --git a/packages/order-utils/src/order_state_utils.ts b/packages/order-utils/src/order_state_utils.ts index 8398776aa..9b21ef6e9 100644 --- a/packages/order-utils/src/order_state_utils.ts +++ b/packages/order-utils/src/order_state_utils.ts @@ -114,7 +114,7 @@ export class OrderStateUtils { * @return State relevant to the signedOrder, as well as whether the signedOrder is "valid". * Validity is defined as a non-zero amount of the order can still be filled. */ - public async getOpenOrderStateAsync(signedOrder: SignedOrder): Promise { + public async getOpenOrderStateAsync(signedOrder: SignedOrder, transactionHash?: string): Promise { const orderRelevantState = await this.getOpenOrderRelevantStateAsync(signedOrder); const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash); @@ -134,6 +134,7 @@ export class OrderStateUtils { isValid: true, orderHash, orderRelevantState, + transactionHash, }; return orderState; } else { @@ -141,6 +142,7 @@ export class OrderStateUtils { isValid: false, orderHash, error: orderValidationResult.error, + transactionHash, }; return orderState; } diff --git a/packages/order-utils/test/order_state_utils_test.ts b/packages/order-utils/test/order_state_utils_test.ts index 91ef23b69..ea88027ae 100644 --- a/packages/order-utils/test/order_state_utils_test.ts +++ b/packages/order-utils/test/order_state_utils_test.ts @@ -120,5 +120,25 @@ describe('OrderStateUtils', () => { const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder); expect(orderState.isValid).to.eq(false); }); + it('should include the transactionHash in orderState if supplied in method invocation', async () => { + const makerAssetAmount = new BigNumber(10); + const takerAssetAmount = new BigNumber(10000000000000000); + const takerBalance = takerAssetAmount; + const orderFilledAmount = new BigNumber(0); + const mockBalanceFetcher = buildMockBalanceFetcher(takerBalance); + const mockOrderFilledFetcher = buildMockOrderFilledFetcher(orderFilledAmount); + const [signedOrder] = testOrderFactory.generateTestSignedOrders( + { + makerAssetAmount, + takerAssetAmount, + }, + 1, + ); + + const orderStateUtils = new OrderStateUtils(mockBalanceFetcher, mockOrderFilledFetcher); + const transactionHash = '0xdeadbeef'; + const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash); + expect(orderState.transactionHash).to.eq(transactionHash); + }); }); }); diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts index cab2efa4b..f9a63efe3 100644 --- a/packages/order-watcher/src/order_watcher/order_watcher.ts +++ b/packages/order-watcher/src/order_watcher/order_watcher.ts @@ -275,6 +275,7 @@ export class OrderWatcher { return; // noop } const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs; + const transactionHash = decodedLog.transactionHash; switch (decodedLog.event) { case ERC20TokenEvents.Approval: case ERC721TokenEvents.Approval: { @@ -290,7 +291,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } else { // ERC721 @@ -303,7 +304,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } } @@ -322,7 +323,7 @@ export class OrderWatcher { args._from, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } else { // ERC721 @@ -336,7 +337,7 @@ export class OrderWatcher { args._from, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } } @@ -350,7 +351,7 @@ export class OrderWatcher { args._owner, tokenAddress, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case WETH9Events.Deposit: { @@ -363,7 +364,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case WETH9Events.Withdrawal: { @@ -376,7 +377,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case ExchangeEvents.Fill: { @@ -387,7 +388,7 @@ export class OrderWatcher { const orderHash = args.orderHash; const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); if (isOrderWatched) { - await this._emitRevalidateOrdersAsync([orderHash]); + await this._emitRevalidateOrdersAsync([orderHash], transactionHash); } break; } @@ -399,7 +400,7 @@ export class OrderWatcher { const orderHash = args.orderHash; const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); if (isOrderWatched) { - await this._emitRevalidateOrdersAsync([orderHash]); + await this._emitRevalidateOrdersAsync([orderHash], transactionHash); } break; } @@ -410,7 +411,7 @@ export class OrderWatcher { this._orderFilledCancelledLazyStore.deleteAllIsCancelled(); // Revalidate orders const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } @@ -418,12 +419,12 @@ export class OrderWatcher { throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event); } } - private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise { + private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise { for (const orderHash of orderHashes) { const signedOrder = this._orderByOrderHash[orderHash]; // Most of these calls will never reach the network because the data is fetched from stores // and only updated when cache is invalidated - const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder); + const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash); if (_.isUndefined(this._callbackIfExists)) { break; // Unsubscribe was called } diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts index 38bfde7ef..60d9069e8 100644 --- a/packages/order-watcher/test/order_watcher_test.ts +++ b/packages/order-watcher/test/order_watcher_test.ts @@ -250,6 +250,32 @@ describe('OrderWatcher', () => { await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress); })().catch(done); }); + it('should include transactionHash in emitted orderStateInvalid when watched order fully filled', (done: DoneCallback) => { + (async () => { + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerAssetData, + takerAssetData, + makerAddress, + takerAddress, + fillableAmount, + ); + await orderWatcher.addOrderAsync(signedOrder); + + let transactionHash: string; + const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => { + expect(orderState.isValid).to.be.false(); + const invalidOrderState = orderState as OrderStateInvalid; + expect(invalidOrderState.transactionHash).to.be.equal(transactionHash); + }); + orderWatcher.subscribe(callback); + + transactionHash = await contractWrappers.exchange.fillOrderAsync( + signedOrder, + fillableAmount, + takerAddress, + ); + })().catch(done); + }); it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => { (async () => { signedOrder = await fillScenarios.createFillableSignedOrderAsync( diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index d27060ee5..5223bf299 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -111,12 +111,14 @@ export interface OrderStateValid { isValid: true; orderHash: string; orderRelevantState: OrderRelevantState; + transactionHash?: string; } export interface OrderStateInvalid { isValid: false; orderHash: string; error: ExchangeContractErrs; + transactionHash?: string; } export type OrderState = OrderStateValid | OrderStateInvalid; -- cgit From 5afc73939785a9b5c6c73773b8f8eac4429762ef Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 16:37:08 +0100 Subject: Add changelog entry --- packages/order-watcher/CHANGELOG.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 9ab0905fe..46dc4c0df 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -11,6 +11,11 @@ "note": "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", "pr": 1080 + }, + { + "note": + "Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction.", + "pr": 1087 } ] }, -- cgit From b40861747b73bb9a0826853751b7caa5cbf085ae Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 17:34:22 +0100 Subject: Properly render function generic types that don't extend another type --- packages/react-docs/src/components/signature.tsx | 21 +++++++++++++-------- packages/react-docs/src/types.ts | 2 +- packages/react-docs/src/utils/typedoc_utils.ts | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index bf9c8be24..4f10f4665 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -134,14 +134,19 @@ function renderTypeParameter( ): React.ReactNode { const typeParam = ( - {`<${typeParameter.name} extends `} - + {`<${typeParameter.name}`} + {!_.isUndefined(typeParameter.type) && ( + + {' extends '} + + + )} {`>`} ); diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index f9cb5e26a..29f5664f5 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -150,7 +150,7 @@ export interface Parameter { export interface TypeParameter { name: string; - type: Type; + type?: Type; } export interface Type { diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index f44945369..e3e9c11fb 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -419,7 +419,10 @@ export class TypeDocUtils { return func; } private _convertTypeParameter(entity: TypeDocNode, sectionName: string): TypeParameter { - const type = this._convertType(entity.type, sectionName); + let type; + if (!_.isUndefined(entity.type)) { + type = this._convertType(entity.type, sectionName); + } const parameter = { name: entity.name, type, -- cgit From 055bcb52f8dc4432a2d9f60d20b240adaa9c3cf8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 25 Sep 2018 22:04:12 +0200 Subject: Change news link --- packages/website/ts/pages/landing/landing.tsx | 4 +- yarn.lock | 64 +++++++++++++-------------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx index 211be7bf2..388e83d51 100644 --- a/packages/website/ts/pages/landing/landing.tsx +++ b/packages/website/ts/pages/landing/landing.tsx @@ -37,8 +37,8 @@ interface Project { } const THROTTLE_TIMEOUT = 100; -const WHATS_NEW_TITLE = '18 ideas for 0x relayers in 2018'; -const WHATS_NEW_URL = 'https://blog.0xproject.com/18-ideas-for-0x-relayers-in-2018-80a1498b955f'; +const WHATS_NEW_TITLE = '0x Protocol v2 is Live!'; +const WHATS_NEW_URL = 'https://blog.0xproject.com/0x-protocol-v2-0-is-live-183aac180149'; const TITLE_STYLE: React.CSSProperties = { fontFamily: 'Roboto Mono', color: colors.grey, diff --git a/yarn.lock b/yarn.lock index 950b39fd8..ff572cae8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1356,9 +1356,9 @@ aes-js@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" -aes-js@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" +aes-js@^0.2.3: + version "0.2.4" + resolved "https://registry.npmjs.org/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" ajv-keywords@^2.1.0: version "2.1.1" @@ -2424,6 +2424,10 @@ balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" +base-x@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/base-x/-/base-x-1.1.0.tgz#42d3d717474f9ea02207f6d1aa1f426913eeb7ac" + base-x@^3.0.2: version "3.0.4" resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.4.tgz#94c1788736da065edb1d68808869e357c977fa77" @@ -2835,7 +2839,7 @@ browserslist@^2.1.2: caniuse-lite "^1.0.30000792" electron-to-chromium "^1.3.30" -bs58@=4.0.1, bs58@^4.0.0: +bs58@=4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" dependencies: @@ -2845,13 +2849,18 @@ bs58@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.1.tgz#55908d58f1982aba2008fa1bed8f91998a29bf8d" -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" +bs58@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/bs58/-/bs58-3.1.0.tgz#d4c26388bf4804cac714141b1945aa47e5eb248e" dependencies: - bs58 "^4.0.0" + base-x "^1.1.0" + +bs58check@^1.0.8: + version "1.3.4" + resolved "https://registry.npmjs.org/bs58check/-/bs58check-1.3.4.tgz#c52540073749117714fa042c3047eb8f9151cbf8" + dependencies: + bs58 "^3.1.0" create-hash "^1.1.0" - safe-buffer "^5.1.2" btoa@1.1.2: version "1.1.2" @@ -5237,7 +5246,7 @@ ethereumjs-util@5.1.5, ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumj safe-buffer "^5.1.1" secp256k1 "^3.0.1" -ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0: +ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.0: version "4.5.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz#3e9428b317eebda3d7260d854fddda954b1f1bc6" dependencies: @@ -5291,18 +5300,17 @@ ethereumjs-vm@^2.0.2, ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4: rustbn.js "~0.1.1" safe-buffer "^5.1.1" -ethereumjs-wallet@~0.6.0: - version "0.6.2" - resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" +ethereumjs-wallet@0.6.0: + version "0.6.0" + resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.0.tgz#82763b1697ee7a796be7155da9dfb49b2f98cfdb" dependencies: - aes-js "^3.1.1" - bs58check "^2.1.2" - ethereumjs-util "^5.2.0" - hdkey "^1.0.0" - safe-buffer "^5.1.2" + aes-js "^0.2.3" + bs58check "^1.0.8" + ethereumjs-util "^4.4.0" + hdkey "^0.7.0" scrypt.js "^0.2.0" - utf8 "^3.0.0" - uuid "^3.3.2" + utf8 "^2.1.1" + uuid "^2.0.1" ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: version "3.0.18" @@ -6061,7 +6069,7 @@ ganache-core@0xProject/ganache-core#monorepo-dep: ethereumjs-tx "0xProject/ethereumjs-tx#fake-tx-include-signature-by-default" ethereumjs-util "^5.2.0" ethereumjs-vm "2.3.5" - ethereumjs-wallet "0.6.0" + ethereumjs-wallet "~0.6.0" fake-merkle-patricia-tree "~1.0.1" heap "~0.2.6" js-scrypt "^0.2.0" @@ -6743,21 +6751,13 @@ hawk@~6.0.2: hoek "4.x.x" sntp "2.x.x" -hdkey@^0.7.1: +hdkey@^0.7.0, hdkey@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-0.7.1.tgz#caee4be81aa77921e909b8d228dd0f29acaee632" dependencies: coinstring "^2.0.0" secp256k1 "^3.0.1" -hdkey@^1.0.0: - version "1.1.0" - resolved "https://registry.npmjs.org/hdkey/-/hdkey-1.1.0.tgz#e74e7b01d2c47f797fa65d1d839adb7a44639f29" - dependencies: - coinstring "^2.0.0" - safe-buffer "^5.1.1" - secp256k1 "^3.0.1" - he@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" @@ -14250,10 +14250,6 @@ utf8@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96" -utf8@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" - util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -- cgit From adf5acd5c43a9710bc5a3074ce684c2cd8849e63 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 21:23:06 +0100 Subject: Update yarn.lock --- yarn.lock | 62 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/yarn.lock b/yarn.lock index 950b39fd8..ab6f6aaf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1356,9 +1356,9 @@ aes-js@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" -aes-js@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" +aes-js@^0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" ajv-keywords@^2.1.0: version "2.1.1" @@ -2424,6 +2424,10 @@ balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" +base-x@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-1.1.0.tgz#42d3d717474f9ea02207f6d1aa1f426913eeb7ac" + base-x@^3.0.2: version "3.0.4" resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.4.tgz#94c1788736da065edb1d68808869e357c977fa77" @@ -2835,7 +2839,7 @@ browserslist@^2.1.2: caniuse-lite "^1.0.30000792" electron-to-chromium "^1.3.30" -bs58@=4.0.1, bs58@^4.0.0: +bs58@=4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" dependencies: @@ -2845,13 +2849,18 @@ bs58@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.1.tgz#55908d58f1982aba2008fa1bed8f91998a29bf8d" -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" +bs58@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-3.1.0.tgz#d4c26388bf4804cac714141b1945aa47e5eb248e" dependencies: - bs58 "^4.0.0" + base-x "^1.1.0" + +bs58check@^1.0.8: + version "1.3.4" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-1.3.4.tgz#c52540073749117714fa042c3047eb8f9151cbf8" + dependencies: + bs58 "^3.1.0" create-hash "^1.1.0" - safe-buffer "^5.1.2" btoa@1.1.2: version "1.1.2" @@ -5237,7 +5246,7 @@ ethereumjs-util@5.1.5, ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumj safe-buffer "^5.1.1" secp256k1 "^3.0.1" -ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0: +ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.0: version "4.5.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz#3e9428b317eebda3d7260d854fddda954b1f1bc6" dependencies: @@ -5291,18 +5300,17 @@ ethereumjs-vm@^2.0.2, ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4: rustbn.js "~0.1.1" safe-buffer "^5.1.1" -ethereumjs-wallet@~0.6.0: - version "0.6.2" - resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" +ethereumjs-wallet@0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.0.tgz#82763b1697ee7a796be7155da9dfb49b2f98cfdb" dependencies: - aes-js "^3.1.1" - bs58check "^2.1.2" - ethereumjs-util "^5.2.0" - hdkey "^1.0.0" - safe-buffer "^5.1.2" + aes-js "^0.2.3" + bs58check "^1.0.8" + ethereumjs-util "^4.4.0" + hdkey "^0.7.0" scrypt.js "^0.2.0" - utf8 "^3.0.0" - uuid "^3.3.2" + utf8 "^2.1.1" + uuid "^2.0.1" ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: version "3.0.18" @@ -6743,21 +6751,13 @@ hawk@~6.0.2: hoek "4.x.x" sntp "2.x.x" -hdkey@^0.7.1: +hdkey@^0.7.0, hdkey@^0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-0.7.1.tgz#caee4be81aa77921e909b8d228dd0f29acaee632" dependencies: coinstring "^2.0.0" secp256k1 "^3.0.1" -hdkey@^1.0.0: - version "1.1.0" - resolved "https://registry.npmjs.org/hdkey/-/hdkey-1.1.0.tgz#e74e7b01d2c47f797fa65d1d839adb7a44639f29" - dependencies: - coinstring "^2.0.0" - safe-buffer "^5.1.1" - secp256k1 "^3.0.1" - he@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" @@ -14250,10 +14250,6 @@ utf8@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96" -utf8@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" - util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -- cgit From 22597674d23284668500efacf551558606401038 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 25 Sep 2018 22:29:16 +0200 Subject: Add weijie and rahul --- packages/website/public/images/team/rahul.png | Bin 0 -> 29636 bytes packages/website/public/images/team/weijie.png | Bin 0 -> 38401 bytes packages/website/ts/pages/about/about.tsx | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 packages/website/public/images/team/rahul.png create mode 100644 packages/website/public/images/team/weijie.png diff --git a/packages/website/public/images/team/rahul.png b/packages/website/public/images/team/rahul.png new file mode 100644 index 000000000..b63cc12b1 Binary files /dev/null and b/packages/website/public/images/team/rahul.png differ diff --git a/packages/website/public/images/team/weijie.png b/packages/website/public/images/team/weijie.png new file mode 100644 index 000000000..69fd51794 Binary files /dev/null and b/packages/website/public/images/team/weijie.png differ diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index 42237bec3..75295349d 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -216,6 +216,23 @@ const teamRow7: ProfileInfo[] = [ }, ]; +const teamRow8: ProfileInfo[] = [ + { + name: 'Weijie Wu', + title: 'Research Fellow', + description: `Researching decentralized governance. Previously Researcher at Huawei and Assistant Professor at Shanghai Jiao Tong University. PhD in Computer Science at The Chinese University of Hong Kong.`, + image: 'images/team/weijie.png', + linkedIn: 'https://www.linkedin.com/in/weijiewu/', + }, + { + name: 'Rahul Singireddy', + title: 'Relayer Success Manager', + description: `Previously community at Zeppelin, growth at Dharma, and cryptocurrency contributor at Forbes. Symbolic Systems at Stanford.`, + image: 'images/team/rahul.png', + linkedIn: 'https://www.linkedin.com/in/rahul-singireddy-3037908a/', + }, +]; + const advisors1: ProfileInfo[] = [ { name: 'Fred Ehrsam', @@ -323,6 +340,7 @@ export class About extends React.Component {
{this._renderProfiles(teamRow5)}
{this._renderProfiles(teamRow6)}
{this._renderProfiles(teamRow7)}
+
{this._renderProfiles(teamRow8)}
Date: Tue, 25 Sep 2018 21:33:55 +0100 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 9 +++++++++ packages/0x.js/CHANGELOG.md | 4 ++++ packages/abi-gen/CHANGELOG.json | 9 +++++++++ packages/abi-gen/CHANGELOG.md | 4 ++++ packages/assert/CHANGELOG.json | 9 +++++++++ packages/assert/CHANGELOG.md | 4 ++++ packages/asset-buyer/CHANGELOG.json | 9 +++++++++ packages/asset-buyer/CHANGELOG.md | 4 ++++ packages/base-contract/CHANGELOG.json | 9 +++++++++ packages/base-contract/CHANGELOG.md | 4 ++++ packages/connect/CHANGELOG.json | 9 +++++++++ packages/connect/CHANGELOG.md | 4 ++++ packages/contract-wrappers/CHANGELOG.json | 3 ++- packages/contract-wrappers/CHANGELOG.md | 5 +++++ packages/dev-utils/CHANGELOG.json | 9 +++++++++ packages/dev-utils/CHANGELOG.md | 4 ++++ packages/ethereum-types/CHANGELOG.json | 9 +++++++++ packages/ethereum-types/CHANGELOG.md | 4 ++++ packages/fill-scenarios/CHANGELOG.json | 9 +++++++++ packages/fill-scenarios/CHANGELOG.md | 4 ++++ packages/json-schemas/CHANGELOG.json | 9 +++++++++ packages/json-schemas/CHANGELOG.md | 4 ++++ packages/migrations/CHANGELOG.json | 9 +++++++++ packages/migrations/CHANGELOG.md | 4 ++++ packages/order-utils/CHANGELOG.json | 9 +++++++++ packages/order-utils/CHANGELOG.md | 4 ++++ packages/order-watcher/CHANGELOG.json | 3 ++- packages/order-watcher/CHANGELOG.md | 6 ++++++ packages/react-docs/CHANGELOG.json | 9 +++++++++ packages/react-docs/CHANGELOG.md | 4 ++++ packages/react-shared/CHANGELOG.json | 9 +++++++++ packages/react-shared/CHANGELOG.md | 4 ++++ packages/sol-compiler/CHANGELOG.json | 9 +++++++++ packages/sol-compiler/CHANGELOG.md | 4 ++++ packages/sol-cov/CHANGELOG.json | 9 +++++++++ packages/sol-cov/CHANGELOG.md | 4 ++++ packages/sol-resolver/CHANGELOG.json | 9 +++++++++ packages/sol-resolver/CHANGELOG.md | 4 ++++ packages/sra-report/CHANGELOG.json | 9 +++++++++ packages/sra-report/CHANGELOG.md | 4 ++++ packages/sra-spec/CHANGELOG.json | 9 +++++++++ packages/sra-spec/CHANGELOG.md | 4 ++++ packages/subproviders/CHANGELOG.json | 9 +++++++++ packages/subproviders/CHANGELOG.md | 4 ++++ packages/types/CHANGELOG.json | 9 +++++++++ packages/types/CHANGELOG.md | 4 ++++ packages/typescript-typings/CHANGELOG.json | 9 +++++++++ packages/typescript-typings/CHANGELOG.md | 4 ++++ packages/utils/CHANGELOG.json | 9 +++++++++ packages/utils/CHANGELOG.md | 4 ++++ packages/web3-wrapper/CHANGELOG.json | 9 +++++++++ packages/web3-wrapper/CHANGELOG.md | 5 +++++ 52 files changed, 328 insertions(+), 2 deletions(-) diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 38966a0b7..391335390 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.5", diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index d881cd825..b9b329085 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.6 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 18aed8716..578557165 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 99fc44f0c..ee46ca2a9 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 851ba6c04..0aa9038d8 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index 26760306e..dab9f933b 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index 50b965f2d..d673f0a45 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.0", diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index b27795d18..bea4a551b 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.1 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.0 - _September 25, 2018_ * Dependencies updated diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 5f94afa43..8403d824b 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "2.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "2.0.4", diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index b3f3b5619..7a3e0f661 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index d4c501eb1..9de956d4d 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "2.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "2.0.3", "changes": [ diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index 2c2483cb6..75906ff4e 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.3 - _September 25, 2018_ * Import SRA-related types from @0xproject/types (#1085) diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index d3e0ad5d1..8863f61f4 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -12,7 +12,8 @@ "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", "pr": 1080 } - ] + ], + "timestamp": 1537907159 }, { "version": "1.0.5", diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 98de9c7f2..41e5645a3 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,11 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.0 - _September 25, 2018_ + + * Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080) + * Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080) + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index bd4f280ba..b0b703b34 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.9", diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index a362330c2..220d499d3 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 25, 2018_ * Dependencies updated diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json index 20d33ea38..ab3018e4b 100644 --- a/packages/ethereum-types/CHANGELOG.json +++ b/packages/ethereum-types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.8", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "1.0.7", diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md index 0de27c2fb..d286fbbfd 100644 --- a/packages/ethereum-types/CHANGELOG.md +++ b/packages/ethereum-types/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.8 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.7 - _September 21, 2018_ * Dependencies updated diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index 3023a43c5..8e6ff9b33 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.4", diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index 4fb3f3c54..4cc8cd855 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index afe8c6f55..facd90878 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.3", diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index dc9a69a3c..763e9dd05 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 25, 2018_ * Dependencies updated diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 1c8418818..25b523e8f 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.11", diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index 80038bebb..a637f30ef 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.12 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.11 - _September 25, 2018_ * Dependencies updated diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index d6742df2e..1162bbc83 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.4", diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index 67e5a54a6..8372ddf16 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 46dc4c0df..fc7037bfb 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -17,7 +17,8 @@ "Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction.", "pr": 1087 } - ] + ], + "timestamp": 1537907159 }, { "version": "1.0.5", diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index d179b2e1a..32837337a 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.0 - _September 25, 2018_ + + * Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080) + * Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080) + * Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction. (#1087) + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index 4e3dfed99..82aaf4e32 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index ca96d479d..8f5cc0cfd 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index 96e2a92f9..32cf66691 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.11", diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index 09f6066cd..fb2bac27e 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.12 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.11 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index af6897b40..69cc7fa0f 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.1.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.1.4", diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index 02058b378..0fc0ff7b1 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.1.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index ef009b586..5fde6d5ee 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "2.1.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "2.1.4", diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index 5dddb1c4d..bf48a74a4 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.1.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index ee439c2d0..72928bbed 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index 53354f4ef..e2959bbaa 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json index 006965b01..8f7048243 100644 --- a/packages/sra-report/CHANGELOG.json +++ b/packages/sra-report/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md index 298ea66ec..9a83159ba 100644 --- a/packages/sra-report/CHANGELOG.md +++ b/packages/sra-report/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index a4a1fe8ff..b50b98127 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.3", diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index e279d517f..501a4cf89 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 25, 2018_ * Dependencies updated diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index 8b6b87d2a..3cd7c2052 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "2.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "2.0.4", diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index 708a94b21..fac8d619d 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index f9479f789..e07699131 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "1.1.0", "changes": [ diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 9841aa301..353420081 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.1 - _September 25, 2018_ + + * Dependencies updated + ## v1.1.0 - _September 25, 2018_ * Add ObjectMap type (#1037) diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index f0b1a6c40..91e6a1e47 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537541580, "version": "2.0.1", diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md index 67e86bb82..1be65ddec 100644 --- a/packages/typescript-typings/CHANGELOG.md +++ b/packages/typescript-typings/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.1 - _September 21, 2018_ * Dependencies updated diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 1536c1960..d395a7dec 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1537875740, "version": "1.0.10", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index ff26a0900..60b6d1b7e 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 8895951bc..1ab2acafc 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1537907159, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "3.0.0", "changes": [ diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index cafbe1340..1c592d22e 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,9 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.1 - _September 25, 2018_ + + * Dependencies updated + ## v3.0.0 - _September 25, 2018_ * Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined. (#1082) + * Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls (#1080) ## v2.0.3 - _September 21, 2018_ -- cgit From 1b35a6e3b5d050fa33097b35e1d739ca13c6806e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 25 Sep 2018 21:34:14 +0100 Subject: Publish - 0x.js@1.0.6 - @0xproject/abi-gen@1.0.11 - @0xproject/assert@1.0.11 - @0xproject/asset-buyer@1.0.1 - @0xproject/base-contract@2.0.5 - @0xproject/connect@2.0.4 - @0xproject/contract-wrappers@2.0.0 - contracts@2.1.47 - @0xproject/dev-utils@1.0.10 - ethereum-types@1.0.8 - @0xproject/fill-scenarios@1.0.5 - @0xproject/json-schemas@1.0.4 - @0xproject/metacoin@0.0.21 - @0xproject/migrations@1.0.12 - @0xproject/order-utils@1.0.5 - @0xproject/order-watcher@2.0.0 - @0xproject/react-docs@1.0.11 - @0xproject/react-shared@1.0.12 - @0xproject/sol-compiler@1.1.5 - @0xproject/sol-cov@2.1.5 - @0xproject/sol-resolver@1.0.11 - @0xproject/sra-report@1.0.11 - @0xproject/sra-spec@1.0.4 - @0xproject/subproviders@2.0.5 - @0xproject/testnet-faucets@1.0.49 - @0xproject/types@1.1.1 - @0xproject/typescript-typings@2.0.2 - @0xproject/utils@1.0.11 - @0xproject/web3-wrapper@3.0.1 - @0xproject/website@0.0.52 --- packages/0x.js/package.json | 30 +++++++++++++++--------------- packages/abi-gen/package.json | 8 ++++---- packages/assert/package.json | 8 ++++---- packages/asset-buyer/package.json | 24 ++++++++++++------------ packages/base-contract/package.json | 10 +++++----- packages/connect/package.json | 14 +++++++------- packages/contract-wrappers/package.json | 30 +++++++++++++++--------------- packages/contracts/package.json | 26 +++++++++++++------------- packages/dev-utils/package.json | 14 +++++++------- packages/ethereum-types/package.json | 2 +- packages/fill-scenarios/package.json | 18 +++++++++--------- packages/json-schemas/package.json | 6 +++--- packages/metacoin/package.json | 24 ++++++++++++------------ packages/migrations/package.json | 24 ++++++++++++------------ packages/order-utils/package.json | 20 ++++++++++---------- packages/order-watcher/package.json | 30 +++++++++++++++--------------- packages/react-docs/package.json | 8 ++++---- packages/react-shared/package.json | 4 ++-- packages/sol-compiler/package.json | 20 ++++++++++---------- packages/sol-cov/package.json | 16 ++++++++-------- packages/sol-resolver/package.json | 6 +++--- packages/sra-report/package.json | 8 ++++---- packages/sra-spec/package.json | 4 ++-- packages/subproviders/package.json | 14 +++++++------- packages/testnet-faucets/package.json | 14 +++++++------- packages/types/package.json | 4 ++-- packages/typescript-typings/package.json | 4 ++-- packages/utils/package.json | 8 ++++---- packages/web3-wrapper/package.json | 12 ++++++------ packages/website/package.json | 24 ++++++++++++------------ 30 files changed, 217 insertions(+), 217 deletions(-) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index d53571dbf..3b8b0f913 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "1.0.5", + "version": "1.0.6", "engines": { "node": ">=6.12" }, @@ -41,9 +41,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/migrations": "^1.0.12", "@0xproject/monorepo-scripts": "^1.0.9", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", @@ -73,17 +73,17 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/order-watcher": "^1.0.5", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/assert": "^1.0.11", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/contract-wrappers": "^2.0.0", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/order-watcher": "^2.0.0", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "ethers": "3.0.22", "lodash": "^4.17.5", "web3-provider-engine": "14.0.6" diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 1fb697299..314addf52 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/abi-gen", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -30,10 +30,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", "chalk": "^2.3.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "glob": "^7.1.2", "handlebars": "^4.0.11", "lodash": "^4.17.5", diff --git a/packages/assert/package.json b/packages/assert/package.json index ee510d14f..3726f4136 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/assert", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -44,9 +44,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", "lodash": "^4.17.5", "valid-url": "^1.0.9" }, diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index d15213e0b..ff0afb782 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/asset-buyer", - "version": "1.0.0", + "version": "1.0.1", "engines": { "node": ">=6.12" }, @@ -36,17 +36,17 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/connect": "^2.0.3", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.11", + "@0xproject/connect": "^2.0.4", + "@0xproject/contract-wrappers": "^2.0.0", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "lodash": "^4.17.10" }, "devDependencies": { diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index cd7f29114..3bba0e81b 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/base-contract", - "version": "2.0.4", + "version": "2.0.5", "engines": { "node": ">=6.12" }, @@ -40,10 +40,10 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/connect/package.json b/packages/connect/package.json index 075089fd2..5e1fa81d4 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/connect", - "version": "2.0.3", + "version": "2.0.4", "engines": { "node": ">=6.12" }, @@ -43,12 +43,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/assert": "^1.0.11", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", "lodash": "^4.17.5", "query-string": "^5.0.1", "sinon": "^4.0.0", diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 57f994ff1..c2b1ecdc9 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/contract-wrappers", - "version": "1.0.5", + "version": "2.0.0", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -41,10 +41,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/migrations": "^1.0.12", + "@0xproject/subproviders": "^2.0.5", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -72,16 +72,16 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/fill-scenarios": "^1.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/assert": "^1.0.11", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/fill-scenarios": "^1.0.5", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 6a7a7c208..536506435 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "contracts", - "version": "2.1.46", + "version": "2.1.47", "engines": { "node": ">=6.12" }, @@ -45,11 +45,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/sol-cov": "^2.1.4", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/sol-compiler": "^1.1.5", + "@0xproject/sol-cov": "^2.1.5", + "@0xproject/subproviders": "^2.0.5", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", @@ -72,15 +72,15 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index c45581e45..876bb60d7 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/dev-utils", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -42,12 +42,12 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index c1abfb79b..32fad87cb 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-types", - "version": "1.0.7", + "version": "1.0.8", "engines": { "node": ">=6.12" }, diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 857ec496f..164a85ebf 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/fill-scenarios", - "version": "1.0.4", + "version": "1.0.5", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", + "@0xproject/abi-gen": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "copyfiles": "^2.0.0", @@ -37,13 +37,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 7dfdb1066..02f00ccc3 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/json-schemas", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -38,14 +38,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/typescript-typings": "^2.0.2", "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", - "@0xproject/utils": "^1.0.10", + "@0xproject/utils": "^1.0.11", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 924408d53..3b32b4099 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/metacoin", - "version": "0.0.20", + "version": "0.0.21", "engines": { "node": ">=6.12" }, @@ -28,25 +28,25 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/sol-cov": "^2.1.4", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/sol-cov": "^2.1.5", + "@0xproject/subproviders": "^2.0.5", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@types/mocha": "^5.2.2", "copyfiles": "^2.0.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethers": "3.0.22", "lodash": "^4.17.5", "run-s": "^0.0.0" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/sol-compiler": "^1.1.5", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/migrations/package.json b/packages/migrations/package.json index f44a254ed..81632e9d8 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/migrations", - "version": "1.0.11", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -30,10 +30,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/dev-utils": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.1.0", + "@0xproject/types": "^1.1.1", "@types/yargs": "^10.0.0", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", @@ -44,15 +44,15 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/sol-compiler": "^1.1.5", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@ledgerhq/hw-app-eth": "^4.3.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethers": "3.0.22", "lodash": "^4.17.5" }, diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 167d32608..f83b9cc14 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-utils", - "version": "1.0.4", + "version": "1.0.5", "engines": { "node": ">=6.12" }, @@ -38,7 +38,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -57,16 +57,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.11", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@types/node": "*", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index b00a76e55..61218b632 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-watcher", - "version": "1.0.5", + "version": "2.0.0", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -42,9 +42,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", + "@0xproject/abi-gen": "^1.0.11", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/migrations": "^1.0.12", "@0xproject/tslint-config": "^1.0.7", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -70,18 +70,18 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/fill-scenarios": "^1.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.11", + "@0xproject/base-contract": "^2.0.5", + "@0xproject/contract-wrappers": "^2.0.0", + "@0xproject/fill-scenarios": "^1.0.5", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "bintrees": "^1.0.2", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-blockstream": "6.0.0", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index d933489b7..be80f8028 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-docs", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -23,7 +23,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/compare-versions": "^3.0.0", "copyfiles": "^2.0.0", @@ -33,8 +33,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/react-shared": "^1.0.11", - "@0xproject/utils": "^1.0.10", + "@0xproject/react-shared": "^1.0.12", + "@0xproject/utils": "^1.0.11", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 9154c2bb6..9ffafc4ee 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-shared", - "version": "1.0.11", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -24,7 +24,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 841e2960c..9d1610180 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-compiler", - "version": "1.1.4", + "version": "1.1.5", "engines": { "node": ">=6.12" }, @@ -41,7 +41,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/mkdirp": "^0.5.2", "@types/require-from-string": "^1.2.0", @@ -64,16 +64,16 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/sol-resolver": "^1.0.10", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.11", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/sol-resolver": "^1.0.11", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 63b8f06d5..dff24181c 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "2.1.4", + "version": "2.1.5", "engines": { "node": ">=6.12" }, @@ -41,13 +41,13 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/dev-utils": "^1.0.10", + "@0xproject/sol-compiler": "^1.1.5", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", + "ethereum-types": "^1.0.8", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index caf7df3aa..535749bc6 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-resolver", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -30,8 +30,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index c916765e2..6b73fb6e0 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-report", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -33,13 +33,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", + "@0xproject/assert": "^1.0.11", "@0xproject/connect": "1.0.4", "@0xproject/json-schemas": "^0.8.3", "@0xproject/order-utils": "^0.0.9", "@0xproject/types": "^0.8.2", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", "chalk": "^2.3.0", "lodash": "^4.17.5", "newman": "^3.9.3", diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index 0c5131848..f16711ea0 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-spec", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, @@ -34,7 +34,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0xproject/json-schemas": "^1.0.3" + "@0xproject/json-schemas": "^1.0.4" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 6740a0743..d513c868b 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/subproviders", - "version": "2.0.4", + "version": "2.0.5", "engines": { "node": ">=6.12" }, @@ -28,11 +28,11 @@ } }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.11", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", "@types/eth-lightwallet": "^3.0.0", @@ -41,7 +41,7 @@ "bip39": "^2.5.0", "bn.js": "^4.11.8", "eth-lightwallet": "^3.0.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "ganache-core": "0xProject/ganache-core#monorepo-dep", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index cfac1b018..a25924de5 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/testnet-faucets", - "version": "1.0.48", + "version": "1.0.49", "engines": { "node": ">=6.12" }, @@ -17,13 +17,13 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^1.0.5", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "0x.js": "^1.0.6", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "body-parser": "^1.17.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "express": "^4.15.2", diff --git a/packages/types/package.json b/packages/types/package.json index f78368198..f5d57635d 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/types", - "version": "1.1.0", + "version": "1.1.1", "engines": { "node": ">=6.12" }, @@ -32,7 +32,7 @@ "dependencies": { "@types/node": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.7" + "ethereum-types": "^1.0.8" }, "publishConfig": { "access": "public" diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index 6f8b7e256..6db9b3160 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/typescript-typings", - "version": "2.0.1", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -26,7 +26,7 @@ "@types/bn.js": "^4.11.0", "@types/react": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "popper.js": "1.14.3" }, "devDependencies": { diff --git a/packages/utils/package.json b/packages/utils/package.json index 77d11c41c..1fd2f57fa 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/utils", - "version": "1.0.10", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -41,13 +41,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", "bignumber.js": "~4.1.0", "detect-node": "2.0.3", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "isomorphic-fetch": "^2.2.1", diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index f895296e9..cf0b186f2 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/web3-wrapper", - "version": "3.0.0", + "version": "3.0.1", "engines": { "node": ">=6.12" }, @@ -53,11 +53,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "ethereum-types": "^1.0.7", + "@0xproject/assert": "^1.0.11", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "ethereum-types": "^1.0.8", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/website/package.json b/packages/website/package.json index 67b2fb4ec..6adbbede0 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/website", - "version": "0.0.51", + "version": "0.0.52", "engines": { "node": ">=6.12" }, @@ -19,22 +19,22 @@ "license": "Apache-2.0", "dependencies": { "0x.js": "^0.38.6", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/react-docs": "^1.0.10", - "@0xproject/react-shared": "^1.0.11", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/contract-wrappers": "^2.0.0", + "@0xproject/json-schemas": "^1.0.4", + "@0xproject/order-utils": "^1.0.5", + "@0xproject/react-docs": "^1.0.11", + "@0xproject/react-shared": "^1.0.12", + "@0xproject/subproviders": "^2.0.5", + "@0xproject/types": "^1.1.1", + "@0xproject/typescript-typings": "^2.0.2", + "@0xproject/utils": "^1.0.11", + "@0xproject/web3-wrapper": "^3.0.1", "accounting": "^0.4.1", "basscss": "^8.0.3", "blockies": "^0.0.2", "bowser": "^1.9.3", "deep-equal": "^1.0.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.8", "ethereumjs-util": "^5.1.1", "find-versions": "^2.0.0", "jsonschema": "^1.2.0", -- cgit From f33ecfd2fcff106c673c5f96350e12f831b3295f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 26 Sep 2018 13:11:12 +0100 Subject: Support passing in package names into publish_release_notes command-line for when publishing must be done manually --- .../monorepo-scripts/src/publish_release_notes.ts | 20 ++++++++++++++++---- packages/monorepo-scripts/src/utils/utils.ts | 7 +++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/monorepo-scripts/src/publish_release_notes.ts b/packages/monorepo-scripts/src/publish_release_notes.ts index a9bc8fe75..101ac87b4 100644 --- a/packages/monorepo-scripts/src/publish_release_notes.ts +++ b/packages/monorepo-scripts/src/publish_release_notes.ts @@ -1,3 +1,4 @@ +import * as _ from 'lodash'; import * as yargs from 'yargs'; import { publishReleaseNotesAsync } from './utils/github_release_utils'; @@ -9,14 +10,25 @@ const args = yargs type: 'boolean', demandOption: true, }) - .example('$0 --isDryRun true', 'Full usage example').argv; + .option('packages', { + describe: + 'Space-separated list of packages to generated release notes for. If not supplied, it does all `Lerna updated` packages', + type: 'string', + }) + .example('$0 --isDryRun true --packages "0x.js @0xproject/web3-wrapper"', 'Full usage example').argv; (async () => { const isDryRun = args.isDryRun; - const shouldIncludePrivate = false; - const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); + let packages; + if (_.isUndefined(args.packages)) { + const shouldIncludePrivate = false; + packages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); + } else { + const packageNames = args.packages.split(' '); + packages = await utils.getPackagesByNameAsync(packageNames); + } - await publishReleaseNotesAsync(allUpdatedPackages, isDryRun); + await publishReleaseNotesAsync(packages, isDryRun); process.exit(0); })().catch(err => { utils.log(err); diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 2ce36942c..5e2e877c7 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -54,6 +54,13 @@ export const utils = { } return packages; }, + async getPackagesByNameAsync(packageNames: string[]): Promise { + const allPackages = utils.getPackages(constants.monorepoRootPath); + const updatedPackages = _.filter(allPackages, pkg => { + return _.includes(packageNames, pkg.packageJson.name); + }); + return updatedPackages; + }, async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise { const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate); const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name); -- cgit From f8532b3f51a5bb4f4294606c495321a82d71c69d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 26 Sep 2018 13:15:42 +0100 Subject: Typo --- packages/monorepo-scripts/src/publish_release_notes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monorepo-scripts/src/publish_release_notes.ts b/packages/monorepo-scripts/src/publish_release_notes.ts index 101ac87b4..6090498e0 100644 --- a/packages/monorepo-scripts/src/publish_release_notes.ts +++ b/packages/monorepo-scripts/src/publish_release_notes.ts @@ -12,7 +12,7 @@ const args = yargs }) .option('packages', { describe: - 'Space-separated list of packages to generated release notes for. If not supplied, it does all `Lerna updated` packages', + 'Space-separated list of packages to generated release notes for. If not supplied, it does all `Lerna updated` packages.', type: 'string', }) .example('$0 --isDryRun true --packages "0x.js @0xproject/web3-wrapper"', 'Full usage example').argv; -- cgit