Fix types
This commit is contained in:
parent
6c857ee02a
commit
3deb37da26
|
@ -1,9 +1,12 @@
|
|||
import axios from 'axios'
|
||||
|
||||
import { getExchangeRatesUrl } from 'src/config'
|
||||
import { Currency } from '../store/model/currencyValues'
|
||||
import { AVAILABLE_CURRENCIES } from '../store/model/currencyValues'
|
||||
|
||||
const fetchCurrenciesRates = async (baseCurrency: Currency, targetCurrencyValue: Currency): Promise<number> => {
|
||||
const fetchCurrenciesRates = async (
|
||||
baseCurrency: AVAILABLE_CURRENCIES,
|
||||
targetCurrencyValue: AVAILABLE_CURRENCIES,
|
||||
): Promise<number> => {
|
||||
let rate = 0
|
||||
const url = `${getExchangeRatesUrl()}?base=${baseCurrency}&symbols=${targetCurrencyValue}`
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import fetchCurrenciesRates from 'src/logic/currencyValues/api/fetchCurrenciesRates'
|
||||
import { setCurrencyRate } from 'src/logic/currencyValues/store/actions/setCurrencyRate'
|
||||
import { AVAILABLE_CURRENCIES, Currency } from 'src/logic/currencyValues/store/model/currencyValues'
|
||||
import { AVAILABLE_CURRENCIES } from 'src/logic/currencyValues/store/model/currencyValues'
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const fetchCurrencyRate = (safeAddress: string, selectedCurrency: Currency) => async (dispatch) => {
|
||||
const fetchCurrencyRate = (safeAddress: string, selectedCurrency: AVAILABLE_CURRENCIES) => async (dispatch) => {
|
||||
if (AVAILABLE_CURRENCIES.USD === selectedCurrency) {
|
||||
return dispatch(setCurrencyRate(safeAddress, 1))
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { createAction } from 'redux-actions'
|
||||
import { Currency } from '../model/currencyValues'
|
||||
import { AVAILABLE_CURRENCIES } from '../model/currencyValues'
|
||||
|
||||
export const SET_CURRENT_CURRENCY = 'SET_CURRENT_CURRENCY'
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
export const setSelectedCurrency = createAction(
|
||||
SET_CURRENT_CURRENCY,
|
||||
(safeAddress: string, selectedCurrency: Currency) => ({
|
||||
(safeAddress: string, selectedCurrency: AVAILABLE_CURRENCIES) => ({
|
||||
safeAddress,
|
||||
selectedCurrency,
|
||||
}),
|
||||
|
|
|
@ -4,7 +4,7 @@ import { SET_CURRENCY_RATE } from 'src/logic/currencyValues/store/actions/setCur
|
|||
import { SET_CURRENT_CURRENCY } from 'src/logic/currencyValues/store/actions/setSelectedCurrency'
|
||||
import { currencyValuesSelector } from 'src/logic/currencyValues/store/selectors'
|
||||
import { saveCurrencyValues } from 'src/logic/currencyValues/store/utils/currencyValuesStorage'
|
||||
import { Currency, CurrencyRateValue } from '../model/currencyValues'
|
||||
import { AVAILABLE_CURRENCIES, CurrencyRateValue } from '../model/currencyValues'
|
||||
|
||||
const watchedActions = [SET_CURRENT_CURRENCY, SET_CURRENCY_RATE, SET_CURRENCY_BALANCES]
|
||||
|
||||
|
@ -24,7 +24,7 @@ const currencyValuesStorageMiddleware = (store) => (next) => async (action) => {
|
|||
const currencyValues = currencyValuesSelector(state)
|
||||
const currencyValuesWithoutBalances: Map<string, CurrencyRateValue> = currencyValues.map((currencyValue) => {
|
||||
const currencyRate: number = currencyValue.get('currencyRate')
|
||||
const selectedCurrency: Currency = currencyValue.get('selectedCurrency')
|
||||
const selectedCurrency: AVAILABLE_CURRENCIES = currencyValue.get('selectedCurrency')
|
||||
return {
|
||||
currencyRate,
|
||||
selectedCurrency,
|
||||
|
|
|
@ -36,11 +36,9 @@ export enum AVAILABLE_CURRENCIES {
|
|||
MYR = 'MYR',
|
||||
}
|
||||
|
||||
export type Currency = keyof typeof AVAILABLE_CURRENCIES
|
||||
|
||||
export type CurrencyRateValue = {
|
||||
currencyRate: number
|
||||
selectedCurrency: Currency
|
||||
selectedCurrency: AVAILABLE_CURRENCIES
|
||||
}
|
||||
|
||||
export const makeBalanceCurrency = Record({
|
||||
|
|
Loading…
Reference in New Issue