From 647d196e1ec42a38cfb4fd8b5d1e0b4709292028 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 3 Oct 2018 14:42:52 +0200 Subject: [PATCH] fix for '0' gasPrice from web3 if i had some accounts already saved and initSendForm requested "gasPrice" from web3 which didn't exists in this moment yet, returned value was '0'. This commit fixes that by returning defaultGasPrice instead of '0' and also initializes web3 during Backend.subscribe (before account is shown) --- src/actions/BlockchainActions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/actions/BlockchainActions.js b/src/actions/BlockchainActions.js index 24c50251..978bf43b 100644 --- a/src/actions/BlockchainActions.js +++ b/src/actions/BlockchainActions.js @@ -57,7 +57,7 @@ export const getTokenBalance = (token: Token): PromiseAction => async (d export const getGasPrice = (network: string, defaultGasPrice: number): PromiseAction => async (dispatch: Dispatch): Promise => { try { const gasPrice = await dispatch(Web3Actions.getCurrentGasPrice(network)); - return new BigNumber(gasPrice); + return gasPrice === '0' ? new BigNumber(defaultGasPrice) : new BigNumber(gasPrice); } catch (error) { return new BigNumber(defaultGasPrice); } @@ -175,6 +175,8 @@ export const subscribe = (network: string): PromiseAction => async (dispat accounts: [], coin: network, }); + // init web3 instance if not exists + await dispatch(Web3Actions.initWeb3(network)); }; // Conditionally subscribe to blockchain backend