mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 05:55:03 +01:00
Removes the UI constant that was a merge of UI_REQUEST and UI_RESPONSE. Updates all 70 files that referenced UI to use the appropriate UI_REQUEST or UI_RESPONSE constant instead. Co-authored-by: mroz22 <30367552+mroz22@users.noreply.github.com>
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import { UnknownAction } from '@reduxjs/toolkit';
|
|
|
|
import { UI_REQUEST, UiRequestDeviceAction } from '@trezor/connect';
|
|
import { isNotNullOrUndefined } from '@trezor/utils';
|
|
|
|
export const pinButtonRequestCodes = [
|
|
'ButtonRequest_PinEntry',
|
|
'PinMatrixRequestType_Current',
|
|
] as const;
|
|
|
|
export const isPinButtonRequestCode = (action: UnknownAction): action is UiRequestDeviceAction =>
|
|
action.type === UI_REQUEST.REQUEST_BUTTON &&
|
|
typeof action.payload === 'object' &&
|
|
isNotNullOrUndefined(action.payload) &&
|
|
'code' in action.payload &&
|
|
pinButtonRequestCodes.includes(action.payload.code as (typeof pinButtonRequestCodes)[number]);
|
|
|
|
export const isPassphraseButtonRequestCode = (
|
|
action: UnknownAction,
|
|
): action is UiRequestDeviceAction =>
|
|
action.type === UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE ||
|
|
(action.type === UI_REQUEST.REQUEST_BUTTON &&
|
|
typeof action.payload === 'object' &&
|
|
isNotNullOrUndefined(action.payload) &&
|
|
'code' in action.payload &&
|
|
action.payload.code === 'ButtonRequest_Other' &&
|
|
'name' in action.payload &&
|
|
action.payload.name === 'passphrase_host1');
|
|
|
|
export const isPassphraseRequest = (action: UnknownAction): action is UiRequestDeviceAction =>
|
|
action.type === UI_REQUEST.REQUEST_PASSPHRASE;
|
|
|
|
export const flowEndingButtonRequests = [
|
|
'ButtonRequest_ConfirmOutput',
|
|
'ButtonRequest_SignTx',
|
|
'ButtonRequest_Address',
|
|
] as const;
|
|
|
|
export const isFlowEndingButtonRequest = (action: UnknownAction) =>
|
|
action.type === UI_REQUEST.REQUEST_BUTTON &&
|
|
typeof action.payload === 'object' &&
|
|
isNotNullOrUndefined(action.payload) &&
|
|
'code' in action.payload &&
|
|
flowEndingButtonRequests.includes(
|
|
action.payload.code as (typeof flowEndingButtonRequests)[number],
|
|
);
|
|
|
|
export const isSuiteSyncButtonRequest = (action: UnknownAction) =>
|
|
action.type === UI_REQUEST.REQUEST_BUTTON &&
|
|
typeof action.payload === 'object' &&
|
|
isNotNullOrUndefined(action.payload) &&
|
|
'name' in action.payload &&
|
|
action.payload.name === 'secure_sync';
|