Skip to content

Commit

Permalink
fixup! refactor(suite): remove redundant comment
Browse files Browse the repository at this point in the history
  • Loading branch information
juriczech committed May 20, 2024
1 parent 8913fb0 commit 5873524
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 70 deletions.
22 changes: 11 additions & 11 deletions packages/suite/src/actions/suite/__fixtures__/suiteActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testMocks } from '@suite-common/test-utils';
import { discoveryActions, deviceActions, authorizeDevice } from '@suite-common/wallet-core';
import { discoveryActions, deviceActions, authorizeDeviceThunk } from '@suite-common/wallet-core';
import { DEVICE, TRANSPORT } from '@trezor/connect';
import { notificationsActions } from '@suite-common/toast-notifications';

Expand Down Expand Up @@ -768,14 +768,14 @@ const authorizeDeviceActions = [
{
description: `without device`,
state: {},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `with disconnected device`,
state: {
selectedDevice: getSuiteDevice(),
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `with unacquired device`,
Expand All @@ -785,7 +785,7 @@ const authorizeDeviceActions = [
connected: true,
}),
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `with device which already has state`,
Expand All @@ -795,7 +795,7 @@ const authorizeDeviceActions = [
state: '012345',
}),
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `with device in unexpected mode`,
Expand All @@ -805,7 +805,7 @@ const authorizeDeviceActions = [
mode: 'bootloader',
}),
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `with device which needs FW update`,
Expand All @@ -815,7 +815,7 @@ const authorizeDeviceActions = [
firmware: 'required',
}),
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
{
description: `success`,
Expand All @@ -824,7 +824,7 @@ const authorizeDeviceActions = [
connected: true,
}),
},
result: authorizeDevice.fulfilled.type,
result: authorizeDeviceThunk.fulfilled.type,
},
{
description: `duplicate detected`,
Expand All @@ -849,7 +849,7 @@ const authorizeDeviceActions = [
state: undefined,
}),
],
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
deviceReducerResult: [
getSuiteDevice({
connected: true,
Expand Down Expand Up @@ -891,7 +891,7 @@ const authorizeDeviceActions = [
state: undefined,
}),
],
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
deviceReducerResult: [
getSuiteDevice({
connected: true,
Expand Down Expand Up @@ -920,7 +920,7 @@ const authorizeDeviceActions = [
error: 'getDeviceState error',
},
},
result: authorizeDevice.rejected.type,
result: authorizeDeviceThunk.rejected.type,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
deviceActions,
acquireDevice,
authConfirm,
authorizeDevice,
authorizeDeviceThunk,
createDeviceInstance,
forgetDisconnectedDevices,
handleDeviceConnect,
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('Suite Actions', () => {
devices: f.devicesState ?? [],
});
const store = initStore(state);
await store.dispatch(authorizeDevice());
await store.dispatch(authorizeDeviceThunk());
if (!f.result) {
expect(filterThunkActionTypes(store.getActions()).length).toEqual(0);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components';

import { authorizeDevice, switchDuplicatedDevice } from '@suite-common/wallet-core';
import { authorizeDeviceThunk, switchDuplicatedDevice } from '@suite-common/wallet-core';
import { Button, Image } from '@trezor/components';

import { Translation, Modal } from 'src/components/suite';
Expand All @@ -23,7 +23,7 @@ export const PassphraseDuplicateModal = ({ device, duplicate }: PassphraseDuplic
const isDeviceLocked = isLocked();

const handleSwitchDevice = () => dispatch(switchDuplicatedDevice({ device, duplicate }));
const handleAuthorizeDevice = () => dispatch(authorizeDevice());
const handleAuthorizeDevice = () => dispatch(authorizeDeviceThunk());

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { authorizeDevice } from '@suite-common/wallet-core';
import { authorizeDeviceThunk } from '@suite-common/wallet-core';

import { useDevice, useDispatch } from 'src/hooks/suite';
import { Translation } from 'src/components/suite';
Expand All @@ -8,7 +8,7 @@ export const AuthFailed = () => {
const dispatch = useDispatch();
const { isLocked } = useDevice();

const handleClick = () => dispatch(authorizeDevice());
const handleClick = () => dispatch(authorizeDeviceThunk());

return (
<AccountExceptionLayout
Expand Down
5 changes: 2 additions & 3 deletions packages/suite/src/middlewares/suite/analyticsMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
discoveryActions,
selectDevices,
selectDevicesCount,
authorizeDevice,
authorizeDeviceThunk,
} from '@suite-common/wallet-core';
import { analytics, EventType } from '@trezor/suite-analytics';
import { TRANSPORT, DEVICE } from '@trezor/connect';
Expand All @@ -33,7 +33,6 @@ import {
} from 'src/reducers/wallet/coinjoinReducer';
import { updateLastAnonymityReportTimestamp } from 'src/actions/wallet/coinjoinAccountActions';
import { Account } from '@suite-common/wallet-types';
import { isAnyOf } from '@reduxjs/toolkit';

/*
In analytics middleware we may intercept actions we would like to log. For example:
Expand All @@ -50,7 +49,7 @@ const analyticsMiddleware =

const state = api.getState();

if (authorizeDevice.fulfilled.match(action)) {
if (authorizeDeviceThunk.fulfilled.match(action)) {
analytics.report({
type: EventType.SelectWalletType,
payload: { type: action.payload.device.walletNumber ? 'hidden' : 'standard' },
Expand Down
5 changes: 2 additions & 3 deletions packages/suite/src/middlewares/suite/eventsMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
selectDevice,
accountsActions,
deviceActions,
authorizeDevice,
authorizeDeviceThunk,
} from '@suite-common/wallet-core';
import * as deviceUtils from '@suite-common/suite-utils';
import { DEVICE } from '@trezor/connect';
Expand All @@ -17,7 +17,6 @@ import {

import { SUITE } from 'src/actions/suite/constants';
import { AppState, Action, Dispatch } from 'src/types/suite';
import { isAnyOf } from '@reduxjs/toolkit';

/*
* Middleware for event notifications.
Expand Down Expand Up @@ -109,7 +108,7 @@ const eventsMiddleware =
});
}

if (authorizeDevice.fulfilled.match(action)) {
if (authorizeDeviceThunk.fulfilled.match(action)) {
api.dispatch(notificationsActions.addEvent({ type: AUTH_DEVICE, seen: true }));
}

Expand Down
7 changes: 3 additions & 4 deletions packages/suite/src/middlewares/suite/logsMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { MiddlewareAPI } from 'redux';
import { isAnyOf } from '@reduxjs/toolkit';
import { authorizeDevice, deviceActions, discoveryActions } from '@suite-common/wallet-core';
import { authorizeDeviceThunk, deviceActions, discoveryActions } from '@suite-common/wallet-core';
import { addLog } from '@suite-common/logger';
import { TRANSPORT, DEVICE } from '@trezor/connect';
import { redactUserPathFromString } from '@trezor/utils';
Expand Down Expand Up @@ -48,10 +47,10 @@ const log =
}
}

if (authorizeDevice.fulfilled.match(action)) {
if (authorizeDeviceThunk.fulfilled.match(action)) {
api.dispatch(
addLog({
type: 'authorizeDevice.fulfilled',
type: 'authorizeDeviceThunk.fulfilled',
payload: {
device: action.payload.device,
firmwareRelease: undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/suite/src/middlewares/suite/sentryMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
blockchainActions,
selectDevice,
deviceActions,
authorizeDevice,
authorizeDeviceThunk,
} from '@suite-common/wallet-core';
import {
getBootloaderVersion,
Expand Down Expand Up @@ -56,7 +56,7 @@ const breadcrumbActions = [
DESKTOP_UPDATE.NOT_AVAILABLE,
DESKTOP_UPDATE.READY,
MODAL.CLOSE,
authorizeDevice.fulfilled.type,
authorizeDeviceThunk.fulfilled.type,
DEVICE.CONNECT,
DEVICE.DISCONNECT,
accountsActions.createAccount.type,
Expand Down
6 changes: 3 additions & 3 deletions packages/suite/src/middlewares/suite/suiteMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AnyAction, isAnyOf } from '@reduxjs/toolkit';

import {
authConfirm,
authorizeDevice,
authorizeDeviceThunk,
deviceActions,
forgetDisconnectedDevices,
handleDeviceConnect,
Expand All @@ -22,8 +22,8 @@ import { appChanged, setFlag } from 'src/actions/suite/suiteActions';
const isActionDeviceRelated = (action: AnyAction): boolean => {
if (
isAnyOf(
authorizeDevice.fulfilled,
authorizeDevice.rejected,
authorizeDeviceThunk.fulfilled,
authorizeDeviceThunk.rejected,
deviceActions.selectDevice,
deviceActions.receiveAuthConfirm,
deviceActions.updatePassphraseMode,
Expand Down
9 changes: 4 additions & 5 deletions packages/suite/src/middlewares/wallet/discoveryMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
authorizeDevice,
authorizeDeviceThunk,
deviceActions,
selectDevice,
selectDeviceDiscovery,
Expand All @@ -10,7 +10,6 @@ import {
stopDiscoveryThunk,
updateNetworkSettingsThunk,
} from '@suite-common/wallet-core';
import { isAnyOf } from '@reduxjs/toolkit';
import * as discoveryActions from '@suite-common/wallet-core';
import { UI } from '@trezor/connect';
import { DiscoveryStatus } from '@suite-common/wallet-constants';
Expand Down Expand Up @@ -107,11 +106,11 @@ export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps(

// 3. begin auth process
if (authorizationIntent) {
dispatch(authorizeDevice());
dispatch(authorizeDeviceThunk());
}

// 4. device state received
if (authorizeDevice.fulfilled.match(action)) {
if (authorizeDeviceThunk.fulfilled.match(action)) {
// `device` is always present here
// to avoid typescript conditioning use device from action as a fallback (never used)
dispatch(
Expand Down Expand Up @@ -139,7 +138,7 @@ export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps(
becomesConnected ||
action.type === SUITE.APP_CHANGED ||
deviceActions.selectDevice.match(action) ||
authorizeDevice.fulfilled.match(action) ||
authorizeDeviceThunk.fulfilled.match(action) ||
walletSettingsActions.changeNetworks.match(action) ||
accountsActions.changeAccountVisibility.match(action)
) {
Expand Down
12 changes: 6 additions & 6 deletions packages/suite/src/reducers/suite/__fixtures__/deviceReducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testMocks } from '@suite-common/test-utils';
import { authorizeDevice, deviceActions } from '@suite-common/wallet-core';
import { authorizeDeviceThunk, deviceActions } from '@suite-common/wallet-core';
import { DEVICE } from '@trezor/connect';

const { getConnectDevice, getSuiteDevice } = testMocks;
Expand Down Expand Up @@ -850,7 +850,7 @@ const authDevice = [
initialState: { devices: [SUITE_DEVICE] },
actions: [
{
type: authorizeDevice.fulfilled.type,
type: authorizeDeviceThunk.fulfilled.type,
payload: {
device: SUITE_DEVICE,
state: 'A',
Expand All @@ -875,7 +875,7 @@ const authDevice = [
},
actions: [
{
type: authorizeDevice.fulfilled.type,
type: authorizeDeviceThunk.fulfilled.type,
payload: {
device: SUITE_DEVICE,
state: 'A',
Expand Down Expand Up @@ -904,7 +904,7 @@ const authDevice = [
},
actions: [
{
type: authorizeDevice.fulfilled.type,
type: authorizeDeviceThunk.fulfilled.type,
payload: {
device: getSuiteDevice({ instance: 1 }),
state: 'A',
Expand Down Expand Up @@ -933,7 +933,7 @@ const authDevice = [
initialState: { devices: [SUITE_DEVICE] },
actions: [
{
type: authorizeDevice.fulfilled.type,
type: authorizeDeviceThunk.fulfilled.type,
payload: {
device: getConnectDevice({
type: 'unacquired',
Expand All @@ -953,7 +953,7 @@ const authDevice = [
initialState: { devices: [] },
actions: [
{
type: authorizeDevice.fulfilled.type,
type: authorizeDeviceThunk.fulfilled.type,
payload: {
device: SUITE_DEVICE,
state: 'A',
Expand Down
4 changes: 2 additions & 2 deletions packages/suite/src/utils/suite/logsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
discoveryActions,
accountsActions,
selectDevices,
authorizeDevice,
authorizeDeviceThunk,
} from '@suite-common/wallet-core';
import { isAnyOf } from '@reduxjs/toolkit';
import {
Expand Down Expand Up @@ -124,7 +124,7 @@ export const redactAction = (action: LogEntry) => {
};
}

if (authorizeDevice.fulfilled.match(action)) {
if (authorizeDeviceThunk.fulfilled.match(action)) {
payload = {
state: REDACTED_REPLACEMENT,
...redactDevice(action.payload.device),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';

import {
authConfirm,
authorizeDevice,
authorizeDeviceThunk,
restartDiscoveryThunk as restartDiscovery,
} from '@suite-common/wallet-core';
import * as accountUtils from '@suite-common/wallet-utils';
Expand Down Expand Up @@ -135,7 +135,7 @@ export const Exception = ({ exception, discovery }: ExceptionProps) => {
title="TR_ACCOUNT_EXCEPTION_AUTH_ERROR"
description="TR_ACCOUNT_EXCEPTION_AUTH_ERROR_DESC"
cta={{
action: () => dispatch(authorizeDevice()),
action: () => dispatch(authorizeDeviceThunk()),
}}
dataTestBase={exception.type}
/>
Expand Down
Loading

0 comments on commit 5873524

Please sign in to comment.