-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathdiscoveryThunks.ts
757 lines (658 loc) · 25.6 KB
/
discoveryThunks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
import { A, G, pipe } from '@mobily/ts-belt';
import { getWeakRandomId, isArrayMember } from '@trezor/utils';
import { createThunk } from '@suite-common/redux-utils';
import {
accountsActions,
DISCOVERY_MODULE_PREFIX,
selectDeviceDiscovery,
updateDiscovery,
createDiscovery,
removeDiscovery,
getAvailableCardanoDerivationsThunk,
selectDeviceAccountByDescriptorAndNetworkSymbol,
selectDevice,
LIMIT,
selectDeviceAccountsForNetworkSymbolAndAccountType,
disableAccountsThunk,
selectFirstNormalAccountForNetworkSymbol,
selectHasDeviceDiscovery,
filterUnavailableAccountTypes,
selectDeviceStaticSessionId,
selectDeviceByStaticSessionId,
} from '@suite-common/wallet-core';
import { selectIsAccountAlreadyDiscovered } from '@suite-native/accounts';
import TrezorConnect, { StaticSessionId } from '@trezor/connect';
import { Account, DiscoveryItem } from '@suite-common/wallet-types';
import {
getDerivationType,
substituteBip43Path,
tryGetAccountIdentity,
} from '@suite-common/wallet-utils';
import {
AccountType,
Network,
NetworkSymbol,
getNetwork,
getNetworkType,
NetworkAccount,
normalizeNetworkAccounts,
} from '@suite-common/wallet-config';
import { DiscoveryStatus } from '@suite-common/wallet-constants';
import { requestDeviceAccess } from '@suite-native/device-mutex';
import { analytics, EventType } from '@suite-native/analytics';
import {
selectDiscoveryInfo,
selectDeviceEnabledDiscoveryNetworkSymbols,
setDiscoveryInfo,
} from './discoveryConfigSlice';
import {
selectCanRunDiscoveryForDevice,
selectDiscoveryAccountsAnalytics,
selectNetworksWithUnfinishedDiscovery,
selectShouldRunDiscoveryForDevice,
} from './discoverySelectors';
const DISCOVERY_DEFAULT_BATCH_SIZE = 2;
const DISCOVERY_BATCH_SIZE_PER_COIN: Partial<Record<NetworkSymbol, number>> = {
bch: 1,
dash: 1,
btg: 1,
dgb: 1,
nmc: 1,
vtc: 1,
zec: 1,
etc: 1,
};
export const discoveryErrors = {
accountNotFound: 'discovery-no-account',
descriptorsNotFound: 'discovery-no-descriptors',
accountLimitReached: 'discovery-account-limit',
};
const getBatchSizeByCoin = (coin: NetworkSymbol): number => {
if (coin in DISCOVERY_BATCH_SIZE_PER_COIN) {
return DISCOVERY_BATCH_SIZE_PER_COIN[coin]!;
}
return DISCOVERY_DEFAULT_BATCH_SIZE;
};
type DiscoveryDescriptorItem = DiscoveryItem & { descriptor: string };
const fetchBundleDescriptorsThunk = createThunk<
DiscoveryDescriptorItem[],
DiscoveryItem[],
{ rejectValue: string }
>(
`${DISCOVERY_MODULE_PREFIX}/fetchBundleDescriptorsThunk`,
async (bundle, { getState, rejectWithValue, fulfillWithValue }) => {
const device = selectDevice(getState());
const result = await TrezorConnect.getAccountDescriptor({
bundle,
skipFinalReload: true,
device,
useEmptyPassphrase: device?.useEmptyPassphrase,
});
if (!result.success) {
return rejectWithValue(result.payload.error);
}
if (result.success && result.payload) {
return fulfillWithValue(
pipe(
result.payload ?? [],
A.filter(G.isNotNullable),
A.map(bundleItem => bundleItem.descriptor),
A.zipWith(bundle, (descriptor, bundleItem) => ({ ...bundleItem, descriptor })),
) as DiscoveryDescriptorItem[],
);
}
return rejectWithValue(discoveryErrors.descriptorsNotFound);
},
);
const finishNetworkTypeDiscoveryThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/finishNetworkTypeDiscoveryThunk`,
(_, { dispatch, getState }) => {
const discovery = selectDeviceDiscovery(getState());
if (!discovery) {
return;
}
const finishedNetworksCount = discovery.loaded + 1;
dispatch(
updateDiscovery({
...discovery,
loaded: finishedNetworksCount,
}),
);
if (finishedNetworksCount >= discovery.total) {
dispatch(removeDiscovery(discovery.deviceState));
// Id used to group multiple analytic events of a single discovery run together.
const discoveryId = getWeakRandomId(10);
const discoveryAccountsAnalytics = selectDiscoveryAccountsAnalytics(
getState(),
discovery.deviceState,
);
// Keboola analytics data backend is unable to parse nested objects, so each network has to be reported separately.
Object.entries(discoveryAccountsAnalytics).forEach(
([networkSymbol, networkAnalyticsPayload]) => {
analytics.report({
type: EventType.CoinDiscovery,
payload: {
discoveryId,
symbol: networkSymbol as NetworkSymbol,
...networkAnalyticsPayload,
},
});
},
);
const discoveryInfo = selectDiscoveryInfo(getState());
// Discovery analytics duration tracking
if (discoveryInfo !== null) {
const endTime = performance.now();
const duration = endTime - discoveryInfo.startTimestamp;
analytics.report({
type: EventType.DiscoveryDuration,
payload: {
discoveryId,
loadDuration: duration,
networkSymbols: discoveryInfo.networkSymbols,
},
});
dispatch(setDiscoveryInfo(null));
}
}
},
);
const getAccountInfoDetailsLevel = (coin: NetworkSymbol) => {
const networkType = getNetworkType(coin);
// For Cardano we need to fetch at least one tx otherwise it will not generate correctly new receive addresses (xpub instead of address)
if (networkType === 'cardano') return { details: 'txs', pageSize: 1 } as const;
// CAUTION: the detail level has to be set to "tokenBalances" or higher. In other case we won't get account receive addresses from the backend.
return { details: 'tokenBalances' } as const;
};
const getCardanoSupportedAccountTypesThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/getCardanoSupportedAccountTypesThunk`,
async (
{
deviceState,
}: {
deviceState: StaticSessionId;
},
{ dispatch, getState },
) => {
const device = selectDeviceByStaticSessionId(getState(), deviceState);
if (!device) {
return undefined;
}
const availableCardanoDerivationsResponse = await requestDeviceAccess({
deviceCallback: () =>
dispatch(
getAvailableCardanoDerivationsThunk({
deviceState,
}),
).unwrap(),
});
if (availableCardanoDerivationsResponse.success) {
return availableCardanoDerivationsResponse.payload;
}
},
);
export const addAccountByDescriptorThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/addAccountByDescriptorThunk`,
async (
{
deviceState,
bundleItem,
identity,
}: {
deviceState: StaticSessionId;
bundleItem: DiscoveryDescriptorItem;
identity?: string;
},
{ dispatch, getState },
) => {
const device = selectDevice(getState());
const { success, payload: accountInfo } = await TrezorConnect.getAccountInfo({
coin: bundleItem.coin,
identity,
device,
descriptor: bundleItem.descriptor,
useEmptyPassphrase: device?.useEmptyPassphrase,
skipFinalReload: true,
...getAccountInfoDetailsLevel(bundleItem.coin),
});
const accounts = selectDeviceAccountsForNetworkSymbolAndAccountType(
getState(),
bundleItem.coin,
bundleItem.accountType,
);
const hasEmptyAccount = accounts.some(account => account.empty);
if (success) {
dispatch(
accountsActions.createIndexLabeledAccount({
discoveryItem: bundleItem,
deviceState,
accountInfo,
// In most cases, there should be already empty account, because this thunk is called after
// changing visibility of first empty hidden account.
// But if there is no empty account (discovery previously failed), we should show this one.
// And because of async calls, we check for empty account here and not passing the value from the previous step.
visible: !hasEmptyAccount,
}),
);
analytics.report({
type: EventType.CoinDiscoveryNewAccount,
payload: {
symbol: bundleItem.coin,
path: bundleItem.path,
type: bundleItem.accountType,
},
});
}
},
);
const discoverAccountsByDescriptorThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/discoverAccountsByDescriptorThunk`,
async (
{
descriptorsBundle,
deviceState,
identity,
}: {
descriptorsBundle: DiscoveryDescriptorItem[];
deviceState: StaticSessionId;
identity?: string;
},
{ dispatch, getState },
) => {
let isFinalRound = false;
if (A.isEmpty(descriptorsBundle)) {
isFinalRound = true;
}
const device = selectDevice(getState());
for (const bundleItem of descriptorsBundle) {
const { success, payload: accountInfo } = await TrezorConnect.getAccountInfo({
coin: bundleItem.coin,
identity,
descriptor: bundleItem.descriptor,
device,
useEmptyPassphrase: device?.useEmptyPassphrase,
skipFinalReload: true,
...getAccountInfoDetailsLevel(bundleItem.coin),
});
const isAccountAlreadyDiscovered = selectIsAccountAlreadyDiscovered(getState(), {
deviceState,
networkSymbol: bundleItem.coin,
path: bundleItem.path,
});
if (success && !isAccountAlreadyDiscovered) {
if (accountInfo.empty) {
isFinalRound = true;
}
const isVisible =
// If the account is not empty, it should be visible.
!accountInfo.empty ||
// first normal account should be visible every time
(bundleItem.accountType === 'normal' && bundleItem.index === 0);
dispatch(
accountsActions.createIndexLabeledAccount({
discoveryItem: bundleItem,
deviceState,
accountInfo,
visible: isVisible,
}),
);
}
}
return isFinalRound;
},
);
export const addAndDiscoverNetworkAccountThunk = createThunk<
Account,
{
accountType: AccountType;
network: Network;
deviceState: StaticSessionId;
},
{ rejectValue: string }
>(
`${DISCOVERY_MODULE_PREFIX}/addAndDiscoverNetworkAccountThunk`,
async (
{ accountType, network, deviceState },
{ dispatch, getState, rejectWithValue, fulfillWithValue },
) => {
const accounts = selectDeviceAccountsForNetworkSymbolAndAccountType(
getState(),
network.symbol,
accountType,
);
const index = accounts.length;
if (index > LIMIT) {
return rejectWithValue(discoveryErrors.accountLimitReached);
}
const accountPath = substituteBip43Path(network.bip43Path, index);
// Take exclusive access to the device and hold it until fetching of the descriptors is done.
const deviceAccessResponse = await requestDeviceAccess({
deviceCallback: async () =>
await dispatch(
fetchBundleDescriptorsThunk([
{
path: accountPath,
coin: network.symbol,
index,
accountType,
networkType: network.networkType,
derivationType: getDerivationType(accountType),
suppressBackupWarning: true,
skipFinalReload: true,
},
]),
).unwrap(),
});
if (!deviceAccessResponse.success) {
return rejectWithValue(deviceAccessResponse.error);
}
if (deviceAccessResponse.payload.length < 1) {
return rejectWithValue(discoveryErrors.accountNotFound);
}
const descriptor = deviceAccessResponse.payload[0];
const identity = tryGetAccountIdentity({
deviceState,
networkType: network.networkType,
});
await dispatch(
addAccountByDescriptorThunk({
bundleItem: descriptor,
deviceState,
identity,
}),
).unwrap();
const account = selectDeviceAccountByDescriptorAndNetworkSymbol(
getState(),
descriptor.descriptor,
network.symbol,
);
if (!account) {
return rejectWithValue(discoveryErrors.accountNotFound);
}
return fulfillWithValue(account);
},
);
const discoverNetworkBatchThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/discoverNetworkBatchThunk`,
async (
{
deviceState,
round = 1,
network,
accountType,
}: {
deviceState: StaticSessionId;
round?: number;
network: Network;
accountType: AccountType;
},
{ dispatch, getState },
) => {
const discovery = selectDeviceDiscovery(getState());
const batchSize = getBatchSizeByCoin(network.symbol);
// expected to be found, because this thunk is called with accountType taken from the network
const normalizedNetworkAccount = normalizeNetworkAccounts(network).find(
a => a.accountType === accountType,
);
if (!discovery || !deviceState || !normalizedNetworkAccount) {
return;
}
const lastDiscoveredAccountIndex = (round - 1) * batchSize;
const chunkBundle: Array<DiscoveryItem> = [];
A.makeWithIndex(batchSize, batchIndex => {
const isEvmLedgerDerivationPath =
network.networkType === 'ethereum' && accountType === 'ledger';
// first Ledger derivation path for EVM networks is the same as trezor, so we need to skip it (consistent with desktop)
const index =
lastDiscoveredAccountIndex + batchIndex + (isEvmLedgerDerivationPath ? 1 : 0);
const { bip43Path } = normalizedNetworkAccount;
const accountPath = substituteBip43Path(bip43Path, index);
const isAccountAlreadyDiscovered = selectIsAccountAlreadyDiscovered(getState(), {
deviceState,
networkSymbol: network.symbol,
path: accountPath,
});
if (!isAccountAlreadyDiscovered) {
chunkBundle.push({
path: accountPath,
coin: network.symbol,
index,
accountType,
networkType: network.networkType,
derivationType: getDerivationType(accountType),
suppressBackupWarning: true,
skipFinalReload: true,
});
}
});
// All accounts of the batch were already discovered, skip it.
if (A.isEmpty(chunkBundle)) {
dispatch(
discoverNetworkBatchThunk({
deviceState,
network,
accountType,
round: round + 1,
}),
);
return;
}
// Take exclusive access to the device and hold it until is the fetching of the descriptors done.
const deviceAccessResponse = await requestDeviceAccess({
deviceCallback: () => dispatch(fetchBundleDescriptorsThunk(chunkBundle)).unwrap(),
});
if (!deviceAccessResponse.success) {
return;
}
const identity = tryGetAccountIdentity({
deviceState,
networkType: network.networkType,
});
const isFinished = await dispatch(
discoverAccountsByDescriptorThunk({
descriptorsBundle: deviceAccessResponse.payload,
deviceState,
identity,
}),
).unwrap();
if (!isFinished) {
dispatch(
discoverNetworkBatchThunk({
deviceState,
network,
accountType,
round: round + 1,
}),
);
} else {
dispatch(finishNetworkTypeDiscoveryThunk());
}
},
);
export const createDescriptorPreloadedDiscoveryThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/createDescriptorPreloadedDiscoveryThunk`,
(
{
deviceState,
networks,
availableCardanoDerivations,
}: {
deviceState: StaticSessionId;
networks: readonly Network[];
availableCardanoDerivations: ('normal' | 'legacy' | 'ledger')[] | undefined;
},
{ dispatch, getState },
) => {
const device = selectDeviceByStaticSessionId(getState(), deviceState);
if (!device) {
return;
}
const hasDiscovery = selectHasDeviceDiscovery(getState());
if (hasDiscovery) {
console.warn(
`Warning discovery for device ${deviceState} already exists. Skipping discovery.`,
);
return;
}
const discoveryNetworksTotalCount = networks.reduce((count, network) => {
const availableAccountTypes = filterUnavailableAccountTypes(network, device).filter(
({ accountType }) =>
// Some cardano derivation may not be supported by the device. We need to exclude them from total count.
network.networkType !== 'cardano' ||
(availableCardanoDerivations !== undefined &&
isArrayMember(accountType, availableCardanoDerivations)),
);
return count + availableAccountTypes.length;
}, 0);
if (discoveryNetworksTotalCount < 1) {
return;
}
const networksSymbols = networks.map(network => network.symbol);
dispatch(
createDiscovery({
deviceState,
authConfirm: false,
index: 0,
status: DiscoveryStatus.RUNNING,
total: discoveryNetworksTotalCount,
bundleSize: 0,
loaded: 0,
failed: [],
availableCardanoDerivations,
networks: networksSymbols,
}),
);
},
);
// runs only for networks with unfinished discovery based on current accounts
export const startDescriptorPreloadedDiscoveryThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/startDescriptorPreloadedDiscoveryThunk`,
async (
{
forcedAreTestnetsEnabled,
forcedDeviceState, // device state can be pushed from outside (e.g. in middleware when fetched from action)
}: { forcedAreTestnetsEnabled?: boolean; forcedDeviceState?: StaticSessionId },
{ dispatch, getState },
) => {
const deviceState = forcedDeviceState ?? selectDeviceStaticSessionId(getState());
if (!deviceState) {
console.warn(
`Warning: deviceState has not been provided nor found. Skipping discovery.`,
);
return;
}
const device = selectDeviceByStaticSessionId(getState(), deviceState);
const hasDiscovery1 = selectHasDeviceDiscovery(getState());
if (hasDiscovery1) {
console.warn(
`Warning: discovery for device ${deviceState} already exists. Skipping discovery.`,
);
return;
}
if (!device) {
console.warn(`Warning: no device found. Skipping discovery.`);
return;
}
const enabledNetworks = selectDeviceEnabledDiscoveryNetworkSymbols(getState());
let availableCardanoDerivations: ('normal' | 'legacy' | 'ledger')[] = [];
if (
enabledNetworks.some(
networkSymbol => getNetwork(networkSymbol).networkType === 'cardano',
)
) {
availableCardanoDerivations =
(await dispatch(
getCardanoSupportedAccountTypesThunk({
deviceState,
}),
).unwrap()) ?? [];
}
const networksWithUnfinishedDiscovery = selectNetworksWithUnfinishedDiscovery(
getState(),
forcedAreTestnetsEnabled,
availableCardanoDerivations,
);
// Start tracking duration and networks for analytics purposes
dispatch(
setDiscoveryInfo({
startTimestamp: performance.now(),
networkSymbols: networksWithUnfinishedDiscovery.map(n => n.symbol),
}),
);
// Some cardano derivation are not supported by the device. We need to filter them out.
// filter out cardano-type networks, if none of their derivations are available
const networksFiltered = networksWithUnfinishedDiscovery.filter(
network =>
network.networkType !== 'cardano' ||
normalizeNetworkAccounts(network).some(({ accountType }) =>
isArrayMember(accountType, availableCardanoDerivations),
),
);
await dispatch(
createDescriptorPreloadedDiscoveryThunk({
deviceState,
networks: networksFiltered,
availableCardanoDerivations,
}),
);
// We need to check again here because it's possible that things changed in the meantime because async thunks
const hasDiscovery2 = selectHasDeviceDiscovery(getState());
if (!hasDiscovery2) {
return;
}
// Start discovery for every network - normal accounts as well as alternative accounts
networksFiltered.forEach(network => {
filterUnavailableAccountTypes(network)
// with Cardano, we only get here if there are at least some accountTypes available, so discover those ones.
.filter(
({ accountType }: NetworkAccount) =>
network.networkType !== 'cardano' ||
isArrayMember(accountType, availableCardanoDerivations),
)
.forEach(({ accountType }: NetworkAccount) => {
dispatch(discoverNetworkBatchThunk({ deviceState, network, accountType }));
});
});
},
);
// idempotent - can be run any time and checks if it SHOULD and CAN run discovery
// then startDescriptorPreloadedDiscoveryThunk runs discovery only for relevant networks
export const discoveryCheckThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/discoveryCheckThunk`,
async (
_,
{ dispatch, getState },
// eslint-disable-next-line require-await
) => {
// check whether we consider some network not to be fully discovered
const shouldRunDiscoveryForDevice = selectShouldRunDiscoveryForDevice(getState());
// check whether we are allowed to run the discovery now
const canRunDiscoveryForDevice = selectCanRunDiscoveryForDevice(getState());
if (canRunDiscoveryForDevice && shouldRunDiscoveryForDevice) {
dispatch(startDescriptorPreloadedDiscoveryThunk({}));
}
},
);
// Called when there are changes in enabled/disabled networks
// It removes accounts for disabled networks and checks whether to start discovery and start if needed
export const applyDiscoveryChangesThunk = createThunk(
`${DISCOVERY_MODULE_PREFIX}/applyDiscoveryChangesThunk`,
(_, { dispatch, getState }) => {
// Make sure that first normal account is visible for enabled networks
// This might be needed in case user has View only device from before coin enabling was active
// in such case the first normal account can be invisible. We need to make it visible.
const enabledDiscoveryNetworkSymbols =
selectDeviceEnabledDiscoveryNetworkSymbols(getState());
enabledDiscoveryNetworkSymbols.forEach(networkSymbol => {
const firstNormalAccount = selectFirstNormalAccountForNetworkSymbol(
getState(),
networkSymbol,
);
if (firstNormalAccount && !firstNormalAccount.visible) {
dispatch(accountsActions.changeAccountVisibility(firstNormalAccount, true));
}
});
dispatch(disableAccountsThunk());
dispatch(discoveryCheckThunk());
},
);