diff options
author | Brandon Millman <brandon@0xproject.com> | 2018-11-08 15:40:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-08 15:40:43 +0800 |
commit | f6abc007ffb249e4bbf85b8a7a77309d43e0a147 (patch) | |
tree | 0bf9d75eed4bc60d37b7aed47be6adc2b4551a40 /packages/instant/src/components/buy_button.tsx | |
parent | 771f8a6a6cff935631e8c6ebcdc012cdd3533de6 (diff) | |
parent | 54b51830d075fcfc9b9e3ce0f4f4a4ef26eaf036 (diff) | |
download | dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar.gz dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar.bz2 dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar.lz dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar.xz dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.tar.zst dexon-0x-contracts-f6abc007ffb249e4bbf85b8a7a77309d43e0a147.zip |
Merge pull request #1221 from 0xProject/feature/instant/fallback-provider
[instant] Ensure we always have a provider from initial state
Diffstat (limited to 'packages/instant/src/components/buy_button.tsx')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index e6d50de96..515cd18e9 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -17,7 +17,7 @@ import { Text } from './ui/text'; export interface BuyButtonProps { buyQuote?: BuyQuote; - assetBuyer?: AssetBuyer; + assetBuyer: AssetBuyer; affiliateInfo?: AffiliateInfo; onValidationPending: (buyQuote: BuyQuote) => void; onValidationFail: (buyQuote: BuyQuote, errorMessage: AssetBuyerError | ZeroExInstantError) => void; @@ -34,7 +34,7 @@ export class BuyButton extends React.Component<BuyButtonProps> { onBuyFailure: util.boundNoop, }; public render(): React.ReactNode { - const shouldDisableButton = _.isUndefined(this.props.buyQuote) || _.isUndefined(this.props.assetBuyer); + const shouldDisableButton = _.isUndefined(this.props.buyQuote); return ( <Button width="100%" onClick={this._handleClick} isDisabled={shouldDisableButton}> <Text fontColor={ColorOption.white} fontWeight={600} fontSize="20px"> @@ -46,11 +46,13 @@ export class BuyButton extends React.Component<BuyButtonProps> { private readonly _handleClick = async () => { // The button is disabled when there is no buy quote anyway. const { buyQuote, assetBuyer, affiliateInfo } = this.props; - if (_.isUndefined(buyQuote) || _.isUndefined(assetBuyer)) { + if (_.isUndefined(buyQuote)) { return; } this.props.onValidationPending(buyQuote); + + // TODO(bmillman): move address and balance fetching to the async state const web3Wrapper = new Web3Wrapper(assetBuyer.provider); const takerAddress = await getBestAddress(web3Wrapper); |