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