diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-25 01:38:56 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-25 01:38:56 +0800 |
commit | ce5bc3c1c945b12997e3030301bf25f982c55365 (patch) | |
tree | 25f561a8fbedd15c83979666123020604174a600 /packages/instant/src/components/buy_button.tsx | |
parent | 33d8044f028b16e3e48ee963790aa840f3191803 (diff) | |
download | dexon-0x-contracts-ce5bc3c1c945b12997e3030301bf25f982c55365.tar.gz dexon-0x-contracts-ce5bc3c1c945b12997e3030301bf25f982c55365.tar.zst dexon-0x-contracts-ce5bc3c1c945b12997e3030301bf25f982c55365.zip |
Message when signature denied
Diffstat (limited to 'packages/instant/src/components/buy_button.tsx')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 9c42f3d87..0d35d36ca 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -1,4 +1,4 @@ -import { AssetBuyer, BuyQuote } from '@0x/asset-buyer'; +import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer'; import * as _ from 'lodash'; import * as React from 'react'; @@ -14,6 +14,7 @@ export interface BuyButtonProps { onClick: (buyQuote: BuyQuote) => void; onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void; onBuyFailure: (buyQuote: BuyQuote, tnxHash?: string) => void; + onBuyPrevented: (buyQuote: BuyQuote, preventedError: Error) => void; } export class BuyButton extends React.Component<BuyButtonProps> { @@ -43,7 +44,11 @@ export class BuyButton extends React.Component<BuyButtonProps> { txnHash = await this.props.assetBuyer.executeBuyQuoteAsync(this.props.buyQuote); const txnReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txnHash); this.props.onBuySuccess(this.props.buyQuote, txnReceipt.transactionHash); - } catch { + } catch (e) { + if (e instanceof Error && e.message === AssetBuyerError.SignatureRequestDenied) { + this.props.onBuyPrevented(this.props.buyQuote, e); + return; + } this.props.onBuyFailure(this.props.buyQuote, txnHash); } }; |