diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-30 00:03:39 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-30 00:03:39 +0800 |
commit | 8288e8cce963bbd96c71b3adeb5d34bb96c30693 (patch) | |
tree | 4aba3a0e514a364f5fc14048bfee616dc9149e8b /packages/instant/src/components/buy_button.tsx | |
parent | 1bb7a28690662d682f865505b6c62fe655d57316 (diff) | |
download | dexon-sol-tools-8288e8cce963bbd96c71b3adeb5d34bb96c30693.tar.gz dexon-sol-tools-8288e8cce963bbd96c71b3adeb5d34bb96c30693.tar.zst dexon-sol-tools-8288e8cce963bbd96c71b3adeb5d34bb96c30693.zip |
When transaction too low, treat as validation error. also modify callback: errorMessage could be AssetBuyError as well
Diffstat (limited to 'packages/instant/src/components/buy_button.tsx')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 876edd396..bceabbca3 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -16,7 +16,7 @@ export interface BuyButtonProps { buyQuote?: BuyQuote; assetBuyer?: AssetBuyer; onValidationPending: (buyQuote: BuyQuote) => void; - onValidationFail: (buyQuote: BuyQuote, error: ZeroExInstantError) => void; + onValidationFail: (buyQuote: BuyQuote, errorMessage: AssetBuyerError | ZeroExInstantError) => void; onSignatureDenied: (buyQuote: BuyQuote, preventedError: Error) => void; onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => void; onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void; @@ -59,9 +59,14 @@ export class BuyButton extends React.Component<BuyButtonProps> { try { txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote, { takerAddress }); } catch (e) { - if (e instanceof Error && e.message === AssetBuyerError.SignatureRequestDenied) { - this.props.onSignatureDenied(buyQuote, e); - return; + if (e instanceof Error) { + if (e.message === AssetBuyerError.SignatureRequestDenied) { + this.props.onSignatureDenied(buyQuote, e); + return; + } else if (e.message === AssetBuyerError.TransactionValueTooLow) { + this.props.onValidationFail(buyQuote, AssetBuyerError.TransactionValueTooLow); + return; + } } throw e; } |