1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 09:23:21 +01:00

Convert actions.js to typescript (#17446)

This commit is contained in:
Brad Decker 2023-02-03 11:56:44 -06:00 committed by GitHub
parent 769efc9fe3
commit 31897b542d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1644 additions and 885 deletions

View File

@ -1,6 +1,5 @@
{
"appState": {
"shouldClose": false,
"menuOpen": false,
"modal": {
"open": false,

View File

@ -407,6 +407,7 @@
"@types/react": "^16.9.53",
"@types/react-dom": "^17.0.11",
"@types/remote-redux-devtools": "^0.5.5",
"@types/w3c-web-hid": "^1.0.3",
"@types/watchify": "^3.11.1",
"@types/yargs": "^17.0.8",
"@typescript-eslint/eslint-plugin": "^5.30.7",

12
types/global.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
// In order for variables to be considered on the global scope they must be
// declared using var and not const or let, which is why this rule is disabled
/* eslint-disable no-var */
declare class Platform {
openTab: (opts: { url: string }) => void;
closeCurrentWindow: () => void;
}
export declare global {
var platform: Platform;
}

View File

@ -8,7 +8,7 @@ import mockState from '../../../../test/data/mock-state.json';
import GasTiming from '.';
jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
getGasFeeTimeEstimate: jest.fn().mockImplementation(() => Promise.resolve()),
}));

View File

@ -18,7 +18,7 @@ jest.mock('react-router-dom', () => {
};
});
jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
detectNewTokens: jest.fn(),
}));

View File

