@@ -5,6 +5,7 @@ import { fromWei, toWei } from 'web3-utils';
55import { useNetwork } from 'store/network';
66import { useWallet } from 'store/wallet';
77import { usePointCursor } from 'store/pointCursor';
8+import { useSuggestedGasPrice } from 'lib/useSuggestedGasPrice';
89
910import { GAS_LIMITS } from './constants';
1011import {
@@ -60,6 +61,7 @@ export default function useEthereumTransaction(
6061 const [nonce, setNonce] = useState();
6162 const [gasPrice, setGasPrice] = useState(initialGasPrice); // gwei
6263 const [suggestedGasPrice, setSuggestedGasPrice] = useState(gasPrice); // gwei
64+ const { gasPrice: estimatedGasPrice } = useSuggestedGasPrice();
6365 const [gasLimit] = useState(initialGasLimit);
6466 const [unsignedTransaction, setUnsignedTransaction] = useState();
6567 const [signedTransaction, setSignedTransaction] = useState();
@@ -188,6 +190,15 @@ export default function useEthereumTransaction(
188190 suggestedGasPrice,
189191 ]);
190192
193+ useEffect(() => {
194+ const gasPrice = parseInt(
195+ fromWei(estimatedGasPrice.toString(), 'gwei'),
196+ 10
197+ );
198+ setSuggestedGasPrice(gasPrice);
199+ setGasPrice(gasPrice);
200+ }, [estimatedGasPrice]);
201+
191202 useEffect(() => {
192203 // if nonce or chainId is undefined, re-fetch on-chain info
193204 if (!(nonce === undefined || chainId === undefined)) {
@@ -197,22 +208,18 @@ export default function useEthereumTransaction(
197208 (async () => {
198209 try {
199210 setError(undefined);
200− const [nonce, chainId, estimatedGasPrice] = await Promise.all([
211+ const [nonce, chainId] = await Promise.all([
201212 _web3.eth.getTransactionCount(_wallet.address),
202213 _web3.eth.net.getId(),
203− _web3.eth.getGasPrice(),
204214 ]);
205215
206216 setNonce(nonce);
207217 setChainId(chainId);
208− const gasPrice = parseInt(fromWei(estimatedGasPrice, 'gwei'), 10);
209− setSuggestedGasPrice(gasPrice);
210− setGasPrice(gasPrice);
211218 } catch (error) {
212219 setError(error);
213220 }
214221 })();
215− }, [_wallet, _web3, setError, nonce, chainId]);
222+ }, [_wallet, _web3, setError, nonce, chainId, networkType]);
216223
217224 useEffect(() => {
218225 let cancelled = false;