mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-24 15:00:58 +00:00
update recommended fee in blockchain reducer
This commit is contained in:
parent
4492dbae63
commit
e130b1edc0
@ -1,6 +1,7 @@
|
||||
/* @flow */
|
||||
|
||||
import { BLOCKCHAIN } from 'trezor-connect';
|
||||
import { BLOCKCHAIN as BLOCKCHAIN_EVENT } from 'trezor-connect';
|
||||
import * as BLOCKCHAIN_ACTION from 'actions/constants/blockchain';
|
||||
|
||||
import type { Action } from 'flowtype';
|
||||
import type { BlockchainConnect, BlockchainError, BlockchainBlock } from 'trezor-connect';
|
||||
@ -66,15 +67,28 @@ const onBlock = (state: State, action: BlockchainBlock): State => {
|
||||
return state;
|
||||
};
|
||||
|
||||
const updateFee = (state: State, shortcut: string, fee: string): State => {
|
||||
const network = state.find(b => b.shortcut === shortcut);
|
||||
if (!network) return state;
|
||||
|
||||
const others = state.filter(b => b !== network);
|
||||
return others.concat([{
|
||||
...network,
|
||||
fee,
|
||||
}]);
|
||||
};
|
||||
|
||||
|
||||
export default (state: State = initialState, action: Action): State => {
|
||||
switch (action.type) {
|
||||
case BLOCKCHAIN.CONNECT:
|
||||
case BLOCKCHAIN_EVENT.CONNECT:
|
||||
return onConnect(state, action);
|
||||
case BLOCKCHAIN.ERROR:
|
||||
case BLOCKCHAIN_EVENT.ERROR:
|
||||
return onError(state, action);
|
||||
case BLOCKCHAIN.BLOCK:
|
||||
case BLOCKCHAIN_EVENT.BLOCK:
|
||||
return onBlock(state, action);
|
||||
case BLOCKCHAIN_ACTION.UPDATE_FEE:
|
||||
return updateFee(state, action.shortcut, action.fee);
|
||||
|
||||
default:
|
||||
return state;
|
||||
|
Loading…
Reference in New Issue
Block a user