From 19f61906d3075391efb32c17c99c2cba1f7a3858 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 10 Oct 2018 18:27:06 -0700 Subject: [PATCH 01/73] feat: Move over features from zrx-buyer --- .../instant/src/components/buy_button.tsx | 59 +++++++++++++++---- .../src/components/instant_heading.tsx | 39 ++++++++++-- .../src/components/zero_ex_instant.tsx | 2 + .../components/zero_ex_instant_container.tsx | 7 ++- packages/instant/src/constants.ts | 4 ++ .../containers/selected_asset_amount_input.ts | 57 ++++++++++++++++++ .../selected_asset_amount_input.tsx | 36 ----------- .../containers/selected_asset_buy_button.ts | 59 +++++++++++++++++++ .../selected_asset_instant_heading.ts | 26 ++++++++ packages/instant/src/redux/async_data.ts | 22 +++++++ packages/instant/src/redux/reducer.ts | 19 +++++- packages/instant/src/types.ts | 10 ++++ packages/instant/src/util/asset_buyer.ts | 11 ++++ packages/instant/src/util/coinbase_api.ts | 8 +++ packages/instant/src/util/provider.ts | 12 ++++ packages/instant/src/util/web3_wrapper.ts | 5 ++ 16 files changed, 321 insertions(+), 55 deletions(-) create mode 100644 packages/instant/src/constants.ts create mode 100644 packages/instant/src/containers/selected_asset_amount_input.ts delete mode 100644 packages/instant/src/containers/selected_asset_amount_input.tsx create mode 100644 packages/instant/src/containers/selected_asset_buy_button.ts create mode 100644 packages/instant/src/containers/selected_asset_instant_heading.ts create mode 100644 packages/instant/src/redux/async_data.ts create mode 100644 packages/instant/src/util/asset_buyer.ts create mode 100644 packages/instant/src/util/coinbase_api.ts create mode 100644 packages/instant/src/util/provider.ts create mode 100644 packages/instant/src/util/web3_wrapper.ts diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 5a32b95753..097b8e5472 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -1,19 +1,56 @@ +import { BuyQuote } from '@0xproject/asset-buyer'; +import * as _ from 'lodash'; import * as React from 'react'; import { ColorOption } from '../style/theme'; +import { assetBuyer } from '../util/asset_buyer'; +import { web3Wrapper } from '../util/web3_wrapper'; import { Button, Container, Text } from './ui'; -export interface BuyButtonProps {} +export interface BuyButtonProps { + buyQuote?: BuyQuote; + onClick: (buyQuote: BuyQuote) => void; + onBuySuccess: (buyQuote: BuyQuote) => void; + onBuyFailure: (buyQuote: BuyQuote) => void; + text: string; +} -export const BuyButton: React.StatelessComponent = props => ( - - - -); +const boundNoop = _.noop.bind(_); -BuyButton.displayName = 'BuyButton'; +export class BuyButton extends React.Component { + public static defaultProps = { + onClick: boundNoop, + onBuySuccess: boundNoop, + onBuyFailure: boundNoop, + }; + public render(): React.ReactNode { + const shouldDisableButton = _.isUndefined(this.props.buyQuote); + return ( + + + + ); + } + private readonly _handleClick = async () => { + // The button is disabled when there is no buy quote anyway. + if (_.isUndefined(this.props.buyQuote)) { + return; + } + this.props.onClick(this.props.buyQuote); + try { + const txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote, { + // HACK: There is a calculation issue in asset-buyer. ETH is refunded anyway so just over-estimate. + ethAmount: this.props.buyQuote.worstCaseQuoteInfo.totalEthAmount.mul(2), + }); + await web3Wrapper.awaitTransactionSuccessAsync(txnHash); + } catch { + this.props.onBuyFailure(this.props.buyQuote); + } + this.props.onBuySuccess(this.props.buyQuote); + }; +} diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index be0414b8d9..cde3862c71 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -1,11 +1,42 @@ +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; import * as React from 'react'; +import { ethDecimals } from '../constants'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; import { Container, Flex, Text } from './ui'; -export interface InstantHeadingProps {} +export interface InstantHeadingProps { + selectedAssetAmount?: BigNumber; + totalEthBaseAmount?: BigNumber; + ethUsdPrice?: BigNumber; +} + +const displaytotalEthBaseAmount = ({ selectedAssetAmount, totalEthBaseAmount }: InstantHeadingProps): string => { + if (_.isUndefined(selectedAssetAmount)) { + return '0 ETH'; + } + if (_.isUndefined(totalEthBaseAmount)) { + return '...loading'; + } + const ethUnitAmount = Web3Wrapper.toUnitAmount(totalEthBaseAmount, ethDecimals); + const roundedAmount = ethUnitAmount.round(4); + return `${roundedAmount} ETH`; +}; + +const displayUsdAmount = ({ totalEthBaseAmount, selectedAssetAmount, ethUsdPrice }: InstantHeadingProps): string => { + if (_.isUndefined(selectedAssetAmount)) { + return '$0.00'; + } + if (_.isUndefined(totalEthBaseAmount) || _.isUndefined(ethUsdPrice)) { + return '...loading'; + } + const ethUnitAmount = Web3Wrapper.toUnitAmount(totalEthBaseAmount, ethDecimals); + return `$${ethUnitAmount.mul(ethUsdPrice).round(2)}`; +}; export const InstantHeading: React.StatelessComponent = props => ( @@ -26,18 +57,18 @@ export const InstantHeading: React.StatelessComponent = pro - rep + zrx - 0 ETH + {displaytotalEthBaseAmount(props)} - $0.00 + {displayUsdAmount(props)} diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx index 0e6230d1b6..17ef737c9d 100644 --- a/packages/instant/src/components/zero_ex_instant.tsx +++ b/packages/instant/src/components/zero_ex_instant.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { Provider } from 'react-redux'; +import { asyncData } from '../redux/async_data'; import { store } from '../redux/store'; import { fonts } from '../style/fonts'; import { theme, ThemeProvider } from '../style/theme'; @@ -8,6 +9,7 @@ import { theme, ThemeProvider } from '../style/theme'; import { ZeroExInstantContainer } from './zero_ex_instant_container'; fonts.include(); +asyncData.fetchAndDispatchToStore(); export interface ZeroExInstantProps {} diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 716227b51a..4ff8b51bd1 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -1,5 +1,8 @@ import * as React from 'react'; +import { SelectedAssetBuyButton } from '../containers/selected_asset_buy_button'; +import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading'; + import { ColorOption } from '../style/theme'; import { BuyButton } from './buy_button'; @@ -12,9 +15,9 @@ export interface ZeroExInstantContainerProps {} export const ZeroExInstantContainer: React.StatelessComponent = props => ( - + - + ); diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts new file mode 100644 index 0000000000..397c9b07a1 --- /dev/null +++ b/packages/instant/src/constants.ts @@ -0,0 +1,4 @@ +export const sraApiUrl = 'https://api.radarrelay.com/0x/v2/'; +export const zrxContractAddress = '0xe41d2489571d322189246dafa5ebde1f4699f498'; +export const zrxDecimals = 18; +export const ethDecimals = 18; diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts new file mode 100644 index 0000000000..b731b889a4 --- /dev/null +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -0,0 +1,57 @@ +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; + +import { zrxContractAddress, zrxDecimals } from '../constants'; +import { State } from '../redux/reducer'; +import { ColorOption } from '../style/theme'; +import { Action, ActionTypes, AsyncProcessState } from '../types'; +import { assetBuyer } from '../util/asset_buyer'; + +import { AmountInput } from '../components/amount_input'; + +export interface SelectedAssetAmountInputProps { + fontColor?: ColorOption; + fontSize?: string; +} + +interface ConnectedState { + value?: BigNumber; +} + +interface ConnectedDispatch { + onChange?: (value?: BigNumber) => void; +} + +const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps): ConnectedState => ({ + value: state.selectedAssetAmount, +}); + +const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ + onChange: async value => { + // Update the input + dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value }); + // invalidate the last buy quote. + dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: undefined }); + // reset our buy state + dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.NONE }); + if (!_.isUndefined(value)) { + // get a new buy quote. + const baseUnitValue = Web3Wrapper.toBaseUnitAmount(value, zrxDecimals); + const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync( + zrxContractAddress, + baseUnitValue, + ); + // invalidate the last buy quote. + dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote }); + } + }, +}); + +export const SelectedAssetAmountInput: React.ComponentClass = connect( + mapStateToProps, + mapDispatchToProps, +)(AmountInput); diff --git a/packages/instant/src/containers/selected_asset_amount_input.tsx b/packages/instant/src/containers/selected_asset_amount_input.tsx deleted file mode 100644 index 800a4c5686..0000000000 --- a/packages/instant/src/containers/selected_asset_amount_input.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { BigNumber } from '@0xproject/utils'; -import * as React from 'react'; -import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; - -import { State } from '../redux/reducer'; -import { ColorOption } from '../style/theme'; -import { Action, ActionTypes } from '../types'; - -import { AmountInput } from '../components/amount_input'; - -export interface SelectedAssetAmountInputProps { - fontColor?: ColorOption; - fontSize?: string; -} - -interface ConnectedState { - value?: BigNumber; -} - -interface ConnectedDispatch { - onChange?: (value?: BigNumber) => void; -} - -const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps): ConnectedState => ({ - value: state.selectedAssetAmount, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - onChange: value => dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value }), -}); - -export const SelectedAssetAmountInput: React.ComponentClass = connect( - mapStateToProps, - mapDispatchToProps, -)(AmountInput); diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts new file mode 100644 index 0000000000..f537294e46 --- /dev/null +++ b/packages/instant/src/containers/selected_asset_buy_button.ts @@ -0,0 +1,59 @@ +import { BuyQuote } from '@0xproject/asset-buyer'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; + +import { State } from '../redux/reducer'; +import { Action, ActionTypes, AsyncProcessState } from '../types'; +import { assetBuyer } from '../util/asset_buyer'; +import { web3Wrapper } from '../util/web3_wrapper'; + +import { BuyButton } from '../components/buy_button'; + +export interface SelectedAssetBuyButtonProps {} + +interface ConnectedState { + text: string; + buyQuote?: BuyQuote; +} + +interface ConnectedDispatch { + onClick: (buyQuote: BuyQuote) => void; + onBuySuccess: (buyQuote: BuyQuote) => void; + onBuyFailure: (buyQuote: BuyQuote) => void; +} + +const textForState = (state: AsyncProcessState): string => { + switch (state) { + case AsyncProcessState.NONE: + return 'Buy'; + case AsyncProcessState.PENDING: + return '...Loading'; + case AsyncProcessState.SUCCESS: + return 'Success!'; + case AsyncProcessState.FAILURE: + return 'Failed'; + default: + return 'Buy'; + } +}; + +const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({ + text: textForState(state.selectedAssetBuyState), + buyQuote: state.latestBuyQuote, +}); + +const mapDispatchToProps = (dispatch: Dispatch, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({ + onClick: buyQuote => + dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.PENDING }), + onBuySuccess: buyQuote => + dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.SUCCESS }), + onBuyFailure: buyQuote => + dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.FAILURE }), +}); + +export const SelectedAssetBuyButton: React.ComponentClass = connect( + mapStateToProps, + mapDispatchToProps, +)(BuyButton); diff --git a/packages/instant/src/containers/selected_asset_instant_heading.ts b/packages/instant/src/containers/selected_asset_instant_heading.ts new file mode 100644 index 0000000000..a9e853fe1e --- /dev/null +++ b/packages/instant/src/containers/selected_asset_instant_heading.ts @@ -0,0 +1,26 @@ +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; + +import { State } from '../redux/reducer'; + +import { InstantHeading } from '../components/instant_heading'; + +export interface InstantHeadingProps {} + +interface ConnectedState { + selectedAssetAmount?: BigNumber; + totalEthBaseAmount?: BigNumber; + ethUsdPrice?: BigNumber; +} + +const mapStateToProps = (state: State, _ownProps: InstantHeadingProps): ConnectedState => ({ + selectedAssetAmount: state.selectedAssetAmount, + totalEthBaseAmount: _.get(state, 'latestBuyQuote.worstCaseQuoteInfo.totalEthAmount'), + ethUsdPrice: state.ethUsdPrice, +}); + +export const SelectedAssetInstantHeading: React.ComponentClass = connect(mapStateToProps)( + InstantHeading, +); diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts new file mode 100644 index 0000000000..3fde2d2e5b --- /dev/null +++ b/packages/instant/src/redux/async_data.ts @@ -0,0 +1,22 @@ +import { BigNumber } from '@0xproject/utils'; + +import { ActionTypes } from '../types'; +import { coinbaseApi } from '../util/coinbase_api'; + +import { store } from './store'; + +export const asyncData = { + fetchAndDispatchToStore: async () => { + let ethUsdPriceStr = '0'; + try { + ethUsdPriceStr = await coinbaseApi.getEthUsdPrice(); + } catch (e) { + // ignore + } finally { + store.dispatch({ + type: ActionTypes.UPDATE_ETH_USD_PRICE, + data: new BigNumber(ethUsdPriceStr), + }); + } + }, +}; diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index 5026895aec..c0c4b06ad4 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -1,16 +1,21 @@ +import { BuyQuote } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import { Action, ActionTypes } from '../types'; +import { Action, ActionTypes, AsyncProcessState } from '../types'; export interface State { - ethUsdPrice?: string; selectedAssetAmount?: BigNumber; + selectedAssetBuyState: AsyncProcessState; + ethUsdPrice?: BigNumber; + latestBuyQuote?: BuyQuote; } export const INITIAL_STATE: State = { ethUsdPrice: undefined, + selectedAssetBuyState: AsyncProcessState.NONE, selectedAssetAmount: undefined, + latestBuyQuote: undefined, }; export const reducer = (state: State = INITIAL_STATE, action: Action): State => { @@ -25,6 +30,16 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => ...state, selectedAssetAmount: action.data, }; + case ActionTypes.UPDATE_LATEST_BUY_QUOTE: + return { + ...state, + latestBuyQuote: action.data, + }; + case ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE: + return { + ...state, + selectedAssetBuyState: action.data, + }; default: return state; } diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index d150bd8aba..bbf31cbf43 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -1,6 +1,16 @@ +// Reusable +export enum AsyncProcessState { + NONE, + PENDING, + SUCCESS, + FAILURE, +} + export enum ActionTypes { UPDATE_ETH_USD_PRICE, UPDATE_SELECTED_ASSET_AMOUNT, + UPDATE_SELECTED_ASSET_BUY_STATE, + UPDATE_LATEST_BUY_QUOTE, } export interface Action { diff --git a/packages/instant/src/util/asset_buyer.ts b/packages/instant/src/util/asset_buyer.ts new file mode 100644 index 0000000000..b030501c4b --- /dev/null +++ b/packages/instant/src/util/asset_buyer.ts @@ -0,0 +1,11 @@ +import { AssetBuyer } from '@0xproject/asset-buyer'; + +import { sraApiUrl } from '../constants'; + +import { getProvider } from './provider'; + +const provider = getProvider(); + +export const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, sraApiUrl, { + expiryBufferSeconds: 300, +}); diff --git a/packages/instant/src/util/coinbase_api.ts b/packages/instant/src/util/coinbase_api.ts new file mode 100644 index 0000000000..63c8077da4 --- /dev/null +++ b/packages/instant/src/util/coinbase_api.ts @@ -0,0 +1,8 @@ +const baseEndpoint = 'https://api.coinbase.com/v2'; +export const coinbaseApi = { + getEthUsdPrice: async (): Promise => { + const res = await fetch(`${baseEndpoint}/prices/ETH-USD/buy`); + const resJson = await res.json(); + return resJson.data.amount; + }, +}; diff --git a/packages/instant/src/util/provider.ts b/packages/instant/src/util/provider.ts new file mode 100644 index 0000000000..49705fd110 --- /dev/null +++ b/packages/instant/src/util/provider.ts @@ -0,0 +1,12 @@ +import { Provider } from 'ethereum-types'; + +export const getProvider = (): Provider => { + const injectedWeb3 = (window as any).web3 || undefined; + try { + // Use MetaMask/Mist provider + return injectedWeb3.currentProvider; + } catch (err) { + // Throws when user doesn't have MetaMask/Mist running + throw new Error(`No injected web3 found: ${err}`); + } +}; diff --git a/packages/instant/src/util/web3_wrapper.ts b/packages/instant/src/util/web3_wrapper.ts new file mode 100644 index 0000000000..d7e43521ff --- /dev/null +++ b/packages/instant/src/util/web3_wrapper.ts @@ -0,0 +1,5 @@ +import { Web3Wrapper } from '@0xproject/web3-wrapper'; + +import { getProvider } from './provider'; + +export const web3Wrapper = new Web3Wrapper(getProvider()); From 63652df3b90ca4ced73d27e09984b67bd32050f4 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 11 Oct 2018 15:05:20 -0700 Subject: [PATCH 02/73] feat: adjust amount input width --- packages/instant/src/components/amount_input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 38810063dc..a2113f1432 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -24,7 +24,7 @@ export class AmountInput extends React.Component { onChange={this._handleChange} value={!_.isUndefined(value) ? value.toString() : ''} placeholder="0.00" - width="2em" + width="2.2em" /> ); From 0edd9b32bab41d3eda9bad297f7e5db4a289cc88 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 11 Oct 2018 15:22:55 -0700 Subject: [PATCH 03/73] feat: debounce the fetching of new quotes --- .../containers/selected_asset_amount_input.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index b731b889a4..fa675b385f 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -30,6 +30,19 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps) value: state.selectedAssetAmount, }); +const updateBuyQuote = async (dispatch: Dispatch, assetAmount?: BigNumber): Promise => { + if (_.isUndefined(assetAmount)) { + return; + } + // get a new buy quote. + const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); + const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(zrxContractAddress, baseUnitValue); + // invalidate the last buy quote. + dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote }); +}; + +const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true }); + const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ onChange: async value => { // Update the input @@ -38,16 +51,7 @@ const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: undefined }); // reset our buy state dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.NONE }); - if (!_.isUndefined(value)) { - // get a new buy quote. - const baseUnitValue = Web3Wrapper.toBaseUnitAmount(value, zrxDecimals); - const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync( - zrxContractAddress, - baseUnitValue, - ); - // invalidate the last buy quote. - dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote }); - } + debouncedUpdateBuyQuote(dispatch, value); }, }); From 1c92ae0ed0b90818aca7bf899c05fd150672d75b Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 11 Oct 2018 17:34:43 -0700 Subject: [PATCH 04/73] fix: export BuyQuoteInfo from asset-buyer --- packages/asset-buyer/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 2da2724d74..e856843f08 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -9,6 +9,7 @@ export { AssetBuyerError, AssetBuyerOpts, BuyQuote, + BuyQuoteInfo, BuyQuoteExecutionOpts, BuyQuoteRequestOpts, OrderProvider, From 03b235bb428e8a61934ff603f22f057d8394b56a Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 11 Oct 2018 17:35:22 -0700 Subject: [PATCH 05/73] feat: populate order details with information from worst buy quote --- .../src/components/instant_heading.tsx | 14 +-- .../instant/src/components/order_details.tsx | 92 +++++++++++++------ .../components/zero_ex_instant_container.tsx | 4 +- packages/instant/src/constants.ts | 2 + .../latest_buy_quote_order_details.ts | 26 ++++++ .../containers/selected_asset_buy_button.ts | 2 +- packages/instant/src/util/format.ts | 45 +++++++++ 7 files changed, 143 insertions(+), 42 deletions(-) create mode 100644 packages/instant/src/containers/latest_buy_quote_order_details.ts create mode 100644 packages/instant/src/util/format.ts diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index cde3862c71..951858695c 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -6,6 +6,7 @@ import * as React from 'react'; import { ethDecimals } from '../constants'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; +import { format } from '../util/format'; import { Container, Flex, Text } from './ui'; @@ -19,23 +20,14 @@ const displaytotalEthBaseAmount = ({ selectedAssetAmount, totalEthBaseAmount }: if (_.isUndefined(selectedAssetAmount)) { return '0 ETH'; } - if (_.isUndefined(totalEthBaseAmount)) { - return '...loading'; - } - const ethUnitAmount = Web3Wrapper.toUnitAmount(totalEthBaseAmount, ethDecimals); - const roundedAmount = ethUnitAmount.round(4); - return `${roundedAmount} ETH`; + return format.ethBaseAmount(totalEthBaseAmount, 4, '...loading'); }; const displayUsdAmount = ({ totalEthBaseAmount, selectedAssetAmount, ethUsdPrice }: InstantHeadingProps): string => { if (_.isUndefined(selectedAssetAmount)) { return '$0.00'; } - if (_.isUndefined(totalEthBaseAmount) || _.isUndefined(ethUsdPrice)) { - return '...loading'; - } - const ethUnitAmount = Web3Wrapper.toUnitAmount(totalEthBaseAmount, ethDecimals); - return `$${ethUnitAmount.mul(ethUsdPrice).round(2)}`; + return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '...loading'); }; export const InstantHeading: React.StatelessComponent = props => ( diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index dbf2c1f0b7..78359898f3 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -1,53 +1,88 @@ +import { BuyQuoteInfo } from '@0xproject/asset-buyer'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; import * as React from 'react'; +import { BIG_NUMBER_ZERO, ethDecimals } from '../constants'; + import { ColorOption } from '../style/theme'; +import { format } from '../util/format'; import { Container, Flex, Text } from './ui'; -export interface OrderDetailsProps {} +export interface OrderDetailsProps { + buyQuoteInfo?: BuyQuoteInfo; + ethUsdPrice?: BigNumber; +} -export const OrderDetails: React.StatelessComponent = props => ( - - - - Order Details - - - - - - -); - -OrderDetails.displayName = 'OrderDetails'; +export class OrderDetails extends React.Component { + public render(): React.ReactNode { + const { buyQuoteInfo, ethUsdPrice } = this.props; + const ethAssetPrice = _.get(buyQuoteInfo, 'ethPerAssetPrice'); + const ethTokenFee = _.get(buyQuoteInfo, 'feeEthAmount'); + const totalEthAmount = _.get(buyQuoteInfo, 'totalEthAmount'); + return ( + + + + Order Details + + + + + + + ); + } +} export interface OrderDetailsRowProps { name: string; - primaryValue: string; - secondaryValue: string; + ethAmount?: BigNumber; + shouldConvertEthToUnitAmount?: boolean; + ethUsdPrice?: BigNumber; shouldEmphasize?: boolean; } -export const OrderDetailsRow: React.StatelessComponent = props => { - const fontWeight = props.shouldEmphasize ? 700 : 400; +export const OrderDetailsRow: React.StatelessComponent = ({ + name, + ethAmount, + shouldConvertEthToUnitAmount, + ethUsdPrice, + shouldEmphasize, +}) => { + const fontWeight = shouldEmphasize ? 700 : 400; + const usdFormatter = shouldConvertEthToUnitAmount ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd; + const ethFormatter = shouldConvertEthToUnitAmount ? format.ethBaseAmount : format.ethUnitAmount; return ( - {props.name} + {name} - ({props.secondaryValue}) + ({usdFormatter(ethAmount, ethUsdPrice)}) - {props.primaryValue} + {ethFormatter(ethAmount)} @@ -57,6 +92,7 @@ export const OrderDetailsRow: React.StatelessComponent = p OrderDetailsRow.defaultProps = { shouldEmphasize: false, + shouldConvertEthToUnitAmount: true, }; OrderDetailsRow.displayName = 'OrderDetailsRow'; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 4ff8b51bd1..44f702aa25 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; +import { LatestBuyQuoteOrderDetails } from '../containers/latest_buy_quote_order_details'; import { SelectedAssetBuyButton } from '../containers/selected_asset_buy_button'; import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading'; @@ -7,7 +8,6 @@ import { ColorOption } from '../style/theme'; import { BuyButton } from './buy_button'; import { InstantHeading } from './instant_heading'; -import { OrderDetails } from './order_details'; import { Container, Flex } from './ui'; export interface ZeroExInstantContainerProps {} @@ -16,7 +16,7 @@ export const ZeroExInstantContainer: React.StatelessComponent - + diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts index 397c9b07a1..75afc474a3 100644 --- a/packages/instant/src/constants.ts +++ b/packages/instant/src/constants.ts @@ -1,3 +1,5 @@ +import { BigNumber } from '@0xproject/utils'; +export const BIG_NUMBER_ZERO = new BigNumber(0); export const sraApiUrl = 'https://api.radarrelay.com/0x/v2/'; export const zrxContractAddress = '0xe41d2489571d322189246dafa5ebde1f4699f498'; export const zrxDecimals = 18; diff --git a/packages/instant/src/containers/latest_buy_quote_order_details.ts b/packages/instant/src/containers/latest_buy_quote_order_details.ts new file mode 100644 index 0000000000..77d84289bc --- /dev/null +++ b/packages/instant/src/containers/latest_buy_quote_order_details.ts @@ -0,0 +1,26 @@ +import { BuyQuoteInfo } from '@0xproject/asset-buyer'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; + +import { State } from '../redux/reducer'; + +import { OrderDetails } from '../components/order_details'; + +export interface LatestBuyQuoteOrderDetailsProps {} + +interface ConnectedState { + buyQuoteInfo?: BuyQuoteInfo; + ethUsdPrice?: BigNumber; +} + +const mapStateToProps = (state: State, _ownProps: LatestBuyQuoteOrderDetailsProps): ConnectedState => ({ + // use the worst case quote info + buyQuoteInfo: _.get(state, 'latestBuyQuote.worstCaseQuoteInfo'), + ethUsdPrice: state.ethUsdPrice, +}); + +export const LatestBuyQuoteOrderDetails: React.ComponentClass = connect( + mapStateToProps, +)(OrderDetails); diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts index f537294e46..678c7e4451 100644 --- a/packages/instant/src/containers/selected_asset_buy_button.ts +++ b/packages/instant/src/containers/selected_asset_buy_button.ts @@ -9,7 +9,7 @@ import { Action, ActionTypes, AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; import { web3Wrapper } from '../util/web3_wrapper'; -import { BuyButton } from '../components/buy_button'; +import { BuyButton, BuyButtonProps } from '../components/buy_button'; export interface SelectedAssetBuyButtonProps {} diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts new file mode 100644 index 0000000000..de7eb62e65 --- /dev/null +++ b/packages/instant/src/util/format.ts @@ -0,0 +1,45 @@ +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; + +import { ethDecimals } from '../constants'; + +export const format = { + ethBaseAmount: (ethBaseAmount?: BigNumber, decimalPlaces: number = 4, defaultText: string = '0 ETH'): string => { + if (_.isUndefined(ethBaseAmount)) { + return defaultText; + } + const ethUnitAmount = Web3Wrapper.toUnitAmount(ethBaseAmount, ethDecimals); + return format.ethUnitAmount(ethUnitAmount, decimalPlaces); + }, + ethUnitAmount: (ethUnitAmount?: BigNumber, decimalPlaces: number = 4, defaultText: string = '0 ETH'): string => { + if (_.isUndefined(ethUnitAmount)) { + return defaultText; + } + const roundedAmount = ethUnitAmount.round(decimalPlaces); + return `${roundedAmount} ETH`; + }, + ethBaseAmountInUsd: ( + ethBaseAmount?: BigNumber, + ethUsdPrice?: BigNumber, + decimalPlaces: number = 2, + defaultText: string = '$0.00', + ): string => { + if (_.isUndefined(ethBaseAmount) || _.isUndefined(ethUsdPrice)) { + return defaultText; + } + const ethUnitAmount = Web3Wrapper.toUnitAmount(ethBaseAmount, ethDecimals); + return format.ethUnitAmountInUsd(ethUnitAmount, ethUsdPrice, decimalPlaces); + }, + ethUnitAmountInUsd: ( + ethUnitAmount?: BigNumber, + ethUsdPrice?: BigNumber, + decimalPlaces: number = 2, + defaultText: string = '$0.00', + ): string => { + if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) { + return defaultText; + } + return `$${ethUnitAmount.mul(ethUsdPrice).round(decimalPlaces)}`; + }, +}; From 09c5ae4e65f8fddd4504be041f27f9107d12df7d Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 12 Oct 2018 09:55:33 -0700 Subject: [PATCH 06/73] feat: have coinbase API return BigNumber for eth-usd price endpoint --- packages/instant/src/redux/async_data.ts | 7 ++++--- packages/instant/src/util/coinbase_api.ts | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts index 3fde2d2e5b..b368491f00 100644 --- a/packages/instant/src/redux/async_data.ts +++ b/packages/instant/src/redux/async_data.ts @@ -1,5 +1,6 @@ import { BigNumber } from '@0xproject/utils'; +import { BIG_NUMBER_ZERO } from '../constants'; import { ActionTypes } from '../types'; import { coinbaseApi } from '../util/coinbase_api'; @@ -7,15 +8,15 @@ import { store } from './store'; export const asyncData = { fetchAndDispatchToStore: async () => { - let ethUsdPriceStr = '0'; + let ethUsdPrice = BIG_NUMBER_ZERO; try { - ethUsdPriceStr = await coinbaseApi.getEthUsdPrice(); + ethUsdPrice = await coinbaseApi.getEthUsdPrice(); } catch (e) { // ignore } finally { store.dispatch({ type: ActionTypes.UPDATE_ETH_USD_PRICE, - data: new BigNumber(ethUsdPriceStr), + data: ethUsdPrice, }); } }, diff --git a/packages/instant/src/util/coinbase_api.ts b/packages/instant/src/util/coinbase_api.ts index 63c8077da4..94a5d3c80d 100644 --- a/packages/instant/src/util/coinbase_api.ts +++ b/packages/instant/src/util/coinbase_api.ts @@ -1,8 +1,10 @@ +import { BigNumber } from '@0xproject/utils'; + const baseEndpoint = 'https://api.coinbase.com/v2'; export const coinbaseApi = { - getEthUsdPrice: async (): Promise => { + getEthUsdPrice: async (): Promise => { const res = await fetch(`${baseEndpoint}/prices/ETH-USD/buy`); const resJson = await res.json(); - return resJson.data.amount; + return new BigNumber(resJson.data.amount); }, }; From f3391e1250767eb9ef7a74f78eded38fa3c94586 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 12 Oct 2018 11:00:36 -0700 Subject: [PATCH 07/73] feat: make redux actions type-sage --- .../src/components/instant_heading.tsx | 2 -- .../instant/src/components/order_details.tsx | 3 -- .../src/components/zero_ex_instant.tsx | 1 + .../components/zero_ex_instant_container.tsx | 2 -- .../containers/selected_asset_amount_input.ts | 12 ++++--- .../containers/selected_asset_buy_button.ts | 16 ++++----- packages/instant/src/redux/actions.ts | 36 +++++++++++++++++++ packages/instant/src/redux/async_data.ts | 5 ++- packages/instant/src/redux/reducer.ts | 4 ++- packages/instant/src/types.ts | 16 +++------ 10 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 packages/instant/src/redux/actions.ts diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 951858695c..377bb20bf2 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -1,9 +1,7 @@ import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import * as React from 'react'; -import { ethDecimals } from '../constants'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; import { format } from '../util/format'; diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index 78359898f3..66e7e24062 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -1,11 +1,8 @@ import { BuyQuoteInfo } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import * as React from 'react'; -import { BIG_NUMBER_ZERO, ethDecimals } from '../constants'; - import { ColorOption } from '../style/theme'; import { format } from '../util/format'; diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx index 17ef737c9d..f6472e811a 100644 --- a/packages/instant/src/components/zero_ex_instant.tsx +++ b/packages/instant/src/components/zero_ex_instant.tsx @@ -9,6 +9,7 @@ import { theme, ThemeProvider } from '../style/theme'; import { ZeroExInstantContainer } from './zero_ex_instant_container'; fonts.include(); +// tslint:disable-next-line:no-floating-promises asyncData.fetchAndDispatchToStore(); export interface ZeroExInstantProps {} diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 44f702aa25..b624d712fc 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -6,8 +6,6 @@ import { SelectedAssetInstantHeading } from '../containers/selected_asset_instan import { ColorOption } from '../style/theme'; -import { BuyButton } from './buy_button'; -import { InstantHeading } from './instant_heading'; import { Container, Flex } from './ui'; export interface ZeroExInstantContainerProps {} diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index fa675b385f..9e3063eccb 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -6,9 +6,10 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { zrxContractAddress, zrxDecimals } from '../constants'; +import { Action, actions } from '../redux/actions'; import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; -import { Action, ActionTypes, AsyncProcessState } from '../types'; +import { AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; import { AmountInput } from '../components/amount_input'; @@ -38,7 +39,7 @@ const updateBuyQuote = async (dispatch: Dispatch, assetAmount?: BigNumbe const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(zrxContractAddress, baseUnitValue); // invalidate the last buy quote. - dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote }); + dispatch(actions.updateLatestBuyQuote(newBuyQuote)); }; const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true }); @@ -46,11 +47,12 @@ const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ onChange: async value => { // Update the input - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value }); + dispatch(actions.updateSelectedAssetAmount(value)); // invalidate the last buy quote. - dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: undefined }); + dispatch(actions.updateLatestBuyQuote(undefined)); // reset our buy state - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.NONE }); + dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE)); + // tslint:disable-next-line:no-floating-promises debouncedUpdateBuyQuote(dispatch, value); }, }); diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts index 678c7e4451..4cbaf55379 100644 --- a/packages/instant/src/containers/selected_asset_buy_button.ts +++ b/packages/instant/src/containers/selected_asset_buy_button.ts @@ -4,12 +4,11 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { Dispatch } from 'redux'; +import { Action, actions } from '../redux/actions'; import { State } from '../redux/reducer'; -import { Action, ActionTypes, AsyncProcessState } from '../types'; -import { assetBuyer } from '../util/asset_buyer'; -import { web3Wrapper } from '../util/web3_wrapper'; +import { AsyncProcessState } from '../types'; -import { BuyButton, BuyButtonProps } from '../components/buy_button'; +import { BuyButton } from '../components/buy_button'; export interface SelectedAssetBuyButtonProps {} @@ -45,12 +44,9 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): }); const mapDispatchToProps = (dispatch: Dispatch, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({ - onClick: buyQuote => - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.PENDING }), - onBuySuccess: buyQuote => - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.SUCCESS }), - onBuyFailure: buyQuote => - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.FAILURE }), + onClick: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.PENDING)), + onBuySuccess: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.SUCCESS)), + onBuyFailure: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.FAILURE)), }); export const SelectedAssetBuyButton: React.ComponentClass = connect( diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts new file mode 100644 index 0000000000..7d07b4950d --- /dev/null +++ b/packages/instant/src/redux/actions.ts @@ -0,0 +1,36 @@ +import { BuyQuote } from '@0xproject/asset-buyer'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { ActionsUnion, AsyncProcessState } from '../types'; + +export interface PlainAction { + type: T; +} + +export interface ActionWithPayload extends PlainAction { + data: P; +} + +export type Action = ActionsUnion; + +function createAction(type: T): PlainAction; +function createAction(type: T, data: P): ActionWithPayload; +function createAction(type: T, data?: P): PlainAction | ActionWithPayload { + return _.isUndefined(data) ? { type } : { type, data }; +} + +export enum ActionTypes { + UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE', + UPDATE_SELECTED_ASSET_AMOUNT = 'UPDATE_SELECTED_ASSET_AMOUNT', + UPDATE_SELECTED_ASSET_BUY_STATE = 'UPDATE_SELECTED_ASSET_BUY_STATE', + UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE', +} + +export const actions = { + updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price), + updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, amount), + updateSelectedAssetBuyState: (buyState: AsyncProcessState) => + createAction(ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, buyState), + updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote), +}; diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts index b368491f00..3488383074 100644 --- a/packages/instant/src/redux/async_data.ts +++ b/packages/instant/src/redux/async_data.ts @@ -1,9 +1,8 @@ -import { BigNumber } from '@0xproject/utils'; - import { BIG_NUMBER_ZERO } from '../constants'; -import { ActionTypes } from '../types'; import { coinbaseApi } from '../util/coinbase_api'; +import { ActionTypes } from './actions'; + import { store } from './store'; export const asyncData = { diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index c0c4b06ad4..56a4ee2368 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -2,7 +2,9 @@ import { BuyQuote } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import { Action, ActionTypes, AsyncProcessState } from '../types'; +import { AsyncProcessState } from '../types'; + +import { Action, ActionTypes } from './actions'; export interface State { selectedAssetAmount?: BigNumber; diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index bbf31cbf43..ffa5d679eb 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -1,3 +1,5 @@ +import { ObjectMap } from '@0xproject/types'; + // Reusable export enum AsyncProcessState { NONE, @@ -6,14 +8,6 @@ export enum AsyncProcessState { FAILURE, } -export enum ActionTypes { - UPDATE_ETH_USD_PRICE, - UPDATE_SELECTED_ASSET_AMOUNT, - UPDATE_SELECTED_ASSET_BUY_STATE, - UPDATE_LATEST_BUY_QUOTE, -} - -export interface Action { - type: ActionTypes; - data?: any; -} +export type FunctionType = (...args: any[]) => any; +export type ActionCreatorsMapObject = ObjectMap; +export type ActionsUnion = ReturnType; From 025614a7fd297444cf47bb5134a83973983ef8a8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 12 Oct 2018 14:52:18 -0700 Subject: [PATCH 08/73] feat: Add AssetData type as union of ERC721AssetData and ERC20AssetData --- packages/types/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 6bc966ba14..ff4c6f0cc2 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -158,16 +158,18 @@ export enum AssetProxyId { } export interface ERC20AssetData { - assetProxyId: string; + assetProxyId: AssetProxyId.ERC20; tokenAddress: string; } export interface ERC721AssetData { - assetProxyId: string; + assetProxyId: AssetProxyId.ERC721; tokenAddress: string; tokenId: BigNumber; } +export type AssetData = ERC20AssetData | ERC721AssetData; + // TODO: DRY. These should be extracted from contract code. export enum RevertReason { OrderUnfillable = 'ORDER_UNFILLABLE', From ccf021b8bf34aa7c0714f29f9153a5a11ce682a2 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 12 Oct 2018 14:52:42 -0700 Subject: [PATCH 09/73] feat: use new AssetData type from types package --- packages/order-utils/src/asset_data_utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/order-utils/src/asset_data_utils.ts b/packages/order-utils/src/asset_data_utils.ts index 0c0b595483..12c11bce9e 100644 --- a/packages/order-utils/src/asset_data_utils.ts +++ b/packages/order-utils/src/asset_data_utils.ts @@ -1,4 +1,4 @@ -import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types'; +import { AssetData, AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import ethAbi = require('ethereumjs-abi'); import ethUtil = require('ethereumjs-util'); @@ -112,7 +112,7 @@ export const assetDataUtils = { * @param assetData Hex encoded assetData string to decode * @return Either a ERC20 or ERC721 assetData object */ - decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData { + decodeAssetDataOrThrow(assetData: string): AssetData { const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData); switch (assetProxyId) { case AssetProxyId.ERC20: From f39541436a5088e928660b61bde7cef5153bc7a1 Mon Sep 17 00:00:00 2001 From: fragosti Date: Fri, 12 Oct 2018 16:11:30 -0700 Subject: [PATCH 10/73] feat: model asset meta data and add dynamic assetData state --- packages/instant/package.json | 1 + .../instant/src/components/amount_input.tsx | 9 ++-- .../src/components/asset_amount_input.tsx | 51 +++++++++++++++++++ .../src/components/instant_heading.tsx | 9 +--- packages/instant/src/constants.ts | 2 +- .../containers/selected_asset_amount_input.ts | 31 +++++++---- packages/instant/src/data/asset_meta_data.ts | 15 ++++++ packages/instant/src/redux/reducer.ts | 8 ++- packages/instant/src/types.ts | 22 +++++++- yarn.lock | 15 ++++++ 10 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 packages/instant/src/components/asset_amount_input.tsx create mode 100644 packages/instant/src/data/asset_meta_data.ts diff --git a/packages/instant/package.json b/packages/instant/package.json index ff40ba2eaf..35cc39d278 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -44,6 +44,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { "@0xproject/asset-buyer": "^2.0.0", + "@0xproject/order-utils": "^1.0.7", "@0xproject/types": "^1.1.4", "@0xproject/typescript-typings": "^2.0.2", "@0xproject/utils": "^2.0.2", diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index a2113f1432..5b81a3d683 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -10,10 +10,13 @@ export interface AmountInputProps { fontColor?: ColorOption; fontSize?: string; value?: BigNumber; - onChange?: (value?: BigNumber) => void; + onChange: (value?: BigNumber) => void; } export class AmountInput extends React.Component { + public static defaultProps = { + onChange: _.noop.bind(_), + }; public render(): React.ReactNode { const { fontColor, fontSize, value } = this.props; return ( @@ -40,8 +43,6 @@ export class AmountInput extends React.Component { return; } } - if (!_.isUndefined(this.props.onChange)) { - this.props.onChange(bigNumberValue); - } + this.props.onChange(bigNumberValue); }; } diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx new file mode 100644 index 0000000000..915c66e1ec --- /dev/null +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -0,0 +1,51 @@ +import { AssetProxyId } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as _ from 'lodash'; +import * as React from 'react'; + +import { assetMetaData } from '../data/asset_meta_data'; +import { ColorOption } from '../style/theme'; + +import { AmountInput, AmountInputProps } from './amount_input'; +import { Container, Text } from './ui'; + +export interface AssetAmountInputProps extends AmountInputProps { + assetData?: string; + onChange: (value?: BigNumber, assetData?: string) => void; +} + +export class AssetAmountInput extends React.Component { + public static defaultProps = { + onChange: _.noop.bind(_), + }; + public render(): React.ReactNode { + const { assetData, onChange, ...rest } = this.props; + return ( + + + + + {this._getLabel()} + + + + ); + } + private readonly _getLabel = (): string => { + const unknownLabel = '???'; + if (_.isUndefined(this.props.assetData)) { + return unknownLabel; + } + const metaData = assetMetaData[this.props.assetData]; + if (_.isUndefined(metaData)) { + return unknownLabel; + } + if (metaData.assetProxyId === AssetProxyId.ERC20) { + return metaData.symbol; + } + return unknownLabel; + }; + private readonly _handleChange = (value?: BigNumber): void => { + this.props.onChange(value, this.props.assetData); + }; +} diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 377bb20bf2..492c1b2c0f 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -43,14 +43,7 @@ export const InstantHeading: React.StatelessComponent = pro - - - - - zrx - - - + diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts index 75afc474a3..1fd321c5a0 100644 --- a/packages/instant/src/constants.ts +++ b/packages/instant/src/constants.ts @@ -1,6 +1,6 @@ import { BigNumber } from '@0xproject/utils'; export const BIG_NUMBER_ZERO = new BigNumber(0); export const sraApiUrl = 'https://api.radarrelay.com/0x/v2/'; -export const zrxContractAddress = '0xe41d2489571d322189246dafa5ebde1f4699f498'; +export const zrxAssetData = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; export const zrxDecimals = 18; export const ethDecimals = 18; diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index 9e3063eccb..f2ca96ae4f 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -5,14 +5,14 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { Dispatch } from 'redux'; -import { zrxContractAddress, zrxDecimals } from '../constants'; +import { zrxDecimals } from '../constants'; import { Action, actions } from '../redux/actions'; import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; import { AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; -import { AmountInput } from '../components/amount_input'; +import { AssetAmountInput } from '../components/asset_amount_input'; export interface SelectedAssetAmountInputProps { fontColor?: ColorOption; @@ -21,31 +21,40 @@ export interface SelectedAssetAmountInputProps { interface ConnectedState { value?: BigNumber; + assetData?: string; } interface ConnectedDispatch { - onChange?: (value?: BigNumber) => void; + onChange: (value?: BigNumber, assetData?: string) => void; } const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps): ConnectedState => ({ value: state.selectedAssetAmount, + assetData: state.selectedAssetData, }); -const updateBuyQuote = async (dispatch: Dispatch, assetAmount?: BigNumber): Promise => { - if (_.isUndefined(assetAmount)) { +const updateBuyQuoteAsync = async ( + dispatch: Dispatch, + assetData?: string, + assetAmount?: BigNumber, +): Promise => { + if (_.isUndefined(assetAmount) || _.isUndefined(assetData)) { return; } // get a new buy quote. const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); - const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(zrxContractAddress, baseUnitValue); + const newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue); // invalidate the last buy quote. dispatch(actions.updateLatestBuyQuote(newBuyQuote)); }; -const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true }); +const debouncedUpdateBuyQuoteAsync = _.debounce(updateBuyQuoteAsync, 200, { trailing: true }); -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - onChange: async value => { +const mapDispatchToProps = ( + dispatch: Dispatch, + _ownProps: SelectedAssetAmountInputProps, +): ConnectedDispatch => ({ + onChange: (value, assetData) => { // Update the input dispatch(actions.updateSelectedAssetAmount(value)); // invalidate the last buy quote. @@ -53,11 +62,11 @@ const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ // reset our buy state dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE)); // tslint:disable-next-line:no-floating-promises - debouncedUpdateBuyQuote(dispatch, value); + debouncedUpdateBuyQuoteAsync(dispatch, assetData, value); }, }); export const SelectedAssetAmountInput: React.ComponentClass = connect( mapStateToProps, mapDispatchToProps, -)(AmountInput); +)(AssetAmountInput); diff --git a/packages/instant/src/data/asset_meta_data.ts b/packages/instant/src/data/asset_meta_data.ts new file mode 100644 index 0000000000..e4d3e8f731 --- /dev/null +++ b/packages/instant/src/data/asset_meta_data.ts @@ -0,0 +1,15 @@ +import { AssetProxyId, ObjectMap } from '@0xproject/types'; + +import { zrxAssetData } from '../constants'; +import { AssetMetaData } from '../types'; + +// Map from assetData string to AssetMetaData object +// TODO: import this from somewhere else. +export const assetMetaData: ObjectMap = { + [zrxAssetData]: { + assetProxyId: AssetProxyId.ERC20, + decimals: 18, + primaryColor: 'rgb(54, 50, 60)', + symbol: 'zrx', + }, +}; diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index 56a4ee2368..adecf2ab70 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -2,11 +2,13 @@ import { BuyQuote } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; +import { zrxAssetData } from '../constants'; import { AsyncProcessState } from '../types'; import { Action, ActionTypes } from './actions'; export interface State { + selectedAssetData?: string; selectedAssetAmount?: BigNumber; selectedAssetBuyState: AsyncProcessState; ethUsdPrice?: BigNumber; @@ -14,9 +16,11 @@ export interface State { } export const INITIAL_STATE: State = { - ethUsdPrice: undefined, - selectedAssetBuyState: AsyncProcessState.NONE, + // TODO: Remove hardcoded zrxAssetData + selectedAssetData: zrxAssetData, selectedAssetAmount: undefined, + selectedAssetBuyState: AsyncProcessState.NONE, + ethUsdPrice: undefined, latestBuyQuote: undefined, }; diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index ffa5d679eb..bf3ee392f7 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -1,4 +1,4 @@ -import { ObjectMap } from '@0xproject/types'; +import { AssetProxyId, ObjectMap } from '@0xproject/types'; // Reusable export enum AsyncProcessState { @@ -11,3 +11,23 @@ export enum AsyncProcessState { export type FunctionType = (...args: any[]) => any; export type ActionCreatorsMapObject = ObjectMap; export type ActionsUnion = ReturnType; + +export interface ERC20AssetMetaData { + assetProxyId: AssetProxyId.ERC20; + decimals: number; + primaryColor?: string; + symbol: string; +} + +export interface ERC721AssetMetaData { + assetProxyId: AssetProxyId.ERC721; + name: string; + primaryColor?: string; +} + +export type AssetMetaData = ERC20AssetMetaData | ERC721AssetMetaData; + +export enum Network { + Kovan = 42, + Mainnet = 1, +} diff --git a/yarn.lock b/yarn.lock index 6e484d1f3e..65aab5e379 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5602,6 +5602,21 @@ ethers@3.0.22: uuid "2.0.1" xmlhttprequest "1.8.0" +ethers@4.0.0-beta.14: + version "4.0.0-beta.14" + resolved "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.14.tgz#76aa9257b9c93a7604ff4dc11f2a445d07f6459d" + dependencies: + "@types/node" "^10.3.2" + aes-js "3.0.0" + bn.js "^4.4.0" + elliptic "6.3.3" + hash.js "1.1.3" + js-sha3 "0.5.7" + scrypt-js "2.0.3" + setimmediate "1.0.4" + uuid "2.0.1" + xmlhttprequest "1.8.0" + ethers@~4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.4.tgz#d3f85e8b27f4b59537e06526439b0fb15b44dc65" From 43f8f2abbd0363cdccbd23fd698e87e2e5f45815 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 14:20:31 -0700 Subject: [PATCH 11/73] feat: add changelog entries for changed packages --- packages/asset-buyer/CHANGELOG.json | 4 ++++ packages/order-utils/CHANGELOG.json | 4 ++++ packages/types/CHANGELOG.json | 4 ++++ yarn.lock | 17 +---------------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index dbb801b691..cb364effaa 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -4,6 +4,10 @@ "changes": [ { "note": "Add `gasLimit` and `gasPrice` as optional properties on `BuyQuoteExecutionOpts`" + }, + { + "note": "Export `BuyQuoteInfo` type", + "pr": 1131 } ] }, diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 5a0c0db473..9bf16ef2a5 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -14,6 +14,10 @@ { "note": "Rename `ecSignOrderHashAsync` to `ecSignHashAsync` removing `SignerType` parameter.", "pr": 1102 + }, + { + "note": "Use `AssetData` union type for function return values.", + "pr": 1131 } ] }, diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index 53e1f3716e..106dc32816 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -9,6 +9,10 @@ { "note": "Added `ZeroExTransaction` type for Exchange executeTransaction", "pr": 1102 + }, + { + "note": "Add `AssetData` union type (`type AssetData = ERC20AssetData | ERC721AssetData`)", + "pr": 1131 } ] }, diff --git a/yarn.lock b/yarn.lock index 7604f7784d..97a7d3ccf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5594,21 +5594,6 @@ ethers@3.0.22: uuid "2.0.1" xmlhttprequest "1.8.0" -ethers@4.0.0-beta.14: - version "4.0.0-beta.14" - resolved "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.14.tgz#76aa9257b9c93a7604ff4dc11f2a445d07f6459d" - dependencies: - "@types/node" "^10.3.2" - aes-js "3.0.0" - bn.js "^4.4.0" - elliptic "6.3.3" - hash.js "1.1.3" - js-sha3 "0.5.7" - scrypt-js "2.0.3" - setimmediate "1.0.4" - uuid "2.0.1" - xmlhttprequest "1.8.0" - ethers@~4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.4.tgz#d3f85e8b27f4b59537e06526439b0fb15b44dc65" @@ -6401,7 +6386,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" From fcf345144835cf142da2cbca544151100791700f Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 17:06:06 -0700 Subject: [PATCH 12/73] Add tnxHash to buy button callbacks --- .../instant/src/components/asset_amount_input.tsx | 4 ++-- packages/instant/src/components/buy_button.tsx | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index 915c66e1ec..72bcfb8fb7 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -25,13 +25,13 @@ export class AssetAmountInput extends React.Component { - {this._getLabel()} + {this._getAssetSymbolLabel()} ); } - private readonly _getLabel = (): string => { + private readonly _getAssetSymbolLabel = (): string => { const unknownLabel = '???'; if (_.isUndefined(this.props.assetData)) { return unknownLabel; diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 097b8e5472..e9466619e1 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -11,8 +11,8 @@ import { Button, Container, Text } from './ui'; export interface BuyButtonProps { buyQuote?: BuyQuote; onClick: (buyQuote: BuyQuote) => void; - onBuySuccess: (buyQuote: BuyQuote) => void; - onBuyFailure: (buyQuote: BuyQuote) => void; + onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void; + onBuyFailure: (buyQuote: BuyQuote, tnxHash?: string) => void; text: string; } @@ -42,15 +42,13 @@ export class BuyButton extends React.Component { return; } this.props.onClick(this.props.buyQuote); + let txnHash; try { - const txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote, { - // HACK: There is a calculation issue in asset-buyer. ETH is refunded anyway so just over-estimate. - ethAmount: this.props.buyQuote.worstCaseQuoteInfo.totalEthAmount.mul(2), - }); + txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote); await web3Wrapper.awaitTransactionSuccessAsync(txnHash); + this.props.onBuySuccess(this.props.buyQuote, txnHash); } catch { - this.props.onBuyFailure(this.props.buyQuote); + this.props.onBuyFailure(this.props.buyQuote, txnHash); } - this.props.onBuySuccess(this.props.buyQuote); }; } From ac3bfdfe5ffc4fc49b88fbad062e1d562987e728 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 17:06:28 -0700 Subject: [PATCH 13/73] Put boundNoop in a util file --- packages/instant/src/components/amount_input.tsx | 3 ++- packages/instant/src/components/asset_amount_input.tsx | 3 ++- packages/instant/src/components/buy_button.tsx | 9 ++++----- packages/instant/src/util/util.ts | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 packages/instant/src/util/util.ts diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 5b81a3d683..7644f5f677 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -3,6 +3,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { ColorOption } from '../style/theme'; +import { util } from '../util/util'; import { Container, Input } from './ui'; @@ -15,7 +16,7 @@ export interface AmountInputProps { export class AmountInput extends React.Component { public static defaultProps = { - onChange: _.noop.bind(_), + onChange: util.boundNoop, }; public render(): React.ReactNode { const { fontColor, fontSize, value } = this.props; diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index 72bcfb8fb7..7c6b03ee90 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -5,6 +5,7 @@ import * as React from 'react'; import { assetMetaData } from '../data/asset_meta_data'; import { ColorOption } from '../style/theme'; +import { util } from '../util/util'; import { AmountInput, AmountInputProps } from './amount_input'; import { Container, Text } from './ui'; @@ -16,7 +17,7 @@ export interface AssetAmountInputProps extends AmountInputProps { export class AssetAmountInput extends React.Component { public static defaultProps = { - onChange: _.noop.bind(_), + onChange: util.boundNoop, }; public render(): React.ReactNode { const { assetData, onChange, ...rest } = this.props; diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index e9466619e1..0706817c97 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { ColorOption } from '../style/theme'; import { assetBuyer } from '../util/asset_buyer'; +import { util } from '../util/util'; import { web3Wrapper } from '../util/web3_wrapper'; import { Button, Container, Text } from './ui'; @@ -16,13 +17,11 @@ export interface BuyButtonProps { text: string; } -const boundNoop = _.noop.bind(_); - export class BuyButton extends React.Component { public static defaultProps = { - onClick: boundNoop, - onBuySuccess: boundNoop, - onBuyFailure: boundNoop, + onClick: util.boundNoop, + onBuySuccess: util.boundNoop, + onBuyFailure: util.boundNoop, }; public render(): React.ReactNode { const shouldDisableButton = _.isUndefined(this.props.buyQuote); diff --git a/packages/instant/src/util/util.ts b/packages/instant/src/util/util.ts new file mode 100644 index 0000000000..232a868503 --- /dev/null +++ b/packages/instant/src/util/util.ts @@ -0,0 +1,5 @@ +import * as _ from 'lodash'; + +export const util = { + boundNoop: _.noop.bind(_), +}; From f8edef66e4eed8fbf26d85b244bf73cae86bc736 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 15 Oct 2018 17:22:15 -0700 Subject: [PATCH 14/73] fix: add Steve's github account to about page, and capitalize AppFolio correctly --- packages/website/ts/pages/about/about.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index 2629f86328..3ede56a718 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -244,9 +244,10 @@ const teamRow9: ProfileInfo[] = [ { name: 'Steve Klebanoff', title: 'Senior Engineer', - description: ` Full-stack engineer. Previously Staff Software Engineer at Appfolio. Computer Science & Cognitive Psychology at Northeastern University.`, + description: ` Full-stack engineer. Previously Staff Software Engineer at AppFolio. Computer Science & Cognitive Psychology at Northeastern University.`, image: 'images/team/steve.png', linkedIn: 'https://www.linkedin.com/in/steveklebanoff/', + github: 'https://github.com/steveklebanoff', }, ]; From fa18db84d976644270adf0815c73a8d6f40cf9a8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 17:33:27 -0700 Subject: [PATCH 15/73] Rename OrderDetailsRow to EthAmountRow --- .../instant/src/components/order_details.tsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index 66e7e24062..9256d1398b 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -32,15 +32,15 @@ export class OrderDetails extends React.Component { Order Details - - - + { } } -export interface OrderDetailsRowProps { - name: string; +export interface EthAmountRowProps { + rowLabel: string; ethAmount?: BigNumber; - shouldConvertEthToUnitAmount?: boolean; + isEthAmountInBaseUnits?: boolean; ethUsdPrice?: BigNumber; shouldEmphasize?: boolean; } -export const OrderDetailsRow: React.StatelessComponent = ({ - name, +export const EthAmountRow: React.StatelessComponent = ({ + rowLabel, ethAmount, - shouldConvertEthToUnitAmount, + isEthAmountInBaseUnits, ethUsdPrice, shouldEmphasize, }) => { const fontWeight = shouldEmphasize ? 700 : 400; - const usdFormatter = shouldConvertEthToUnitAmount ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd; - const ethFormatter = shouldConvertEthToUnitAmount ? format.ethBaseAmount : format.ethUnitAmount; + const usdFormatter = isEthAmountInBaseUnits ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd; + const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseAmount : format.ethUnitAmount; return ( - {name} + {rowLabel} @@ -87,9 +87,9 @@ export const OrderDetailsRow: React.StatelessComponent = ( ); }; -OrderDetailsRow.defaultProps = { +EthAmountRow.defaultProps = { shouldEmphasize: false, - shouldConvertEthToUnitAmount: true, + isEthAmountInBaseUnits: true, }; -OrderDetailsRow.displayName = 'OrderDetailsRow'; +EthAmountRow.displayName = 'EthAmountRow'; From 18667d739c112955478ab07cb245dc435b31a974 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 17:39:52 -0700 Subject: [PATCH 16/73] Hide USD price when ETH-USD price is not available --- packages/instant/src/components/order_details.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index 9256d1398b..bd31bfba83 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -68,6 +68,11 @@ export const EthAmountRow: React.StatelessComponent = ({ const fontWeight = shouldEmphasize ? 700 : 400; const usdFormatter = isEthAmountInBaseUnits ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd; const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseAmount : format.ethUnitAmount; + const usdPriceSection = _.isUndefined(ethUsdPrice) ? null : ( + + ({usdFormatter(ethAmount, ethUsdPrice)}) + + ); return ( @@ -75,9 +80,7 @@ export const EthAmountRow: React.StatelessComponent = ({ {rowLabel} - - ({usdFormatter(ethAmount, ethUsdPrice)}) - + {usdPriceSection} {ethFormatter(ethAmount)} From f2e5fd88469c9e3396197b42298d0b2de8a4d47c Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 18:07:19 -0700 Subject: [PATCH 17/73] Add ts-optchain and use it instead of lodash get --- packages/instant/package.json | 3 +- .../instant/src/components/order_details.tsx | 8 ++-- .../latest_buy_quote_order_details.ts | 3 +- .../selected_asset_instant_heading.ts | 3 +- yarn.lock | 43 ++++++++++++++++++- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/packages/instant/package.json b/packages/instant/package.json index 35cc39d278..7203e3c96d 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -56,7 +56,8 @@ "react-dom": "^16.5.2", "react-redux": "^5.0.7", "redux": "^4.0.0", - "styled-components": "^3.4.9" + "styled-components": "^3.4.9", + "ts-optchain": "^0.1.1" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.8", diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index bd31bfba83..a15ff411b2 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -2,6 +2,7 @@ import { BuyQuoteInfo } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; +import { oc } from 'ts-optchain'; import { ColorOption } from '../style/theme'; import { format } from '../util/format'; @@ -16,9 +17,10 @@ export interface OrderDetailsProps { export class OrderDetails extends React.Component { public render(): React.ReactNode { const { buyQuoteInfo, ethUsdPrice } = this.props; - const ethAssetPrice = _.get(buyQuoteInfo, 'ethPerAssetPrice'); - const ethTokenFee = _.get(buyQuoteInfo, 'feeEthAmount'); - const totalEthAmount = _.get(buyQuoteInfo, 'totalEthAmount'); + const buyQuoteAccessor = oc(buyQuoteInfo); + const ethAssetPrice = buyQuoteAccessor.ethPerAssetPrice(); + const ethTokenFee = buyQuoteAccessor.feeEthAmount(); + const totalEthAmount = buyQuoteAccessor.totalEthAmount(); return ( diff --git a/packages/instant/src/containers/latest_buy_quote_order_details.ts b/packages/instant/src/containers/latest_buy_quote_order_details.ts index 77d84289bc..b354c78fa5 100644 --- a/packages/instant/src/containers/latest_buy_quote_order_details.ts +++ b/packages/instant/src/containers/latest_buy_quote_order_details.ts @@ -3,6 +3,7 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; +import { oc } from 'ts-optchain'; import { State } from '../redux/reducer'; @@ -17,7 +18,7 @@ interface ConnectedState { const mapStateToProps = (state: State, _ownProps: LatestBuyQuoteOrderDetailsProps): ConnectedState => ({ // use the worst case quote info - buyQuoteInfo: _.get(state, 'latestBuyQuote.worstCaseQuoteInfo'), + buyQuoteInfo: oc(state).latestBuyQuote.worstCaseQuoteInfo(), ethUsdPrice: state.ethUsdPrice, }); diff --git a/packages/instant/src/containers/selected_asset_instant_heading.ts b/packages/instant/src/containers/selected_asset_instant_heading.ts index a9e853fe1e..c97cfe11ab 100644 --- a/packages/instant/src/containers/selected_asset_instant_heading.ts +++ b/packages/instant/src/containers/selected_asset_instant_heading.ts @@ -2,6 +2,7 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; +import { oc } from 'ts-optchain'; import { State } from '../redux/reducer'; @@ -17,7 +18,7 @@ interface ConnectedState { const mapStateToProps = (state: State, _ownProps: InstantHeadingProps): ConnectedState => ({ selectedAssetAmount: state.selectedAssetAmount, - totalEthBaseAmount: _.get(state, 'latestBuyQuote.worstCaseQuoteInfo.totalEthAmount'), + totalEthBaseAmount: oc(state).latestBuyQuote.worstCaseQuoteInfo.totalEthAmount(), ethUsdPrice: state.ethUsdPrice, }); diff --git a/yarn.lock b/yarn.lock index 97a7d3ccf6..7915f8aa04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1592,6 +1592,10 @@ aes-js@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" +aes-js@^3.1.1: + version "3.1.1" + resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" + ajv-errors@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" @@ -2992,7 +2996,7 @@ bs-logger@0.x: dependencies: fast-json-stable-stringify "^2.0.0" -bs58@=4.0.1: +bs58@=4.0.1, bs58@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" dependencies: @@ -3015,6 +3019,14 @@ bs58check@^1.0.8: bs58 "^3.1.0" create-hash "^1.1.0" +bs58check@^2.1.2: + version "2.1.2" + resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" + dependencies: + bs58 "^4.0.0" + create-hash "^1.1.0" + safe-buffer "^5.1.2" + bser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -5579,6 +5591,19 @@ ethereumjs-wallet@0.6.0: utf8 "^2.1.1" uuid "^2.0.1" +ethereumjs-wallet@~0.6.0: + version "0.6.2" + resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" + dependencies: + aes-js "^3.1.1" + bs58check "^2.1.2" + ethereumjs-util "^5.2.0" + hdkey "^1.0.0" + safe-buffer "^5.1.2" + scrypt.js "^0.2.0" + utf8 "^3.0.0" + uuid "^3.3.2" + ethers@3.0.22: version "3.0.22" resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" @@ -7073,6 +7098,14 @@ hdkey@^0.7.0, hdkey@^0.7.1: 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" @@ -14708,6 +14741,10 @@ ts-node@^7.0.0: source-map-support "^0.5.6" yn "^2.0.0" +ts-optchain@^0.1.1: + version "0.1.1" + resolved "https://registry.npmjs.org/ts-optchain/-/ts-optchain-0.1.1.tgz#9d45e2c3fc6201c2f9be82edad4c76fefb2a36d9" + tslib@1.9.0, tslib@^1.8.0, tslib@^1.8.1: version "1.9.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" @@ -15216,6 +15253,10 @@ 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" From 875f621f20431389131730536afe578a1060152a Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 18:13:09 -0700 Subject: [PATCH 18/73] Remove expiry buffer seconds option from AssetBuyer init --- packages/instant/src/util/asset_buyer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/instant/src/util/asset_buyer.ts b/packages/instant/src/util/asset_buyer.ts index b030501c4b..27d66d6002 100644 --- a/packages/instant/src/util/asset_buyer.ts +++ b/packages/instant/src/util/asset_buyer.ts @@ -6,6 +6,4 @@ import { getProvider } from './provider'; const provider = getProvider(); -export const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, sraApiUrl, { - expiryBufferSeconds: 300, -}); +export const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, sraApiUrl); From 7aab4d10defc06bf96bb0510bee1bb929b1d2245 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 12 Oct 2018 15:07:04 -0700 Subject: [PATCH 19/73] feat(asset-buyer): add hooks for documentation --- package.json | 2 +- packages/asset-buyer/CHANGELOG.json | 8 ++++++++ packages/asset-buyer/package.json | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 031f73ba82..9d5337164b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "config": { "mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic", - "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types" + "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types asset-buyer" }, "bundlewatch" : { "files": [ diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index b50fe2c63f..0d50b7bc33 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -9,6 +9,14 @@ "note": "Updated to use new modularized artifacts and the latest version of @0xproject/contract-wrappers", "pr": 1105 + }, + { + "note": "Add `gasLimit` and `gasPrice` as optional properties on `BuyQuoteExecutionOpts`", + "pr": 1116 + }, + { + "note": "Add `docs:json` command to package.json", + "pr": 1139 } ] }, diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 8c8f3c92c8..13de96e6b2 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -17,7 +17,8 @@ "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" + "clean": "shx rm -rf lib test_temp", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" }, "config": { "postpublish": { From 4976b3473893befeb538c57ca6f8010722addd07 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 15 Oct 2018 10:27:57 -0700 Subject: [PATCH 20/73] feat(asset-buyer): add missing types to public interface --- packages/asset-buyer/CHANGELOG.json | 4 ++++ packages/asset-buyer/src/index.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index 0d50b7bc33..52a8d0d0df 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -17,6 +17,10 @@ { "note": "Add `docs:json` command to package.json", "pr": 1139 + }, + { + "note": "Add missing types to public interface", + "pr": 1139 } ] }, diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 2da2724d74..9ac3c0b8ae 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -1,4 +1,10 @@ -export { Provider } from 'ethereum-types'; +export { + JSONRPCRequestPayload, + JSONRPCResponsePayload, + JSONRPCResponseError, + JSONRPCErrorCallback, + Provider, +} from 'ethereum-types'; export { SignedOrder } from '@0xproject/types'; export { BigNumber } from '@0xproject/utils'; @@ -10,6 +16,7 @@ export { AssetBuyerOpts, BuyQuote, BuyQuoteExecutionOpts, + BuyQuoteInfo, BuyQuoteRequestOpts, OrderProvider, OrderProviderRequest, From 2c286ad897d7ae9f2dcc48919033fb0d1c026641 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 15 Oct 2018 10:51:38 -0700 Subject: [PATCH 21/73] feat(monorepo-scripts): add AssetBuyerError to IGNORED_EXCESSIVE_TYPES --- packages/monorepo-scripts/CHANGELOG.json | 8 ++++++++ packages/monorepo-scripts/src/doc_gen_configs.ts | 8 +++++++- .../src/utils/doc_generate_and_upload_utils.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 3b8684fab0..4fd87c1d83 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "1.0.6", + "changes": [ + { + "note": "Add AssetBuyerError to the IGNORED_EXCESSIVE_TYPES array" + } + ] + }, { "timestamp": 1534210131, "version": "1.0.5", diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts index e3ddeddc9e..3d5c97dc48 100644 --- a/packages/monorepo-scripts/src/doc_gen_configs.ts +++ b/packages/monorepo-scripts/src/doc_gen_configs.ts @@ -43,7 +43,13 @@ export const docGenConfigs: DocGenConfigs = { // Some types are not explicitly part of the public interface like params, return values, etc... But we still // want them exported. E.g error enum types that can be thrown by methods. These must be manually added to this // config - IGNORED_EXCESSIVE_TYPES: ['NonceSubproviderErrors', 'Web3WrapperErrors', 'ContractWrappersError', 'OrderError'], + IGNORED_EXCESSIVE_TYPES: [ + 'NonceSubproviderErrors', + 'Web3WrapperErrors', + 'ContractWrappersError', + 'OrderError', + 'AssetBuyerError', + ], // Some libraries only export types. In those cases, we cannot check if the exported types are part of the // "exported public interface". Thus we add them here and skip those checks. TYPES_ONLY_LIBRARIES: ['ethereum-types', 'types'], diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index 4fea94414d..547b65eeb7 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -331,7 +331,7 @@ export class DocGenerateAndUploadUtils { throw new Error( `${this._packageName} package exports BUT does not need: \n${excessiveReferencesExceptIgnored.join( '\n', - )} \nin it\'s index.ts. Remove them then try again.`, + )} \nin it\'s index.ts. Remove them then try again OR if we still want them exported (e.g error enum types), then add them to the IGNORED_EXCESSIVE_TYPES array.`, ); } } From 55be070dcfd7b9704ba24bc387bca0001f0c47f5 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 15 Oct 2018 22:28:29 -0700 Subject: [PATCH 22/73] feat(monorepo-scripts): add AssetBuyer to CLASSES_WITH_HIDDEN_CONSTRUCTORS --- packages/monorepo-scripts/src/doc_gen_configs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts index 3d5c97dc48..b5a36376aa 100644 --- a/packages/monorepo-scripts/src/doc_gen_configs.ts +++ b/packages/monorepo-scripts/src/doc_gen_configs.ts @@ -30,6 +30,7 @@ export const docGenConfigs: DocGenConfigs = { // factory method which instantiates an instance of a class, but we don't want users instantiating it themselves // and getting confused. Any class name in this list will not have it's constructor rendered in our docs. CLASSES_WITH_HIDDEN_CONSTRUCTORS: [ + 'AssetBuyer', 'ERC20ProxyWrapper', 'ERC20TokenWrapper', 'ERC721ProxyWrapper', From aa1085c8f3866da4965c0102be27c0f5e19b3db6 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 15 Oct 2018 23:27:56 -0700 Subject: [PATCH 23/73] feat(website): add asset-buyer documentation --- .../md/docs/asset_buyer/installation.md | 17 +++++ .../md/docs/asset_buyer/introduction.md | 1 + packages/website/md/docs/asset_buyer/usage.md | 39 +++++++++++ packages/website/translations/english.json | 1 + .../website/ts/components/top_bar/top_bar.tsx | 7 ++ .../containers/asset_buyer_documentation.ts | 69 +++++++++++++++++++ packages/website/ts/index.tsx | 8 ++- .../ts/pages/documentation/doc_page.tsx | 1 + packages/website/ts/types.ts | 3 + 9 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 packages/website/md/docs/asset_buyer/installation.md create mode 100644 packages/website/md/docs/asset_buyer/introduction.md create mode 100644 packages/website/md/docs/asset_buyer/usage.md create mode 100644 packages/website/ts/containers/asset_buyer_documentation.ts diff --git a/packages/website/md/docs/asset_buyer/installation.md b/packages/website/md/docs/asset_buyer/installation.md new file mode 100644 index 0000000000..483ee2b652 --- /dev/null +++ b/packages/website/md/docs/asset_buyer/installation.md @@ -0,0 +1,17 @@ +**Install** + +```bash +yarn add @0xproject/asset-buyer +``` + +**Import** + +```javascript +import { AssetBuyer } from '@0xproject/asset-buyer'; +``` + +or + +```javascript +var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer; +``` diff --git a/packages/website/md/docs/asset_buyer/introduction.md b/packages/website/md/docs/asset_buyer/introduction.md new file mode 100644 index 0000000000..a40d20cc9f --- /dev/null +++ b/packages/website/md/docs/asset_buyer/introduction.md @@ -0,0 +1 @@ +Welcome to the [@0xproject/asset-buyer](https://github.com/0xProject/0x-monorepo/tree/development/packages/asset-buyer) documentation! AssetBuyer is a library that provides an easy way to buy any asset with ETH in one click, leveraging 0x liquidity and the [Forwarder contract](https://0xproject.com/docs/contracts#Forwarder). diff --git a/packages/website/md/docs/asset_buyer/usage.md b/packages/website/md/docs/asset_buyer/usage.md new file mode 100644 index 0000000000..93c681f409 --- /dev/null +++ b/packages/website/md/docs/asset_buyer/usage.md @@ -0,0 +1,39 @@ +**Construction** + +Connecting to a standard relayer API compliant url: + +```typescript +const provider = web3.currentProvider; +const apiUrl = 'https://api.relayer.com/v2'; +const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, apiUrl); +``` + +Providing your own orders: + +```typescript +const provider = web3.currentProvider; +const orders = []; // get these from your own API, a relayer, a friend, from anywhere +const assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, orders); +``` + +**Get a quote** + +A [BuyQuote](#types-BuyQuote) object contains enough information to display buy information to an end user + +```typescript +const erc20TokenAddress = '0x5fa3c....'; +const amountToBuy = new BigNumber(50000000000000000000); +const buyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(erc20TokenAddress, amountToBuy); +const quoteInfo = buyQuote.worstCaseQuoteInfo; +console.log(quoteInfo.ethAmount); // the total amount the user needs to pay to buy the desired amount (including fees) +console.log(quoteInfo.feeAmount); // a portion of the total ethAmount above that was used to buy fees +console.log(quoteInfo.ethPerAssetPrice); // the rate that this quote provides (e.g. 0.0035ETH / REP) +``` + +**Perform a buy** + +Pass the [BuyQuote](#types-BuyQuote) object from above back to the assetBuyer in order to initiate the buy transaction + +```typescript +const txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote); // the hash of the transaction submitted to the Ethereum network +``` diff --git a/packages/website/translations/english.json b/packages/website/translations/english.json index 9ce458111f..ac8e4900ac 100644 --- a/packages/website/translations/english.json +++ b/packages/website/translations/english.json @@ -73,6 +73,7 @@ "WIKI": "wiki", "WEB3_WRAPPER": "Web3Wrapper", "ORDER_UTILS": "Order Utils", + "ASSET_BUYER": "AssetBuyer", "FAQ": "FAQ", "SMART_CONTRACTS": "0x smart contracts", "STANDARD_RELAYER_API": "standard relayer API", diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 7cf3c6ecb6..fe2c1fcf91 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -92,6 +92,7 @@ const DOC_WEBSITE_PATHS_TO_KEY = { [WebsitePaths.ZeroExJs]: Key.ZeroExJs, [WebsitePaths.OrderUtils]: Key.OrderUtils, [WebsitePaths.OrderWatcher]: Key.OrderWatcher, + [WebsitePaths.AssetBuyer]: Key.AssetBuyer, }; const DEFAULT_HEIGHT = 68; @@ -214,6 +215,12 @@ export class TopBar extends React.Component { primaryText={this.props.translate.get(Key.EthereumTypes, Deco.CapWords)} /> , + + + , ({ + docsVersion: state.docsVersion, + availableDocVersions: state.availableDocVersions, + translate: state.translate, + docsInfo, +}); + +const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ + dispatcher: new Dispatcher(dispatch), +}); + +export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index d4a79cc4f3..bb218eac17 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -68,6 +68,9 @@ const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async ( const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', async () => import(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'), ); +const LazyAssetBuyerDocumentation = createLazyComponent('Documentation', async () => + import(/* webpackChunkName: "assetBuyerDocs" */ 'ts/containers/asset_buyer_documentation'), +); const DOCUMENT_TITLE = '0x: The Protocol for Trading Tokens'; const DOCUMENT_DESCRIPTION = 'An Open Protocol For Decentralized Exchange On The Ethereum Blockchain'; @@ -133,7 +136,10 @@ render( path={`${WebsitePaths.EthereumTypes}/:version?`} component={LazyEthereumTypesDocumentation} /> - + {/* Legacy endpoints */} Date: Tue, 16 Oct 2018 16:13:23 -0700 Subject: [PATCH 24/73] Add tests for format and use toFixed instead of round for usd --- packages/instant/package.json | 1 + packages/instant/src/util/format.ts | 2 +- packages/instant/test/util/format.test.ts | 97 +++++++++++++++++++++++ yarn.lock | 4 + 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 packages/instant/test/util/format.test.ts diff --git a/packages/instant/package.json b/packages/instant/package.json index befedfc179..b991d0e053 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -63,6 +63,7 @@ "@0xproject/tslint-config": "^1.0.8", "@types/enzyme": "^3.1.14", "@types/enzyme-adapter-react-16": "^1.0.3", + "@types/jest": "^23.3.5", "@types/lodash": "^4.14.116", "@types/node": "*", "@types/react": "^16.4.16", diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts index de7eb62e65..b62c968fb4 100644 --- a/packages/instant/src/util/format.ts +++ b/packages/instant/src/util/format.ts @@ -40,6 +40,6 @@ export const format = { if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) { return defaultText; } - return `$${ethUnitAmount.mul(ethUsdPrice).round(decimalPlaces)}`; + return `$${ethUnitAmount.mul(ethUsdPrice).toFixed(decimalPlaces)}`; }, }; diff --git a/packages/instant/test/util/format.test.ts b/packages/instant/test/util/format.test.ts new file mode 100644 index 0000000000..073b86b19a --- /dev/null +++ b/packages/instant/test/util/format.test.ts @@ -0,0 +1,97 @@ +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; + +import { ethDecimals } from '../../src/constants'; +import { format } from '../../src/util/format'; + +const BIG_NUMBER_ONE = new BigNumber(1); +const BIG_NUMBER_DECIMAL = new BigNumber(0.432414); +const BIG_NUMBER_IRRATIONAL = new BigNumber(5.3014059295032); +const ONE_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_ONE, ethDecimals); +const DECIMAL_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_DECIMAL, ethDecimals); +const IRRATIONAL_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_IRRATIONAL, ethDecimals); +const BIG_NUMBER_FAKE_ETH_USD_PRICE = new BigNumber(2.534); + +describe('format', () => { + describe('ethBaseAmount', () => { + it('converts 1 ETH in base units to the string `1 ETH`', () => { + expect(format.ethBaseAmount(ONE_ETH_IN_BASE_UNITS)).toBe('1 ETH'); + }); + it('converts .432414 ETH in base units to the string `.4324 ETH`', () => { + expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS)).toBe('0.4324 ETH'); + }); + it('converts 5.3014059295032 ETH in base units to the string `5.3014 ETH`', () => { + expect(format.ethBaseAmount(IRRATIONAL_ETH_IN_BASE_UNITS)).toBe('5.3014 ETH'); + }); + it('returns defaultText param when ethBaseAmount is not defined', () => { + const defaultText = 'defaultText'; + expect(format.ethBaseAmount(undefined, 4, defaultText)).toBe(defaultText); + }); + it('it allows for configurable decimal places', () => { + expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS, 2)).toBe('0.43 ETH'); + }); + }); + describe('ethUnitAmount', () => { + it('converts BigNumber(1) to the string `1 ETH`', () => { + expect(format.ethUnitAmount(BIG_NUMBER_ONE)).toBe('1 ETH'); + }); + it('converts BigNumer(.432414) to the string `.4324 ETH`', () => { + expect(format.ethUnitAmount(BIG_NUMBER_DECIMAL)).toBe('0.4324 ETH'); + }); + it('converts BigNumber(5.3014059295032) to the string `5.3014 ETH`', () => { + expect(format.ethUnitAmount(BIG_NUMBER_IRRATIONAL)).toBe('5.3014 ETH'); + }); + it('returns defaultText param when ethUnitAmount is not defined', () => { + const defaultText = 'defaultText'; + expect(format.ethUnitAmount(undefined, 4, defaultText)).toBe(defaultText); + expect(format.ethUnitAmount(BIG_NUMBER_ONE, 4, defaultText)).toBe('1 ETH'); + }); + it('it allows for configurable decimal places', () => { + expect(format.ethUnitAmount(BIG_NUMBER_DECIMAL, 2)).toBe('0.43 ETH'); + }); + }); + describe('ethBaseAmountInUsd', () => { + it('correctly formats 1 ETH to usd according to some price', () => { + expect(format.ethBaseAmountInUsd(ONE_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53'); + }); + it('correctly formats .432414 ETH to usd according to some price', () => { + expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$1.10'); + }); + it('correctly formats 5.3014059295032 ETH to usd according to some price', () => { + expect(format.ethBaseAmountInUsd(IRRATIONAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe( + '$13.43', + ); + }); + it('returns defaultText param when ethBaseAmountInUsd or ethUsdPrice is not defined', () => { + const defaultText = 'defaultText'; + expect(format.ethBaseAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText); + expect(format.ethBaseAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText); + expect(format.ethBaseAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText); + }); + it('it allows for configurable decimal places', () => { + expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe( + '$1.0957', + ); + }); + }); + describe('ethUnitAmountInUsd', () => { + it('correctly formats 1 ETH to usd according to some price', () => { + expect(format.ethUnitAmountInUsd(BIG_NUMBER_ONE, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53'); + }); + it('correctly formats .432414 ETH to usd according to some price', () => { + expect(format.ethUnitAmountInUsd(BIG_NUMBER_DECIMAL, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$1.10'); + }); + it('correctly formats 5.3014059295032 ETH to usd according to some price', () => { + expect(format.ethUnitAmountInUsd(BIG_NUMBER_IRRATIONAL, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$13.43'); + }); + it('returns defaultText param when ethUnitAmountInUsd or ethUsdPrice is not defined', () => { + const defaultText = 'defaultText'; + expect(format.ethUnitAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText); + expect(format.ethUnitAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText); + expect(format.ethUnitAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText); + }); + it('it allows for configurable decimal places', () => { + expect(format.ethUnitAmountInUsd(BIG_NUMBER_DECIMAL, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe('$1.0957'); + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index af3f9938b1..82b5743b66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1022,6 +1022,10 @@ version "0.4.30" resolved "https://registry.yarnpkg.com/@types/istanbul/-/istanbul-0.4.30.tgz#073159320ab3296b2cfeb481f756a1f8f4c9c8e4" +"@types/jest@^23.3.5": + version "23.3.5" + resolved "https://registry.npmjs.org/@types/jest/-/jest-23.3.5.tgz#870a1434208b60603745bfd214fc3fc675142364" + "@types/js-combinatorics@^0.5.29": version "0.5.29" resolved "https://registry.yarnpkg.com/@types/js-combinatorics/-/js-combinatorics-0.5.29.tgz#47a7819a0b6925b6dc4bd2c2278a7e6329b29387" From c3286163300d4213edde1a9d6d1b717e4f3d059f Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 16:20:23 -0700 Subject: [PATCH 25/73] Run tests on circle CI --- .circleci/config.yml | 1 + .../instant/test/components/zero_ex_instant.test.tsx | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 876b861d30..1cf665cce7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,6 +98,7 @@ jobs: - run: yarn wsrun test:circleci @0xproject/subproviders - run: yarn wsrun test:circleci @0xproject/web3-wrapper - run: yarn wsrun test:circleci @0xproject/utils + - run: yarn wsrun test:circleci @0xproject/instant - save_cache: key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }} paths: diff --git a/packages/instant/test/components/zero_ex_instant.test.tsx b/packages/instant/test/components/zero_ex_instant.test.tsx index 5858732cfb..e373bb002d 100644 --- a/packages/instant/test/components/zero_ex_instant.test.tsx +++ b/packages/instant/test/components/zero_ex_instant.test.tsx @@ -4,10 +4,12 @@ import * as React from 'react'; configure({ adapter: new Adapter() }); -import { ZeroExInstant } from '../../src'; - -describe('', () => { - it('shallow renders without crashing', () => { - shallow(); +// TODO: Write non-trivial tests. +// At time of writing we cannot render ZeroExInstant +// because we are looking for a provider on window. +// But in the future it will be dependency injected. +describe('', () => { + it('runs a test', () => { + shallow(
); }); }); From 6a89935e3bcfb72c053198213ff30eff6246163d Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 16:58:21 -0700 Subject: [PATCH 26/73] Remove order-utils from dependencies --- packages/instant/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/instant/package.json b/packages/instant/package.json index b991d0e053..203ac48943 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -44,7 +44,6 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { "@0xproject/asset-buyer": "^2.0.0", - "@0xproject/order-utils": "^1.0.7", "@0xproject/types": "^1.1.4", "@0xproject/typescript-typings": "^2.0.2", "@0xproject/utils": "^2.0.2", From d2adbc364769719abc2010aa862c27553899a96b Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 16:59:53 -0700 Subject: [PATCH 27/73] chore: temporarily increase the bundle size for instant --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 031f73ba82..043c7a0ca2 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, { "path": "packages/instant/public/main.bundle.js", - "maxSize": "350kB" + "maxSize": "400kB" } ], "ci": { From 009b5b575c35b1f09f690eee46b4d274caeebfcb Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 17:00:18 -0700 Subject: [PATCH 28/73] feat: export AssetData from utils --- packages/0x.js/CHANGELOG.json | 4 ++++ packages/0x.js/src/index.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 4efd8f035d..98791139fb 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -24,6 +24,10 @@ { "note": "Make web3-provider-engine types a 'dependency' so it's available to users of the library", "pr": 1105 + }, + { + "note": "Export new `AssetData` type from types", + "pr": 1131 } ] }, diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 7fd48da378..2fcfb5ce7c 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -79,6 +79,7 @@ export { OrderStateInvalid, OrderState, AssetProxyId, + AssetData, ERC20AssetData, ERC721AssetData, SignatureType, From 8ba65346d410c5e5a636b1c8626bfdf611b800e9 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 17:00:53 -0700 Subject: [PATCH 29/73] feat: export AssetData from order-utils --- packages/order-utils/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts index dbb782b857..a356a1d447 100644 --- a/packages/order-utils/src/index.ts +++ b/packages/order-utils/src/index.ts @@ -35,6 +35,7 @@ export { OrderRelevantState, OrderState, ECSignature, + AssetData, ERC20AssetData, ERC721AssetData, AssetProxyId, From eda0b3e693783e0865dcdb00ff24e004381ae17f Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 17:48:25 -0700 Subject: [PATCH 30/73] fix: dont use enum string as type as typedoc gets confused --- packages/types/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index c038df50c1..3c9b6bbc58 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -158,12 +158,12 @@ export enum AssetProxyId { } export interface ERC20AssetData { - assetProxyId: AssetProxyId.ERC20; + assetProxyId: string; tokenAddress: string; } export interface ERC721AssetData { - assetProxyId: AssetProxyId.ERC721; + assetProxyId: string; tokenAddress: string; tokenId: BigNumber; } From 32beeae2f0fa4538f12036aca8dd8d30b1de8bc9 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 16 Oct 2018 18:03:13 -0700 Subject: [PATCH 31/73] Bump max bundle size for instant --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 043c7a0ca2..fd4035b1c3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ }, { "path": "packages/instant/public/main.bundle.js", - "maxSize": "400kB" + "maxSize": "500kB" } ], "ci": { From 0013bafc62571bc81f2984974c4893c3770b1786 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Wed, 17 Oct 2018 14:14:48 +1100 Subject: [PATCH 32/73] fix(monorepo-scripts): Format date as UTC not local time. Down under is in the future and causes many conflicts when formatting the timestamp in the local context. All previous releases jumped a day ahead. By setting this to UTC we will have consistent formatted dates in the changelogs no matter where one publishes from. npm-cli-login fails on node 10 as a deprecation in node 9 has finished. This package appears to be unmaintained so we now have a fork with a fix --- package.json | 2 +- packages/monorepo-scripts/CHANGELOG.json | 9 +++++++++ .../monorepo-scripts/src/utils/changelog_utils.ts | 3 ++- yarn.lock | 14 +++++++------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 031f73ba82..15fb8df646 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "coveralls": "^3.0.0", "ganache-cli": "6.1.8", "lcov-result-merger": "^3.0.0", - "npm-cli-login": "^0.0.10", + "@0xproject/npm-cli-login": "^0.0.11", "npm-run-all": "^4.1.2", "prettier": "^1.11.1", "source-map-support": "^0.5.6", diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 3b8684fab0..cf7a22bb7c 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "1.0.6", + "changes": [ + { + "note": "Render date formats in UTC to prevent conflicts when publishing in different timezones.", + "pr": 1143 + } + ] + }, { "timestamp": 1534210131, "version": "1.0.5", diff --git a/packages/monorepo-scripts/src/utils/changelog_utils.ts b/packages/monorepo-scripts/src/utils/changelog_utils.ts index 8058d222bd..0b46bf670d 100644 --- a/packages/monorepo-scripts/src/utils/changelog_utils.ts +++ b/packages/monorepo-scripts/src/utils/changelog_utils.ts @@ -19,7 +19,8 @@ CHANGELOG export const changelogUtils = { getChangelogMdTitle(versionChangelog: VersionChangelog): string { - const date = moment(`${versionChangelog.timestamp}`, 'X').format('MMMM D, YYYY'); + // Use UTC rather than the local machines time (formatted date time is +0:00) + const date = moment.utc(`${versionChangelog.timestamp}`, 'X').format('MMMM D, YYYY'); const title = `\n## v${versionChangelog.version} - _${date}_\n\n`; return title; }, diff --git a/yarn.lock b/yarn.lock index 5dbc8310fe..490f18f982 100644 --- a/yarn.lock +++ b/yarn.lock @@ -571,6 +571,12 @@ jsonschema "1.2.2" lodash.values "4.3.0" +"@0xproject/npm-cli-login@^0.0.11": + version "0.0.11" + resolved "https://registry.yarnpkg.com/@0xproject/npm-cli-login/-/npm-cli-login-0.0.11.tgz#3f1ec06112ce62aad300ff0575358f68aeecde2e" + dependencies: + npm-registry-client "7.0.9" + "@0xproject/order-utils@^0.0.9": version "0.0.9" resolved "https://registry.yarnpkg.com/@0xproject/order-utils/-/order-utils-0.0.9.tgz#75225dfbd87335d18810abf995d8e077b9a84868" @@ -6375,7 +6381,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" @@ -10337,12 +10343,6 @@ npm-bundled@^1.0.1: version "1.0.3" resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.3.tgz#7e71703d973af3370a9591bafe3a63aca0be2308" -npm-cli-login@^0.0.10: - version "0.0.10" - resolved "https://registry.yarnpkg.com/npm-cli-login/-/npm-cli-login-0.0.10.tgz#b1e8b5b7405008e0a26ccc170443434a59c5364c" - dependencies: - npm-registry-client "7.0.9" - npm-lifecycle@^2.0.0: version "2.0.3" resolved "http://registry.yarnpkg.com/npm-lifecycle/-/npm-lifecycle-2.0.3.tgz#696bedf1143371163e9cc16fe872357e25d8d90e" From 7d9009bb96fa576c98abd82200cd0fc2b4d27e40 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 13:28:26 +0100 Subject: [PATCH 33/73] Convert all schemas to json files, so it's easier for devs in other languages to use it --- .../json-schemas/schemas/address_schema.json | 5 ++ .../schemas/basic_type_schemas.ts | 17 ----- .../schemas/block_param_schema.json | 11 +++ .../schemas/block_range_schema.json | 8 ++ .../schemas/block_range_schema.ts | 20 ----- .../schemas/call_data_schema.json | 27 +++++++ .../json-schemas/schemas/call_data_schema.ts | 27 ------- .../ec_signature_parameter_schema.json | 5 ++ .../schemas/ec_signature_schema.json | 14 ++++ .../schemas/ec_signature_schema.ts | 20 ----- .../json-schemas/schemas/eip712_typed_data.ts | 28 ------- .../schemas/eip712_typed_data_schema.json | 28 +++++++ packages/json-schemas/schemas/hex_schema.json | 5 ++ .../schemas/index_filter_values_schema.json | 7 ++ .../schemas/index_filter_values_schema.ts | 7 -- packages/json-schemas/schemas/js_number.json | 5 ++ .../json-schemas/schemas/number_schema.json | 5 ++ .../schemas/order_cancel_schema.json | 12 +++ .../schemas/order_cancel_schema.ts | 12 --- .../order_fill_or_kill_requests_schema.json | 12 +++ .../order_fill_or_kill_requests_schema.ts | 12 --- .../schemas/order_fill_requests_schema.json | 12 +++ .../schemas/order_fill_requests_schema.ts | 12 --- .../schemas/order_hash_schema.json | 5 ++ .../json-schemas/schemas/order_hash_schema.ts | 5 -- .../json-schemas/schemas/order_schema.json | 34 +++++++++ .../json-schemas/schemas/order_schemas.ts | 47 ------------ .../json-schemas/schemas/orders_schema.json | 5 ++ .../json-schemas/schemas/orders_schema.ts | 5 -- .../schemas/paginated_collection_schema.json | 10 +++ .../schemas/paginated_collection_schema.ts | 10 --- ..._api_asset_data_pairs_response_schema.json | 13 ++++ .../relayer_api_asset_data_pairs_schema.json | 12 +++ ...ayer_api_asset_data_trade_info_schema.json | 11 +++ ...relayer_api_asset_pairs_response_schema.ts | 38 ---------- .../relayer_api_error_response_schema.json | 21 ++++++ .../relayer_api_error_response_schema.ts | 21 ------ ...er_api_fee_recipients_response_schema.json | 16 ++++ ...ayer_api_fee_recipients_response_schema.ts | 16 ---- ...layer_api_order_config_payload_schema.json | 24 ++++++ ...relayer_api_order_config_payload_schema.ts | 24 ------ ...ayer_api_order_config_response_schema.json | 11 +++ ...elayer_api_order_config_response_schema.ts | 11 --- .../schemas/relayer_api_order_schema.json | 9 +++ .../schemas/relayer_api_order_schema.ts | 9 --- ...relayer_api_orderbook_response_schema.json | 9 +++ .../relayer_api_orderbook_response_schema.ts | 9 --- ...ders_channel_subscribe_payload_schema.json | 14 ++++ ...r_api_orders_channel_subscribe_schema.json | 11 +++ ...yer_api_orders_channel_subscribe_schema.ts | 26 ------- ...orders_channel_update_response_schema.json | 11 +++ ...i_orders_channel_update_response_schema.ts | 11 --- .../relayer_api_orders_response_schema.json | 13 ++++ .../relayer_api_orders_response_schema.ts | 13 ---- .../schemas/relayer_api_orders_schema.json | 5 ++ .../schemas/relayer_api_orders_schema.ts | 5 -- .../schemas/signed_order_schema.json | 12 +++ .../schemas/signed_orders_schema.json | 5 ++ .../schemas/signed_orders_schema.ts | 5 -- .../json-schemas/schemas/token_schema.json | 11 +++ packages/json-schemas/schemas/token_schema.ts | 11 --- .../json-schemas/schemas/tx_data_schema.json | 26 +++++++ .../json-schemas/schemas/tx_data_schema.ts | 32 -------- .../schemas/zero_ex_transaction_schema.json | 10 +++ .../schemas/zero_ex_transaction_schema.ts | 10 --- packages/json-schemas/src/globals.d.ts | 6 -- packages/json-schemas/src/schemas.ts | 74 ++++++++++--------- packages/json-schemas/tsconfig.json | 44 ++++++++++- 68 files changed, 534 insertions(+), 507 deletions(-) create mode 100644 packages/json-schemas/schemas/address_schema.json delete mode 100644 packages/json-schemas/schemas/basic_type_schemas.ts create mode 100644 packages/json-schemas/schemas/block_param_schema.json create mode 100644 packages/json-schemas/schemas/block_range_schema.json delete mode 100644 packages/json-schemas/schemas/block_range_schema.ts create mode 100644 packages/json-schemas/schemas/call_data_schema.json delete mode 100644 packages/json-schemas/schemas/call_data_schema.ts create mode 100644 packages/json-schemas/schemas/ec_signature_parameter_schema.json create mode 100644 packages/json-schemas/schemas/ec_signature_schema.json delete mode 100644 packages/json-schemas/schemas/ec_signature_schema.ts delete mode 100644 packages/json-schemas/schemas/eip712_typed_data.ts create mode 100644 packages/json-schemas/schemas/eip712_typed_data_schema.json create mode 100644 packages/json-schemas/schemas/hex_schema.json create mode 100644 packages/json-schemas/schemas/index_filter_values_schema.json delete mode 100644 packages/json-schemas/schemas/index_filter_values_schema.ts create mode 100644 packages/json-schemas/schemas/js_number.json create mode 100644 packages/json-schemas/schemas/number_schema.json create mode 100644 packages/json-schemas/schemas/order_cancel_schema.json delete mode 100644 packages/json-schemas/schemas/order_cancel_schema.ts create mode 100644 packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json delete mode 100644 packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts create mode 100644 packages/json-schemas/schemas/order_fill_requests_schema.json delete mode 100644 packages/json-schemas/schemas/order_fill_requests_schema.ts create mode 100644 packages/json-schemas/schemas/order_hash_schema.json delete mode 100644 packages/json-schemas/schemas/order_hash_schema.ts create mode 100644 packages/json-schemas/schemas/order_schema.json delete mode 100644 packages/json-schemas/schemas/order_schemas.ts create mode 100644 packages/json-schemas/schemas/orders_schema.json delete mode 100644 packages/json-schemas/schemas/orders_schema.ts create mode 100644 packages/json-schemas/schemas/paginated_collection_schema.json delete mode 100644 packages/json-schemas/schemas/paginated_collection_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json create mode 100644 packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json create mode 100644 packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_error_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_error_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_config_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_order_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json create mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_response_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_orders_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_schema.json delete mode 100644 packages/json-schemas/schemas/relayer_api_orders_schema.ts create mode 100644 packages/json-schemas/schemas/signed_order_schema.json create mode 100644 packages/json-schemas/schemas/signed_orders_schema.json delete mode 100644 packages/json-schemas/schemas/signed_orders_schema.ts create mode 100644 packages/json-schemas/schemas/token_schema.json delete mode 100644 packages/json-schemas/schemas/token_schema.ts create mode 100644 packages/json-schemas/schemas/tx_data_schema.json delete mode 100644 packages/json-schemas/schemas/tx_data_schema.ts create mode 100644 packages/json-schemas/schemas/zero_ex_transaction_schema.json delete mode 100644 packages/json-schemas/schemas/zero_ex_transaction_schema.ts delete mode 100644 packages/json-schemas/src/globals.d.ts diff --git a/packages/json-schemas/schemas/address_schema.json b/packages/json-schemas/schemas/address_schema.json new file mode 100644 index 0000000000..0dc02d3313 --- /dev/null +++ b/packages/json-schemas/schemas/address_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/addressSchema", + "type": "string", + "pattern": "^0x[0-9a-f]{40}$" +} diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts deleted file mode 100644 index a59afaef81..0000000000 --- a/packages/json-schemas/schemas/basic_type_schemas.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const addressSchema = { - id: '/addressSchema', - type: 'string', - pattern: '^0x[0-9a-f]{40}$', -}; - -export const hexSchema = { - id: '/hexSchema', - type: 'string', - pattern: '^0x(([0-9a-f][0-9a-f])+)?$', -}; - -export const numberSchema = { - id: '/numberSchema', - type: 'string', - pattern: '^\\d+(\\.\\d+)?$', -}; diff --git a/packages/json-schemas/schemas/block_param_schema.json b/packages/json-schemas/schemas/block_param_schema.json new file mode 100644 index 0000000000..ed4dd1e875 --- /dev/null +++ b/packages/json-schemas/schemas/block_param_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/blockParamSchema", + "oneOf": [ + { + "type": "number" + }, + { + "enum": ["latest", "earliest", "pending"] + } + ] +} diff --git a/packages/json-schemas/schemas/block_range_schema.json b/packages/json-schemas/schemas/block_range_schema.json new file mode 100644 index 0000000000..b142946490 --- /dev/null +++ b/packages/json-schemas/schemas/block_range_schema.json @@ -0,0 +1,8 @@ +{ + "id": "/blockRangeSchema", + "properties": { + "fromBlock": { "$ref": "/blockParamSchema" }, + "toBlock": { "$ref": "/blockParamSchema" } + }, + "type": "object" +} diff --git a/packages/json-schemas/schemas/block_range_schema.ts b/packages/json-schemas/schemas/block_range_schema.ts deleted file mode 100644 index 9eb242fc6c..0000000000 --- a/packages/json-schemas/schemas/block_range_schema.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const blockParamSchema = { - id: '/blockParamSchema', - oneOf: [ - { - type: 'number', - }, - { - enum: ['latest', 'earliest', 'pending'], - }, - ], -}; - -export const blockRangeSchema = { - id: '/blockRangeSchema', - properties: { - fromBlock: { $ref: '/blockParamSchema' }, - toBlock: { $ref: '/blockParamSchema' }, - }, - type: 'object', -}; diff --git a/packages/json-schemas/schemas/call_data_schema.json b/packages/json-schemas/schemas/call_data_schema.json new file mode 100644 index 0000000000..c5972e8c18 --- /dev/null +++ b/packages/json-schemas/schemas/call_data_schema.json @@ -0,0 +1,27 @@ +{ + "id": "/callDataSchema", + "properties": { + "from": { "$ref": "/addressSchema" }, + "to": { "$ref": "/addressSchema" }, + "value": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gas": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gasPrice": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "data": { + "type": "string", + "pattern": "^0x[0-9a-f]*$" + }, + "nonce": { + "type": "number", + "minimum": 0 + } + }, + "required": [], + "type": "object", + "additionalProperties": false +} diff --git a/packages/json-schemas/schemas/call_data_schema.ts b/packages/json-schemas/schemas/call_data_schema.ts deleted file mode 100644 index 4c77d9f9d8..0000000000 --- a/packages/json-schemas/schemas/call_data_schema.ts +++ /dev/null @@ -1,27 +0,0 @@ -export const callDataSchema = { - id: '/callDataSchema', - properties: { - from: { $ref: '/addressSchema' }, - to: { $ref: '/addressSchema' }, - value: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gas: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gasPrice: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - data: { - type: 'string', - pattern: '^0x[0-9a-f]*$', - }, - nonce: { - type: 'number', - minimum: 0, - }, - }, - required: [], - type: 'object', - additionalProperties: false, -}; diff --git a/packages/json-schemas/schemas/ec_signature_parameter_schema.json b/packages/json-schemas/schemas/ec_signature_parameter_schema.json new file mode 100644 index 0000000000..0c08ec2403 --- /dev/null +++ b/packages/json-schemas/schemas/ec_signature_parameter_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/ecSignatureParameterSchema", + "type": "string", + "pattern": "^0[xX][0-9A-Fa-f]{64}$" +} diff --git a/packages/json-schemas/schemas/ec_signature_schema.json b/packages/json-schemas/schemas/ec_signature_schema.json new file mode 100644 index 0000000000..bc79ca5e96 --- /dev/null +++ b/packages/json-schemas/schemas/ec_signature_schema.json @@ -0,0 +1,14 @@ +{ + "id": "/ECSignature", + "properties": { + "v": { + "type": "number", + "minimum": 27, + "maximum": 28 + }, + "r": { "$ref": "/ecSignatureParameterSchema" }, + "s": { "$ref": "/ecSignatureParameterSchema" } + }, + "required": ["v", "r", "s"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts deleted file mode 100644 index c59532f092..0000000000 --- a/packages/json-schemas/schemas/ec_signature_schema.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const ecSignatureParameterSchema = { - id: '/ecSignatureParameterSchema', - type: 'string', - pattern: '^0[xX][0-9A-Fa-f]{64}$', -}; - -export const ecSignatureSchema = { - id: '/ECSignature', - properties: { - v: { - type: 'number', - minimum: 27, - maximum: 28, - }, - r: { $ref: '/ecSignatureParameterSchema' }, - s: { $ref: '/ecSignatureParameterSchema' }, - }, - required: ['v', 'r', 's'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/eip712_typed_data.ts b/packages/json-schemas/schemas/eip712_typed_data.ts deleted file mode 100644 index 31ad74610c..0000000000 --- a/packages/json-schemas/schemas/eip712_typed_data.ts +++ /dev/null @@ -1,28 +0,0 @@ -export const eip712TypedDataSchema = { - id: '/eip712TypedData', - type: 'object', - properties: { - types: { - type: 'object', - properties: { - EIP712Domain: { type: 'array' }, - }, - additionalProperties: { - type: 'array', - items: { - type: 'object', - properties: { - name: { type: 'string' }, - type: { type: 'string' }, - }, - required: ['name', 'type'], - }, - }, - required: ['EIP712Domain'], - }, - primaryType: { type: 'string' }, - domain: { type: 'object' }, - message: { type: 'object' }, - }, - required: ['types', 'primaryType', 'domain', 'message'], -}; diff --git a/packages/json-schemas/schemas/eip712_typed_data_schema.json b/packages/json-schemas/schemas/eip712_typed_data_schema.json new file mode 100644 index 0000000000..8efd6de448 --- /dev/null +++ b/packages/json-schemas/schemas/eip712_typed_data_schema.json @@ -0,0 +1,28 @@ +{ + "id": "/eip712TypedDataSchema", + "type": "object", + "properties": { + "types": { + "type": "object", + "properties": { + "EIP712Domain": { "type": "array" } + }, + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "type": { "type": "string" } + }, + "required": ["name", "type"] + } + }, + "required": ["EIP712Domain"] + }, + "primaryType": { "type": "string" }, + "domain": { "type": "object" }, + "message": { "type": "object" } + }, + "required": ["types", "primaryType", "domain", "message"] +} diff --git a/packages/json-schemas/schemas/hex_schema.json b/packages/json-schemas/schemas/hex_schema.json new file mode 100644 index 0000000000..f37815d5bd --- /dev/null +++ b/packages/json-schemas/schemas/hex_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/hexSchema", + "type": "string", + "pattern": "^0x(([0-9a-f][0-9a-f])+)?$" +} diff --git a/packages/json-schemas/schemas/index_filter_values_schema.json b/packages/json-schemas/schemas/index_filter_values_schema.json new file mode 100644 index 0000000000..bec00d79e8 --- /dev/null +++ b/packages/json-schemas/schemas/index_filter_values_schema.json @@ -0,0 +1,7 @@ +{ + "id": "/indexFilterValuesSchema", + "additionalProperties": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }] + }, + "type": "object" +} diff --git a/packages/json-schemas/schemas/index_filter_values_schema.ts b/packages/json-schemas/schemas/index_filter_values_schema.ts deleted file mode 100644 index f3c8cef685..0000000000 --- a/packages/json-schemas/schemas/index_filter_values_schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const indexFilterValuesSchema = { - id: '/indexFilterValuesSchema', - additionalProperties: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/addressSchema' }, { $ref: '/orderHashSchema' }], - }, - type: 'object', -}; diff --git a/packages/json-schemas/schemas/js_number.json b/packages/json-schemas/schemas/js_number.json new file mode 100644 index 0000000000..6a72d92c07 --- /dev/null +++ b/packages/json-schemas/schemas/js_number.json @@ -0,0 +1,5 @@ +{ + "id": "/jsNumber", + "type": "number", + "minimum": 0 +} diff --git a/packages/json-schemas/schemas/number_schema.json b/packages/json-schemas/schemas/number_schema.json new file mode 100644 index 0000000000..a48f3e8cff --- /dev/null +++ b/packages/json-schemas/schemas/number_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/numberSchema", + "type": "string", + "pattern": "^\\d+(\\.\\d+)?$" +} diff --git a/packages/json-schemas/schemas/order_cancel_schema.json b/packages/json-schemas/schemas/order_cancel_schema.json new file mode 100644 index 0000000000..09d4068c63 --- /dev/null +++ b/packages/json-schemas/schemas/order_cancel_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderCancellationRequestsSchema", + "type": "array", + "items": { + "properties": { + "order": { "$ref": "/orderSchema" }, + "takerTokenCancelAmount": { "$ref": "/numberSchema" } + }, + "required": ["order", "takerTokenCancelAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_cancel_schema.ts b/packages/json-schemas/schemas/order_cancel_schema.ts deleted file mode 100644 index e4edfbca98..0000000000 --- a/packages/json-schemas/schemas/order_cancel_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderCancellationRequestsSchema = { - id: '/orderCancellationRequestsSchema', - type: 'array', - items: { - properties: { - order: { $ref: '/orderSchema' }, - takerTokenCancelAmount: { $ref: '/numberSchema' }, - }, - required: ['order', 'takerTokenCancelAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json new file mode 100644 index 0000000000..c9549c72ea --- /dev/null +++ b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderFillOrKillRequestsSchema", + "type": "array", + "items": { + "properties": { + "signedOrder": { "$ref": "/signedOrderSchema" }, + "fillTakerAmount": { "$ref": "/numberSchema" } + }, + "required": ["signedOrder", "fillTakerAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts deleted file mode 100644 index e2c18ef0a2..0000000000 --- a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderFillOrKillRequestsSchema = { - id: '/orderFillOrKillRequestsSchema', - type: 'array', - items: { - properties: { - signedOrder: { $ref: '/signedOrderSchema' }, - fillTakerAmount: { $ref: '/numberSchema' }, - }, - required: ['signedOrder', 'fillTakerAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.json b/packages/json-schemas/schemas/order_fill_requests_schema.json new file mode 100644 index 0000000000..98325653b4 --- /dev/null +++ b/packages/json-schemas/schemas/order_fill_requests_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderFillRequestsSchema", + "type": "array", + "items": { + "properties": { + "signedOrder": { "$ref": "/signedOrderSchema" }, + "takerTokenFillAmount": { "$ref": "/numberSchema" } + }, + "required": ["signedOrder", "takerTokenFillAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_requests_schema.ts deleted file mode 100644 index ea8b35e545..0000000000 --- a/packages/json-schemas/schemas/order_fill_requests_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderFillRequestsSchema = { - id: '/orderFillRequestsSchema', - type: 'array', - items: { - properties: { - signedOrder: { $ref: '/signedOrderSchema' }, - takerTokenFillAmount: { $ref: '/numberSchema' }, - }, - required: ['signedOrder', 'takerTokenFillAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_hash_schema.json b/packages/json-schemas/schemas/order_hash_schema.json new file mode 100644 index 0000000000..4a770579fc --- /dev/null +++ b/packages/json-schemas/schemas/order_hash_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/orderHashSchema", + "type": "string", + "pattern": "^0x[0-9a-fA-F]{64}$" +} diff --git a/packages/json-schemas/schemas/order_hash_schema.ts b/packages/json-schemas/schemas/order_hash_schema.ts deleted file mode 100644 index 9773a88f95..0000000000 --- a/packages/json-schemas/schemas/order_hash_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const orderHashSchema = { - id: '/orderHashSchema', - type: 'string', - pattern: '^0x[0-9a-fA-F]{64}$', -}; diff --git a/packages/json-schemas/schemas/order_schema.json b/packages/json-schemas/schemas/order_schema.json new file mode 100644 index 0000000000..de2c8c7c24 --- /dev/null +++ b/packages/json-schemas/schemas/order_schema.json @@ -0,0 +1,34 @@ +{ + "id": "/orderSchema", + "properties": { + "makerAddress": { "$ref": "/addressSchema" }, + "takerAddress": { "$ref": "/addressSchema" }, + "makerFee": { "$ref": "/numberSchema" }, + "takerFee": { "$ref": "/numberSchema" }, + "senderAddress": { "$ref": "/addressSchema" }, + "makerAssetAmount": { "$ref": "/numberSchema" }, + "takerAssetAmount": { "$ref": "/numberSchema" }, + "makerAssetData": { "$ref": "/hexSchema" }, + "takerAssetData": { "$ref": "/hexSchema" }, + "salt": { "$ref": "/numberSchema" }, + "exchangeAddress": { "$ref": "/addressSchema" }, + "feeRecipientAddress": { "$ref": "/addressSchema" }, + "expirationTimeSeconds": { "$ref": "/numberSchema" } + }, + "required": [ + "makerAddress", + "takerAddress", + "makerFee", + "takerFee", + "senderAddress", + "makerAssetAmount", + "takerAssetAmount", + "makerAssetData", + "takerAssetData", + "salt", + "exchangeAddress", + "feeRecipientAddress", + "expirationTimeSeconds" + ], + "type": "object" +} diff --git a/packages/json-schemas/schemas/order_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts deleted file mode 100644 index eb7fdaf5a6..0000000000 --- a/packages/json-schemas/schemas/order_schemas.ts +++ /dev/null @@ -1,47 +0,0 @@ -export const orderSchema = { - id: '/orderSchema', - properties: { - makerAddress: { $ref: '/addressSchema' }, - takerAddress: { $ref: '/addressSchema' }, - makerFee: { $ref: '/numberSchema' }, - takerFee: { $ref: '/numberSchema' }, - senderAddress: { $ref: '/addressSchema' }, - makerAssetAmount: { $ref: '/numberSchema' }, - takerAssetAmount: { $ref: '/numberSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - salt: { $ref: '/numberSchema' }, - exchangeAddress: { $ref: '/addressSchema' }, - feeRecipientAddress: { $ref: '/addressSchema' }, - expirationTimeSeconds: { $ref: '/numberSchema' }, - }, - required: [ - 'makerAddress', - 'takerAddress', - 'makerFee', - 'takerFee', - 'senderAddress', - 'makerAssetAmount', - 'takerAssetAmount', - 'makerAssetData', - 'takerAssetData', - 'salt', - 'exchangeAddress', - 'feeRecipientAddress', - 'expirationTimeSeconds', - ], - type: 'object', -}; - -export const signedOrderSchema = { - id: '/signedOrderSchema', - allOf: [ - { $ref: '/orderSchema' }, - { - properties: { - signature: { $ref: '/hexSchema' }, - }, - required: ['signature'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/orders_schema.json b/packages/json-schemas/schemas/orders_schema.json new file mode 100644 index 0000000000..1e1c6a8751 --- /dev/null +++ b/packages/json-schemas/schemas/orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/ordersSchema", + "type": "array", + "items": { "$ref": "/orderSchema" } +} diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts deleted file mode 100644 index de0abcf00c..0000000000 --- a/packages/json-schemas/schemas/orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const ordersSchema = { - id: '/ordersSchema', - type: 'array', - items: { $ref: '/orderSchema' }, -}; diff --git a/packages/json-schemas/schemas/paginated_collection_schema.json b/packages/json-schemas/schemas/paginated_collection_schema.json new file mode 100644 index 0000000000..9dcedf5b47 --- /dev/null +++ b/packages/json-schemas/schemas/paginated_collection_schema.json @@ -0,0 +1,10 @@ +{ + "id": "/paginatedCollectionSchema", + "type": "object", + "properties": { + "total": { "type": "number" }, + "perPage": { "type": "number" }, + "page": { "type": "number" } + }, + "required": ["total", "perPage", "page"] +} diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts deleted file mode 100644 index 16044c70af..0000000000 --- a/packages/json-schemas/schemas/paginated_collection_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const paginatedCollectionSchema = { - id: '/paginatedCollectionSchema', - type: 'object', - properties: { - total: { type: 'number' }, - perPage: { type: 'number' }, - page: { type: 'number' }, - }, - required: ['total', 'perPage', 'page'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json new file mode 100644 index 0000000000..d1150d3dbc --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json @@ -0,0 +1,13 @@ +{ + "id": "/relayerApiAssetDataPairsResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { "$ref": "/relayerApiAssetDataPairsSchema" } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json new file mode 100644 index 0000000000..62d4745b8c --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/relayerApiAssetDataPairsSchema", + "type": "array", + "items": { + "properties": { + "assetDataA": { "$ref": "/relayerApiAssetDataTradeInfoSchema" }, + "assetDataB": { "$ref": "/relayerApiAssetDataTradeInfoSchema" } + }, + "required": ["assetDataA", "assetDataB"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json new file mode 100644 index 0000000000..0ab9b444f1 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiAssetDataTradeInfoSchema", + "type": "object", + "properties": { + "assetData": { "$ref": "/hexSchema" }, + "minAmount": { "$ref": "/numberSchema" }, + "maxAmount": { "$ref": "/numberSchema" }, + "precision": { "type": "number" } + }, + "required": ["assetData"] +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts b/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts deleted file mode 100644 index c13396d29d..0000000000 --- a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts +++ /dev/null @@ -1,38 +0,0 @@ -export const relayerApiAssetDataPairsResponseSchema = { - id: '/relayerApiAssetDataPairsResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { $ref: '/relayerApiAssetDataPairsSchema' }, - }, - required: ['records'], - }, - ], -}; - -export const relayerApiAssetDataPairsSchema = { - id: '/relayerApiAssetDataPairsSchema', - type: 'array', - items: { - properties: { - assetDataA: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, - assetDataB: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, - }, - required: ['assetDataA', 'assetDataB'], - type: 'object', - }, -}; - -export const relayerApiAssetDataTradeInfoSchema = { - id: '/relayerApiAssetDataTradeInfoSchema', - type: 'object', - properties: { - assetData: { $ref: '/hexSchema' }, - minAmount: { $ref: '/numberSchema' }, - maxAmount: { $ref: '/numberSchema' }, - precision: { type: 'number' }, - }, - required: ['assetData'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.json b/packages/json-schemas/schemas/relayer_api_error_response_schema.json new file mode 100644 index 0000000000..be4659b0bd --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.json @@ -0,0 +1,21 @@ +{ + "id": "/relayerApiErrorResponseSchema", + "type": "object", + "properties": { + "code": { "type": "integer", "minimum": 100, "maximum": 103 }, + "reason": { "type": "string" }, + "validationErrors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { "type": "string" }, + "code": { "type": "integer", "minimum": 1000, "maximum": 1006 }, + "reason": { "type": "string" } + }, + "required": ["field", "code", "reason"] + } + } + }, + "required": ["code", "reason"] +} diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts deleted file mode 100644 index 79e33fc850..0000000000 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const relayerApiErrorResponseSchema = { - id: '/relayerApiErrorResponseSchema', - type: 'object', - properties: { - code: { type: 'integer', minimum: 100, maximum: 103 }, - reason: { type: 'string' }, - validationErrors: { - type: 'array', - items: { - type: 'object', - properties: { - field: { type: 'string' }, - code: { type: 'integer', minimum: 1000, maximum: 1006 }, - reason: { type: 'string' }, - }, - required: ['field', 'code', 'reason'], - }, - }, - }, - required: ['code', 'reason'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json new file mode 100644 index 0000000000..c73506dbb1 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json @@ -0,0 +1,16 @@ +{ + "id": "/relayerApiFeeRecipientsResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { + "type": "array", + "items": { "$ref": "/addressSchema" } + } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts deleted file mode 100644 index 5f6bc05303..0000000000 --- a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts +++ /dev/null @@ -1,16 +0,0 @@ -export const relayerApiFeeRecipientsResponseSchema = { - id: '/relayerApiFeeRecipientsResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { - type: 'array', - items: { $ref: '/addressSchema' }, - }, - }, - required: ['records'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json new file mode 100644 index 0000000000..bc95b61efb --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json @@ -0,0 +1,24 @@ +{ + "id": "/relayerApiOrderConfigPayloadSchema", + "type": "object", + "properties": { + "makerAddress": { "$ref": "/addressSchema" }, + "takerAddress": { "$ref": "/addressSchema" }, + "makerAssetAmount": { "$ref": "/numberSchema" }, + "takerAssetAmount": { "$ref": "/numberSchema" }, + "makerAssetData": { "$ref": "/hexSchema" }, + "takerAssetData": { "$ref": "/hexSchema" }, + "exchangeAddress": { "$ref": "/addressSchema" }, + "expirationTimeSeconds": { "$ref": "/numberSchema" } + }, + "required": [ + "makerAddress", + "takerAddress", + "makerAssetAmount", + "takerAssetAmount", + "makerAssetData", + "takerAssetData", + "exchangeAddress", + "expirationTimeSeconds" + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts deleted file mode 100644 index 8d1d408d67..0000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const relayerApiOrderConfigPayloadSchema = { - id: '/relayerApiOrderConfigPayloadSchema', - type: 'object', - properties: { - makerAddress: { $ref: '/addressSchema' }, - takerAddress: { $ref: '/addressSchema' }, - makerAssetAmount: { $ref: '/numberSchema' }, - takerAssetAmount: { $ref: '/numberSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - exchangeAddress: { $ref: '/addressSchema' }, - expirationTimeSeconds: { $ref: '/numberSchema' }, - }, - required: [ - 'makerAddress', - 'takerAddress', - 'makerAssetAmount', - 'takerAssetAmount', - 'makerAssetData', - 'takerAssetData', - 'exchangeAddress', - 'expirationTimeSeconds', - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json new file mode 100644 index 0000000000..0742febdfe --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrderConfigResponseSchema", + "type": "object", + "properties": { + "makerFee": { "$ref": "/numberSchema" }, + "takerFee": { "$ref": "/numberSchema" }, + "feeRecipientAddress": { "$ref": "/addressSchema" }, + "senderAddress": { "$ref": "/addressSchema" } + }, + "required": ["makerFee", "takerFee", "feeRecipientAddress", "senderAddress"] +} diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts deleted file mode 100644 index 390d0b2621..0000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const relayerApiOrderConfigResponseSchema = { - id: '/relayerApiOrderConfigResponseSchema', - type: 'object', - properties: { - makerFee: { $ref: '/numberSchema' }, - takerFee: { $ref: '/numberSchema' }, - feeRecipientAddress: { $ref: '/addressSchema' }, - senderAddress: { $ref: '/addressSchema' }, - }, - required: ['makerFee', 'takerFee', 'feeRecipientAddress', 'senderAddress'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.json b/packages/json-schemas/schemas/relayer_api_order_schema.json new file mode 100644 index 0000000000..e0f6539b9f --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_schema.json @@ -0,0 +1,9 @@ +{ + "id": "/relayerApiOrderSchema", + "type": "object", + "properties": { + "order": { "$ref": "/orderSchema" }, + "metaData": { "type": "object" } + }, + "required": ["order", "metaData"] +} diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts deleted file mode 100644 index 3952e9683d..0000000000 --- a/packages/json-schemas/schemas/relayer_api_order_schema.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const relayerApiOrderSchema = { - id: '/relayerApiOrderSchema', - type: 'object', - properties: { - order: { $ref: '/orderSchema' }, - metaData: { type: 'object' }, - }, - required: ['order', 'metaData'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json new file mode 100644 index 0000000000..b44f2a7408 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json @@ -0,0 +1,9 @@ +{ + "id": "/relayerApiOrderbookResponseSchema", + "type": "object", + "properties": { + "bids": { "$ref": "/relayerApiOrdersResponseSchema" }, + "asks": { "$ref": "/relayerApiOrdersResponseSchema" } + }, + "required": ["bids", "asks"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts deleted file mode 100644 index 7c0b8e0dfc..0000000000 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const relayerApiOrderbookResponseSchema = { - id: '/relayerApiOrderbookResponseSchema', - type: 'object', - properties: { - bids: { $ref: '/relayerApiOrdersResponseSchema' }, - asks: { $ref: '/relayerApiOrdersResponseSchema' }, - }, - required: ['bids', 'asks'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json new file mode 100644 index 0000000000..274ef1625a --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json @@ -0,0 +1,14 @@ +{ + "id": "/relayerApiOrdersChannelSubscribePayloadSchema", + "type": "object", + "properties": { + "makerAssetProxyId": { "$ref": "/hexSchema" }, + "takerAssetProxyId": { "$ref": "/hexSchema" }, + "networkId": { "type": "number" }, + "makerAssetAddress": { "$ref": "/addressSchema" }, + "takerAssetAddress": { "$ref": "/addressSchema" }, + "makerAssetData": { "$ref": "/hexSchema" }, + "takerAssetData": { "$ref": "/hexSchema" }, + "traderAssetData": { "$ref": "/hexSchema" } + } +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json new file mode 100644 index 0000000000..29561d09fc --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrdersChannelSubscribeSchema", + "type": "object", + "properties": { + "type": { "enum": ["subscribe"] }, + "channel": { "enum": ["orders"] }, + "requestId": { "type": "string" }, + "payload": { "$ref": "/relayerApiOrdersChannelSubscribePayloadSchema" } + }, + "required": ["type", "channel", "requestId"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts deleted file mode 100644 index a3b9b6d95a..0000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const relayerApiOrdersChannelSubscribeSchema = { - id: '/relayerApiOrdersChannelSubscribeSchema', - type: 'object', - properties: { - type: { enum: ['subscribe'] }, - channel: { enum: ['orders'] }, - requestId: { type: 'string' }, - payload: { $ref: '/relayerApiOrdersChannelSubscribePayload' }, - }, - required: ['type', 'channel', 'requestId'], -}; - -export const relayerApiOrdersChannelSubscribePayload = { - id: '/relayerApiOrdersChannelSubscribePayload', - type: 'object', - properties: { - makerAssetProxyId: { $ref: '/hexSchema' }, - takerAssetProxyId: { $ref: '/hexSchema' }, - networkId: { type: 'number' }, - makerAssetAddress: { $ref: '/addressSchema' }, - takerAssetAddress: { $ref: '/addressSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - traderAssetData: { $ref: '/hexSchema' }, - }, -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json new file mode 100644 index 0000000000..239e7c5861 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrdersChannelUpdateSchema", + "type": "object", + "properties": { + "type": { "enum": ["update"] }, + "channel": { "enum": ["orders"] }, + "requestId": { "type": "string" }, + "payload": { "$ref": "/relayerApiOrdersSchema" } + }, + "required": ["type", "channel", "requestId"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts deleted file mode 100644 index 800b818e2f..0000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const relayerApiOrdersChannelUpdateSchema = { - id: '/relayerApiOrdersChannelUpdateSchema', - type: 'object', - properties: { - type: { enum: ['update'] }, - channel: { enum: ['orders'] }, - requestId: { type: 'string' }, - payload: { $ref: '/relayerApiOrdersSchema' }, - }, - required: ['type', 'channel', 'requestId'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json new file mode 100644 index 0000000000..a5023a3fc1 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json @@ -0,0 +1,13 @@ +{ + "id": "/relayerApiOrdersResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { "$ref": "/relayerApiOrdersSchema" } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts deleted file mode 100644 index c10d64ca91..0000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const relayerApiOrdersResponseSchema = { - id: '/relayerApiOrdersResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { $ref: '/relayerApiOrdersSchema' }, - }, - required: ['records'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.json b/packages/json-schemas/schemas/relayer_api_orders_schema.json new file mode 100644 index 0000000000..84e75cd045 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/relayerApiOrdersSchema", + "type": "array", + "items": { "$ref": "/relayerApiOrderSchema" } +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_schema.ts deleted file mode 100644 index ba8ce47226..0000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const relayerApiOrdersSchema = { - id: '/relayerApiOrdersSchema', - type: 'array', - items: { $ref: '/relayerApiOrderSchema' }, -}; diff --git a/packages/json-schemas/schemas/signed_order_schema.json b/packages/json-schemas/schemas/signed_order_schema.json new file mode 100644 index 0000000000..137ae4a249 --- /dev/null +++ b/packages/json-schemas/schemas/signed_order_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/signedOrderSchema", + "allOf": [ + { "$ref": "/orderSchema" }, + { + "properties": { + "signature": { "$ref": "/hexSchema" } + }, + "required": ["signature"] + } + ] +} diff --git a/packages/json-schemas/schemas/signed_orders_schema.json b/packages/json-schemas/schemas/signed_orders_schema.json new file mode 100644 index 0000000000..e7c3a0b6c9 --- /dev/null +++ b/packages/json-schemas/schemas/signed_orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/signedOrdersSchema", + "type": "array", + "items": { "$ref": "/signedOrderSchema" } +} diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts deleted file mode 100644 index e2a5aeb56d..0000000000 --- a/packages/json-schemas/schemas/signed_orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const signedOrdersSchema = { - id: '/signedOrdersSchema', - type: 'array', - items: { $ref: '/signedOrderSchema' }, -}; diff --git a/packages/json-schemas/schemas/token_schema.json b/packages/json-schemas/schemas/token_schema.json new file mode 100644 index 0000000000..31e41c4b87 --- /dev/null +++ b/packages/json-schemas/schemas/token_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/tokenSchema", + "properties": { + "name": { "type": "string" }, + "symbol": { "type": "string" }, + "decimals": { "type": "number" }, + "address": { "$ref": "/addressSchema" } + }, + "required": ["name", "symbol", "decimals", "address"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/token_schema.ts b/packages/json-schemas/schemas/token_schema.ts deleted file mode 100644 index a0b1ae27f8..0000000000 --- a/packages/json-schemas/schemas/token_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const tokenSchema = { - id: '/tokenSchema', - properties: { - name: { type: 'string' }, - symbol: { type: 'string' }, - decimals: { type: 'number' }, - address: { $ref: '/addressSchema' }, - }, - required: ['name', 'symbol', 'decimals', 'address'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/tx_data_schema.json b/packages/json-schemas/schemas/tx_data_schema.json new file mode 100644 index 0000000000..4643521ce4 --- /dev/null +++ b/packages/json-schemas/schemas/tx_data_schema.json @@ -0,0 +1,26 @@ +{ + "id": "/txDataSchema", + "properties": { + "from": { "$ref": "/addressSchema" }, + "to": { "$ref": "/addressSchema" }, + "value": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gas": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gasPrice": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "data": { + "type": "string", + "pattern": "^0x[0-9a-f]*$" + }, + "nonce": { + "type": "number", + "minimum": 0 + } + }, + "required": ["from"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/tx_data_schema.ts b/packages/json-schemas/schemas/tx_data_schema.ts deleted file mode 100644 index c57e184610..0000000000 --- a/packages/json-schemas/schemas/tx_data_schema.ts +++ /dev/null @@ -1,32 +0,0 @@ -export const jsNumber = { - id: '/jsNumber', - type: 'number', - minimum: 0, -}; - -export const txDataSchema = { - id: '/txDataSchema', - properties: { - from: { $ref: '/addressSchema' }, - to: { $ref: '/addressSchema' }, - value: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gas: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gasPrice: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - data: { - type: 'string', - pattern: '^0x[0-9a-f]*$', - }, - nonce: { - type: 'number', - minimum: 0, - }, - }, - required: ['from'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json new file mode 100644 index 0000000000..ad3b11583a --- /dev/null +++ b/packages/json-schemas/schemas/zero_ex_transaction_schema.json @@ -0,0 +1,10 @@ +{ + "id": "/zeroExTransactionSchema", + "properties": { + "data": { "$ref": "/hexSchema" }, + "signerAddress": { "$ref": "/addressSchema" }, + "salt": { "$ref": "/numberSchema" } + }, + "required": ["data", "salt", "signerAddress"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.ts b/packages/json-schemas/schemas/zero_ex_transaction_schema.ts deleted file mode 100644 index 7f729b7242..0000000000 --- a/packages/json-schemas/schemas/zero_ex_transaction_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const zeroExTransactionSchema = { - id: '/zeroExTransactionSchema', - properties: { - data: { $ref: '/hexSchema' }, - signerAddress: { $ref: '/addressSchema' }, - salt: { $ref: '/numberSchema' }, - }, - required: ['data', 'salt', 'signerAddress'], - type: 'object', -}; diff --git a/packages/json-schemas/src/globals.d.ts b/packages/json-schemas/src/globals.d.ts deleted file mode 100644 index 94e63a32de..0000000000 --- a/packages/json-schemas/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/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 4eb96092d4..8318df6174 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -1,38 +1,40 @@ -import { addressSchema, hexSchema, numberSchema } from '../schemas/basic_type_schemas'; -import { blockParamSchema, blockRangeSchema } from '../schemas/block_range_schema'; -import { callDataSchema } from '../schemas/call_data_schema'; -import { ecSignatureParameterSchema, ecSignatureSchema } from '../schemas/ec_signature_schema'; -import { eip712TypedDataSchema } from '../schemas/eip712_typed_data'; -import { indexFilterValuesSchema } from '../schemas/index_filter_values_schema'; -import { orderCancellationRequestsSchema } from '../schemas/order_cancel_schema'; -import { orderFillOrKillRequestsSchema } from '../schemas/order_fill_or_kill_requests_schema'; -import { orderFillRequestsSchema } from '../schemas/order_fill_requests_schema'; -import { orderHashSchema } from '../schemas/order_hash_schema'; -import { orderSchema, signedOrderSchema } from '../schemas/order_schemas'; -import { ordersSchema } from '../schemas/orders_schema'; -import { paginatedCollectionSchema } from '../schemas/paginated_collection_schema'; -import { - relayerApiAssetDataPairsResponseSchema, - relayerApiAssetDataPairsSchema, - relayerApiAssetDataTradeInfoSchema, -} from '../schemas/relayer_api_asset_pairs_response_schema'; -import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema'; -import { relayerApiFeeRecipientsResponseSchema } from '../schemas/relayer_api_fee_recipients_response_schema'; -import { relayerApiOrderConfigPayloadSchema } from '../schemas/relayer_api_order_config_payload_schema'; -import { relayerApiOrderConfigResponseSchema } from '../schemas/relayer_api_order_config_response_schema'; -import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; -import { relayerApiOrderbookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema'; -import { - relayerApiOrdersChannelSubscribePayload, - relayerApiOrdersChannelSubscribeSchema, -} from '../schemas/relayer_api_orders_channel_subscribe_schema'; -import { relayerApiOrdersChannelUpdateSchema } from '../schemas/relayer_api_orders_channel_update_response_schema'; -import { relayerApiOrdersResponseSchema } from '../schemas/relayer_api_orders_response_schema'; -import { relayerApiOrdersSchema } from '../schemas/relayer_api_orders_schema'; -import { signedOrdersSchema } from '../schemas/signed_orders_schema'; -import { tokenSchema } from '../schemas/token_schema'; -import { jsNumber, txDataSchema } from '../schemas/tx_data_schema'; -import { zeroExTransactionSchema } from '../schemas/zero_ex_transaction_schema'; +import * as addressSchema from '../schemas/address_schema.json'; +import * as blockParamSchema from '../schemas/block_param_schema.json'; +import * as blockRangeSchema from '../schemas/block_range_schema.json'; +import * as callDataSchema from '../schemas/call_data_schema.json'; +import * as ecSignatureParameterSchema from '../schemas/ec_signature_parameter_schema.json'; +import * as ecSignatureSchema from '../schemas/ec_signature_schema.json'; +import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json'; +import * as hexSchema from '../schemas/hex_schema.json'; +import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json'; +import * as jsNumber from '../schemas/js_number.json'; +import * as numberSchema from '../schemas/number_schema.json'; +import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json'; +import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_requests_schema.json'; +import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json'; +import * as orderHashSchema from '../schemas/order_hash_schema.json'; +import * as orderSchema from '../schemas/order_schema.json'; +import * as ordersSchema from '../schemas/orders_schema.json'; +import * as paginatedCollectionSchema from '../schemas/paginated_collection_schema.json'; +import * as relayerApiAssetDataPairsResponseSchema from '../schemas/relayer_api_asset_data_pairs_response_schema.json'; +import * as relayerApiAssetDataPairsSchema from '../schemas/relayer_api_asset_data_pairs_schema.json'; +import * as relayerApiAssetDataTradeInfoSchema from '../schemas/relayer_api_asset_data_trade_info_schema.json'; +import * as relayerApiErrorResponseSchema from '../schemas/relayer_api_error_response_schema.json'; +import * as relayerApiFeeRecipientsResponseSchema from '../schemas/relayer_api_fee_recipients_response_schema.json'; +import * as relayerApiOrderConfigPayloadSchema from '../schemas/relayer_api_order_config_payload_schema.json'; +import * as relayerApiOrderConfigResponseSchema from '../schemas/relayer_api_order_config_response_schema.json'; +import * as relayerApiOrderSchema from '../schemas/relayer_api_order_schema.json'; +import * as relayerApiOrderbookResponseSchema from '../schemas/relayer_api_orderbook_response_schema.json'; +import * as relayerApiOrdersChannelSubscribePayloadSchema from '../schemas/relayer_api_orders_channel_subscribe_payload_schema.json'; +import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_orders_channel_subscribe_schema.json'; +import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json'; +import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json'; +import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json'; +import * as signedOrderSchema from '../schemas/signed_order_schema.json'; +import * as signedOrdersSchema from '../schemas/signed_orders_schema.json'; +import * as tokenSchema from '../schemas/token_schema.json'; +import * as txDataSchema from '../schemas/tx_data_schema.json'; +import * as zeroExTransactionSchema from '../schemas/zero_ex_transaction_schema.json'; export const schemas = { numberSchema, @@ -67,7 +69,7 @@ export const schemas = { relayerApiAssetDataPairsResponseSchema, relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelSubscribePayloadSchema, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, relayerApiAssetDataPairsSchema, diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json index 96bf8789e6..6837871029 100644 --- a/packages/json-schemas/tsconfig.json +++ b/packages/json-schemas/tsconfig.json @@ -2,7 +2,47 @@ "extends": "../../tsconfig", "compilerOptions": { "outDir": "lib", - "rootDir": "." + "rootDir": ".", + "resolveJsonModule": true }, - "include": ["./src/**/*", "./test/**/*", "./schemas/**/*"] + "include": ["./src/**/*", "./test/**/*", "./schemas/**/*"], + "files": [ + "./schemas/address_schema.json", + "./schemas/number_schema.json", + "./schemas/hex_schema.json", + "./schemas/block_param_schema.json", + "./schemas/block_range_schema.json", + "./schemas/call_data_schema.json", + "./schemas/ec_signature_parameter_schema.json", + "./schemas/ec_signature_schema.json", + "./schemas/eip712_typed_data_schema.json", + "./schemas/order_cancel_schema.json", + "./schemas/order_fill_or_kill_requests_schema.json", + "./schemas/order_fill_requests_schema.json", + "./schemas/order_hash_schema.json", + "./schemas/order_schema.json", + "./schemas/signed_order_schema.json", + "./schemas/orders_schema.json", + "./schemas/paginated_collection_schema.json", + "./schemas/relayer_api_asset_data_pairs_response_schema.json", + "./schemas/relayer_api_asset_data_pairs_schema.json", + "./schemas/relayer_api_asset_data_trade_info_schema.json", + "./schemas/relayer_api_error_response_schema.json", + "./schemas/relayer_api_fee_recipients_response_schema.json", + "./schemas/relayer_api_order_config_payload_schema.json", + "./schemas/relayer_api_order_config_response_schema.json", + "./schemas/relayer_api_order_schema.json", + "./schemas/relayer_api_orderbook_response_schema.json", + "./schemas/relayer_api_orders_channel_subscribe_payload_schema.json", + "./schemas/relayer_api_orders_channel_subscribe_schema.json", + "./schemas/relayer_api_orders_channel_update_response_schema.json", + "./schemas/relayer_api_orders_response_schema.json", + "./schemas/relayer_api_orders_schema.json", + "./schemas/signed_orders_schema.json", + "./schemas/token_schema.json", + "./schemas/js_number.json", + "./schemas/zero_ex_transaction_schema.json", + "./schemas/tx_data_schema.json", + "./schemas/index_filter_values_schema.json" + ] } From 9176e535aa54c9e5c831cc0e678262b4e42d1d2b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 13:52:43 +0100 Subject: [PATCH 34/73] Fix sra-spec & connect --- packages/connect/src/utils/assert.ts | 2 +- packages/sra-spec/src/json-schemas.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/connect/src/utils/assert.ts b/packages/connect/src/utils/assert.ts index 3d8f1c7997..4e2202d2ef 100644 --- a/packages/connect/src/utils/assert.ts +++ b/packages/connect/src/utils/assert.ts @@ -14,7 +14,7 @@ export const assert = { sharedAssert.doesConformToSchema( variableName, subscriptionOpts, - schemas.relayerApiOrdersChannelSubscribePayload, + schemas.relayerApiOrdersChannelSubscribePayloadSchema, ); }, isOrdersChannelHandler(variableName: string, handler: any): void { diff --git a/packages/sra-spec/src/json-schemas.ts b/packages/sra-spec/src/json-schemas.ts index 173a04bfb8..47cca9b040 100644 --- a/packages/sra-spec/src/json-schemas.ts +++ b/packages/sra-spec/src/json-schemas.ts @@ -21,7 +21,7 @@ const { relayerApiAssetDataPairsResponseSchema, relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelSubscribePayloadSchema, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, relayerApiAssetDataPairsSchema, @@ -47,7 +47,7 @@ const usedSchemas = { relayerApiAssetDataPairsResponseSchema, relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelSubscribePayloadSchema, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, relayerApiAssetDataPairsSchema, From bd00f1279b2b8bdfc4971580b2ec547d2849d5df Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 13:54:27 +0100 Subject: [PATCH 35/73] Add CHANGELOG entry --- packages/json-schemas/CHANGELOG.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index 53d929901b..08e74b6dbb 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,4 +1,14 @@ [ + { + "version": "2.0.0", + "changes": [ + { + "note": + "Convert all schemas to JSON files so that they can be used with `json-schema` implemenations in other programming languages.", + "pr": 1145 + } + ] + }, { "timestamp": 1538693146, "version": "1.0.7", From d87643fdfa722237247d28333e8ce50404670040 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 14:02:38 +0100 Subject: [PATCH 36/73] Update schemas markdown section for v2 docs --- .../md/docs/json_schemas/2.0.0/schemas.md | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/website/md/docs/json_schemas/2.0.0/schemas.md b/packages/website/md/docs/json_schemas/2.0.0/schemas.md index 4f3200b1c7..ec7cf6f15e 100644 --- a/packages/website/md/docs/json_schemas/2.0.0/schemas.md +++ b/packages/website/md/docs/json_schemas/2.0.0/schemas.md @@ -1,28 +1,40 @@ +Basic Schemas + +* [Address type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/address.json) +* [Number type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/number.json) +* [Hex type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/hex.json) +* [JS number](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/js_number.json) + 0x Protocol Schemas -* [Basic types](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/basic_type_schemas.ts) (e.g Ethereum address, number, hex) -* [Order/SignedOrder](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_schemas.ts) -* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_hash_schema.ts) +* [Order](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_schema.json) +* [SignedOrder](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_order_schema.json) +* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_hash_schema.json) +* [ECSignature](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/ec_signature_schema.json) 0x.js Schemas -* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_range_schema.ts) -* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/index_filter_values_schema.ts) -* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_requests_schema.ts) -* [OrderCancellationRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_cancel_schema.ts) -* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts) -* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_orders_schema.ts) -* [Token](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/token_schema.ts) -* [TxData](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/tx_data_schema.ts) +* [BlockParam](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_param_schema.json) +* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_range_schema.json) +* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/index_filter_values_schema.json) +* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_requests_schema.json) +* [OrderCancellationRequests](https://github.com/0xProjet/0x-monorepo/blob/development/packages/json-schemas/schemas/order_cancel_schema.json) +* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json) +* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_orders_schema.json) +* [Token](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/token_schema.json) +* [TxData](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/tx_data_schema.json) Standard Relayer API Schemas -* [Paginated collection](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/paginated_collection_schema.ts) -* [Error response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.ts) -* [Order config payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts) -* [Order config response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts) -* [Orders channel subscribe](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts) -* [Orders channel update](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts) -* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts) -* [Asset pairs response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts) -* [Fee recipients response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts) +* [Paginated collection](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/paginated_collection_schema.json) +* [Error response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.json) +* [Order config payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json) +* [Order config response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json) +* [Orders channel subscribe payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json) +* [Orders channel subscribe](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json) +* [Orders channel update](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json) +* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json) +* [Asset pairs](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_schema.json) +* [Trade info](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_trade_info_schema.json) +* [Asset pairs response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.json) +* [Fee recipients response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json) From abc00b05c3e5b09004c247f5c1b7f7cf007591f6 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 17 Oct 2018 14:04:01 +0100 Subject: [PATCH 37/73] chore: remove schemas from include section --- packages/json-schemas/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json index 6837871029..425dfcfe18 100644 --- a/packages/json-schemas/tsconfig.json +++ b/packages/json-schemas/tsconfig.json @@ -5,7 +5,7 @@ "rootDir": ".", "resolveJsonModule": true }, - "include": ["./src/**/*", "./test/**/*", "./schemas/**/*"], + "include": ["./src/**/*", "./test/**/*"], "files": [ "./schemas/address_schema.json", "./schemas/number_schema.json", From 0ecaa90ffd723ab4f07eb94e0c816e19b910269d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 17 Oct 2018 15:14:23 +0200 Subject: [PATCH 38/73] Add leo to CODEOWNERS on some packages --- CODEOWNERS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index e2a8d93cd5..b55f4f148d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,3 +8,16 @@ packages/asset-buyer/ @BMillman19 @fragosti @steveklebanoff packages/instant/ @BMillman19 @fragosti @steveklebanoff packages/website/ @BMillman19 @fragosti @fabioberger @steveklebanoff + +# Dev tools & setup +packages/abi-gen/ @LogvinovLeon +packages/base-contract/ @LogvinovLeon +packages/contract_templates/ @LogvinovLeon +packages/dev-utils/ @LogvinovLeon +packages/ethereum-types/ @LogvinovLeon +packages/metacoin/ @LogvinovLeon +packages/sol-compiler/ @LogvinovLeon +packages/sol-cov/ @LogvinovLeon +packages/sol-resolver/ @LogvinovLeon +packages/web3-wrapper/ @LogvinovLeon +.circleci/ @LogvinovLeon From b7d7c5f38b834ed9addfaf016dc7cae1fc107ff2 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 14:20:49 +0100 Subject: [PATCH 39/73] chore: Add json schemas to prettier ignore --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 8d302a2753..79dec3d1f4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ lib /packages/contracts/generated-artifacts /packages/abi-gen-wrappers/src/generated-wrappers /packages/contract-artifacts/artifacts +/packages/json-schemas/schemas /packages/metacoin/src/contract_wrappers /packages/metacoin/artifacts /packages/sra-spec/public/ From 7fab0a5a869032ad39e179b2a6e2d142526eff04 Mon Sep 17 00:00:00 2001 From: Kadinsky Date: Wed, 17 Oct 2018 16:25:05 +0200 Subject: [PATCH 40/73] Update CODEOWNERS --- CODEOWNERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index b55f4f148d..481abc05e6 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -13,7 +13,8 @@ packages/website/ @BMillman19 @fragosti @fabioberger @steveklebanoff packages/abi-gen/ @LogvinovLeon packages/base-contract/ @LogvinovLeon packages/contract_templates/ @LogvinovLeon -packages/dev-utils/ @LogvinovLeon +packages/dev-utils/ @LogvinovLeon @fabioberger + packages/ethereum-types/ @LogvinovLeon packages/metacoin/ @LogvinovLeon packages/sol-compiler/ @LogvinovLeon From 7db53cf92c7db9e88dd42f15c11bff53bc3f5454 Mon Sep 17 00:00:00 2001 From: Kadinsky Date: Wed, 17 Oct 2018 16:25:10 +0200 Subject: [PATCH 41/73] Update CODEOWNERS --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 481abc05e6..9d1ea67c0e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -20,5 +20,5 @@ packages/metacoin/ @LogvinovLeon packages/sol-compiler/ @LogvinovLeon packages/sol-cov/ @LogvinovLeon packages/sol-resolver/ @LogvinovLeon -packages/web3-wrapper/ @LogvinovLeon +packages/web3-wrapper/ @LogvinovLeon @fabioberger .circleci/ @LogvinovLeon From 492df3108cb7add39600ad5a54740643782a9732 Mon Sep 17 00:00:00 2001 From: Kadinsky Date: Wed, 17 Oct 2018 16:25:17 +0200 Subject: [PATCH 42/73] Update CODEOWNERS --- CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index 9d1ea67c0e..278234affb 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -22,3 +22,7 @@ packages/sol-cov/ @LogvinovLeon packages/sol-resolver/ @LogvinovLeon packages/web3-wrapper/ @LogvinovLeon @fabioberger .circleci/ @LogvinovLeon +packages/subproviders/ @fabioberger @dekz +packages/connect/ @fragosti +packages/monorepo-scripts/ @fabioberger +packages/order-utils/ @fabioberger @LogvinovLeon From f2e5a9635bdd61dbba2713ef6c556d412481251d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 15:33:50 +0100 Subject: [PATCH 43/73] chore: make linter ignore json schemas --- packages/json-schemas/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 38dee306da..46305b6abb 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -10,7 +10,7 @@ "scripts": { "build": "tsc -b", "build:ci": "yarn build", - "lint": "tslint --project .", + "lint": "tslint --project . --exclude **/schemas/**/*", "test": "yarn run_mocha", "rebuild_and_test": "run-s clean build test", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", From 7c87d2e38b070fa9c3f2704c60f4e886d921cda3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 16:18:28 +0100 Subject: [PATCH 44/73] chore: Update TypeDoc to 0.13.0 (supports TS v3.1) --- packages/0x.js/package.json | 2 +- packages/asset-buyer/package.json | 2 +- packages/connect/package.json | 2 +- packages/contract-wrappers/package.json | 2 +- packages/instant/package.json | 2 +- packages/json-schemas/package.json | 2 +- packages/monorepo-scripts/package.json | 2 +- packages/order-utils/package.json | 2 +- packages/sol-compiler/package.json | 2 +- packages/sol-cov/package.json | 2 +- packages/subproviders/package.json | 2 +- packages/web3-wrapper/package.json | 2 +- yarn.lock | 16 ++++++++++------ 13 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index a78457e223..c439c8af32 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -68,7 +68,7 @@ "sinon": "^4.0.0", "source-map-support": "^0.5.0", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1", "uglifyjs-webpack-plugin": "^2.0.1", "webpack": "^4.20.2" diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 8c8f3c92c8..1f97365f4e 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -63,7 +63,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "publishConfig": { diff --git a/packages/connect/package.json b/packages/connect/package.json index e47ca3b798..591db0f833 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -77,7 +77,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "publishConfig": { diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 3924378d3a..ef19057cd8 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -60,7 +60,7 @@ "sinon": "^4.0.0", "source-map-support": "^0.5.0", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1", "web3-provider-engine": "14.0.6" }, diff --git a/packages/instant/package.json b/packages/instant/package.json index 203ac48943..0c4b470fac 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -79,7 +79,7 @@ "shx": "^0.2.2", "ts-jest": "^23.10.3", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1", "webpack": "^4.20.2", "webpack-cli": "^3.1.1", diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 46305b6abb..20d2e48cef 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -59,7 +59,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "publishConfig": { diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 83091ae841..57e8bc1473 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -65,7 +65,7 @@ "semver": "5.5.0", "semver-diff": "^2.1.0", "semver-sort": "0.0.4", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "yargs": "^10.0.3" }, "publishConfig": { diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 50bc0f0a00..09eef849f7 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -49,7 +49,7 @@ "shx": "^0.2.2", "sinon": "^4.0.0", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "dependencies": { diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 9ee88a5ef0..828ce1dbc9 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -58,7 +58,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "types-bn": "^0.0.1", "typescript": "3.0.1", "web3-typescript-typings": "^0.10.2", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index e093aa2adb..49473f6c8f 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -78,7 +78,7 @@ "shx": "^0.2.2", "sinon": "^4.0.0", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "publishConfig": { diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index bef93a5728..1fe1ee4ade 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -73,7 +73,7 @@ "shx": "^0.2.2", "sinon": "^4.0.0", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1", "webpack": "^4.20.2" }, diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 972dfa7a27..4d033e1306 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -49,7 +49,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0.12.0", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "dependencies": { diff --git a/yarn.lock b/yarn.lock index 661d4b475a..b4f48b8ac9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6410,7 +6410,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" @@ -14877,9 +14877,9 @@ typedoc-default-themes@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz#6dc2433e78ed8bea8e887a3acde2f31785bd6227" -typedoc@0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.12.0.tgz#c5d606f52af29d841658e18d9faa1a72acf0e270" +typedoc@0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.13.0.tgz#9efdf352bd54873955cd161bd4b75f24a8c59dde" dependencies: "@types/fs-extra" "^5.0.3" "@types/handlebars" "^4.0.38" @@ -14897,7 +14897,7 @@ typedoc@0.12.0: progress "^2.0.0" shelljs "^0.8.2" typedoc-default-themes "^0.5.0" - typescript "3.0.x" + typescript "3.1.x" types-bn@^0.0.1: version "0.0.1" @@ -14905,10 +14905,14 @@ types-bn@^0.0.1: dependencies: bn.js "4.11.7" -typescript@3.0.1, typescript@3.0.x: +typescript@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb" +typescript@3.1.x: + version "3.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5" + typewise-core@^1.2, typewise-core@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/typewise-core/-/typewise-core-1.2.0.tgz#97eb91805c7f55d2f941748fa50d315d991ef195" From f3f97896ed647c457d4ab5f5f5e732cebe629c3a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 16:18:51 +0100 Subject: [PATCH 45/73] chore: add `resolveJsonModule` to TypeDoc tsconfig.json --- typedoc-tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/typedoc-tsconfig.json b/typedoc-tsconfig.json index 5882851402..32efdb4cfd 100644 --- a/typedoc-tsconfig.json +++ b/typedoc-tsconfig.json @@ -8,6 +8,7 @@ "experimentalDecorators": true, "downlevelIteration": true, "noImplicitReturns": true, + "resolveJsonModule": true, "pretty": true, "skipLibCheck": true, "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], From 852f50d1a0e2d7f6c95231406c8604f9e56dc1dc Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 17:09:35 +0100 Subject: [PATCH 46/73] chore: Re-cast to EventAbi after checking the the type is set to 'event' --- packages/utils/src/abi_decoder.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index ac3e54efb6..9cc8639090 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -99,11 +99,12 @@ export class AbiDecoder { const ethersInterface = new ethers.utils.Interface(abiArray); _.map(abiArray, (abi: AbiDefinition) => { if (abi.type === AbiType.Event) { - const topic = ethersInterface.events[abi.name].topic; - const numIndexedArgs = _.reduce(abi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0); + const eventAbi = abi as EventAbi; + const topic = ethersInterface.events[eventAbi.name].topic; + const numIndexedArgs = _.reduce(eventAbi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0); this._methodIds[topic] = { ...this._methodIds[topic], - [numIndexedArgs]: abi, + [numIndexedArgs]: eventAbi, }; } }); From f7de26f65c4aebcf5d27dab07f4b75081b48d7ac Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 17:13:32 +0100 Subject: [PATCH 47/73] chore: make abi `type` prop always of type string to fix TypeDoc issue related to reading in artifacts from JSON files --- packages/ethereum-types/src/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index ddd4720101..eff38711aa 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -20,7 +20,9 @@ export type ConstructorStateMutability = 'nonpayable' | 'payable'; export type StateMutability = 'pure' | 'view' | ConstructorStateMutability; export interface MethodAbi { - type: 'function'; // We hardcode this here b/c doc pages cannot render an enum value + // Ideally this would be set to: `'function'` but then TS complains when artifacts are loaded + // from JSON files, and this value has type `string` not type `'function'` + type: string; name: string; inputs: DataItem[]; outputs: DataItem[]; @@ -30,14 +32,18 @@ export interface MethodAbi { } export interface ConstructorAbi { - type: 'constructor'; // We hardcode this here b/c doc pages cannot render an enum value + // Ideally this would be set to: `'constructor'` but then TS complains when artifacts are loaded + // from JSON files, and this value has type `string` not type `'constructor'` + type: string; inputs: DataItem[]; payable: boolean; stateMutability: ConstructorStateMutability; } export interface FallbackAbi { - type: 'fallback'; // We hardcode this here b/c doc pages cannot render an enum value + // Ideally this would be set to: `'fallback'` but then TS complains when artifacts are loaded + // from JSON files, and this value has type `string` not type `'fallback'` + type: string; payable: boolean; } @@ -46,7 +52,9 @@ export interface EventParameter extends DataItem { } export interface EventAbi { - type: 'event'; // We hardcode this here b/c doc pages cannot render an enum value + // Ideally this would be set to: `'event'` but then TS complains when artifacts are loaded + // from JSON files, and this value has type `string` not type `'event'` + type: string; name: string; inputs: EventParameter[]; anonymous: boolean; From a31f3b542f96b0a332c9b6424d5bf21f5a4dd8b9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 17:18:00 +0100 Subject: [PATCH 48/73] Add necessary cast --- packages/base-contract/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index a8e4ad2e26..354362d456 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -1,5 +1,6 @@ import { abiUtils, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { FunctionAbi } from 'ethereum-protocol'; import { AbiDefinition, AbiType, @@ -129,7 +130,7 @@ export class BaseContract { if (abiDefinition.type !== AbiType.Function) { return false; } - const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition); + const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition as MethodAbi); if (abiFunctionSignature === functionSignature) { return true; } From 87fabbb943779d868d29c437f078a341cb177b2b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 17:36:21 +0100 Subject: [PATCH 49/73] chore: Fix remaining necessary casts --- packages/sol-compiler/src/utils/encoder.ts | 5 +++-- packages/sol-doc/src/sol_doc.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/sol-compiler/src/utils/encoder.ts b/packages/sol-compiler/src/utils/encoder.ts index 0f2d756910..6527304d6a 100644 --- a/packages/sol-compiler/src/utils/encoder.ts +++ b/packages/sol-compiler/src/utils/encoder.ts @@ -1,4 +1,4 @@ -import { AbiDefinition, AbiType, ContractAbi, DataItem } from 'ethereum-types'; +import { AbiDefinition, AbiType, ConstructorAbi, ContractAbi, DataItem } from 'ethereum-types'; import * as _ from 'lodash'; import * as web3Abi from 'web3-eth-abi'; @@ -7,7 +7,8 @@ export const encoder = { const constructorTypes: string[] = []; _.each(abi, (element: AbiDefinition) => { if (element.type === AbiType.Constructor) { - _.each(element.inputs, (input: DataItem) => { + const constuctorAbi = element as ConstructorAbi; + _.each(constuctorAbi.inputs, (input: DataItem) => { constructorTypes.push(input.type); }); } diff --git a/packages/sol-doc/src/sol_doc.ts b/packages/sol-doc/src/sol_doc.ts index 138882c922..35ba2c6e8f 100644 --- a/packages/sol-doc/src/sol_doc.ts +++ b/packages/sol-doc/src/sol_doc.ts @@ -324,19 +324,21 @@ export class SolDoc { switch (abiDefinition.type) { case 'constructor': docSection.constructors.push( - this._genConstructorDoc(contractName, abiDefinition, compiledContract.devdoc), + this._genConstructorDoc(contractName, abiDefinition as ConstructorAbi, compiledContract.devdoc), ); break; case 'event': - (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition)); + (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition as EventAbi)); // note that we're not sending devdoc to this._genEventDoc(). // that's because the type of the events array doesn't have any fields for documentation! break; case 'function': - docSection.methods.push(this._genMethodDoc(abiDefinition, compiledContract.devdoc)); + docSection.methods.push(this._genMethodDoc(abiDefinition as MethodAbi, compiledContract.devdoc)); break; case 'fallback': - docSection.methods.push(SolDoc._genFallbackDoc(abiDefinition, compiledContract.devdoc)); + docSection.methods.push( + SolDoc._genFallbackDoc(abiDefinition as FallbackAbi, compiledContract.devdoc), + ); break; default: throw new Error( From bdae4ba2a2c9b7b3b41c352c628cb11cd4a1f295 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 17 Oct 2018 18:23:06 +0100 Subject: [PATCH 50/73] chore: tslint fix --- packages/base-contract/src/index.ts | 2 +- packages/sol-compiler/src/utils/encoder.ts | 1 + packages/sol-doc/src/sol_doc.ts | 4 ++++ packages/utils/src/abi_decoder.ts | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index 354362d456..73550ffd4e 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -1,6 +1,5 @@ import { abiUtils, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { FunctionAbi } from 'ethereum-protocol'; import { AbiDefinition, AbiType, @@ -130,6 +129,7 @@ export class BaseContract { if (abiDefinition.type !== AbiType.Function) { return false; } + // tslint:disable-next-line:no-unnecessary-type-assertion const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition as MethodAbi); if (abiFunctionSignature === functionSignature) { return true; diff --git a/packages/sol-compiler/src/utils/encoder.ts b/packages/sol-compiler/src/utils/encoder.ts index 6527304d6a..40b103fd55 100644 --- a/packages/sol-compiler/src/utils/encoder.ts +++ b/packages/sol-compiler/src/utils/encoder.ts @@ -7,6 +7,7 @@ export const encoder = { const constructorTypes: string[] = []; _.each(abi, (element: AbiDefinition) => { if (element.type === AbiType.Constructor) { + // tslint:disable-next-line:no-unnecessary-type-assertion const constuctorAbi = element as ConstructorAbi; _.each(constuctorAbi.inputs, (input: DataItem) => { constructorTypes.push(input.type); diff --git a/packages/sol-doc/src/sol_doc.ts b/packages/sol-doc/src/sol_doc.ts index 35ba2c6e8f..686e9ca348 100644 --- a/packages/sol-doc/src/sol_doc.ts +++ b/packages/sol-doc/src/sol_doc.ts @@ -324,18 +324,22 @@ export class SolDoc { switch (abiDefinition.type) { case 'constructor': docSection.constructors.push( + // tslint:disable-next-line:no-unnecessary-type-assertion this._genConstructorDoc(contractName, abiDefinition as ConstructorAbi, compiledContract.devdoc), ); break; case 'event': + // tslint:disable-next-line:no-unnecessary-type-assertion (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition as EventAbi)); // note that we're not sending devdoc to this._genEventDoc(). // that's because the type of the events array doesn't have any fields for documentation! break; case 'function': + // tslint:disable-next-line:no-unnecessary-type-assertion docSection.methods.push(this._genMethodDoc(abiDefinition as MethodAbi, compiledContract.devdoc)); break; case 'fallback': + // tslint:disable-next-line:no-unnecessary-type-assertion docSection.methods.push( SolDoc._genFallbackDoc(abiDefinition as FallbackAbi, compiledContract.devdoc), ); diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index 9cc8639090..c0b2c7950a 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -99,6 +99,7 @@ export class AbiDecoder { const ethersInterface = new ethers.utils.Interface(abiArray); _.map(abiArray, (abi: AbiDefinition) => { if (abi.type === AbiType.Event) { + // tslint:disable-next-line:no-unnecessary-type-assertion const eventAbi = abi as EventAbi; const topic = ethersInterface.events[eventAbi.name].topic; const numIndexedArgs = _.reduce(eventAbi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0); From 75e3b44d9e2028eb8d07356c8939450240e35958 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 17 Oct 2018 10:33:05 -0700 Subject: [PATCH 51/73] Update asset-buyer usage wording --- packages/website/md/docs/asset_buyer/usage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/website/md/docs/asset_buyer/usage.md b/packages/website/md/docs/asset_buyer/usage.md index 93c681f409..6462d938e4 100644 --- a/packages/website/md/docs/asset_buyer/usage.md +++ b/packages/website/md/docs/asset_buyer/usage.md @@ -25,8 +25,8 @@ const erc20TokenAddress = '0x5fa3c....'; const amountToBuy = new BigNumber(50000000000000000000); const buyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(erc20TokenAddress, amountToBuy); const quoteInfo = buyQuote.worstCaseQuoteInfo; -console.log(quoteInfo.ethAmount); // the total amount the user needs to pay to buy the desired amount (including fees) -console.log(quoteInfo.feeAmount); // a portion of the total ethAmount above that was used to buy fees +console.log(quoteInfo.ethAmount); // the total amount the user needs to pay to buy the desired amount (including ZRX fees) +console.log(quoteInfo.feeAmount); // a portion of the total ethAmount above that was used to buy affiliate fees console.log(quoteInfo.ethPerAssetPrice); // the rate that this quote provides (e.g. 0.0035ETH / REP) ``` From 81505ba56cc8a5b0a2991b07e8320a442ee74f27 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 17 Oct 2018 10:44:25 -0700 Subject: [PATCH 52/73] Fix duplicate BuyQuoteInfo --- packages/asset-buyer/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts index 20a36b2501..9ac3c0b8ae 100644 --- a/packages/asset-buyer/src/index.ts +++ b/packages/asset-buyer/src/index.ts @@ -15,7 +15,6 @@ export { AssetBuyerError, AssetBuyerOpts, BuyQuote, - BuyQuoteInfo, BuyQuoteExecutionOpts, BuyQuoteInfo, BuyQuoteRequestOpts, From 18c9907d6f168577c9d5f60117901268a25f6af9 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 12 Oct 2018 15:35:20 -0700 Subject: [PATCH 53/73] feat(instant): add sliding error --- .../src/components/animations/slide_up_and_down_animation.tsx | 1 - packages/instant/src/components/ui/text.tsx | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx b/packages/instant/src/components/animations/slide_up_and_down_animation.tsx index 9c18e09336..5fa0b0eda5 100644 --- a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx +++ b/packages/instant/src/components/animations/slide_up_and_down_animation.tsx @@ -19,7 +19,6 @@ export interface SlideAnimationProps { animationType: string; animationDirection?: string; } - export const SlideAnimation = styled.div < SlideAnimationProps > diff --git a/packages/instant/src/components/ui/text.tsx b/packages/instant/src/components/ui/text.tsx index 9fb8ea26f7..af8e4d9331 100644 --- a/packages/instant/src/components/ui/text.tsx +++ b/packages/instant/src/components/ui/text.tsx @@ -21,6 +21,8 @@ export interface TextProps { hoverColor?: string; noWrap?: boolean; display?: string; + marginRight?: string; + marginLeft?: string; } const PlainText: React.StatelessComponent = ({ children, className, onClick }) => ( @@ -47,6 +49,8 @@ export const Text = styled(PlainText)` ${props => (props.display ? `display: ${props.display}` : '')}; ${props => (props.letterSpacing ? `letter-spacing: ${props.letterSpacing}` : '')}; ${props => (props.textTransform ? `text-transform: ${props.textTransform}` : '')}; + ${props => (props.marginRight ? `margin-right: ${props.marginRight}` : '')}; + ${props => (props.marginLeft ? `margin-right: ${props.marginLeft}` : '')}; &:hover { ${props => props.onClick From f36352be47a3caf92e16e3965c86b593bfc46fea Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 15 Oct 2018 14:04:53 -0700 Subject: [PATCH 54/73] move z-index setting to zero instant container, and add ability for zindex to be set on container --- packages/instant/src/components/zero_ex_instant_container.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 51f9dc63ec..0c37e41dbf 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -6,6 +6,10 @@ import { SelectedAssetInstantHeading } from '../containers/selected_asset_instan import { ColorOption } from '../style/theme'; +import { BuyButton } from './buy_button'; +import { InstantHeading } from './instant_heading'; +import { OrderDetails } from './order_details'; +import { SlidingError } from './sliding_error'; import { Container, Flex } from './ui'; export interface ZeroExInstantContainerProps {} From db77cd10c550803c4f3fac585adc0a7f6ffa8999 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 16 Oct 2018 11:25:52 -0700 Subject: [PATCH 55/73] feat(instant): Handle AssetBuyer errors --- .../animations/slide_animations.tsx | 54 +++++++++++ .../slide_up_and_down_animation.tsx | 95 ------------------- .../src/components/asset_amount_input.tsx | 19 +--- .../instant/src/components/sliding_error.tsx | 20 ++-- .../components/zero_ex_instant_container.tsx | 4 + .../instant/src/containers/latest_error.tsx | 36 +++++++ .../containers/selected_asset_amount_input.ts | 13 ++- packages/instant/src/redux/actions.ts | 6 ++ packages/instant/src/redux/reducer.ts | 30 +++++- packages/instant/src/redux/store.ts | 3 +- packages/instant/src/util/asset_data.ts | 18 ++++ .../instant/src/util/error_description.ts | 23 +++++ packages/instant/src/util/error_flasher.ts | 27 ++++++ 13 files changed, 228 insertions(+), 120 deletions(-) create mode 100644 packages/instant/src/components/animations/slide_animations.tsx delete mode 100644 packages/instant/src/components/animations/slide_up_and_down_animation.tsx create mode 100644 packages/instant/src/containers/latest_error.tsx create mode 100644 packages/instant/src/util/asset_data.ts create mode 100644 packages/instant/src/util/error_description.ts create mode 100644 packages/instant/src/util/error_flasher.ts diff --git a/packages/instant/src/components/animations/slide_animations.tsx b/packages/instant/src/components/animations/slide_animations.tsx new file mode 100644 index 0000000000..1f10a2ed6c --- /dev/null +++ b/packages/instant/src/components/animations/slide_animations.tsx @@ -0,0 +1,54 @@ +import * as React from 'react'; + +import { keyframes, styled } from '../../style/theme'; + +const slideKeyframeGenerator = (fromY: string, toY: string) => keyframes` + from { + position: relative; + top: ${fromY}; + } + + to { + position: relative; + top: ${toY}; + } +`; + +export interface SlideAnimationProps { + keyframes: string; + animationType: string; + animationDirection?: string; +} + +export const SlideAnimation = + styled.div < + SlideAnimationProps > + ` + animation-name: ${props => props.keyframes}; + animation-duration: 0.3s; + animation-timing-function: ${props => props.animationType}; + animation-delay: 0s; + animation-iteration-count: 1; + animation-fill-mode: ${props => props.animationDirection || 'none'}; + position: relative; +`; + +export interface SlideAnimationComponentProps { + downY: string; +} + +export const SlideUpAnimation: React.StatelessComponent = props => ( + + {props.children} + +); + +export const SlideDownAnimation: React.StatelessComponent = props => ( + + {props.children} + +); diff --git a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx b/packages/instant/src/components/animations/slide_up_and_down_animation.tsx deleted file mode 100644 index 5fa0b0eda5..0000000000 --- a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import * as React from 'react'; - -import { keyframes, styled } from '../../style/theme'; - -const slideKeyframeGenerator = (fromY: string, toY: string) => keyframes` - from { - position: relative; - top: ${fromY}; - } - - to { - position: relative; - top: ${toY}; - } -`; - -export interface SlideAnimationProps { - keyframes: string; - animationType: string; - animationDirection?: string; -} -export const SlideAnimation = - styled.div < - SlideAnimationProps > - ` - animation-name: ${props => props.keyframes}; - animation-duration: 0.3s; - animation-timing-function: ${props => props.animationType}; - animation-delay: 0s; - animation-iteration-count: 1; - animation-fill-mode: ${props => props.animationDirection || 'none'}; - position: relative; -`; - -export interface SlideAnimationComponentProps { - downY: string; -} - -export const SlideUpAnimationComponent: React.StatelessComponent = props => ( - - {props.children} - -); - -export const SlideDownAnimationComponent: React.StatelessComponent = props => ( - - {props.children} - -); - -export interface SlideUpAndDownAnimationProps extends SlideAnimationComponentProps { - delayMs: number; -} - -enum SlideState { - Up = 'up', - Down = 'down', -} -interface SlideUpAndDownState { - slideState: SlideState; -} - -export class SlideUpAndDownAnimation extends React.Component { - public state = { - slideState: SlideState.Up, - }; - - private _timeoutId?: number; - public render(): React.ReactNode { - return this._renderSlide(); - } - public componentDidMount(): void { - this._timeoutId = window.setTimeout(() => { - this.setState({ - slideState: SlideState.Down, - }); - }, this.props.delayMs); - - return; - } - public componentWillUnmount(): void { - if (this._timeoutId) { - window.clearTimeout(this._timeoutId); - } - } - private _renderSlide(): React.ReactNode { - const SlideComponent = this.state.slideState === 'up' ? SlideUpAnimationComponent : SlideDownAnimationComponent; - - return {this.props.children}; - } -} diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index 7c6b03ee90..a7df2da4d9 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -3,7 +3,8 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; -import { assetMetaData } from '../data/asset_meta_data'; +import { bestNameForAsset } from '../util/asset_data'; + import { ColorOption } from '../style/theme'; import { util } from '../util/util'; @@ -26,26 +27,12 @@ export class AssetAmountInput extends React.Component { - {this._getAssetSymbolLabel()} + {bestNameForAsset(this.props.assetData, '???')} ); } - private readonly _getAssetSymbolLabel = (): string => { - const unknownLabel = '???'; - if (_.isUndefined(this.props.assetData)) { - return unknownLabel; - } - const metaData = assetMetaData[this.props.assetData]; - if (_.isUndefined(metaData)) { - return unknownLabel; - } - if (metaData.assetProxyId === AssetProxyId.ERC20) { - return metaData.symbol; - } - return unknownLabel; - }; private readonly _handleChange = (value?: BigNumber): void => { this.props.onChange(value, this.props.assetData); }; diff --git a/packages/instant/src/components/sliding_error.tsx b/packages/instant/src/components/sliding_error.tsx index 0237fb7e9d..ad87481c45 100644 --- a/packages/instant/src/components/sliding_error.tsx +++ b/packages/instant/src/components/sliding_error.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { ColorOption } from '../style/theme'; -import { SlideUpAndDownAnimation } from './animations/slide_up_and_down_animation'; +import { SlideDownAnimation, SlideUpAnimation } from './animations/slide_animations'; import { Container, Text } from './ui'; @@ -29,8 +29,16 @@ export const Error: React.StatelessComponent = props => ( ); -export const SlidingError: React.StatelessComponent = props => ( - - - -); +export type SlidingDirection = 'up' | 'down'; +export interface SlidingErrorProps extends ErrorProps { + direction: SlidingDirection; +} +export const SlidingError: React.StatelessComponent = props => { + const AnimationComponent = props.direction === 'up' ? SlideUpAnimation : SlideDownAnimation; + + return ( + + + + ); +}; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index 0c37e41dbf..cc718d200d 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { LatestBuyQuoteOrderDetails } from '../containers/latest_buy_quote_order_details'; +import { LatestError } from '../containers/latest_error'; import { SelectedAssetBuyButton } from '../containers/selected_asset_buy_button'; import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading'; @@ -16,6 +17,9 @@ export interface ZeroExInstantContainerProps {} export const ZeroExInstantContainer: React.StatelessComponent = props => ( + + + = props => { + if (!props.latestError) { + return
; + } + const slidingDirection = props.latestErrorDismissed ? 'down' : 'up'; + const { icon, message } = errorDescription(props.latestError, props.assetData); + return ; +}; + +interface ConnectedState { + assetData?: string; + latestError?: any; + latestErrorDismissed?: boolean; +} +export interface LatestErrorProps {} +const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({ + assetData: state.selectedAssetData, + latestError: state.latestError, + latestErrorDismissed: state.latestErrorDismissed, +}); + +export const LatestError = connect(mapStateToProps)(LatestErrorComponent); diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index f2ca96ae4f..00c0a11149 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -1,3 +1,4 @@ +import { BuyQuote } from '@0xproject/asset-buyer'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; @@ -11,6 +12,7 @@ import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; import { AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; +import { errorFlasher } from '../util/error_flasher'; import { AssetAmountInput } from '../components/asset_amount_input'; @@ -43,7 +45,16 @@ const updateBuyQuoteAsync = async ( } // get a new buy quote. const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); - const newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue); + + let newBuyQuote: BuyQuote | undefined; + try { + newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue); + errorFlasher.clearError(dispatch); + } catch (error) { + errorFlasher.flashNewError(dispatch, error); + return; + } + // invalidate the last buy quote. dispatch(actions.updateLatestBuyQuote(newBuyQuote)); }; diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts index 7d07b4950d..cf5b39790f 100644 --- a/packages/instant/src/redux/actions.ts +++ b/packages/instant/src/redux/actions.ts @@ -25,6 +25,9 @@ export enum ActionTypes { UPDATE_SELECTED_ASSET_AMOUNT = 'UPDATE_SELECTED_ASSET_AMOUNT', UPDATE_SELECTED_ASSET_BUY_STATE = 'UPDATE_SELECTED_ASSET_BUY_STATE', UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE', + SET_ERROR = 'SET_ERROR', + HIDE_ERROR = 'HIDE_ERROR', + CLEAR_ERROR = 'CLEAR_ERROR', } export const actions = { @@ -33,4 +36,7 @@ export const actions = { updateSelectedAssetBuyState: (buyState: AsyncProcessState) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, buyState), updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote), + setError: (error?: any) => createAction(ActionTypes.SET_ERROR, error), + hideError: () => createAction(ActionTypes.HIDE_ERROR), + clearError: () => createAction(ActionTypes.CLEAR_ERROR), }; diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index adecf2ab70..4ff49c2259 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -7,13 +7,22 @@ import { AsyncProcessState } from '../types'; import { Action, ActionTypes } from './actions'; -export interface State { +interface BaseState { selectedAssetData?: string; selectedAssetAmount?: BigNumber; selectedAssetBuyState: AsyncProcessState; ethUsdPrice?: BigNumber; latestBuyQuote?: BuyQuote; } +interface StateWithError extends BaseState { + latestError: any; + latestErrorDismissed: boolean; +} +interface StateWithoutError extends BaseState { + latestError: undefined; + latestErrorDismissed: undefined; +} +export type State = StateWithError | StateWithoutError; export const INITIAL_STATE: State = { // TODO: Remove hardcoded zrxAssetData @@ -22,6 +31,8 @@ export const INITIAL_STATE: State = { selectedAssetBuyState: AsyncProcessState.NONE, ethUsdPrice: undefined, latestBuyQuote: undefined, + latestError: undefined, + latestErrorDismissed: undefined, }; export const reducer = (state: State = INITIAL_STATE, action: Action): State => { @@ -46,6 +57,23 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => ...state, selectedAssetBuyState: action.data, }; + case ActionTypes.SET_ERROR: + return { + ...state, + latestError: action.data, + latestErrorDismissed: false, + }; + case ActionTypes.HIDE_ERROR: + return { + ...state, + latestErrorDismissed: true, + }; + case ActionTypes.CLEAR_ERROR: + return { + ...state, + latestError: undefined, + latestErrorDismissed: undefined, + }; default: return state; } diff --git a/packages/instant/src/redux/store.ts b/packages/instant/src/redux/store.ts index fcd19f9a82..8d9fe34cbc 100644 --- a/packages/instant/src/redux/store.ts +++ b/packages/instant/src/redux/store.ts @@ -3,4 +3,5 @@ import { createStore, Store as ReduxStore } from 'redux'; import { reducer, State } from './reducer'; -export const store: ReduxStore = createStore(reducer); +const reduxDevTools = (window as any).__REDUX_DEVTOOLS_EXTENSION__; +export const store: ReduxStore = createStore(reducer, reduxDevTools && reduxDevTools()); diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts new file mode 100644 index 0000000000..958f500bbe --- /dev/null +++ b/packages/instant/src/util/asset_data.ts @@ -0,0 +1,18 @@ +import { AssetProxyId } from '@0xproject/types'; + +import { assetMetaData } from '../data/asset_meta_data'; + +// TODO: tests for this +export const bestNameForAsset = (assetData: string | undefined, defaultString: string) => { + if (assetData === undefined) { + return defaultString; + } + const metaData = assetMetaData[assetData]; + if (metaData === undefined) { + return defaultString; + } + if (metaData.assetProxyId === AssetProxyId.ERC20) { + return metaData.symbol.toUpperCase(); + } + return defaultString; +}; diff --git a/packages/instant/src/util/error_description.ts b/packages/instant/src/util/error_description.ts new file mode 100644 index 0000000000..78af9e9ff5 --- /dev/null +++ b/packages/instant/src/util/error_description.ts @@ -0,0 +1,23 @@ +import { AssetBuyerError } from '@0xproject/asset-buyer'; + +import { bestNameForAsset } from '../util/asset_data'; + +const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { + if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { + const assetName = bestNameForAsset(assetData, 'of this asset'); + return `Not enough ${assetName} available`; + } + + return undefined; +}; + +export const errorDescription = (error?: any, assetData?: string): { icon: string; message: string } => { + let bestMessage: string | undefined; + if (error instanceof Error) { + bestMessage = humanReadableMessageForError(error, assetData); + } + return { + icon: '😢', + message: bestMessage || 'Something went wrong...', + }; +}; diff --git a/packages/instant/src/util/error_flasher.ts b/packages/instant/src/util/error_flasher.ts new file mode 100644 index 0000000000..f43c4211bc --- /dev/null +++ b/packages/instant/src/util/error_flasher.ts @@ -0,0 +1,27 @@ +import { Dispatch } from 'redux'; + +import { Action, actions } from '../redux/actions'; + +class ErrorFlasher { + private _timeoutId?: number; + public flashNewError(dispatch: Dispatch, error: any, delayMs: number = 7000): void { + this._clearTimeout(); + + // dispatch new message + dispatch(actions.setError(error)); + + this._timeoutId = window.setTimeout(() => { + dispatch(actions.hideError()); + }, delayMs); + } + public clearError(dispatch: Dispatch): void { + this._clearTimeout(); + dispatch(actions.hideError()); + } + private _clearTimeout(): void { + if (this._timeoutId) { + window.clearTimeout(this._timeoutId); + } + } +} +export const errorFlasher = new ErrorFlasher(); From 1d079490871ebb0d63bf182a75695303a3a9f1f2 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 16 Oct 2018 17:30:32 -0700 Subject: [PATCH 56/73] linting, removing unused imports --- packages/instant/src/components/asset_amount_input.tsx | 1 - packages/instant/src/components/zero_ex_instant_container.tsx | 4 ---- 2 files changed, 5 deletions(-) diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index a7df2da4d9..c9d9c52b39 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -1,4 +1,3 @@ -import { AssetProxyId } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx index cc718d200d..cf918d8901 100644 --- a/packages/instant/src/components/zero_ex_instant_container.tsx +++ b/packages/instant/src/components/zero_ex_instant_container.tsx @@ -7,10 +7,6 @@ import { SelectedAssetInstantHeading } from '../containers/selected_asset_instan import { ColorOption } from '../style/theme'; -import { BuyButton } from './buy_button'; -import { InstantHeading } from './instant_heading'; -import { OrderDetails } from './order_details'; -import { SlidingError } from './sliding_error'; import { Container, Flex } from './ui'; export interface ZeroExInstantContainerProps {} From dfc5d7d860c2edb93fe45653f755fe8ff530bf1d Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Mon, 15 Oct 2018 13:41:36 -0700 Subject: [PATCH 57/73] get rid of unused marginLeft and marginRight props --- packages/instant/src/components/ui/text.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/instant/src/components/ui/text.tsx b/packages/instant/src/components/ui/text.tsx index af8e4d9331..9fb8ea26f7 100644 --- a/packages/instant/src/components/ui/text.tsx +++ b/packages/instant/src/components/ui/text.tsx @@ -21,8 +21,6 @@ export interface TextProps { hoverColor?: string; noWrap?: boolean; display?: string; - marginRight?: string; - marginLeft?: string; } const PlainText: React.StatelessComponent = ({ children, className, onClick }) => ( @@ -49,8 +47,6 @@ export const Text = styled(PlainText)` ${props => (props.display ? `display: ${props.display}` : '')}; ${props => (props.letterSpacing ? `letter-spacing: ${props.letterSpacing}` : '')}; ${props => (props.textTransform ? `text-transform: ${props.textTransform}` : '')}; - ${props => (props.marginRight ? `margin-right: ${props.marginRight}` : '')}; - ${props => (props.marginLeft ? `margin-right: ${props.marginLeft}` : '')}; &:hover { ${props => props.onClick From d46b28873385a8d6521d36f2a529451e1f725b26 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 11:08:56 -0700 Subject: [PATCH 58/73] use redux dev tools from package --- packages/instant/package.json | 1 + packages/instant/src/redux/store.ts | 4 +-- yarn.lock | 43 ++++------------------------- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/packages/instant/package.json b/packages/instant/package.json index 0c4b470fac..5c4436c52f 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -55,6 +55,7 @@ "react-dom": "^16.5.2", "react-redux": "^5.0.7", "redux": "^4.0.0", + "redux-devtools-extension": "^2.13.5", "styled-components": "^3.4.9", "ts-optchain": "^0.1.1" }, diff --git a/packages/instant/src/redux/store.ts b/packages/instant/src/redux/store.ts index 8d9fe34cbc..b9ce9c0c11 100644 --- a/packages/instant/src/redux/store.ts +++ b/packages/instant/src/redux/store.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { createStore, Store as ReduxStore } from 'redux'; +import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly'; import { reducer, State } from './reducer'; -const reduxDevTools = (window as any).__REDUX_DEVTOOLS_EXTENSION__; -export const store: ReduxStore = createStore(reducer, reduxDevTools && reduxDevTools()); +export const store: ReduxStore = createStore(reducer, devToolsEnhancer({})); diff --git a/yarn.lock b/yarn.lock index b4f48b8ac9..0a85f90114 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1602,10 +1602,6 @@ aes-js@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" -aes-js@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" - ajv-errors@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" @@ -3006,7 +3002,7 @@ bs-logger@0.x: dependencies: fast-json-stable-stringify "^2.0.0" -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: @@ -3029,14 +3025,6 @@ bs58check@^1.0.8: bs58 "^3.1.0" create-hash "^1.1.0" -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" - dependencies: - bs58 "^4.0.0" - create-hash "^1.1.0" - safe-buffer "^5.1.2" - bser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -5590,19 +5578,6 @@ ethereumjs-wallet@0.6.0: utf8 "^2.1.1" uuid "^2.0.1" -ethereumjs-wallet@~0.6.0: - version "0.6.2" - resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" - dependencies: - aes-js "^3.1.1" - bs58check "^2.1.2" - ethereumjs-util "^5.2.0" - hdkey "^1.0.0" - safe-buffer "^5.1.2" - scrypt.js "^0.2.0" - utf8 "^3.0.0" - uuid "^3.3.2" - ethers@3.0.22: version "3.0.22" resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" @@ -7097,14 +7072,6 @@ hdkey@^0.7.0, hdkey@^0.7.1: 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" @@ -12520,6 +12487,10 @@ redux-devtools-extension@^2.13.2: version "2.13.2" resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.2.tgz#e0f9a8e8dfca7c17be92c7124958a3b94eb2911d" +redux-devtools-extension@^2.13.5: + version "2.13.5" + resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.5.tgz#3ff34f7227acfeef3964194f5f7fc2765e5c5a39" + redux@*, redux@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03" @@ -15246,10 +15217,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" From 187bbc7fc14ccc0385981a38602334de65e2506c Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 13:26:18 -0700 Subject: [PATCH 59/73] latestErrorDismissed -> latestErrorDisplay enum --- .../instant/src/containers/latest_error.tsx | 11 ++++---- packages/instant/src/redux/reducer.ts | 25 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/instant/src/containers/latest_error.tsx b/packages/instant/src/containers/latest_error.tsx index 5272d96108..7f36d3bf85 100644 --- a/packages/instant/src/containers/latest_error.tsx +++ b/packages/instant/src/containers/latest_error.tsx @@ -3,34 +3,33 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { SlidingError } from '../components/sliding_error'; -import { State } from '../redux/reducer'; +import { LatestErrorDisplay, State } from '../redux/reducer'; import { errorDescription } from '../util/error_description'; export interface LatestErrorComponentProps { assetData?: string; latestError?: any; - latestErrorDismissed?: boolean; + slidingDirection: 'down' | 'up'; } export const LatestErrorComponent: React.StatelessComponent = props => { if (!props.latestError) { return
; } - const slidingDirection = props.latestErrorDismissed ? 'down' : 'up'; const { icon, message } = errorDescription(props.latestError, props.assetData); - return ; + return ; }; interface ConnectedState { assetData?: string; latestError?: any; - latestErrorDismissed?: boolean; + slidingDirection: 'down' | 'up'; } export interface LatestErrorProps {} const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({ assetData: state.selectedAssetData, latestError: state.latestError, - latestErrorDismissed: state.latestErrorDismissed, + slidingDirection: state.latestErrorDisplay === LatestErrorDisplay.Present ? 'up' : 'down', }); export const LatestError = connect(mapStateToProps)(LatestErrorComponent); diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index 4ff49c2259..d23064db77 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -7,22 +7,19 @@ import { AsyncProcessState } from '../types'; import { Action, ActionTypes } from './actions'; -interface BaseState { +export enum LatestErrorDisplay { + Present, + Hidden, +} +export interface State { selectedAssetData?: string; selectedAssetAmount?: BigNumber; selectedAssetBuyState: AsyncProcessState; ethUsdPrice?: BigNumber; latestBuyQuote?: BuyQuote; + latestError?: any; + latestErrorDisplay: LatestErrorDisplay; } -interface StateWithError extends BaseState { - latestError: any; - latestErrorDismissed: boolean; -} -interface StateWithoutError extends BaseState { - latestError: undefined; - latestErrorDismissed: undefined; -} -export type State = StateWithError | StateWithoutError; export const INITIAL_STATE: State = { // TODO: Remove hardcoded zrxAssetData @@ -32,7 +29,7 @@ export const INITIAL_STATE: State = { ethUsdPrice: undefined, latestBuyQuote: undefined, latestError: undefined, - latestErrorDismissed: undefined, + latestErrorDisplay: LatestErrorDisplay.Hidden, }; export const reducer = (state: State = INITIAL_STATE, action: Action): State => { @@ -61,18 +58,18 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => return { ...state, latestError: action.data, - latestErrorDismissed: false, + latestErrorDisplay: LatestErrorDisplay.Present, }; case ActionTypes.HIDE_ERROR: return { ...state, - latestErrorDismissed: true, + latestErrorDisplay: LatestErrorDisplay.Hidden, }; case ActionTypes.CLEAR_ERROR: return { ...state, latestError: undefined, - latestErrorDismissed: undefined, + latestErrorDisplay: LatestErrorDisplay.Hidden, }; default: return state; From 32fa1bcc387e2eecae53db4b082e93f6fb09ae10 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 13:31:28 -0700 Subject: [PATCH 60/73] export assetDataUtil big obj --- .../src/components/asset_amount_input.tsx | 4 +-- packages/instant/src/util/asset_data.ts | 25 ++++++++++--------- .../instant/src/util/error_description.ts | 4 +-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index c9d9c52b39..db3dbe7f33 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -2,7 +2,7 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; -import { bestNameForAsset } from '../util/asset_data'; +import { assetDataUtil } from '../util/asset_data'; import { ColorOption } from '../style/theme'; import { util } from '../util/util'; @@ -26,7 +26,7 @@ export class AssetAmountInput extends React.Component { - {bestNameForAsset(this.props.assetData, '???')} + {assetDataUtil.bestNameForAsset(this.props.assetData, '???')} diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts index 958f500bbe..4f3db8447c 100644 --- a/packages/instant/src/util/asset_data.ts +++ b/packages/instant/src/util/asset_data.ts @@ -2,17 +2,18 @@ import { AssetProxyId } from '@0xproject/types'; import { assetMetaData } from '../data/asset_meta_data'; -// TODO: tests for this -export const bestNameForAsset = (assetData: string | undefined, defaultString: string) => { - if (assetData === undefined) { +export const assetDataUtil = { + bestNameForAsset: (assetData: string | undefined, defaultString: string) => { + if (assetData === undefined) { + return defaultString; + } + const metaData = assetMetaData[assetData]; + if (metaData === undefined) { + return defaultString; + } + if (metaData.assetProxyId === AssetProxyId.ERC20) { + return metaData.symbol.toUpperCase(); + } return defaultString; - } - const metaData = assetMetaData[assetData]; - if (metaData === undefined) { - return defaultString; - } - if (metaData.assetProxyId === AssetProxyId.ERC20) { - return metaData.symbol.toUpperCase(); - } - return defaultString; + }, }; diff --git a/packages/instant/src/util/error_description.ts b/packages/instant/src/util/error_description.ts index 78af9e9ff5..9419a1e162 100644 --- a/packages/instant/src/util/error_description.ts +++ b/packages/instant/src/util/error_description.ts @@ -1,10 +1,10 @@ import { AssetBuyerError } from '@0xproject/asset-buyer'; -import { bestNameForAsset } from '../util/asset_data'; +import { assetDataUtil } from '../util/asset_data'; const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { - const assetName = bestNameForAsset(assetData, 'of this asset'); + const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset'); return `Not enough ${assetName} available`; } From d052342df7247f1efc830797a8f69245db247166 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 13:32:54 -0700 Subject: [PATCH 61/73] use lodash isUndefined per PR comment --- packages/instant/src/util/asset_data.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts index 4f3db8447c..f7c5b78cd8 100644 --- a/packages/instant/src/util/asset_data.ts +++ b/packages/instant/src/util/asset_data.ts @@ -1,14 +1,16 @@ +import * as _ from 'lodash'; + import { AssetProxyId } from '@0xproject/types'; import { assetMetaData } from '../data/asset_meta_data'; export const assetDataUtil = { bestNameForAsset: (assetData: string | undefined, defaultString: string) => { - if (assetData === undefined) { + if (_.isUndefined(assetData)) { return defaultString; } const metaData = assetMetaData[assetData]; - if (metaData === undefined) { + if (_.isUndefined(metaData)) { return defaultString; } if (metaData.assetProxyId === AssetProxyId.ERC20) { From 155858de6e79d488293473e34868e20d2c39ef37 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 13:42:28 -0700 Subject: [PATCH 62/73] creating big error util file per francescos comment in PR --- .../instant/src/containers/latest_error.tsx | 4 +- .../containers/selected_asset_amount_input.ts | 6 +-- packages/instant/src/util/error.ts | 51 +++++++++++++++++++ .../instant/src/util/error_description.ts | 23 --------- packages/instant/src/util/error_flasher.ts | 27 ---------- 5 files changed, 56 insertions(+), 55 deletions(-) create mode 100644 packages/instant/src/util/error.ts delete mode 100644 packages/instant/src/util/error_description.ts delete mode 100644 packages/instant/src/util/error_flasher.ts diff --git a/packages/instant/src/containers/latest_error.tsx b/packages/instant/src/containers/latest_error.tsx index 7f36d3bf85..08ea418e75 100644 --- a/packages/instant/src/containers/latest_error.tsx +++ b/packages/instant/src/containers/latest_error.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { SlidingError } from '../components/sliding_error'; import { LatestErrorDisplay, State } from '../redux/reducer'; -import { errorDescription } from '../util/error_description'; +import { errorUtil } from '../util/error'; export interface LatestErrorComponentProps { assetData?: string; @@ -16,7 +16,7 @@ export const LatestErrorComponent: React.StatelessComponent; } - const { icon, message } = errorDescription(props.latestError, props.assetData); + const { icon, message } = errorUtil.errorDescription(props.latestError, props.assetData); return ; }; diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index 00c0a11149..0d2c6dd7bc 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -12,7 +12,7 @@ import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; import { AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; -import { errorFlasher } from '../util/error_flasher'; +import { errorUtil } from '../util/error'; import { AssetAmountInput } from '../components/asset_amount_input'; @@ -49,9 +49,9 @@ const updateBuyQuoteAsync = async ( let newBuyQuote: BuyQuote | undefined; try { newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue); - errorFlasher.clearError(dispatch); + errorUtil.errorFlasher.clearError(dispatch); } catch (error) { - errorFlasher.flashNewError(dispatch, error); + errorUtil.errorFlasher.flashNewError(dispatch, error); return; } diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts new file mode 100644 index 0000000000..78d056e110 --- /dev/null +++ b/packages/instant/src/util/error.ts @@ -0,0 +1,51 @@ +import { AssetBuyerError } from '@0xproject/asset-buyer'; +import { Dispatch } from 'redux'; + +import { Action, actions } from '../redux/actions'; +import { assetDataUtil } from '../util/asset_data'; + +class ErrorFlasher { + private _timeoutId?: number; + public flashNewError(dispatch: Dispatch, error: any, delayMs: number = 7000): void { + this._clearTimeout(); + + // dispatch new message + dispatch(actions.setError(error)); + + this._timeoutId = window.setTimeout(() => { + dispatch(actions.hideError()); + }, delayMs); + } + public clearError(dispatch: Dispatch): void { + this._clearTimeout(); + dispatch(actions.hideError()); + } + private _clearTimeout(): void { + if (this._timeoutId) { + window.clearTimeout(this._timeoutId); + } + } +} + +const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { + if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { + const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset'); + return `Not enough ${assetName} available`; + } + + return undefined; +}; + +export const errorUtil = { + errorFlasher: new ErrorFlasher(), + errorDescription: (error?: any, assetData?: string): { icon: string; message: string } => { + let bestMessage: string | undefined; + if (error instanceof Error) { + bestMessage = humanReadableMessageForError(error, assetData); + } + return { + icon: '😢', + message: bestMessage || 'Something went wrong...', + }; + }, +}; diff --git a/packages/instant/src/util/error_description.ts b/packages/instant/src/util/error_description.ts deleted file mode 100644 index 9419a1e162..0000000000 --- a/packages/instant/src/util/error_description.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { AssetBuyerError } from '@0xproject/asset-buyer'; - -import { assetDataUtil } from '../util/asset_data'; - -const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { - if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { - const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset'); - return `Not enough ${assetName} available`; - } - - return undefined; -}; - -export const errorDescription = (error?: any, assetData?: string): { icon: string; message: string } => { - let bestMessage: string | undefined; - if (error instanceof Error) { - bestMessage = humanReadableMessageForError(error, assetData); - } - return { - icon: '😢', - message: bestMessage || 'Something went wrong...', - }; -}; diff --git a/packages/instant/src/util/error_flasher.ts b/packages/instant/src/util/error_flasher.ts deleted file mode 100644 index f43c4211bc..0000000000 --- a/packages/instant/src/util/error_flasher.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Dispatch } from 'redux'; - -import { Action, actions } from '../redux/actions'; - -class ErrorFlasher { - private _timeoutId?: number; - public flashNewError(dispatch: Dispatch, error: any, delayMs: number = 7000): void { - this._clearTimeout(); - - // dispatch new message - dispatch(actions.setError(error)); - - this._timeoutId = window.setTimeout(() => { - dispatch(actions.hideError()); - }, delayMs); - } - public clearError(dispatch: Dispatch): void { - this._clearTimeout(); - dispatch(actions.hideError()); - } - private _clearTimeout(): void { - if (this._timeoutId) { - window.clearTimeout(this._timeoutId); - } - } -} -export const errorFlasher = new ErrorFlasher(); From 2b495a793521397ed4e81764aa87c3a51fef0a72 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 13:54:19 -0700 Subject: [PATCH 63/73] bigger emoji --- packages/instant/src/components/sliding_error.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/instant/src/components/sliding_error.tsx b/packages/instant/src/components/sliding_error.tsx index ad87481c45..3865a87976 100644 --- a/packages/instant/src/components/sliding_error.tsx +++ b/packages/instant/src/components/sliding_error.tsx @@ -20,8 +20,8 @@ export const Error: React.StatelessComponent = props => ( borderRadius="6px" marginBottom="10px" > - - {props.icon} + + {props.icon} {props.message} From ae4f1a093a3d02f13e56716dca2383a42b6422ba Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 14:02:39 -0700 Subject: [PATCH 64/73] handle other errors --- packages/instant/src/util/error.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts index 78d056e110..48cb131a9e 100644 --- a/packages/instant/src/util/error.ts +++ b/packages/instant/src/util/error.ts @@ -28,11 +28,22 @@ class ErrorFlasher { } const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => { - if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { + const hasInsufficientLiquidity = + error.message === AssetBuyerError.InsufficientAssetLiquidity || + error.message === AssetBuyerError.InsufficientZrxLiquidity; + if (hasInsufficientLiquidity) { const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset'); return `Not enough ${assetName} available`; } + if ( + error.message === AssetBuyerError.StandardRelayerApiError || + error.message.startsWith(AssetBuyerError.AssetUnavailable) + ) { + const assetName = assetDataUtil.bestNameForAsset(assetData, 'This asset'); + return `${assetName} is currently unavailable`; + } + return undefined; }; From f2f7598c0edcbef2a190595f835870c0b76af0cc Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 14:19:18 -0700 Subject: [PATCH 65/73] asset data util tests --- packages/instant/test/util/asset_data.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 packages/instant/test/util/asset_data.test.ts diff --git a/packages/instant/test/util/asset_data.test.ts b/packages/instant/test/util/asset_data.test.ts new file mode 100644 index 0000000000..cf247142ad --- /dev/null +++ b/packages/instant/test/util/asset_data.test.ts @@ -0,0 +1,17 @@ +import { assetDataUtil } from '../../src/util/asset_data'; + +const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; + +describe('assetDataUtil', () => { + describe('bestNameForAsset', () => { + it('should return default string if assetData is undefined', () => { + expect(assetDataUtil.bestNameForAsset(undefined, 'xyz')).toEqual('xyz'); + }); + it('should return default string if assetData isnt found', () => { + expect(assetDataUtil.bestNameForAsset('fake', 'mah default')).toEqual('mah default'); + }); + it('should return ZRX for ZRX assetData', () => { + expect(assetDataUtil.bestNameForAsset(ZRX_ASSET_DATA, 'mah default')).toEqual('ZRX'); + }); + }); +}); From 7b43cd14b305e3f01081e7ea7d0385966e4529be Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 14:34:04 -0700 Subject: [PATCH 66/73] error test --- packages/instant/test/util/error.test.ts | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/instant/test/util/error.test.ts diff --git a/packages/instant/test/util/error.test.ts b/packages/instant/test/util/error.test.ts new file mode 100644 index 0000000000..56f3a1e861 --- /dev/null +++ b/packages/instant/test/util/error.test.ts @@ -0,0 +1,48 @@ +import { AssetBuyerError } from '@0xproject/asset-buyer'; + +import { errorUtil } from '../../src/util/error'; + +const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; + +describe('errorUtil', () => { + describe('errorFlasher', () => { + it('should return error and asset name for InsufficientAssetLiquidity', () => { + const insufficientAssetError = new Error(AssetBuyerError.InsufficientAssetLiquidity); + expect(errorUtil.errorDescription(insufficientAssetError, ZRX_ASSET_DATA).message).toEqual( + 'Not enough ZRX available', + ); + }); + it('should return error default name for InsufficientAssetLiquidity', () => { + const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity); + expect(errorUtil.errorDescription(insufficientZrxError).message).toEqual( + 'Not enough of this asset available', + ); + }); + it('should return asset name for InsufficientAssetLiquidity', () => { + const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity); + expect(errorUtil.errorDescription(insufficientZrxError, ZRX_ASSET_DATA).message).toEqual( + 'Not enough ZRX available', + ); + }); + it('should return unavailable error and asset name for StandardRelayerApiError', () => { + const standardRelayerError = new Error(AssetBuyerError.StandardRelayerApiError); + expect(errorUtil.errorDescription(standardRelayerError, ZRX_ASSET_DATA).message).toEqual( + 'ZRX is currently unavailable', + ); + }); + it('should return error for AssetUnavailable error', () => { + const assetUnavailableError = new Error( + `${AssetBuyerError.AssetUnavailable}: For assetData ${ZRX_ASSET_DATA}`, + ); + expect(errorUtil.errorDescription(assetUnavailableError, ZRX_ASSET_DATA).message).toEqual( + 'ZRX is currently unavailable', + ); + }); + it('should return default for AssetUnavailable error', () => { + const assetUnavailableError = new Error(`${AssetBuyerError.AssetUnavailable}: For assetData xyz`); + expect(errorUtil.errorDescription(assetUnavailableError, 'xyz').message).toEqual( + 'This asset is currently unavailable', + ); + }); + }); +}); From 6cf8d57aee3ed332bd1109f8f39792894147d2dd Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 16:41:35 -0700 Subject: [PATCH 67/73] add concept of quoteState --- .../src/components/instant_heading.tsx | 22 +++++++++++++---- .../containers/selected_asset_amount_input.ts | 24 ++++++++++++------- .../selected_asset_instant_heading.ts | 3 +++ packages/instant/src/redux/actions.ts | 4 ++++ packages/instant/src/redux/reducer.ts | 17 ++++++++++++- packages/instant/src/types.ts | 8 +++---- 6 files changed, 60 insertions(+), 18 deletions(-) diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 492c1b2c0f..8480568007 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; +import { AsyncProcessState } from '../types'; import { format } from '../util/format'; import { Container, Flex, Text } from './ui'; @@ -12,20 +13,33 @@ export interface InstantHeadingProps { selectedAssetAmount?: BigNumber; totalEthBaseAmount?: BigNumber; ethUsdPrice?: BigNumber; + quoteState: AsyncProcessState; } const displaytotalEthBaseAmount = ({ selectedAssetAmount, totalEthBaseAmount }: InstantHeadingProps): string => { if (_.isUndefined(selectedAssetAmount)) { return '0 ETH'; } - return format.ethBaseAmount(totalEthBaseAmount, 4, '...loading'); + return format.ethBaseAmount(totalEthBaseAmount, 4, '-'); }; const displayUsdAmount = ({ totalEthBaseAmount, selectedAssetAmount, ethUsdPrice }: InstantHeadingProps): string => { if (_.isUndefined(selectedAssetAmount)) { return '$0.00'; } - return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '...loading'); + return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '-'); +}; + +const loadingOrAmount = (quoteState: AsyncProcessState, amount: string): React.ReactNode => { + if (quoteState === AsyncProcessState.PENDING) { + return ( + + …loading + + ); + } else { + return amount; + } }; export const InstantHeading: React.StatelessComponent = props => ( @@ -47,11 +61,11 @@ export const InstantHeading: React.StatelessComponent = pro - {displaytotalEthBaseAmount(props)} + {loadingOrAmount(props.quoteState, displaytotalEthBaseAmount(props))} - {displayUsdAmount(props)} + {loadingOrAmount(props.quoteState, displayUsdAmount(props))} diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index 0d2c6dd7bc..87bb0e335b 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -37,24 +37,25 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps) const updateBuyQuoteAsync = async ( dispatch: Dispatch, - assetData?: string, - assetAmount?: BigNumber, + assetData: string, + assetAmount: BigNumber, ): Promise => { - if (_.isUndefined(assetAmount) || _.isUndefined(assetData)) { - return; - } // get a new buy quote. const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); + // mark quote as pending + dispatch(actions.updateBuyQuoteStatePending()); + let newBuyQuote: BuyQuote | undefined; try { newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue); - errorUtil.errorFlasher.clearError(dispatch); } catch (error) { + dispatch(actions.updateBuyQuoteStateFailure()); errorUtil.errorFlasher.flashNewError(dispatch, error); return; } - + // We have a successful new buy quote + errorUtil.errorFlasher.clearError(dispatch); // invalidate the last buy quote. dispatch(actions.updateLatestBuyQuote(newBuyQuote)); }; @@ -72,8 +73,13 @@ const mapDispatchToProps = ( dispatch(actions.updateLatestBuyQuote(undefined)); // reset our buy state dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE)); - // tslint:disable-next-line:no-floating-promises - debouncedUpdateBuyQuoteAsync(dispatch, assetData, value); + + if (!_.isUndefined(value) && !_.isUndefined(assetData)) { + // even if it's debounced, give them the illusion it's loading + dispatch(actions.updateBuyQuoteStatePending()); + // tslint:disable-next-line:no-floating-promises + debouncedUpdateBuyQuoteAsync(dispatch, assetData, value); + } }, }); diff --git a/packages/instant/src/containers/selected_asset_instant_heading.ts b/packages/instant/src/containers/selected_asset_instant_heading.ts index c97cfe11ab..be31527f1f 100644 --- a/packages/instant/src/containers/selected_asset_instant_heading.ts +++ b/packages/instant/src/containers/selected_asset_instant_heading.ts @@ -5,6 +5,7 @@ import { connect } from 'react-redux'; import { oc } from 'ts-optchain'; import { State } from '../redux/reducer'; +import { AsyncProcessState } from '../types'; import { InstantHeading } from '../components/instant_heading'; @@ -14,12 +15,14 @@ interface ConnectedState { selectedAssetAmount?: BigNumber; totalEthBaseAmount?: BigNumber; ethUsdPrice?: BigNumber; + quoteState: AsyncProcessState; } const mapStateToProps = (state: State, _ownProps: InstantHeadingProps): ConnectedState => ({ selectedAssetAmount: state.selectedAssetAmount, totalEthBaseAmount: oc(state).latestBuyQuote.worstCaseQuoteInfo.totalEthAmount(), ethUsdPrice: state.ethUsdPrice, + quoteState: state.quoteState, }); export const SelectedAssetInstantHeading: React.ComponentClass = connect(mapStateToProps)( diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts index cf5b39790f..e12c728bba 100644 --- a/packages/instant/src/redux/actions.ts +++ b/packages/instant/src/redux/actions.ts @@ -25,6 +25,8 @@ export enum ActionTypes { UPDATE_SELECTED_ASSET_AMOUNT = 'UPDATE_SELECTED_ASSET_AMOUNT', UPDATE_SELECTED_ASSET_BUY_STATE = 'UPDATE_SELECTED_ASSET_BUY_STATE', UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE', + UPDATE_BUY_QUOTE_STATE_PENDING = 'UPDATE_BUY_QUOTE_STATE_PENDING', + UPDATE_BUY_QUOTE_STATE_FAILURE = 'UPDATE_BUY_QUOTE_STATE_FAILURE', SET_ERROR = 'SET_ERROR', HIDE_ERROR = 'HIDE_ERROR', CLEAR_ERROR = 'CLEAR_ERROR', @@ -36,6 +38,8 @@ export const actions = { updateSelectedAssetBuyState: (buyState: AsyncProcessState) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, buyState), updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote), + updateBuyQuoteStatePending: () => createAction(ActionTypes.UPDATE_BUY_QUOTE_STATE_PENDING), + updateBuyQuoteStateFailure: () => createAction(ActionTypes.UPDATE_BUY_QUOTE_STATE_FAILURE), setError: (error?: any) => createAction(ActionTypes.SET_ERROR, error), hideError: () => createAction(ActionTypes.HIDE_ERROR), clearError: () => createAction(ActionTypes.CLEAR_ERROR), diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index d23064db77..ed8d0f6cf8 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -14,9 +14,10 @@ export enum LatestErrorDisplay { export interface State { selectedAssetData?: string; selectedAssetAmount?: BigNumber; - selectedAssetBuyState: AsyncProcessState; + selectedAssetBuyState: AsyncProcessState; // TODO: rename buyOrderState ethUsdPrice?: BigNumber; latestBuyQuote?: BuyQuote; + quoteState: AsyncProcessState; latestError?: any; latestErrorDisplay: LatestErrorDisplay; } @@ -30,6 +31,7 @@ export const INITIAL_STATE: State = { latestBuyQuote: undefined, latestError: undefined, latestErrorDisplay: LatestErrorDisplay.Hidden, + quoteState: AsyncProcessState.NONE, }; export const reducer = (state: State = INITIAL_STATE, action: Action): State => { @@ -48,6 +50,19 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => return { ...state, latestBuyQuote: action.data, + quoteState: AsyncProcessState.SUCCESS, + }; + case ActionTypes.UPDATE_BUY_QUOTE_STATE_PENDING: + return { + ...state, + latestBuyQuote: undefined, + quoteState: AsyncProcessState.PENDING, + }; + case ActionTypes.UPDATE_BUY_QUOTE_STATE_FAILURE: + return { + ...state, + latestBuyQuote: undefined, + quoteState: AsyncProcessState.FAILURE, }; case ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE: return { diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index bf3ee392f7..f0ffb893b6 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -2,10 +2,10 @@ import { AssetProxyId, ObjectMap } from '@0xproject/types'; // Reusable export enum AsyncProcessState { - NONE, - PENDING, - SUCCESS, - FAILURE, + NONE = 'None', + PENDING = 'Pending', + SUCCESS = 'Success', + FAILURE = 'Failure', } export type FunctionType = (...args: any[]) => any; From 01b98c3ed09429dac92a46446bb73c8596116d18 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 16:46:01 -0700 Subject: [PATCH 68/73] ReactNode as default for formatters, and show bold dash --- .../src/components/instant_heading.tsx | 20 +++++++++++++++---- packages/instant/src/util/format.ts | 20 +++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 8480568007..73a419019c 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -16,18 +16,30 @@ export interface InstantHeadingProps { quoteState: AsyncProcessState; } -const displaytotalEthBaseAmount = ({ selectedAssetAmount, totalEthBaseAmount }: InstantHeadingProps): string => { +const Placeholder = () => ( + + — + +); +const displaytotalEthBaseAmount = ({ + selectedAssetAmount, + totalEthBaseAmount, +}: InstantHeadingProps): React.ReactNode => { if (_.isUndefined(selectedAssetAmount)) { return '0 ETH'; } - return format.ethBaseAmount(totalEthBaseAmount, 4, '-'); + return format.ethBaseAmount(totalEthBaseAmount, 4, ); }; -const displayUsdAmount = ({ totalEthBaseAmount, selectedAssetAmount, ethUsdPrice }: InstantHeadingProps): string => { +const displayUsdAmount = ({ + totalEthBaseAmount, + selectedAssetAmount, + ethUsdPrice, +}: InstantHeadingProps): React.ReactNode => { if (_.isUndefined(selectedAssetAmount)) { return '$0.00'; } - return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '-'); + return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, ); }; const loadingOrAmount = (quoteState: AsyncProcessState, amount: string): React.ReactNode => { diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts index b62c968fb4..09eb880b2a 100644 --- a/packages/instant/src/util/format.ts +++ b/packages/instant/src/util/format.ts @@ -5,14 +5,22 @@ import * as _ from 'lodash'; import { ethDecimals } from '../constants'; export const format = { - ethBaseAmount: (ethBaseAmount?: BigNumber, decimalPlaces: number = 4, defaultText: string = '0 ETH'): string => { + ethBaseAmount: ( + ethBaseAmount?: BigNumber, + decimalPlaces: number = 4, + defaultText: React.ReactNode = '0 ETH', + ): React.ReactNode => { if (_.isUndefined(ethBaseAmount)) { return defaultText; } const ethUnitAmount = Web3Wrapper.toUnitAmount(ethBaseAmount, ethDecimals); return format.ethUnitAmount(ethUnitAmount, decimalPlaces); }, - ethUnitAmount: (ethUnitAmount?: BigNumber, decimalPlaces: number = 4, defaultText: string = '0 ETH'): string => { + ethUnitAmount: ( + ethUnitAmount?: BigNumber, + decimalPlaces: number = 4, + defaultText: React.ReactNode = '0 ETH', + ): React.ReactNode => { if (_.isUndefined(ethUnitAmount)) { return defaultText; } @@ -23,8 +31,8 @@ export const format = { ethBaseAmount?: BigNumber, ethUsdPrice?: BigNumber, decimalPlaces: number = 2, - defaultText: string = '$0.00', - ): string => { + defaultText: React.ReactNode = '$0.00', + ): React.ReactNode => { if (_.isUndefined(ethBaseAmount) || _.isUndefined(ethUsdPrice)) { return defaultText; } @@ -35,8 +43,8 @@ export const format = { ethUnitAmount?: BigNumber, ethUsdPrice?: BigNumber, decimalPlaces: number = 2, - defaultText: string = '$0.00', - ): string => { + defaultText: React.ReactNode = '$0.00', + ): React.ReactNode => { if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) { return defaultText; } From 1d38b75d6f599b37c14bf06bf95811e4f6bafb54 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 16:49:57 -0700 Subject: [PATCH 69/73] fix type --- packages/instant/src/components/instant_heading.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 73a419019c..f57b59b731 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -42,7 +42,7 @@ const displayUsdAmount = ({ return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, ); }; -const loadingOrAmount = (quoteState: AsyncProcessState, amount: string): React.ReactNode => { +const loadingOrAmount = (quoteState: AsyncProcessState, amount: React.ReactNode): React.ReactNode => { if (quoteState === AsyncProcessState.PENDING) { return ( From 6ea386a7af89c1b8a4df94b656ae1772c29c1401 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 17 Oct 2018 16:50:21 -0700 Subject: [PATCH 70/73] selectedAssetBuyState -> buyOrderState --- .../instant/src/containers/selected_asset_amount_input.ts | 2 +- .../instant/src/containers/selected_asset_buy_button.ts | 8 ++++---- packages/instant/src/redux/actions.ts | 2 +- packages/instant/src/redux/reducer.ts | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index 87bb0e335b..0873f1ab6d 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -72,7 +72,7 @@ const mapDispatchToProps = ( // invalidate the last buy quote. dispatch(actions.updateLatestBuyQuote(undefined)); // reset our buy state - dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE)); + dispatch(actions.updatebuyOrderState(AsyncProcessState.NONE)); if (!_.isUndefined(value) && !_.isUndefined(assetData)) { // even if it's debounced, give them the illusion it's loading diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts index 4cbaf55379..7d3919468e 100644 --- a/packages/instant/src/containers/selected_asset_buy_button.ts +++ b/packages/instant/src/containers/selected_asset_buy_button.ts @@ -39,14 +39,14 @@ const textForState = (state: AsyncProcessState): string => { }; const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({ - text: textForState(state.selectedAssetBuyState), + text: textForState(state.buyOrderState), buyQuote: state.latestBuyQuote, }); const mapDispatchToProps = (dispatch: Dispatch, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({ - onClick: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.PENDING)), - onBuySuccess: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.SUCCESS)), - onBuyFailure: buyQuote => dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.FAILURE)), + onClick: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.PENDING)), + onBuySuccess: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.SUCCESS)), + onBuyFailure: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.FAILURE)), }); export const SelectedAssetBuyButton: React.ComponentClass = connect( diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts index e12c728bba..bec8477421 100644 --- a/packages/instant/src/redux/actions.ts +++ b/packages/instant/src/redux/actions.ts @@ -35,7 +35,7 @@ export enum ActionTypes { export const actions = { updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price), updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, amount), - updateSelectedAssetBuyState: (buyState: AsyncProcessState) => + updatebuyOrderState: (buyState: AsyncProcessState) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, buyState), updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote), updateBuyQuoteStatePending: () => createAction(ActionTypes.UPDATE_BUY_QUOTE_STATE_PENDING), diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index ed8d0f6cf8..54290483b8 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -14,7 +14,7 @@ export enum LatestErrorDisplay { export interface State { selectedAssetData?: string; selectedAssetAmount?: BigNumber; - selectedAssetBuyState: AsyncProcessState; // TODO: rename buyOrderState + buyOrderState: AsyncProcessState; ethUsdPrice?: BigNumber; latestBuyQuote?: BuyQuote; quoteState: AsyncProcessState; @@ -26,7 +26,7 @@ export const INITIAL_STATE: State = { // TODO: Remove hardcoded zrxAssetData selectedAssetData: zrxAssetData, selectedAssetAmount: undefined, - selectedAssetBuyState: AsyncProcessState.NONE, + buyOrderState: AsyncProcessState.NONE, ethUsdPrice: undefined, latestBuyQuote: undefined, latestError: undefined, @@ -67,7 +67,7 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => case ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE: return { ...state, - selectedAssetBuyState: action.data, + buyOrderState: action.data, }; case ActionTypes.SET_ERROR: return { From 02cf99fa367f8058447a0a05b1d148afb68ab85c Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Thu, 18 Oct 2018 11:07:00 +1100 Subject: [PATCH 71/73] fix(order-utils): remove constants export --- packages/monorepo-scripts/src/doc_gen_configs.ts | 6 ++++++ packages/order-utils/src/index.ts | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts index b5a36376aa..0aaf5a6a5e 100644 --- a/packages/monorepo-scripts/src/doc_gen_configs.ts +++ b/packages/monorepo-scripts/src/doc_gen_configs.ts @@ -16,8 +16,14 @@ export const docGenConfigs: DocGenConfigs = { Schema: 'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49', Uint8Array: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array', + // HACK: CI can handle these without the namespace but some local setups (Jacob) require the namespace prefix + // This is duplicated until we can discover the source of the issue. GanacheOpts: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8', keystore: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36', + 'Ganache.GanacheOpts': + 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8', + 'lightwallet.keystore': + 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36', }, // If a 0x package re-exports an external package, we should add a link to it's exported items here EXTERNAL_EXPORT_TO_LINK: { diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts index a356a1d447..50b8a88a8f 100644 --- a/packages/order-utils/src/index.ts +++ b/packages/order-utils/src/index.ts @@ -18,7 +18,6 @@ export { ExchangeTransferSimulator } from './exchange_transfer_simulator'; export { BalanceAndProxyAllowanceLazyStore } from './store/balance_and_proxy_allowance_lazy_store'; export { OrderFilledCancelledLazyStore } from './store/order_filled_cancelled_lazy_store'; -export { constants } from './constants'; export { eip712Utils } from './eip712_utils'; export { From 95775dca1fbd115f57ee7cde314ebcdb9ca80c45 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 18 Oct 2018 00:10:33 -0700 Subject: [PATCH 72/73] feat(website): add expanded and minimized display types to relayer grid --- .../website/ts/components/portal/portal.tsx | 9 +++- .../relayer_index/relayer_grid_tile.tsx | 46 ++++++++++++------- .../relayer_index/relayer_index.tsx | 23 ++++++++-- yarn.lock | 39 +--------------- 4 files changed, 57 insertions(+), 60 deletions(-) diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index b42954f606..1470239d6a 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -18,7 +18,7 @@ import { Loading } from 'ts/components/portal/loading'; import { Menu, MenuTheme } from 'ts/components/portal/menu'; import { Section } from 'ts/components/portal/section'; import { TextHeader } from 'ts/components/portal/text_header'; -import { RelayerIndex } from 'ts/components/relayer_index/relayer_index'; +import { RelayerIndex, RelayerIndexCellStyle } from 'ts/components/relayer_index/relayer_index'; import { TokenBalances } from 'ts/components/token_balances'; import { TopBar, TopBarDisplayType } from 'ts/components/top_bar/top_bar'; import { TradeHistory } from 'ts/components/trade_history/trade_history'; @@ -541,6 +541,7 @@ export class Portal extends React.Component { } private _renderRelayerIndexSection(): React.ReactNode { const isMobile = utils.isMobileWidth(this.props.screenWidth); + // TODO(bmillman): revert RelayerIndex cellStyle to Expanded once data pipeline is tracking v2 volume return (
} @@ -551,7 +552,11 @@ export class Portal extends React.Component { {this._renderStartOnboarding()} )} - + } /> diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx index 193dd237a0..a81ab107a1 100644 --- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx +++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx @@ -14,9 +14,15 @@ import { styled } from 'ts/style/theme'; import { WebsiteBackendRelayerInfo } from 'ts/types'; import { utils } from 'ts/utils/utils'; +export enum RelayerGridTileStyle { + Expanded = 0, + Minimized, +} + export interface RelayerGridTileProps { relayerInfo: WebsiteBackendRelayerInfo; networkId: number; + style: RelayerGridTileStyle; } const styles: Styles = { @@ -30,10 +36,14 @@ const styles: Styles = { height: '100%', boxSizing: 'border-box', }, - header: { + expandedHeader: { height: '50%', width: '100%', }, + minimizedHeader: { + height: '100%', + width: '100%', + }, body: { height: '50%', width: '100%', @@ -75,10 +85,12 @@ export const RelayerGridTile: React.StatelessComponent = ( !_.isUndefined(headerImageUrl) && !_.isUndefined(props.relayerInfo.primaryColor) ? props.relayerInfo.primaryColor : FALLBACK_PRIMARY_COLOR; + const isExpanded = props.style === RelayerGridTileStyle.Expanded; + const headerStyle = isExpanded ? styles.expandedHeader : styles.minimizedHeader; return (
-
+
= ( height={RELAYER_ICON_HEIGHT} />
-
-
- {props.relayerInfo.name} -
-
- {!_.isUndefined(weeklyTxnVolume) && ( -
{props.relayerInfo.weeklyTxnVolume}
- )} -
- -
- {!_.isEmpty(topTokens) && } + {isExpanded && ( +
+
+ {props.relayerInfo.name} +
+
+ {!_.isUndefined(weeklyTxnVolume) && ( +
{props.relayerInfo.weeklyTxnVolume}
+ )}
- -
+ +
+ {!_.isEmpty(topTokens) && } +
+
+
+ )}
); diff --git a/packages/website/ts/components/relayer_index/relayer_index.tsx b/packages/website/ts/components/relayer_index/relayer_index.tsx index 91dbeb27a6..e88c20d7e9 100644 --- a/packages/website/ts/components/relayer_index/relayer_index.tsx +++ b/packages/website/ts/components/relayer_index/relayer_index.tsx @@ -3,14 +3,20 @@ import CircularProgress from 'material-ui/CircularProgress'; import { GridList } from 'material-ui/GridList'; import * as React from 'react'; -import { RelayerGridTile } from 'ts/components/relayer_index/relayer_grid_tile'; +import { RelayerGridTile, RelayerGridTileStyle } from 'ts/components/relayer_index/relayer_grid_tile'; import { Retry } from 'ts/components/ui/retry'; import { ScreenWidths, WebsiteBackendRelayerInfo } from 'ts/types'; import { backendClient } from 'ts/utils/backend_client'; +export enum RelayerIndexCellStyle { + Expanded = 0, + Minimized, +} + export interface RelayerIndexProps { networkId: number; screenWidth: ScreenWidths; + cellStyle: RelayerIndexCellStyle; } interface RelayerIndexState { @@ -18,7 +24,8 @@ interface RelayerIndexState { error?: Error; } -const CELL_HEIGHT = 290; +const CELL_HEIGHT_EXPANDED = 290; +const CELL_HEIGHT_MINIMIZED = 225; const NUMBER_OF_COLUMNS_LARGE = 3; const NUMBER_OF_COLUMNS_MEDIUM = 2; const NUMBER_OF_COLUMNS_SMALL = 2; @@ -61,15 +68,23 @@ export class RelayerIndex extends React.Component {this.state.relayerInfos.map((relayerInfo: WebsiteBackendRelayerInfo, index) => ( - + ))} ); diff --git a/yarn.lock b/yarn.lock index b4f48b8ac9..b0bbd8fb31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1602,10 +1602,6 @@ aes-js@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" -aes-js@^3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" - ajv-errors@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" @@ -3006,7 +3002,7 @@ bs-logger@0.x: dependencies: fast-json-stable-stringify "^2.0.0" -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: @@ -3029,14 +3025,6 @@ bs58check@^1.0.8: bs58 "^3.1.0" create-hash "^1.1.0" -bs58check@^2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" - dependencies: - bs58 "^4.0.0" - create-hash "^1.1.0" - safe-buffer "^5.1.2" - bser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -5590,19 +5578,6 @@ ethereumjs-wallet@0.6.0: utf8 "^2.1.1" uuid "^2.0.1" -ethereumjs-wallet@~0.6.0: - version "0.6.2" - resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" - dependencies: - aes-js "^3.1.1" - bs58check "^2.1.2" - ethereumjs-util "^5.2.0" - hdkey "^1.0.0" - safe-buffer "^5.1.2" - scrypt.js "^0.2.0" - utf8 "^3.0.0" - uuid "^3.3.2" - ethers@3.0.22: version "3.0.22" resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" @@ -7097,14 +7072,6 @@ hdkey@^0.7.0, hdkey@^0.7.1: 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" @@ -15246,10 +15213,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" From 376034ac7e2053ea81aa637983d1f6a7e61588d9 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Thu, 18 Oct 2018 20:03:22 +1100 Subject: [PATCH 73/73] Update changelog entries for unpublished packages --- packages/contract-addresses/CHANGELOG.json | 10 +++++++++- packages/contract-artifacts/CHANGELOG.json | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/contract-addresses/CHANGELOG.json b/packages/contract-addresses/CHANGELOG.json index d91ad0b36e..d9bd2c0771 100644 --- a/packages/contract-addresses/CHANGELOG.json +++ b/packages/contract-addresses/CHANGELOG.json @@ -1,11 +1,19 @@ [ { - "version": "1.0.0", + "version": "1.0.1", "changes": [ { "pr": 1105, "note": "Initial release" } ] + }, + { + "version": "1.0.0", + "changes": [ + { + "note": "Unpublished Package" + } + ] } ] diff --git a/packages/contract-artifacts/CHANGELOG.json b/packages/contract-artifacts/CHANGELOG.json index d91ad0b36e..d9bd2c0771 100644 --- a/packages/contract-artifacts/CHANGELOG.json +++ b/packages/contract-artifacts/CHANGELOG.json @@ -1,11 +1,19 @@ [ { - "version": "1.0.0", + "version": "1.0.1", "changes": [ { "pr": 1105, "note": "Initial release" } ] + }, + { + "version": "1.0.0", + "changes": [ + { + "note": "Unpublished Package" + } + ] } ]