@ -12,7 +12,7 @@ import AccountDetailsModal from '.';
const mockShowModal = jest.fn();
jest.mock('../../../../store/actions.js', () => {
jest.mock('../../../../store/actions.ts', () => {
return {
showModal: () => mockShowModal,
};

View File

@ -14,7 +14,7 @@ const mockCreateCancelTransaction = jest.fn();
const mockShowModal = jest.fn();
const mockHideModal = jest.fn();
jest.mock('../../../../store/actions.js', () => {
jest.mock('../../../../store/actions.ts', () => {
return {
createCancelTransaction: () => mockCreateCancelTransaction,
showModal: () => mockShowModal,

View File

@ -7,7 +7,7 @@ import { renderWithProvider } from '../../../../test/lib/render-helpers';
import mockState from '../../../../test/data/mock-state.json';
import TransactionListItemDetails from '.';
jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
tryReverseResolveAddress: () => jest.fn(),
getGasFeeEstimatesAndStartPolling: jest.fn().mockResolvedValue(),
addPollingTokenToAppState: jest.fn(),

View File

@ -42,7 +42,7 @@ describe('App State', () => {
it('opens alert', () => {
const state = reduceApp(metamaskState, {
type: actions.ALERT_OPEN,
value: 'test message',
payload: 'test message',
});
expect(state.alertOpen).toStrictEqual(true);
@ -243,7 +243,7 @@ describe('App State', () => {
};
const state = reduceApp(metamaskState, {
type: actions.SET_HARDWARE_WALLET_DEFAULT_HD_PATH,
value: {
payload: {
device: HardwareDeviceNames.ledger,
path: "m/44'/60'/0'",
},
@ -255,7 +255,7 @@ describe('App State', () => {
it('shows loading message', () => {
const state = reduceApp(metamaskState, {
type: actions.SHOW_LOADING,
value: 'loading',
payload: 'loading',
});
expect(state.isLoading).toStrictEqual(true);
@ -276,7 +276,7 @@ describe('App State', () => {
it('displays warning', () => {
const state = reduceApp(metamaskState, {
type: actions.DISPLAY_WARNING,
value: 'warning',
payload: 'warning',
});
expect(state.isLoading).toStrictEqual(false);
@ -296,7 +296,7 @@ describe('App State', () => {
it('shows private key', () => {
const state = reduceApp(metamaskState, {
type: actions.SHOW_PRIVATE_KEY,
value: 'private key',
payload: 'private key',
});
expect(state.accountDetail.privateKey).toStrictEqual('private key');
@ -305,7 +305,7 @@ describe('App State', () => {
it('set mouse user state', () => {
const state = reduceApp(metamaskState, {
type: actions.SET_MOUSE_USER_STATE,
value: true,
payload: true,
});
expect(state.isMouseUser).toStrictEqual(true);

View File

@ -159,7 +159,7 @@ export default function reduceApp(
return {
...appState,
alertOpen: true,
alertMessage: action.value,
alertMessage: action.payload,
};
case actionConstants.ALERT_CLOSE:
@ -263,27 +263,10 @@ export default function reduceApp(
};
case actionConstants.COMPLETED_TX:
if (action.value.unconfirmedActionsCount > 0) {
return {
...appState,
txId: null,
warning: null,
};
}
return {
...appState,
// indicate notification should close
shouldClose: true,
warning: null,
txId: null,
accountDetail: {
subview: 'transactions',
},
};
case actionConstants.TRANSACTION_ERROR:
return {
...appState,
};
case actionConstants.UNLOCK_FAILED:
@ -299,7 +282,7 @@ export default function reduceApp(
};
case actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH: {
const { device, path } = action.value;
const { device, path } = action.payload;
const newDefaults = { ...appState.defaultHdPaths } as any;
newDefaults[device] = path;
@ -313,7 +296,7 @@ export default function reduceApp(
return {
...appState,
isLoading: true,
loadingMessage: action.value,
loadingMessage: action.payload,
};
case actionConstants.HIDE_LOADING:
@ -325,7 +308,7 @@ export default function reduceApp(
case actionConstants.DISPLAY_WARNING:
return {
...appState,
warning: action.value,
warning: action.payload,
isLoading: false,
};
@ -339,46 +322,44 @@ export default function reduceApp(
return {
...appState,
accountDetail: {
subview: 'export',
accountExport: 'completed',
privateKey: action.value,
privateKey: action.payload,
},
};
case actionConstants.SET_MOUSE_USER_STATE:
return {
...appState,
isMouseUser: action.value,
isMouseUser: action.payload,
};
case actionConstants.SET_SELECTED_SETTINGS_RPC_URL:
return {
...appState,
networksTabSelectedRpcUrl: action.value,
networksTabSelectedRpcUrl: action.payload,
};
case actionConstants.SET_NEW_NETWORK_ADDED:
return {
...appState,
newNetworkAdded: action.value,
newNetworkAdded: action.payload,
};
case actionConstants.SET_NEW_TOKENS_IMPORTED:
return {
...appState,
newTokensImported: action.value,
newTokensImported: action.payload,
};
case actionConstants.SET_NEW_COLLECTIBLE_ADDED_MESSAGE:
return {
...appState,
newCollectibleAddedMessage: action.value,
newCollectibleAddedMessage: action.payload,
};
case actionConstants.SET_REMOVE_COLLECTIBLE_MESSAGE:
return {
...appState,
removeCollectibleMessage: action.value,
removeCollectibleMessage: action.payload,
};
case actionConstants.PORTFOLIO_TOOLTIP_WAS_SHOWN_IN_THIS_SESSION:
@ -396,13 +377,7 @@ export default function reduceApp(
case actionConstants.SET_OPEN_METAMASK_TAB_IDS:
return {
...appState,
openMetaMaskTabs: action.value,
};
case actionConstants.SET_CURRENT_WINDOW_TAB:
return {
...appState,
currentWindowTab: action.value,
openMetaMaskTabs: action.payload,
};
case actionConstants.HIDE_WHATS_NEW_POPUP:

View File

@ -1,12 +1,12 @@
import * as actionConstants from '../../store/actionConstants';
export default function reduceLocaleMessages(state = {}, { type, value }) {
export default function reduceLocaleMessages(state = {}, { type, payload }) {
switch (type) {
case actionConstants.SET_CURRENT_LOCALE:
return {
...state,
current: value.messages,
currentLocale: value.locale,
current: payload.messages,
currentLocale: payload.locale,
};
default:
return state;

View File

@ -162,7 +162,7 @@ export default function reduceMetamask(state = initialState, action) {
case actionConstants.SET_NEXT_NONCE: {
return {
...metamaskState,
nextNonce: action.value,
nextNonce: action.payload,
};
}

View File

@ -571,6 +571,8 @@ export const computeEstimatedGasLimit = createAsyncThunk(
* the send slice. It returns the values that might change from this action and
* those values are written to the slice in the `initializeSendState.fulfilled`
* action handler.
*
* @type {import('@reduxjs/toolkit').AsyncThunk<any, { chainHasChanged: boolean }, {}>}
*/
export const initializeSendState = createAsyncThunk(
'send/initializeSendState',

View File

@ -2308,7 +2308,7 @@ describe('Send Slice', () => {
},
};
jest.mock('../../store/actions.js');
jest.mock('../../store/actions.ts');
const store = mockStore(tokenTransferTxState);
@ -2345,7 +2345,7 @@ describe('Send Slice', () => {
},
};
jest.mock('../../store/actions.js');
jest.mock('../../store/actions.ts');
const store = mockStore(editStageSignTxState);

View File

@ -10,7 +10,7 @@ import swapsReducer, * as swaps from './swaps';
const middleware = [thunk];
jest.mock('../../store/actions.js', () => ({
jest.mock('../../store/actions.ts', () => ({
setSwapsLiveness: jest.fn(),
setSwapsFeatureFlags: jest.fn(),
fetchSmartTransactionsLiveness: jest.fn(),

View File

@ -9,8 +9,8 @@ export default function txHelper(
decryptMsgs: Record<string, any> | null,
encryptionPublicKeyMsgs: Record<string, any> | null,
typedMessages: Record<string, any> | null,
network: string,
chainId: string,
network?: string,
chainId?: string,
): Record<string, any> {
log.debug('tx-helper called with params:');
log.debug({

View File

@ -7,7 +7,7 @@ import RevealSeedPage from './reveal-seed';
const mockRequestRevealSeedWords = jest.fn().mockResolvedValue();
jest.mock('../../store/actions.js', () => ({
jest.mock('../../store/actions.ts', () => ({
requestRevealSeedWords: () => mockRequestRevealSeedWords,
}));

View File

@ -23,7 +23,6 @@ export default class PermissionConnect extends Component {
approvePermissionsRequest: PropTypes.func.isRequired,
rejectPermissionsRequest: PropTypes.func.isRequired,
getRequestAccountTabIds: PropTypes.func.isRequired,
getCurrentWindowTab: PropTypes.func.isRequired,
accounts: PropTypes.array.isRequired,
currentAddress: PropTypes.string.isRequired,
origin: PropTypes.string,
@ -100,13 +99,11 @@ export default class PermissionConnect extends Component {
snapUpdatePath,
isSnap,
///: END:ONLY_INCLUDE_IN
getCurrentWindowTab,
getRequestAccountTabIds,
permissionsRequest,
history,
isRequestingAccounts,
} = this.props;
getCurrentWindowTab();
getRequestAccountTabIds();
if (!permissionsRequest) {

View File

@ -18,7 +18,6 @@ import {
approvePermissionsRequest,
rejectPermissionsRequest,
showModal,
getCurrentWindowTab,
getRequestAccountTabIds,
///: BEGIN:ONLY_INCLUDE_IN(flask)
resolvePendingApproval,
@ -159,7 +158,6 @@ const mapDispatchToProps = (dispatch) => {
);
},
getRequestAccountTabIds: () => dispatch(getRequestAccountTabIds()),
getCurrentWindowTab: () => dispatch(getCurrentWindowTab()),
};
};

View File

@ -22,7 +22,7 @@ jest.mock('../../../ducks/send/index.js', () => ({
resetSendState: () => mockResetSendState,
}));
jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
addToAddressBook: () => mockAddtoAddressBook,
cancelTx: () => mockCancelTx,
}));

View File

@ -9,7 +9,7 @@ import AdvancedTab from '.';
const mockSetAutoLockTimeLimit = jest.fn();
const mockSetShowTestNetworks = jest.fn();
jest.mock('../../../store/actions.js', () => {
jest.mock('../../../store/actions.ts', () => {
return {
setAutoLockTimeLimit: () => mockSetAutoLockTimeLimit,
setShowTestNetworks: () => mockSetShowTestNetworks,

View File

@ -10,7 +10,7 @@ const mockSetParticipateInMetaMetrics = jest.fn();
const mockSetUsePhishDetect = jest.fn();
const mockSetUseCurrencyRateCheck = jest.fn();
jest.mock('../../../store/actions.js', () => {
jest.mock('../../../store/actions.ts', () => {
return {
setFeatureFlag: () => mockSetFeatureFlag,
setParticipateInMetaMetrics: () => mockSetParticipateInMetaMetrics,

View File

@ -13,7 +13,7 @@ const mockSetUseNativeCurrencyAsPrimaryCurrencyPreference = jest.fn();
const mockSetUseBlockie = jest.fn();
const mockSetHideZeroBalanceTokens = jest.fn();
jest.mock('../../../store/actions.js', () => ({
jest.mock('../../../store/actions.ts', () => ({
setCurrentCurrency: () => mockSetCurrentCurrency,
updateCurrentLocale: () => mockUpdateCurrentLocale,
setUseNativeCurrencyAsPrimaryCurrencyPreference: () =>

View File

@ -7,7 +7,7 @@ import UnlockPage from '.';
const mockMarkPasswordForgotten = jest.fn();
jest.mock('../../store/actions.js', () => ({
jest.mock('../../store/actions.ts', () => ({
markPasswordForgotten: () => mockMarkPasswordForgotten,
}));

View File

@ -87,7 +87,6 @@ export const LOADING_METHOD_DATA_STARTED = 'LOADING_METHOD_DATA_STARTED';
export const LOADING_METHOD_DATA_FINISHED = 'LOADING_METHOD_DATA_FINISHED';
export const SET_REQUEST_ACCOUNT_TABS = 'SET_REQUEST_ACCOUNT_TABS';
export const SET_CURRENT_WINDOW_TAB = 'SET_CURRENT_WINDOW_TAB';
export const SET_OPEN_METAMASK_TAB_IDS = 'SET_OPEN_METAMASK_TAB_IDS';
// Home Screen

View File

@ -60,7 +60,7 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'UNLOCK_IN_PROGRESS' },
{ type: 'UNLOCK_SUCCEEDED', value: undefined },
{
@ -85,7 +85,7 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'UNLOCK_IN_PROGRESS' },
{ type: 'UNLOCK_FAILED', value: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
@ -129,7 +129,7 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{
type: 'UPDATE_METAMASK_STATE',
value: baseMockState,
@ -155,8 +155,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -201,8 +201,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -274,8 +274,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -302,7 +302,7 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'SHOW_ACCOUNTS_PAGE' },
];
@ -322,9 +322,9 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
await expect(store.dispatch(actions.resetAccount())).rejects.toThrow(
@ -370,9 +370,9 @@ describe('Actions', () => {
const expectedActions = [
{
type: 'SHOW_LOADING_INDICATION',
value: 'This may take a while, please be patient.',
payload: 'This may take a while, please be patient.',
},
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -412,8 +412,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -460,8 +460,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -497,8 +497,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -550,9 +550,9 @@ describe('Actions', () => {
const expectedActions = [
{
type: 'SHOW_LOADING_INDICATION',
value: 'Looking for your Ledger...',
payload: 'Looking for your Ledger...',
},
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -599,8 +599,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -634,8 +634,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -676,8 +676,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -722,8 +722,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -801,8 +801,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -875,7 +875,7 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{
type: 'UPDATE_TRANSACTION_PARAMS',
id: '1',
@ -888,7 +888,6 @@ describe('Actions', () => {
},
},
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'TRANSACTION_ERROR', message: 'error' },
{ type: 'GO_HOME' },
];
@ -926,8 +925,8 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'LOCK_METAMASK' },
];
@ -976,8 +975,8 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -1009,7 +1008,7 @@ describe('Actions', () => {
expect(setSelectedAddressSpy.callCount).toStrictEqual(1);
});
it('displays warning if setSelectedAddress throws', async () => {
it('displays warning if setSelectedAccount throws', async () => {
const store = mockStore({
activeTab: {},
metamask: { alertEnabledness: {}, selectedAddress: '0x123' },
@ -1026,8 +1025,8 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -1086,7 +1085,7 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{
type: 'UPDATE_METAMASK_STATE',
value: baseMockState,
@ -1140,8 +1139,8 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{
type: 'UPDATE_METAMASK_STATE',
value: baseMockState,
@ -1189,7 +1188,10 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'DISPLAY_WARNING', value: 'Had a problem changing networks!' },
{
type: 'DISPLAY_WARNING',
payload: 'Had a problem changing networks!',
},
];
await store.dispatch(actions.setProviderType());
@ -1223,7 +1225,10 @@ describe('Actions', () => {
_setBackgroundConnection(background);
const expectedActions = [
{ type: 'DISPLAY_WARNING', value: 'Had a problem changing networks!' },
{
type: 'DISPLAY_WARNING',
payload: 'Had a problem changing networks!',
},
];
await store.dispatch(actions.setRpcTarget());
@ -1275,11 +1280,11 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{
type: 'SHOW_PRIVATE_KEY',
value: testPrivKey,
payload: testPrivKey,
},
];
@ -1305,9 +1310,9 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'Incorrect Password.' },
{ type: 'DISPLAY_WARNING', payload: 'Incorrect Password.' },
];
await expect(
@ -1334,11 +1339,11 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{
type: 'DISPLAY_WARNING',
value: 'Had a problem exporting the account.',
payload: 'Had a problem exporting the account.',
},
];
@ -1387,9 +1392,9 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
await expect(
@ -1437,9 +1442,9 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
await expect(store.dispatch(actions.setFeatureFlag())).rejects.toThrow(
@ -1481,8 +1486,8 @@ describe('Actions', () => {
_setBackgroundConnection(background.getApi());
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -1517,9 +1522,9 @@ describe('Actions', () => {
_setBackgroundConnection({ setUseBlockie: setUseBlockieStub });
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
await store.dispatch(actions.setUseBlockie());
@ -1554,9 +1559,9 @@ describe('Actions', () => {
});
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
store.dispatch(actions.setUsePhishDetect());
@ -1595,9 +1600,9 @@ describe('Actions', () => {
});
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'HIDE_LOADING_INDICATION' },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'DISPLAY_WARNING', payload: 'error' },
];
store.dispatch(actions.setUseMultiAccountBalanceChecker());
@ -1624,10 +1629,10 @@ describe('Actions', () => {
});
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{
type: 'SET_CURRENT_LOCALE',
value: { locale: 'test', messages: enLocale },
payload: { locale: 'test', messages: enLocale },
},
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -1647,8 +1652,8 @@ describe('Actions', () => {
});
const expectedActions = [
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
{ type: 'DISPLAY_WARNING', value: 'error' },
{ type: 'SHOW_LOADING_INDICATION', payload: undefined },
{ type: 'DISPLAY_WARNING', payload: 'error' },
{ type: 'HIDE_LOADING_INDICATION' },
];
@ -1726,7 +1731,7 @@ describe('Actions', () => {
expect(resultantActions[0]).toStrictEqual({
type: 'DISPLAY_WARNING',
value: warningText,
payload: warningText,
});
});
});
@ -1819,12 +1824,13 @@ describe('Actions', () => {
await store.dispatch(actions.cancelMsgs(msgsList));
const resultantActions = store.getActions();
console.log(resultantActions);
const expectedActions = resultantActions.filter(
(action) => action.type === 'COMPLETED_TX',
);
expect(expectedActions[0].value.id).toStrictEqual(msgsList[0]);
expect(expectedActions[1].value.id).toStrictEqual(msgsList[1]);
expect(expectedActions[0].value.id).toStrictEqual(msgsList[0].id);
expect(expectedActions[1].value.id).toStrictEqual(msgsList[1].id);
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -7567,6 +7567,13 @@ __metadata:
languageName: node
linkType: hard
"@types/w3c-web-hid@npm:^1.0.3":
version: 1.0.3
resolution: "@types/w3c-web-hid@npm:1.0.3"
checksum: 90ee1eeb2acf5d5ddf0b7acefd4f8aaa7d0175d991c3606a9ad62bdfa7a8de93665f5f6218dc4ecb34ea1d2f3e357813b315f46c1ea6b8aa1693e217e436c9b2
languageName: node
linkType: hard
"@types/wait-on@npm:^5.2.0":
version: 5.3.1
resolution: "@types/wait-on@npm:5.3.1"
@ -24143,6 +24150,7 @@ __metadata:
"@types/react": ^16.9.53
"@types/react-dom": ^17.0.11
"@types/remote-redux-devtools": ^0.5.5
"@types/w3c-web-hid": ^1.0.3
"@types/watchify": ^3.11.1
"@types/yargs": ^17.0.8
"@typescript-eslint/eslint-plugin": ^5.30.7