-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(refactor): clean up around login folder (#6218)
- Loading branch information
1 parent
1331624
commit e6e9daa
Showing
8 changed files
with
60 additions
and
126 deletions.
There are no files selected for viewing
64 changes: 25 additions & 39 deletions
64
packages/blockchain-wallet-v4-frontend/src/data/cache/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,46 +1,32 @@ | ||
import { path, prop } from 'ramda' | ||
|
||
import { crypto as wCrypto } from '@core' | ||
import { RootState } from 'data/rootReducer' | ||
|
||
export const getLastAnnouncementState = (state): object | undefined => | ||
path(['cache', 'announcements'], state) | ||
export const getCache = (state) => prop('cache', state) | ||
export const getEmail = (state): string | undefined => path(['cache', 'lastEmail'], state) | ||
export const getExchangeEmail = (state): string | undefined => | ||
path(['cache', 'exchangeEmail'], state) | ||
export const getExchangeWalletGuid = (state): string | undefined => | ||
path(['cache', 'exchangeWalletGuid'], state) | ||
export const getStoredGuid = (state): string | undefined => path(['cache', 'guidStored'], state) | ||
export const getMobileConnected = (state): string | undefined => | ||
path(['cache', 'mobileConnected'], state) | ||
export const getLastGuid = (state): string | undefined => path(['cache', 'lastGuid'], state) | ||
export const getChannelChannelId = (state): string | undefined => | ||
path(['cache', 'channelChannelId'], state) | ||
export const getChannelPrivKey = (state): string | undefined => | ||
path(['cache', 'channelPrivKey'], state) | ||
export const getPhonePubkey = (state): string | undefined => | ||
path(['cache', 'channelPhonePubkey'], state) | ||
export const getHasCloudBackup = (state): boolean | undefined => | ||
path(['cache', 'hasCloudBackup'], state) | ||
export const getLastLogoutTimestamp = (state): boolean | undefined => | ||
path(['cache', 'lastLogoutTimestamp'], state) | ||
export const getUnifiedAccountStatus = (state): boolean | undefined => | ||
path(['cache', 'unifiedAccount'], state) | ||
export const getLastUnusedAmounts = (state): boolean | undefined => | ||
path(['cache', 'lastUnusedAmounts'], state) | ||
export const getLastAnnouncementState = (state: RootState) => state.cache.announcements | ||
export const getCache = (state: RootState) => state.cache | ||
export const getEmail = (state: RootState) => state.cache.lastEmail | ||
export const getExchangeEmail = (state: RootState) => state.cache.exchangeEmail | ||
export const getExchangeWalletGuid = (state: RootState) => state.cache.exchangeWalletGuid | ||
export const getStoredGuid = (state: RootState) => state.cache.guidStored | ||
export const getMobileConnected = (state: RootState) => state.cache.mobileConnected | ||
export const getLastGuid = (state: RootState) => state.cache.lastGuid | ||
export const getChannelChannelId = (state: RootState) => state.cache.channelChannelId | ||
export const getChannelPrivKey = (state: RootState) => state.cache.channelPrivKey | ||
export const getPhonePubkey = (state: RootState) => state.cache.channelPhonePubkey | ||
export const getHasCloudBackup = (state: RootState) => state.cache.hasCloudBackup | ||
export const getLastLogoutTimestamp = (state: RootState) => state.cache.lastLogoutTimestamp | ||
export const getUnifiedAccountStatus = (state: RootState) => state.cache.unifiedAccount | ||
export const getLastUnusedAmounts = (state: RootState) => state.cache.lastUnusedAmounts | ||
|
||
export const getNoActionRequiredSweep = (state): { guid: string; seen: boolean } | undefined => | ||
path(['cache', 'noActionRequiredSweep'], state) | ||
export const getNoActionRequiredSweep = (state: RootState) => state.cache.noActionRequiredSweep | ||
|
||
export const getChannelPrivKeyForQrData = (state) => { | ||
export const getChannelPrivKeyForQrData = (state: RootState) => { | ||
const channelPrivKey = getChannelPrivKey(state) | ||
|
||
if (channelPrivKey) { | ||
return JSON.stringify({ | ||
channelId: getChannelChannelId(state), | ||
pubkey: wCrypto.derivePubFromPriv(Buffer.from(channelPrivKey, 'hex')).toString('hex'), | ||
type: 'login_wallet' | ||
}) | ||
} | ||
return '' | ||
if (!channelPrivKey) return '' | ||
|
||
return JSON.stringify({ | ||
channelId: getChannelChannelId(state), | ||
pubkey: wCrypto.derivePubFromPriv(Buffer.from(channelPrivKey, 'hex')).toString('hex'), | ||
type: 'login_wallet' | ||
}) | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
packages/blockchain-wallet-v4-frontend/src/scenes/Login/utils.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