diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-01 04:15:13 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-01 04:15:13 +0800 |
commit | 935e5da78e14f78685ad9270c19f473fa193d542 (patch) | |
tree | 3476c3bd1da0f99e54577dd0172b0186e50531a7 /packages/instant/src/components | |
parent | 27258fe3d45b8ffae81b74da43e473ae5905edc1 (diff) | |
parent | 5d6fde356a19658ae91114df68fa507d93ff8049 (diff) | |
download | dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar.gz dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar.bz2 dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar.lz dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar.xz dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.tar.zst dexon-sol-tools-935e5da78e14f78685ad9270c19f473fa193d542.zip |
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/basic-token-modal
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 7 | ||||
-rw-r--r-- | packages/instant/src/components/zero_ex_instant.tsx | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index e65e62e47..93bd8e635 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -2,11 +2,12 @@ import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer'; import * as _ from 'lodash'; import * as React from 'react'; -import { DEFAULT_GAS_PRICE, WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX } from '../constants'; +import { WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX } from '../constants'; import { ColorOption } from '../style/theme'; import { ZeroExInstantError } from '../types'; import { getBestAddress } from '../util/address'; import { balanceUtil } from '../util/balance'; +import { gasPriceEstimator } from '../util/gas_price_estimator'; import { util } from '../util/util'; import { web3Wrapper } from '../util/web3_wrapper'; @@ -56,9 +57,9 @@ export class BuyButton extends React.Component<BuyButtonProps> { } let txHash: string | undefined; + const gasPrice = await gasPriceEstimator.getFastAmountInWeiAsync(); try { - const gasPrice = DEFAULT_GAS_PRICE; - txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote, { gasPrice, takerAddress }); + txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote, { takerAddress, gasPrice }); } catch (e) { if (e instanceof Error) { if (e.message === AssetBuyerError.SignatureRequestDenied) { diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx index 19a2d6b9b..d54dfc153 100644 --- a/packages/instant/src/components/zero_ex_instant.tsx +++ b/packages/instant/src/components/zero_ex_instant.tsx @@ -13,6 +13,7 @@ import { AssetMetaData, Network } from '../types'; import { assetUtils } from '../util/asset'; import { BigNumberInput } from '../util/big_number_input'; import { errorFlasher } from '../util/error_flasher'; +import { gasPriceEstimator } from '../util/gas_price_estimator'; import { getProvider } from '../util/provider'; import { web3Wrapper } from '../util/web3_wrapper'; @@ -78,6 +79,12 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> { public componentDidMount(): void { // tslint:disable-next-line:no-floating-promises asyncData.fetchAndDispatchToStore(this._store); + + // warm up the gas price estimator cache just in case we can't + // grab the gas price estimate when submitting the transaction + // tslint:disable-next-line:no-floating-promises + gasPriceEstimator.getFastAmountInWeiAsync(); + // tslint:disable-next-line:no-floating-promises this._flashErrorIfWrongNetwork(); } |