Skip to content
Permalink
Browse files

[DDW-893] Flow errors

  • Loading branch information...
daniloprates committed Sep 12, 2019
1 parent fb84801 commit 0b01e0308b9ede20864ed95759c05ad4b327d8e9
@@ -6,7 +6,6 @@ export type GeneratePaperWalletParams = {
isMainnet: boolean,
buildLabel: string,
timestamp: string,
createdAt: Date,
messages: {
walletAddressLabel: string,
recoveryPhraseLabel: string,
@@ -10,7 +10,7 @@ type Props = {
activeItem: string,
isActiveScreen: Function,
onWalletNavItemClick: Function,
hasNotification: boolean,
hasNotification?: boolean,
};

@observer
@@ -54,7 +54,7 @@ type Props = {
activeItem: string,
isActiveNavItem: Function,
onNavItemClick: Function,
hasNotification: boolean,
hasNotification?: boolean,
};

@observer
@@ -85,14 +85,16 @@ export const messages = defineMessages({
});

type Props = {
mnemonicsConfirmationDate: Date,
walletCreationDate: Date,
openDialogAction: Function,
isDialogOpen: Function,
walletRecoveryPhraseStep1Container: Node,
walletRecoveryPhraseStep2Container: Node,
walletRecoveryPhraseStep3Container: Node,
walletRecoveryPhraseStep4Container: Node,
mnemonicsConfirmationDate: ?Date,
mnemonicsConfirmationStatus: string,
mnemonicsConfirmationStatusType: string,
};

@observer
@@ -135,24 +137,32 @@ export default class WalletRecoveryPhrase extends Component<Props> {
}

get recoveryPhraseStatus() {
const { mnemonicsConfirmationDate, walletCreationDate } = this.props;
const dateToCheck = mnemonicsConfirmationDate || walletCreationDate;
const daysSinceDate = moment().diff(moment(dateToCheck), 'days');
let status = 'ok';
if (daysSinceDate > MNEMONICS_CHECKING_NOTIFICATION)
status = 'notification';
else if (daysSinceDate > MNEMONICS_CHECKING_WARNING) status = 'warning';
const type = mnemonicsConfirmationDate ? 'alreadyChecked' : 'neverChecked';
const statuses = this.statuses[type];
const { icon, message } = statuses[status];
const {
walletCreationDate,
mnemonicsConfirmationDate,
mnemonicsConfirmationStatus,
mnemonicsConfirmationStatusType,
} = this.props;

const statuses = this.statuses[mnemonicsConfirmationStatusType];
const { icon, message } = statuses[mnemonicsConfirmationStatus];
const timeAgo = moment(mnemonicsConfirmationDate).fromNow();
const timeUntilWarning = 'few months, more or less';
const timeUntilNotification = 'couple of days, more or less';
const fromNowToWarning = moment().add(MNEMONICS_CHECKING_WARNING, 'days');
const fromNowToNotification = moment().add(
MNEMONICS_CHECKING_NOTIFICATION,
'days'
);
const timeUntilWarning = moment(walletCreationDate).diff(
fromNowToWarning,
'days'
);
const timeUntilNotification = moment(walletCreationDate).diff(
fromNowToNotification,
'days'
);
return {
icon,
message,
type,
status,
timeAgo,
timeUntilWarning,
timeUntilNotification,
@@ -168,19 +178,19 @@ export default class WalletRecoveryPhrase extends Component<Props> {
walletRecoveryPhraseStep2Container,
walletRecoveryPhraseStep3Container,
walletRecoveryPhraseStep4Container,
mnemonicsConfirmationStatus,
} = this.props;
const {
icon,
message,
status,
timeAgo,
timeUntilWarning,
timeUntilNotification,
} = this.recoveryPhraseStatus;

const validationStatusStyles = classnames([
styles.validationStatus,
styles[`validationStatus${capitalize(status)}`],
styles[`validationStatus${capitalize(mnemonicsConfirmationStatus)}`],
]);

return (
@@ -54,7 +54,7 @@ export default class WalletRecoveryPhraseStep1 extends Component<Props, State> {
safetyAgreement: false,
};

onToggleSafetyAgreement = checked => {
onToggleSafetyAgreement = (checked: boolean) => {
this.setState({
safetyAgreement: checked,
});
@@ -53,7 +53,7 @@ export default class WalletRecoveryPhraseStep1 extends Component<Props, State> {
safetyAgreement: false,
};

onToggleSafetyAgreement = checked => {
onToggleSafetyAgreement = (checked: boolean) => {
this.setState({
safetyAgreement: checked,
});
@@ -79,7 +79,9 @@ type Props = {
walletRecoveryPhraseStep2Container: Node,
walletRecoveryPhraseStep3Container: Node,
walletRecoveryPhraseStep4Container: Node,
mnemonicsConfirmationDate?: Date,
mnemonicsConfirmationDate: ?Date,
mnemonicsConfirmationStatus: string,
mnemonicsConfirmationStatusType: string,
};

@observer
@@ -127,6 +129,8 @@ export default class WalletSettings extends Component<Props> {
walletRecoveryPhraseStep3Container,
walletRecoveryPhraseStep4Container,
mnemonicsConfirmationDate,
mnemonicsConfirmationStatus,
mnemonicsConfirmationStatusType,
} = this.props;

const assuranceLevelOptions = assuranceLevels.map(assurance => ({
@@ -188,6 +192,8 @@ export default class WalletSettings extends Component<Props> {

<WalletRecoveryPhrase
mnemonicsConfirmationDate={mnemonicsConfirmationDate}
mnemonicsConfirmationStatus={mnemonicsConfirmationStatus}
mnemonicsConfirmationStatusType={mnemonicsConfirmationStatusType}
walletCreationDate={walletCreationDate}
openDialogAction={openDialogAction}
isDialogOpen={isDialogOpen}
@@ -73,8 +73,9 @@ export default class Wallet extends Component<Props> {
0
);
const hasNotification =
wallets.active &&
wallets.active.mnemonicsConfirmationStatus ===
WalletStatuses.NOTIFICATION;
WalletStatuses.NOTIFICATION;

return (
<MainLayout>
@@ -4,7 +4,6 @@ import { observer, inject } from 'mobx-react';
import WalletSettings from '../../components/wallet/settings/WalletSettings';
import type { InjectedProps } from '../../types/injectedPropsType';
import { isValidWalletName } from '../../utils/validations';
// import { getWalletLocalData } from '../../utils/walletLocalStorage.js';
import ChangeSpendingPasswordDialogContainer from './dialogs/settings/ChangeSpendingPasswordDialogContainer';
import DeleteWalletDialogContainer from './dialogs/settings/DeleteWalletDialogContainer';
import ExportWalletToFileDialogContainer from './dialogs/settings/ExportWalletToFileDialogContainer';
@@ -54,6 +53,10 @@ export default class WalletSettingsPage extends Component<Props> {
isSpendingPasswordSet={activeWallet.hasPassword}
spendingPasswordUpdateDate={activeWallet.passwordUpdateDate}
mnemonicsConfirmationDate={activeWallet.mnemonicsConfirmationDate}
mnemonicsConfirmationStatus={activeWallet.mnemonicsConfirmationStatus}
mnemonicsConfirmationStatusType={
activeWallet.mnemonicsConfirmationStatusType
}
isDialogOpen={uiDialogs.isOpen}
walletId={activeWallet.id}
walletName={activeWallet.name}
@@ -21,10 +21,10 @@ export default class WalletRecoveryPhraseStep2Container extends Component<Props>
updateWalletLocalData = () => {
const { wallets } = this.props.stores;
const activeWallet = wallets.active;
activeWallet.updateWalletLocalData();
if (activeWallet) activeWallet.updateWalletLocalData();
};

handleVerify = successful => {
handleVerify = (successful: boolean) => {
const dialog = successful
? WalletRecoveryPhraseStep3Dialog
: WalletRecoveryPhraseStep4Dialog;
@@ -73,6 +73,9 @@ export type WalletProps = {
isDelegated?: boolean,
delegatedStakePool?: StakePool,
createdAt: Date,
mnemonicsConfirmationDate: ?Date,
mnemonicsConfirmationStatus: string,
mnemonicsConfirmationStatusType: string,
};

export default class Wallet {
@@ -109,8 +112,8 @@ export default class Wallet {
};

getWalletStatus = (mnemonicsConfirmationDate: ?Date) => {
const { walletCreationDate } = this;
const dateToCheck = mnemonicsConfirmationDate || walletCreationDate;
const { createdAt } = this;
const dateToCheck = mnemonicsConfirmationDate || createdAt;
const daysSinceDate = moment().diff(moment(dateToCheck), 'days');
let status = WalletStatuses.OK;
if (daysSinceDate > MNEMONICS_CHECKING_NOTIFICATION)
@@ -15,7 +15,7 @@ const storageKeys = {

export type WalletLocalData = {
id: string,
mnemonicsConfirmationDate: ?Date,
mnemonicsConfirmationDate?: ?Date,
};

export const getWalletLocalData = (
@@ -51,7 +51,6 @@ export const setWalletLocalData = (

export const updateWalletLocalData = (updatedWalletData: {
id: string,
mnemonicsConfirmationDate: Date,
}): Promise<void> =>
new Promise(async (resolve, reject) => {
const walletId = updatedWalletData.id;
@@ -19,20 +19,23 @@ const sidebarMenus = observable({
info: '100 ADA',
isConnected: true,
isLegacy: false,
mnemonicsConfirmationStatus: 'ok',
},
{
id: '2',
title: 'Second',
info: '200 ADA',
isConnected: true,
isLegacy: false,
mnemonicsConfirmationStatus: 'ok',
},
{
id: '3',
title: 'Third',
info: '300 ADA',
isConnected: true,
isLegacy: false,
mnemonicsConfirmationStatus: 'ok',
},
],
activeWalletId: '1',
@@ -36,6 +36,10 @@ storiesOf('SidebarWalletsMenu', module)
isRestoreActive: false,
restoreProgress: 0,
isLegacy: false,
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
},
{
id: '2',
@@ -45,6 +49,10 @@ storiesOf('SidebarWalletsMenu', module)
isRestoreActive: false,
restoreProgress: 0,
isLegacy: false,
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
},
{
id: '3',
@@ -54,6 +62,10 @@ storiesOf('SidebarWalletsMenu', module)
isRestoreActive: false,
restoreProgress: 0,
isLegacy: false,
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
},
{
id: '4',
@@ -63,6 +75,10 @@ storiesOf('SidebarWalletsMenu', module)
isRestoreActive: false,
restoreProgress: 0,
isLegacy: false,
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
},
]}
isActiveWallet={id => id === '2'}
@@ -29,6 +29,10 @@ const wallets = [
inactiveStakePercentage: 24,
isDelegated: true,
delegatedStakePool: STAKE_POOLS[0],
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
}),
new Wallet({
id: 'wallet2',
@@ -41,6 +45,10 @@ const wallets = [
inactiveStakePercentage: 35,
isDelegated: true,
delegatedStakePool: STAKE_POOLS[1],
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
}),
new Wallet({
id: 'wallet3',
@@ -52,6 +60,10 @@ const wallets = [
isLegacy: false,
inactiveStakePercentage: 0,
isDelegated: false,
createdAt: new Date(),
mnemonicsConfirmationDate: new Date(),
mnemonicsConfirmationStatus: 'ok',
mnemonicsConfirmationStatusType: 'neverChecked',
}),
];

@@ -73,11 +73,8 @@ const getWalletDates = (type: string, status: string) => {
.subtract(MNEMONICS_CHECKING_NOTIFICATION + 10, 'days')
.toDate();

let walletCreationDate;
let mnemonicsConfirmationDate;

if (type === 'alreadyChecked') mnemonicsConfirmationDate = date;
else walletCreationDate = date;
const mnemonicsConfirmationDate = date;
const walletCreationDate = date;

return {
mnemonicsConfirmationDate,
@@ -248,12 +245,31 @@ export default () => {
onClose={action('Export Wallet - onClose')}
/>
}
walletRecoveryPhraseStep1Container={<WalletRecoveryPhraseStep1Dialog />}
walletRecoveryPhraseStep2Container={<WalletRecoveryPhraseStep2Dialog />}
walletRecoveryPhraseStep3Container={<WalletRecoveryPhraseStep3Dialog />}
walletRecoveryPhraseStep4Container={<WalletRecoveryPhraseStep4Dialog />}
walletRecoveryPhraseStep1Container={
<WalletRecoveryPhraseStep1Dialog
onClose={action('onClose')}
onContinue={action('onContinue')}
/>
}
walletRecoveryPhraseStep2Container={
<WalletRecoveryPhraseStep2Dialog
onClose={action('onClose')}
onVerify={action('onVerify')}
/>
}
walletRecoveryPhraseStep3Container={
<WalletRecoveryPhraseStep3Dialog onClose={action('onClose')} />
}
walletRecoveryPhraseStep4Container={
<WalletRecoveryPhraseStep4Dialog
onClose={action('onClose')}
onVerifyAgain={action('onVerifyAgain')}
/>
}
walletCreationDate={walletCreationDate}
mnemonicsConfirmationDate={mnemonicsConfirmationDate}
mnemonicsConfirmationStatus={status}
mnemonicsConfirmationStatusType={type}
/>
);
};
@@ -113,6 +113,7 @@ export default class StoryLayout extends Component<Props> {
isRestoreActive: get(wallet, 'syncState.tag', 'synced') === 'restoring',
restoreProgress: get(wallet, 'syncState.data.percentage.quantity', 0),
isLegacy: wallet.isLegacy,
mnemonicsConfirmationStatus: wallet.mnemonicsConfirmationStatus,
}));

getSidebarMenus = (

0 comments on commit 0b01e03

Please sign in to comment.
You can’t perform that action at this time.