Skip to content

Commit

Permalink
feat(Exchange): finish typing exchange component
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Jan 23, 2020
1 parent faf0c4f commit 97f2954
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import * as AT from './actionTypes'
import { ExchangeActionTypes } from './types'
import * as Currencies from 'blockchain-wallet-v4/src/exchange/currencies'
import { ExchangeActionTypes, LimitAmountType, LimitsType } from './types'

// @PHIL Don't see this action being used anywhere. There is a set step reducer, but I don't see it anything called
// step in the state
// export const setStep = (step): ExchangeActionTypes => ({
// type: AT.SET_STEP,
// payload: { step }
// })
export const initialize = requestedValues => ({
type: AT.INITIALIZE,
payload: { requestedValues }
Expand Down Expand Up @@ -42,15 +37,20 @@ export const updateLimits = () => ({
export const fetchLimitsLoading = (): ExchangeActionTypes => ({
type: AT.FETCH_LIMITS_LOADING
})
export const fetchLimitsSuccess = (limits): ExchangeActionTypes => ({
export const fetchLimitsSuccess = (
limits: Currencies<LimitsType>
): ExchangeActionTypes => ({
type: AT.FETCH_LIMITS_SUCCESS,
payload: { limits }
})
export const fetchLimitsError = (error): ExchangeActionTypes => ({
export const fetchLimitsError = (error: string): ExchangeActionTypes => ({
type: AT.FETCH_LIMITS_ERROR,
payload: { error }
})
export const setMinMax = (min, max): ExchangeActionTypes => ({
export const setMinMax = (
min: LimitAmountType,
max: LimitAmountType
): ExchangeActionTypes => ({
type: AT.SET_MIN_MAX,
payload: { min, max }
})
Expand All @@ -64,14 +64,14 @@ export const setSourceFee = fee => ({
type: AT.SET_SOURCE_FEE,
payload: { fee }
})
export const setShowError = (showError): ExchangeActionTypes => ({
export const setShowError = (showError: boolean): ExchangeActionTypes => ({
type: AT.SET_SHOW_ERROR,
payload: { showError }
})
export const recheckLatestTx = () => ({
type: AT.RECHECK_LATEST_TX
})
export const setTxError = (error): ExchangeActionTypes => ({
export const setTxError = (error: string): ExchangeActionTypes => ({
type: AT.SET_TX_ERROR,
payload: { error }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import { RemoteData } from 'blockchain-wallet-v4/src/remote/types'
import { String } from 'index'

// Types
// @PHIL limts are repetitive, should this be explicit for every one?

export type LimitsType = {
annual: LimitDurationType
balanceMax: BalanceMaxType
balanceMax: LimitAmountType
daily: LimitDurationType
maxFiatLimit: MaxFiatLimitType
maxOrder: OrderType
maxPossibleOrder: OrderType
minOrder: OrderType
maxFiatLimit: LimitAmountType
maxOrder: LimitAmountType
maxPossibleOrder: LimitAmountType
minOrder: LimitAmountType
weekly: LimitDurationType
}

export type OrderType = {
export type LimitAmountType = {
amount: string
fiat: boolean
symbol: string
Expand All @@ -35,18 +34,6 @@ export type LimitDurationType = {
symbol: string
}

export type MaxFiatLimitType = {
amount: string
fiat: boolean
symbol: string
}

export type BalanceMaxType = {
amount: string
fiat: boolean
symbol: string
}

export type SourceFeeType = {
isSourceErc20: boolean
mempoolFees: {
Expand All @@ -65,8 +52,8 @@ export type SourceFeeType = {
// State
export interface ExchangeState {
limits: RemoteData<string, Currencies<LimitsType>>
max: null | AmountType
min: null | AmountType
max: null | LimitAmountType
min: null | LimitAmountType
showError: boolean
sourceFee: SourceFeeType
txError: string | null
Expand Down Expand Up @@ -95,8 +82,8 @@ interface FetchLimitsSuccess {

interface SetMinMax {
payload: {
max: AmountType
min: AmountType
max: LimitAmountType | null
min: LimitAmountType | null
}
type: typeof AT.SET_MIN_MAX
}
Expand All @@ -113,15 +100,6 @@ interface SetSourceFee {
}
type: typeof AT.SET_SOURCE_FEE
}

// interface SetStep {
// // @PHIL not sure what the data type for step is, I don't think it's being used
// payload: {
// step: any
// }
// type: typeof AT.SET_STEP
// }

interface SetTxError {
payload: {
error: string
Expand All @@ -140,6 +118,5 @@ export type ExchangeActionTypes =
| SetMinMax
| SetShowError
| SetSourceFee
// SetStep |
| SetTxError
| ShowConfirmation

0 comments on commit 97f2954

Please sign in to comment.