1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

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)
This commit is contained in:
Szymon Lesisz 2018-10-03 14:42:52 +02:00
parent ac0b9508de
commit 647d196e1e

View File

@ -57,7 +57,7 @@ export const getTokenBalance = (token: Token): PromiseAction<string> => async (d
export const getGasPrice = (network: string, defaultGasPrice: number): PromiseAction<BigNumber> => async (dispatch: Dispatch): Promise<BigNumber> => { export const getGasPrice = (network: string, defaultGasPrice: number): PromiseAction<BigNumber> => async (dispatch: Dispatch): Promise<BigNumber> => {
try { try {
const gasPrice = await dispatch(Web3Actions.getCurrentGasPrice(network)); const gasPrice = await dispatch(Web3Actions.getCurrentGasPrice(network));
return new BigNumber(gasPrice); return gasPrice === '0' ? new BigNumber(defaultGasPrice) : new BigNumber(gasPrice);
} catch (error) { } catch (error) {
return new BigNumber(defaultGasPrice); return new BigNumber(defaultGasPrice);
} }
@ -175,6 +175,8 @@ export const subscribe = (network: string): PromiseAction<void> => async (dispat
accounts: [], accounts: [],
coin: network, coin: network,
}); });
// init web3 instance if not exists
await dispatch(Web3Actions.initWeb3(network));
}; };
// Conditionally subscribe to blockchain backend // Conditionally subscribe to blockchain backend