Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philip London
committed
Jul 22, 2020
1 parent
df4ede9
commit 8564227
Showing
9 changed files
with
129 additions
and
60 deletions.
There are no files selected for viewing
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
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
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: 45 additions & 0 deletions
45
packages/blockchain-wallet-v4-frontend/src/components/Display/FiatDisplay/selectors.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,45 @@ | ||
import { CoinTypeEnum, FiatTypeEnum } from 'blockchain-wallet-v4/src/types' | ||
import { Exchange } from 'blockchain-wallet-v4/src' | ||
import { fiatToString } from 'blockchain-wallet-v4/src/exchange/currency' | ||
import { lift, prop } from 'ramda' | ||
import { selectors } from 'data' | ||
|
||
export const getData = (state, coin, amount, defaultCurrency, defaultRates) => { | ||
const currencyR = selectors.core.settings | ||
.getSettings(state) | ||
.map(prop('currency')) | ||
|
||
const ratesR = selectors.core.data.misc.getRatesSelector(coin, state) | ||
|
||
let value | ||
if (coin in CoinTypeEnum) { | ||
value = Exchange.convertCoinToCoin({ | ||
value: amount, | ||
coin, | ||
baseToStandard: true | ||
}).value | ||
} | ||
|
||
const convert = (currency, rates) => { | ||
if (coin in FiatTypeEnum) { | ||
if (coin === currency) | ||
return fiatToString({ value: amount, unit: currency }) | ||
|
||
value = Exchange.convertFiatToFiat({ | ||
value: amount, | ||
fromCurrency: coin, | ||
toCurrency: currency, | ||
rates | ||
}).value | ||
return fiatToString({ value, unit: currency }) | ||
} | ||
return Exchange.displayCoinToFiat({ | ||
value, | ||
fromCoin: coin, | ||
fromUnit: coin, | ||
toCurrency: defaultCurrency || currency, | ||
rates: defaultRates || rates | ||
}) | ||
} | ||
return lift(convert)(currencyR, ratesR) | ||
} |
27 changes: 0 additions & 27 deletions
27
packages/blockchain-wallet-v4-frontend/src/components/Display/FiatDisplay/selectors.tsx
This file was deleted.
Oops, something went wrong.
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
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
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
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