-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Exchange): typed exchange component actions and reducers
- Loading branch information
Showing
5 changed files
with
110 additions
and
134 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
packages/blockchain-wallet-v4-frontend/src/data/components/exchange/reducers.js
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
packages/blockchain-wallet-v4-frontend/src/data/components/exchange/reducers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import * as AT from 'data/components/exchange/actionTypes' | ||
import { assoc, compose } from 'ramda' | ||
import { ExchangeActionTypes, ExchangeState } from './types' | ||
import Remote from 'blockchain-wallet-v4/src/remote/remote' | ||
|
||
const INITIAL_STATE: ExchangeState = { | ||
limits: Remote.NotAsked, | ||
min: null, | ||
max: null, | ||
// @PHIL how to solve for default state for all these, 15-28 | ||
sourceFee: { | ||
isSourceErc20: false, | ||
mempoolFees: { | ||
limits: { | ||
max: 0, | ||
min: 0 | ||
}, | ||
priority: 0, | ||
regular: 0 | ||
}, | ||
source: 0, | ||
sourceFiat: '', | ||
target: 0 | ||
}, | ||
showError: false, | ||
txError: null | ||
} | ||
|
||
export function exchangeReducer ( | ||
state = INITIAL_STATE, | ||
action: ExchangeActionTypes | ||
): ExchangeState { | ||
switch (action.type) { | ||
case AT.FETCH_LIMITS_LOADING: { | ||
return { | ||
...state, | ||
limits: Remote.Loading | ||
} | ||
} | ||
case AT.FETCH_LIMITS_SUCCESS: { | ||
return { | ||
...state, | ||
limits: Remote.Success(action.payload.limits) | ||
} | ||
} | ||
case AT.FETCH_LIMITS_ERROR: { | ||
return { | ||
...state, | ||
limits: Remote.Failure(action.payload.error) | ||
} | ||
} | ||
case AT.SET_MIN_MAX: { | ||
return { | ||
...state, | ||
min: action.payload.min, | ||
max: action.payload.max | ||
} | ||
} | ||
case AT.SET_SOURCE_FEE: { | ||
return { | ||
...state, | ||
sourceFee: action.payload.fee | ||
} | ||
} | ||
case AT.SET_SHOW_ERROR: { | ||
return { | ||
...state, | ||
showError: action.payload.showError | ||
} | ||
} | ||
case AT.SET_TX_ERROR: { | ||
return { | ||
...state, | ||
txError: action.payload.error | ||
} | ||
} | ||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters