diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-10-24 08:00:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 08:00:54 +0800 |
commit | 4a72dc6c6f0825232d61e470f5b7975aec2e5c0e (patch) | |
tree | fe6a9ee3ebe2c3a3aa21931261eca3c91f8072d7 /packages/instant/src/components/buy_button.tsx | |
parent | 2110ac32b7fceb230467ae0e2bb2bcd5e582f25f (diff) | |
parent | 864f89c535cf68a9325f27eae7f49a088c481120 (diff) | |
download | dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.gz dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.zst dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.zip |
Merge pull request #1159 from 0xProject/feature/instant/beta-render-et-al
[instant] Pass in liquiditySource, assetData and other settings from render
Diffstat (limited to 'packages/instant/src/components/buy_button.tsx')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index d2a8bd07a..adc32f071 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -1,9 +1,8 @@ -import { BuyQuote } from '@0x/asset-buyer'; +import { AssetBuyer, BuyQuote } from '@0x/asset-buyer'; import * as _ from 'lodash'; 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'; @@ -11,6 +10,7 @@ import { Button, Container, Text } from './ui'; export interface BuyButtonProps { buyQuote?: BuyQuote; + assetBuyer?: AssetBuyer; onClick: (buyQuote: BuyQuote) => void; onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void; onBuyFailure: (buyQuote: BuyQuote, tnxHash?: string) => void; @@ -24,7 +24,7 @@ export class BuyButton extends React.Component<BuyButtonProps> { onBuyFailure: util.boundNoop, }; public render(): React.ReactNode { - const shouldDisableButton = _.isUndefined(this.props.buyQuote); + const shouldDisableButton = _.isUndefined(this.props.buyQuote) || _.isUndefined(this.props.assetBuyer); return ( <Container padding="20px" width="100%"> <Button width="100%" onClick={this._handleClick} isDisabled={shouldDisableButton}> @@ -37,13 +37,13 @@ export class BuyButton extends React.Component<BuyButtonProps> { } private readonly _handleClick = async () => { // The button is disabled when there is no buy quote anyway. - if (_.isUndefined(this.props.buyQuote)) { + if (_.isUndefined(this.props.buyQuote) || _.isUndefined(this.props.assetBuyer)) { return; } this.props.onClick(this.props.buyQuote); let txnHash; try { - txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote); + txnHash = await this.props.assetBuyer.executeBuyQuoteAsync(this.props.buyQuote); await web3Wrapper.awaitTransactionSuccessAsync(txnHash); this.props.onBuySuccess(this.props.buyQuote, txnHash); } catch { |