Skip to content

Commit c15ebce

Browse files
authored
[DDW] Implement NTP force check (#1996)
* Implement NTP force check * Update cardano-wallet * Fix local storage
1 parent 54b7265 commit c15ebce

File tree

18 files changed

+116
-71
lines changed

18 files changed

+116
-71
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Changelog
33

44
## 1.0.0
55

6+
### Features
7+
8+
- Implemented NTP force check ([PR 1996](https://github.com/input-output-hk/daedalus/pull/1996))
9+
610
### Fixes
711

812
- Fixed UI issues on wallet import overlays ([PR 1983](https://github.com/input-output-hk/daedalus/pull/1983))

nix/sources.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
"homepage": null,
4242
"owner": "input-output-hk",
4343
"repo": "cardano-wallet",
44-
"rev": "b8ae9821f27eb24a119aa06532519cce2ab11cbc",
45-
"sha256": "1j5wv2mjbpqbjl9r9647gxq7jsv14xghizslrhcahrvkv1f5p8m4",
44+
"rev": "a638544c454bf71eb4d97a18f2fc3ff49bbab2b0",
45+
"sha256": "06qvra6x4886gff5dfnnwb8n83q0bpfz4flghlsxwb8ahh8mr2vc",
4646
"type": "tarball",
47-
"url": "https://github.com/input-output-hk/cardano-wallet/archive/b8ae9821f27eb24a119aa06532519cce2ab11cbc.tar.gz",
47+
"url": "https://github.com/input-output-hk/cardano-wallet/archive/a638544c454bf71eb4d97a18f2fc3ff49bbab2b0.tar.gz",
4848
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
4949
"version": "v2020-04-07"
5050
},

source/renderer/app/actions/network-status-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export default class NetworkStatusActions {
99
restartNode: Action<any> = new Action();
1010
toggleSplash: Action<any> = new Action();
1111
copyStateDirectoryPath: Action<any> = new Action();
12+
forceCheckNetworkClock: Action<any> = new Action();
1213
}

source/renderer/app/api/api.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,19 +1587,25 @@ export default class AdaApi {
15871587
}
15881588
};
15891589

1590-
getNetworkClock = async (): Promise<GetNetworkClockResponse> => {
1591-
logger.debug('AdaApi::getNetworkClock called');
1590+
getNetworkClock = async (
1591+
isForceCheck: boolean
1592+
): Promise<GetNetworkClockResponse> => {
1593+
logger.debug('AdaApi::getNetworkClock called', { isForceCheck });
15921594
try {
15931595
const networkClock: NetworkClockResponse = await getNetworkClock(
1594-
this.config
1596+
this.config,
1597+
isForceCheck
15951598
);
1596-
logger.debug('AdaApi::getNetworkClock success', { networkClock });
1599+
logger.debug('AdaApi::getNetworkClock success', {
1600+
networkClock,
1601+
isForceCheck,
1602+
});
15971603
return {
15981604
status: networkClock.status,
15991605
offset: get(networkClock, 'offset.quantity', null),
16001606
};
16011607
} catch (error) {
1602-
logger.error('AdaApi::getNetworkClock error', { error });
1608+
logger.error('AdaApi::getNetworkClock error', { error, isForceCheck });
16031609
throw new ApiError(error);
16041610
}
16051611
};

source/renderer/app/api/network/requests/getNetworkClock.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import type { NetworkClockResponse } from '../types';
44
import { request } from '../../utils/request';
55

66
export const getNetworkClock = (
7-
config: RequestConfig
7+
config: RequestConfig,
8+
isForceCheck: boolean
89
): Promise<NetworkClockResponse> =>
9-
request({
10-
method: 'GET',
11-
path: '/v2/network/clock',
12-
...config,
13-
});
10+
request(
11+
{
12+
method: 'GET',
13+
path: '/v2/network/clock',
14+
...config,
15+
},
16+
{ forceNtpCheck: isForceCheck }
17+
);

source/renderer/app/api/utils/localStorage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export default class LocalStorageApi {
151151
LocalStorageApi.unset(this.storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE);
152152

153153
getWalletsLocalData = (): Promise<Object> =>
154-
LocalStorageApi.get(this.storageKeys.THEME, {});
154+
LocalStorageApi.get(this.storageKeys.WALLETS, {});
155155

156156
getWalletLocalData = (walletId: string): Promise<WalletLocalData> =>
157157
LocalStorageApi.get(`${this.storageKeys.WALLETS}.${walletId}`, {

source/renderer/app/components/loading/system-time-error/SystemTimeError.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
opacity: 0.8;
8181

8282
&.disabled {
83+
border-bottom-color: transparent !important;
8384
cursor: default;
84-
text-decoration: none;
8585
@include animated-ellipsis($width: 16px);
8686
}
8787
}

source/renderer/app/components/status/DaedalusDiagnostics.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ const messages = defineMessages({
183183
},
184184
checkingNodeTime: {
185185
id: 'daedalus.diagnostics.dialog.checkingNodeTime',
186-
defaultMessage: '!!!Checking Cardano node time',
187-
description: 'Checking Cardano node time',
186+
defaultMessage: '!!!Checking system time',
187+
description: 'Checking system time',
188188
},
189189
cardanoNodeStatus: {
190190
id: 'daedalus.diagnostics.dialog.cardanoNodeStatus',
@@ -354,16 +354,16 @@ type Props = {
354354
localTimeDifference: ?number,
355355
isSystemTimeCorrect: boolean,
356356
isSystemTimeIgnored: boolean,
357-
// isForceCheckingNodeTime: boolean,
357+
isCheckingSystemTime: boolean,
358+
isForceCheckingSystemTime: boolean,
358359
localTip: ?TipInfo,
359360
networkTip: ?TipInfo,
360-
// onForceCheckLocalTimeDifference: Function,
361361
onOpenStateDirectory: Function,
362362
onOpenExternalLink: Function,
363363
onRestartNode: Function,
364364
onClose: Function,
365365
onCopyStateDirectoryPath: Function,
366-
isCheckingSystemTime: boolean,
366+
onForceCheckNetworkClock: Function,
367367
};
368368

369369
type State = {
@@ -453,7 +453,6 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
453453
localTimeDifference,
454454
isSystemTimeCorrect,
455455
isSystemTimeIgnored,
456-
// isForceCheckingNodeTime,
457456
localTip,
458457
networkTip,
459458
onOpenStateDirectory,
@@ -462,6 +461,7 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
462461
nodeConnectionError,
463462
onOpenExternalLink,
464463
isCheckingSystemTime,
464+
isForceCheckingSystemTime,
465465
} = this.props;
466466

467467
const {
@@ -509,11 +509,13 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
509509
}
510510

511511
const localTimeDifferenceClasses = isCheckingSystemTime
512-
? styles.layoutData
512+
? classNames([styles.layoutData, styles.localTimeDifference])
513513
: classNames([
514514
styles.layoutData,
515+
styles.localTimeDifference,
515516
!isNTPServiceReachable ||
516-
(localTimeDifference && localTimeDifference > ALLOWED_TIME_DIFFERENCE)
517+
(localTimeDifference &&
518+
Math.abs(localTimeDifference) > ALLOWED_TIME_DIFFERENCE)
517519
? styles.red
518520
: styles.green,
519521
]);
@@ -657,18 +659,20 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
657659
{intl.formatMessage(messages.localTimeDifference)}:
658660
</div>
659661
<div className={localTimeDifferenceClasses}>
660-
{/*
662+
{
661663
<button
662664
onClick={() => this.checkTime()}
663-
disabled={isForceCheckingNodeTime || !isConnected}
665+
disabled={isForceCheckingSystemTime || !isNodeResponding}
664666
>
665-
{isForceCheckingNodeTime
666-
? intl.formatMessage(messages.localTimeDifferenceChecking)
667+
{isForceCheckingSystemTime
668+
? intl.formatMessage(
669+
messages.localTimeDifferenceChecking
670+
)
667671
: intl.formatMessage(
668672
messages.localTimeDifferenceCheckTime
669673
)}
670674
</button>
671-
*/}
675+
}
672676
{isCheckingSystemTime ? (
673677
<span className={localTimeDifferenceClasses}>-</span>
674678
) : (
@@ -684,16 +688,18 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
684688
</div>
685689
{getRow('systemTimeCorrect', isSystemTimeCorrect)}
686690
{getRow('systemTimeIgnored', isSystemTimeIgnored)}
687-
{/*
691+
{
688692
<div className={styles.layoutRow}>
689-
<div className={styles.layoutHeader}>{intl.formatMessage(messages.checkingNodeTime)}:</div>
693+
<div className={styles.layoutHeader}>
694+
{intl.formatMessage(messages.checkingNodeTime)}:
695+
</div>
690696
<div className={styles.layoutData}>
691-
{isForceCheckingNodeTime
697+
{isCheckingSystemTime
692698
? intl.formatMessage(messages.statusOn)
693699
: intl.formatMessage(messages.statusOff)}
694700
</div>
695701
</div>
696-
*/}
702+
}
697703
</div>
698704
<div>
699705
{getSectionRow(
@@ -778,7 +784,7 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
778784
};
779785

780786
checkTime = () => {
781-
// this.props.onForceCheckLocalTimeDifference();
787+
this.props.onForceCheckNetworkClock();
782788
this.restoreDialogCloseOnEscKey();
783789
};
784790

source/renderer/app/components/status/DaedalusDiagnostics.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,9 @@
304304
}
305305
}
306306

307-
.layoutData.localTimeDifferenceItem {
307+
.layoutData.localTimeDifference {
308308
align-items: center;
309309
display: flex;
310-
311-
button {
312-
padding-top: 0;
313-
}
314310
}
315311

316312
.layoutData.lastNetworkBlock,

source/renderer/app/components/wallet/WalletSendConfirmationDialog.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type Props = {
103103
onCancel: Function,
104104
onExternalLinkClick: Function,
105105
isSubmitting: boolean,
106-
isMainnet: boolean,
106+
isFlight: boolean,
107107
error: ?LocalizableError,
108108
currencyUnit: string,
109109
};
@@ -183,7 +183,7 @@ export default class WalletSendConfirmationDialog extends Component<Props> {
183183
totalAmount,
184184
transactionFee,
185185
isSubmitting,
186-
isMainnet,
186+
isFlight,
187187
error,
188188
currencyUnit,
189189
onExternalLinkClick,
@@ -206,7 +206,7 @@ export default class WalletSendConfirmationDialog extends Component<Props> {
206206
className: confirmButtonClasses,
207207
disabled:
208208
!passphraseField.isValid ||
209-
(!flightCandidateCheckboxField.value && isMainnet),
209+
(!flightCandidateCheckboxField.value && isFlight),
210210
},
211211
];
212212

@@ -290,7 +290,7 @@ export default class WalletSendConfirmationDialog extends Component<Props> {
290290
/>
291291
</div>
292292

293-
{isMainnet && (
293+
{isFlight && (
294294
<div className={styles.flightCandidateWarning}>
295295
<FormattedHTMLMessage
296296
{...messages.flightCandidateWarning}

0 commit comments

Comments
 (0)