Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sb): add fiat to balances, brokeen
- Loading branch information
Philip London
committed
Jul 21, 2020
1 parent
6c6e569
commit df4ede9
Showing
15 changed files
with
150 additions
and
91 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
44 changes: 44 additions & 0 deletions
44
packages/blockchain-wallet-v4-frontend/src/data/components/utils/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,44 @@ | ||
import { | ||
CoinTypeEnum, | ||
ExtractSuccess, | ||
SupportedWalletCurrencyType | ||
} from 'blockchain-wallet-v4/src/types' | ||
import { lift, mapObjIndexed, values } from 'ramda' | ||
import { RootState } from 'data/rootReducer' | ||
import { selectors } from 'data' | ||
|
||
export const getSupportedCoinsWithMethodAndOrder = (state: RootState) => { | ||
const sbMethodsR = selectors.components.simpleBuy.getSBPaymentMethods(state) | ||
const supportedCoinsR = selectors.core.walletOptions.getSupportedCoins(state) | ||
|
||
const transform = ( | ||
paymentMethods: ExtractSuccess<typeof sbMethodsR>, | ||
supportedCoins: ExtractSuccess<typeof supportedCoinsR> | ||
) => { | ||
const coinOrder = [ | ||
supportedCoins.EUR, | ||
supportedCoins.GBP, | ||
supportedCoins.BTC, | ||
supportedCoins.ETH, | ||
supportedCoins.BCH, | ||
supportedCoins.XLM, | ||
supportedCoins.ALGO, | ||
supportedCoins.PAX, | ||
supportedCoins.USDT | ||
] | ||
return values( | ||
mapObjIndexed((coin: SupportedWalletCurrencyType) => { | ||
return { | ||
...coin, | ||
method: | ||
coin.coinCode in CoinTypeEnum || | ||
!!paymentMethods.methods.find( | ||
method => method.currency === coin.coinCode | ||
) | ||
} | ||
}, coinOrder) | ||
) | ||
} | ||
|
||
return lift(transform)(sbMethodsR, supportedCoinsR) | ||
} |
59 changes: 10 additions & 49 deletions
59
packages/blockchain-wallet-v4-frontend/src/layouts/Wallet/MenuLeft/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 |
---|---|---|
@@ -1,83 +1,44 @@ | ||
import { | ||
CoinTypeEnum, | ||
ExtractSuccess, | ||
SupportedCoinType, | ||
SupportedFiatType | ||
} from 'core/types' | ||
import { createDeepEqualSelector } from 'services/ReselectHelper' | ||
import { lift, mapObjIndexed, values } from 'ramda' | ||
import { ExtractSuccess } from 'core/types' | ||
import { lift } from 'ramda' | ||
import { selectors } from 'data' | ||
|
||
export const getData = createDeepEqualSelector( | ||
[ | ||
selectors.components.layoutWallet.getMenuOpened, | ||
selectors.components.simpleBuy.getSBPaymentMethods, | ||
selectors.components.utils.getSupportedCoinsWithMethodAndOrder, | ||
selectors.auth.getFirstLogin, | ||
selectors.router.getPathname, | ||
selectors.core.kvStore.lockbox.getDevices, | ||
selectors.core.settings.getCountryCode, | ||
selectors.core.walletOptions.getDomains, | ||
selectors.core.walletOptions.getSupportedCoins | ||
selectors.core.walletOptions.getDomains | ||
], | ||
( | ||
menuOpened: boolean, | ||
paymentMethodsR, | ||
coinsR, | ||
firstLogin: boolean, | ||
pathname, | ||
lockboxDevicesR, | ||
countryCodeR, | ||
domainsR, | ||
supportedCoinsR | ||
domainsR | ||
) => { | ||
const transform = ( | ||
coins: ExtractSuccess<typeof coinsR>, | ||
countryCode, | ||
domains: ExtractSuccess<typeof domainsR>, | ||
paymentMethods: ExtractSuccess<typeof paymentMethodsR>, | ||
lockboxDevices, | ||
supportedCoins: ExtractSuccess<typeof supportedCoinsR> | ||
lockboxDevices | ||
) => { | ||
const coinOrder = [ | ||
supportedCoins.EUR, | ||
supportedCoins.GBP, | ||
supportedCoins.BTC, | ||
supportedCoins.ETH, | ||
supportedCoins.BCH, | ||
supportedCoins.XLM, | ||
supportedCoins.ALGO, | ||
supportedCoins.PAX, | ||
supportedCoins.USDT | ||
] | ||
const coins = values( | ||
mapObjIndexed((coin: SupportedCoinType | SupportedFiatType) => { | ||
return { | ||
...coin, | ||
method: | ||
coin.coinCode in CoinTypeEnum || | ||
!!paymentMethods.methods.find( | ||
method => method.currency === coin.coinCode | ||
) | ||
} | ||
}, coinOrder) | ||
) | ||
|
||
return { | ||
coins, | ||
countryCode, | ||
domains, | ||
firstLogin, | ||
lockboxDevices, | ||
menuOpened, | ||
pathname, | ||
paymentMethods | ||
pathname | ||
} | ||
} | ||
|
||
return lift(transform)( | ||
countryCodeR, | ||
domainsR, | ||
paymentMethodsR, | ||
lockboxDevicesR, | ||
supportedCoinsR | ||
) | ||
return lift(transform)(coinsR, countryCodeR, domainsR, lockboxDevicesR) | ||
} | ||
) |
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
7 changes: 5 additions & 2 deletions
7
...s/blockchain-wallet-v4-frontend/src/scenes/Home/Balances/CoinBalance/template.success.tsx
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
Oops, something went wrong.