1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-30 19:00:53 +00:00

handle blockchain_disconnect when wallet init in offline mode

This commit is contained in:
Szymon Lesisz 2018-12-20 10:12:44 +01:00
parent ce5b13223c
commit 6f334182aa
3 changed files with 9 additions and 5 deletions

View File

@ -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) {

View File

@ -86,10 +86,11 @@ export const estimateGasLimit = (network: string, data: string, value: string, g
export const subscribe = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const accounts: Array<string> = 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));
};

View File

@ -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 => {