Skip to content

Commit

Permalink
[DDW-814] Fix flow
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvalentin committed Nov 22, 2021
1 parent eadcdfb commit 2d201ac
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 23 deletions.
Expand Up @@ -21,9 +21,9 @@ export function WalletUtxoDescription({
<FormattedHTMLMessage
{...description}
values={{
formattedWalletAmount: discreetModeFeature.discreetValue(
formattedWalletAmount
),
formattedWalletAmount: discreetModeFeature.discreetValue({
value: formattedWalletAmount,
}),
walletUtxosAmount,
}}
/>
Expand Down
4 changes: 2 additions & 2 deletions source/renderer/app/features/discreet-mode/feature.js
Expand Up @@ -6,7 +6,7 @@ import Request from '../../stores/lib/LocalizedRequest';
import { DiscreetModeApi } from './api';
import { SENSITIVE_DATA_SYMBOL } from './config';
import { defaultReplacer } from './replacers/defaultReplacer';
import type { DiscreetValueReplacer } from './types';
import type { ReplacerFn } from './types';

export class DiscreetMode extends Feature {
api: DiscreetModeApi;
Expand Down Expand Up @@ -56,7 +56,7 @@ export class DiscreetMode extends Feature {
replacer = defaultReplacer(),
value,
}: {
replacer: DiscreetValueReplacer,
replacer?: ReplacerFn,
value?: any,
}) {
return replacer(this.isDiscreetMode, SENSITIVE_DATA_SYMBOL, value);
Expand Down
@@ -1,6 +1,9 @@
// @flow
export function defaultReplacer() {
return (isDiscreetMode, symbol: string, value: any) => {

import type { DiscreetValueReplacer } from '../types';

export const defaultReplacer: DiscreetValueReplacer = () => {
return (isDiscreetMode, symbol, value) => {
return isDiscreetMode ? symbol : value;
};
}
};
@@ -1,7 +1,7 @@
// @flow
import BigNumber from 'bignumber.js';
import { formattedWalletAmount } from '../../../utils/formatters';
import { DiscreetValueReplacer } from '../types';
import type { DiscreetValueReplacer } from '../types';

export type DiscreetWalletAmountProps = {
amount: BigNumber,
Expand Down
Expand Up @@ -2,7 +2,7 @@
import BigNumber from 'bignumber.js';
import type { AssetMetadata } from '../../../api/assets/types';
import { formattedTokenWalletAmount } from '../../../utils/formatters';
import { DiscreetValueReplacer } from '../types';
import type { DiscreetValueReplacer } from '../types';

export type DiscreetWalletTokenAmountProps = {
amount: BigNumber,
Expand Down
4 changes: 3 additions & 1 deletion source/renderer/app/features/discreet-mode/types.js
@@ -1,7 +1,9 @@
// @flow

export type DiscreetValueReplacer = () => (
export type ReplacerFn = (
isDiscreetMode: boolean,
symbol: string,
value: any
) => string;

export type DiscreetValueReplacer = (args: any) => ReplacerFn;
@@ -1,10 +1,8 @@
// @flow
import React from 'react';
import { observer } from 'mobx-react';
import {
discreetWalletTokenAmount,
DiscreetWalletTokenAmountProps,
} from '../replacers/discreetWalletTokenAmount';
import { discreetWalletTokenAmount } from '../replacers/discreetWalletTokenAmount';
import type { DiscreetWalletTokenAmountProps } from '../replacers/discreetWalletTokenAmount';
import DiscreetValue from './DiscreetValue';

function DiscreetTokenWalletAmount(props: DiscreetWalletTokenAmountProps) {
Expand Down
Expand Up @@ -6,11 +6,11 @@ import type { Node } from 'react';
import { useDiscreetModeFeature } from '../context';
import { SENSITIVE_DATA_SYMBOL } from '../config';
import { defaultReplacer } from '../replacers/defaultReplacer';
import { DiscreetValueReplacer } from '../types';
import type { ReplacerFn } from '../types';

type Props = {
children: Node,
replacer: DiscreetValueReplacer,
replacer: ReplacerFn,
};

function DiscreetValue({ children, replacer = defaultReplacer() }: Props) {
Expand Down
@@ -1,9 +1,7 @@
// @flow
import React from 'react';
import {
discreetWalletAmount,
DiscreetWalletAmountProps,
} from '../replacers/discreetWalletAmount';
import { discreetWalletAmount } from '../replacers/discreetWalletAmount';
import type { DiscreetWalletAmountProps } from '../replacers/discreetWalletAmount';
import DiscreetValue from './DiscreetValue';

export default function DiscreetWalletAmount(props: DiscreetWalletAmountProps) {
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/features/local-storage/context.js
Expand Up @@ -5,7 +5,7 @@ import type { Node } from 'react';
import { merge } from 'lodash/fp';
import { getFeatureFromContext } from '../../utils/mobx-features/hooks';

import { LocalStorageApi } from './types';
import type { LocalStorageApi } from './types';

export const localStorageContext = React.createContext<LocalStorageApi | null>(
null
Expand Down
4 changes: 3 additions & 1 deletion source/renderer/app/features/local-storage/types.js
@@ -1,7 +1,9 @@
// @flow

import type { StorageKey } from '../../../../common/types/electron-store.types';

export type LocalStorageApi = {
get: (key: StorageKey, defaultValue: any) => boolean,
get: (key: StorageKey, defaultValue: any) => Promise<any>,
set: (key: StorageKey, value: any) => Promise<void>,
unset: (key: StorageKey) => Promise<void>,
};
@@ -1,6 +1,7 @@
// @flow

import React from 'react';
import type { Node } from 'react';
import { LocalStorageFeatureProvider } from '../context';

type Props = {
Expand Down

0 comments on commit 2d201ac

Please sign in to comment.