diff --git a/src/actions/Web3Actions.js b/src/actions/Web3Actions.js index 94030727..dd665224 100644 --- a/src/actions/Web3Actions.js +++ b/src/actions/Web3Actions.js @@ -289,9 +289,7 @@ export const estimateGasLimit = (network: string, $options: EstimateGasOptions): return limit.toString(); }; -export const disconnect = (coinInfo: any): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { - // incoming "coinInfo" from TrezorConnect is CoinInfo | EthereumNetwork type - const network: string = coinInfo.shortcut.toLowerCase(); +export const disconnect = (network: string): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { // check if Web3 was already initialized const instance = getState().web3.find(w3 => w3.network === network); if (instance) { diff --git a/src/actions/ethereum/BlockchainActions.js b/src/actions/ethereum/BlockchainActions.js index b965d79e..72dec1d7 100644 --- a/src/actions/ethereum/BlockchainActions.js +++ b/src/actions/ethereum/BlockchainActions.js @@ -86,10 +86,11 @@ export const estimateGasLimit = (network: string, data: string, value: string, g export const subscribe = (network: string): PromiseAction => async (dispatch: Dispatch, getState: GetState): Promise => { const accounts: Array = getState().accounts.filter(a => a.network === network).map(a => a.address); // eslint-disable-line no-unused-vars - await TrezorConnect.blockchainSubscribe({ + const response = await TrezorConnect.blockchainSubscribe({ accounts, coin: network, }); + if (!response.success) return; // init web3 instance if not exists await dispatch(Web3Actions.initWeb3(network)); }; diff --git a/src/reducers/BlockchainReducer.js b/src/reducers/BlockchainReducer.js index e92d9468..6cecb15f 100644 --- a/src/reducers/BlockchainReducer.js +++ b/src/reducers/BlockchainReducer.js @@ -50,7 +50,12 @@ const onError = (state: State, action: BlockchainError): State => { }]); } - return state; + return state.concat([{ + shortcut, + connected: false, + fee: '0', + block: 0, + }]); }; const onBlock = (state: State, action: BlockchainBlock): State => {