aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/buy_button.tsx
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2018-10-24 08:00:54 +0800
committerGitHub <noreply@github.com>2018-10-24 08:00:54 +0800
commit4a72dc6c6f0825232d61e470f5b7975aec2e5c0e (patch)
treefe6a9ee3ebe2c3a3aa21931261eca3c91f8072d7 /packages/instant/src/components/buy_button.tsx
parent2110ac32b7fceb230467ae0e2bb2bcd5e582f25f (diff)
parent864f89c535cf68a9325f27eae7f49a088c481120 (diff)
downloaddexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar
dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.gz
dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.bz2
dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.lz
dexon-sol-tools-4a72dc6c6f0825232d61e470f5b7975aec2e5c0e.tar.xz
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.tsx10
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 {