mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-29 02:18:06 +00:00
handle blockchain_disconnect when wallet init in offline mode
This commit is contained in:
parent
ce5b13223c
commit
6f334182aa
@ -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) {
|
||||
|
@ -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));
|
||||
};
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user