Skip to content

Commit 1a82fce

Browse files
authored
Merge pull request #2723 from input-output-hk/feature/ddw-738-implement-discreet-mode
[DDW-738] Implement discreet Mode
2 parents ebdac0f + 357591e commit 1a82fce

File tree

121 files changed

+3014
-953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3014
-953
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
### Features
1111

12+
- Implemented "discreet mode" ([PR 2723](https://github.com/input-output-hk/daedalus/pull/2723), [PR 2724](https://github.com/input-output-hk/daedalus/pull/2724), [PR 2725](https://github.com/input-output-hk/daedalus/pull/2725), [PR 2742](https://github.com/input-output-hk/daedalus/pull/2742), [PR 2740](https://github.com/input-output-hk/daedalus/pull/2740), [PR 2756](https://github.com/input-output-hk/daedalus/pull/2756))
1213
- Updated slider component to only execute onAfterChange if slider had moved ([PR 2766](https://github.com/input-output-hk/daedalus/pull/2766))
14+
15+
### Fixes
16+
1317
- Fixed app update for specific platform ([PR 2759](https://github.com/input-output-hk/daedalus/pull/2759))
1418

1519
### Fixes

jest.config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ module.exports = {
8585
// ],
8686

8787
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
88-
// moduleNameMapper: {},
88+
moduleNameMapper: {
89+
// Jest does not support WASM imports from ESM modules
90+
// https://github.com/facebook/jest/issues/9430
91+
'^@iohk-jormungandr/wallet-js$': 'identity-obj-proxy',
92+
},
8993

9094
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
9195
// modulePathIgnorePatterns: [],
@@ -121,7 +125,7 @@ module.exports = {
121125
// rootDir: undefined,
122126

123127
// A list of paths to directories that Jest should use to search for files in
124-
roots: ['<rootDir>/tests'],
128+
roots: ['<rootDir>/tests', '<rootDir>/source'],
125129

126130
// Allows you to use a custom runner instead of Jest's default test runner
127131
// runner: "jest-runner",
@@ -171,7 +175,11 @@ module.exports = {
171175
// timers: "real",
172176

173177
// A map from regular expressions to paths to transformers
174-
// transform: undefined,
178+
transform: {
179+
'\\.[jt]sx?$': 'babel-jest',
180+
'^.+\\.svg$': 'jest-svg-transformer',
181+
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
182+
},
175183

176184
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
177185
// transformIgnorePatterns: [

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start:dev": "NODE_ENV=development gulp start",
1313
"dev": "IS_WATCH_MODE=true gulp dev",
1414
"test": "NODE_ENV=test yarn build && yarn test:unit && yarn test:e2e:fail-fast",
15-
"test:jest": "jest",
15+
"test:jest": "NODE_OPTIONS=--experimental-vm-modules jest",
1616
"test:generate:report": "node tests/reporter.js",
1717
"test:unit": "yarn cucumber:run --require 'tests/**/unit/**/*.js' --tags '@unit and not @skip and not @wip'",
1818
"test:unit:rerun": "yarn cucumber:rerun --require 'tests/**/unit/**/*.js' --tags '@unit and not @skip and not @wip'",
@@ -87,6 +87,8 @@
8787
"@storybook/addons": "5.3.14",
8888
"@storybook/core": "5.3.14",
8989
"@storybook/react": "5.3.14",
90+
"@testing-library/jest-dom": "5.15.1",
91+
"@testing-library/react": "12.1.2",
9092
"asar": "2.1.0",
9193
"autodll-webpack-plugin": "0.4.2",
9294
"axios": "0.21.1",
@@ -130,8 +132,11 @@
130132
"hash.js": "1.1.7",
131133
"html-loader": "0.5.5",
132134
"husky": "4.3.0",
135+
"identity-obj-proxy": "3.0.0",
133136
"jest": "26.6.3",
137+
"jest-css-modules-transform": "^4.3.0",
134138
"jest-environment-jsdom": "26.6.2",
139+
"jest-svg-transformer": "^1.0.0",
135140
"markdown-loader": "5.1.0",
136141
"mini-css-extract-plugin": "0.9.0",
137142
"minimist": "1.2.5",
@@ -278,7 +283,6 @@
278283
"**/**/node-fetch": "2.6.1",
279284
"**/**/mobx-react-lite": "2.2.2",
280285
"**/**/ini": "1.3.8",
281-
"**/**/usb": "1.7.2",
282-
"**/**/istanbul-lib-report": "2.0.8"
286+
"**/**/usb": "1.7.2"
283287
}
284288
}

source/common/config/electron-store.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ export const STORAGE_KEYS: {
2020
CURRENCY_ACTIVE: 'CURRENCY-ACTIVE',
2121
CURRENCY_SELECTED: 'CURRENCY-SELECTED',
2222
DATA_LAYER_MIGRATION_ACCEPTANCE: 'DATA-LAYER-MIGRATION-ACCEPTANCE',
23+
DISCREET_MODE_ENABLED: 'DISCREET-MODE-ENABLED',
24+
DISCREET_MODE_SETTINGS_TOOLTIP: 'DISCREET-MODE-SETTINGS-TOOLTIP',
25+
DISCREET_MODE_NOTIFICATION: 'DISCREET-MODE-NOTIFICATION',
2326
DOWNLOAD_MANAGER: 'DOWNLOAD-MANAGER',
24-
HARDWARE_WALLET_DEVICES: 'HARDWARE-WALLET-DEVICES',
2527
HARDWARE_WALLETS: 'HARDWARE-WALLETS',
28+
HARDWARE_WALLET_DEVICES: 'HARDWARE-WALLET-DEVICES',
2629
READ_NEWS: 'READ-NEWS',
2730
RESET: 'RESET',
2831
SMASH_SERVER: 'SMASH-SERVER',
@@ -35,7 +38,7 @@ export const STORAGE_KEYS: {
3538
USER_LOCALE: 'USER-LOCALE',
3639
USER_NUMBER_FORMAT: 'USER-NUMBER-FORMAT',
3740
USER_TIME_FORMAT: 'USER-TIME-FORMAT',
38-
WALLET_MIGRATION_STATUS: 'WALLET-MIGRATION-STATUS',
3941
WALLETS: 'WALLETS',
42+
WALLET_MIGRATION_STATUS: 'WALLET-MIGRATION-STATUS',
4043
WINDOW_BOUNDS: 'WINDOW-BOUNDS',
4144
};

source/common/types/electron-store.types.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export type StorageKey =
1111
| 'CURRENCY-ACTIVE'
1212
| 'CURRENCY-SELECTED'
1313
| 'DATA-LAYER-MIGRATION-ACCEPTANCE'
14+
| 'DISCREET-MODE-ENABLED'
15+
| 'DISCREET-MODE-SETTINGS-TOOLTIP'
16+
| 'DISCREET-MODE-NOTIFICATION'
1417
| 'DOWNLOAD-MANAGER'
1518
| 'HARDWARE-WALLET-DEVICES'
1619
| 'HARDWARE-WALLETS'

source/main/ipc/electronStoreConversation.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const reset = async () => {
3232
await unset(keys.CURRENCY_ACTIVE);
3333
await unset(keys.CURRENCY_SELECTED);
3434
await unset(keys.DATA_LAYER_MIGRATION_ACCEPTANCE);
35+
await unset(keys.DISCREET_MODE_ENABLED);
36+
await unset(keys.DISCREET_MODE_SETTINGS_TOOLTIP);
37+
await unset(keys.DISCREET_MODE_NOTIFICATION);
3538
await unset(keys.DOWNLOAD_MANAGER);
3639
await unset(keys.HARDWARE_WALLET_DEVICES);
3740
await unset(keys.HARDWARE_WALLETS);
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
// @flow
22
export const installChromeExtensions = async (isDev: boolean) => {
33
if (isDev) {
4-
const installer = require('electron-devtools-installer'); // eslint-disable-line global-require
4+
const {
5+
default: installExtension,
6+
REACT_DEVELOPER_TOOLS,
7+
} = require('electron-devtools-installer'); // eslint-disable-line global-require
8+
const { app } = require('electron');
59

6-
const extensions = ['REACT_DEVELOPER_TOOLS'];
7-
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
8-
for (const name of extensions) {
9-
try {
10-
await installer.default(installer[name], forceDownload);
11-
} catch (e) {} // eslint-disable-line
12-
}
10+
const extensions = [REACT_DEVELOPER_TOOLS];
11+
const options = {
12+
loadExtensionOptions: { allowFileAccess: true },
13+
};
14+
15+
try {
16+
await app.whenReady();
17+
await installExtension(extensions, options);
18+
} catch (e) {} // eslint-disable-line
1319
}
1420
};

source/renderer/app/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export default class App extends Component<{
4848
!isNodeStopping && // Daedalus is not shutting down
4949
!isNodeStopped; // Daedalus is not shutting down
5050

51+
if (document.documentElement) {
52+
document.documentElement.lang = locale;
53+
}
54+
5155
return (
5256
<Fragment>
5357
<ThemeManager variables={themeVars} />

source/renderer/app/Routes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import WalletsSettingsPage from './containers/settings/categories/WalletsSetting
1212
import StakePoolsSettingsPage from './containers/settings/categories/StakePoolsSettingsPage';
1313
import SupportSettingsPage from './containers/settings/categories/SupportSettingsPage';
1414
import TermsOfUseSettingsPage from './containers/settings/categories/TermsOfUseSettingsPage';
15+
import SecuritySettingsPage from './containers/settings/categories/SecuritySettingsPage';
1516
import TermsOfUsePage from './containers/profile/TermsOfUsePage';
1617
import DataLayerMigrationPage from './containers/profile/DataLayerMigrationPage';
1718
import DisplaySettingsPage from './containers/settings/categories/DisplaySettingsPage';
@@ -114,6 +115,10 @@ export const Routes = withRouter(() => (
114115
path={ROUTES.SETTINGS.DISPLAY}
115116
component={DisplaySettingsPage}
116117
/>
118+
<Route
119+
path={ROUTES.SETTINGS.SECURITY}
120+
component={SecuritySettingsPage}
121+
/>
117122
</Settings>
118123
</Route>
119124
<Route
Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// @flow
2-
import React, { Component } from 'react';
2+
import React from 'react';
33
import BigNumber from 'bignumber.js';
44
import classnames from 'classnames';
55
import { PopOver } from 'react-polymorph/lib/components/PopOver';
6-
import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl';
6+
import { defineMessages, FormattedHTMLMessage } from 'react-intl';
77
import { observer } from 'mobx-react';
8+
import { discreetWalletTokenAmount } from '../../features/discreet-mode/replacers/discreetWalletTokenAmount';
89
import styles from './AssetAmount.scss';
9-
import { formattedTokenWalletAmount } from '../../utils/formatters';
1010
import type { AssetMetadata } from '../../api/assets/types';
11+
import { useDiscreetModeFeature } from '../../features/discreet-mode';
1112

1213
const messages = defineMessages({
1314
unformattedAmount: {
@@ -26,47 +27,57 @@ type Props = {
2627
isShort?: boolean,
2728
};
2829

29-
@observer
30-
export default class AssetAmount extends Component<Props> {
31-
static contextTypes = {
32-
intl: intlShape.isRequired,
33-
};
30+
function AssetAmount({
31+
amount,
32+
metadata,
33+
decimals,
34+
isLoading,
35+
className,
36+
isShort,
37+
}: Props) {
38+
const discreetModeFeature = useDiscreetModeFeature();
3439

35-
render() {
36-
const {
37-
amount,
38-
metadata,
39-
decimals,
40-
isLoading,
41-
className,
42-
isShort,
43-
} = this.props;
44-
if (isLoading) return '-';
45-
const componentStyles = classnames([styles.component, className]);
46-
const content = !isLoading
47-
? formattedTokenWalletAmount(amount, metadata, decimals, isShort)
48-
: '-';
49-
return (
50-
<div className={componentStyles}>
51-
{decimals ? (
52-
<PopOver
53-
content={
54-
<FormattedHTMLMessage
55-
{...messages.unformattedAmount}
56-
values={{
57-
amount: formattedTokenWalletAmount(amount, null, 0),
58-
}}
59-
/>
60-
}
61-
visible={decimals ? undefined : false}
62-
className={styles.unformattedAmount}
63-
>
64-
{content}
65-
</PopOver>
66-
) : (
67-
<span>{content}</span>
68-
)}
69-
</div>
70-
);
71-
}
40+
if (isLoading) return '-';
41+
const componentStyles = classnames([styles.component, className]);
42+
const content = !isLoading
43+
? discreetModeFeature.discreetValue({
44+
replacer: discreetWalletTokenAmount({
45+
amount,
46+
metadata,
47+
decimals,
48+
isShort,
49+
}),
50+
})
51+
: '-';
52+
53+
return (
54+
<div className={componentStyles}>
55+
{decimals ? (
56+
<PopOver
57+
content={
58+
<FormattedHTMLMessage
59+
{...messages.unformattedAmount}
60+
values={{
61+
amount: discreetModeFeature.discreetValue({
62+
replacer: discreetWalletTokenAmount({
63+
amount,
64+
metadata: null,
65+
decimals: 0,
66+
}),
67+
}),
68+
}}
69+
/>
70+
}
71+
visible={decimals ? undefined : false}
72+
className={styles.unformattedAmount}
73+
>
74+
{content}
75+
</PopOver>
76+
) : (
77+
<span>{content}</span>
78+
)}
79+
</div>
80+
);
7281
}
82+
83+
export default observer(AssetAmount);

0 commit comments

Comments
 (0)