diff --git a/packages/suite/src/actions/firmware/__fixtures__/firmwareActions.ts b/packages/suite/src/actions/firmware/__fixtures__/firmwareActions.ts index 1990804dd2e..7d61767e81f 100644 --- a/packages/suite/src/actions/firmware/__fixtures__/firmwareActions.ts +++ b/packages/suite/src/actions/firmware/__fixtures__/firmwareActions.ts @@ -26,8 +26,8 @@ const bootloaderDeviceNoIntermediaryT1 = { ), }; const firmwareUpdateResponsePayload = { - hash: 'abc', - challenge: 'def', + check: 'valid', + versionCheck: true, }; export const actions = [ diff --git a/packages/suite/src/middlewares/suite/eventsMiddleware.ts b/packages/suite/src/middlewares/suite/eventsMiddleware.ts index 2a9cd5f73df..bb09cb2c791 100644 --- a/packages/suite/src/middlewares/suite/eventsMiddleware.ts +++ b/packages/suite/src/middlewares/suite/eventsMiddleware.ts @@ -67,6 +67,10 @@ const eventsMiddleware = } } + if (action.type === DEVICE.FIRMWARE_VERSION_CHANGED) { + // TODO: show warning? move this to different middleware? + } + if (deviceActions.selectDevice.match(action)) { // Find and mark all notification associated (new connected!, update required etc) if (!action.payload) return action; diff --git a/suite-common/firmware/src/firmwareThunks.ts b/suite-common/firmware/src/firmwareThunks.ts index 036f96ba56e..416e8835e19 100644 --- a/suite-common/firmware/src/firmwareThunks.ts +++ b/suite-common/firmware/src/firmwareThunks.ts @@ -154,7 +154,7 @@ export const firmwareUpdate = createThunk< connectResponse: firmwareUpdateResponse, }); } else { - const { check } = firmwareUpdateResponse.payload; + const { check, versionCheck } = firmwareUpdateResponse.payload; if (check === 'mismatch') { // hash check was performed, and it does not match, so consider firmware counterfeit dispatch(handleFwHashMismatch(device)); @@ -165,6 +165,8 @@ export const firmwareUpdate = createThunk< errorMessage: firmwareUpdateResponse.payload.checkError, }), ); + } else if (!binary && !versionCheck) { + // TODO: log to sentry } else { dispatch(handleFwHashValid(device)); } diff --git a/suite-common/wallet-core/src/device/deviceActions.ts b/suite-common/wallet-core/src/device/deviceActions.ts index 647bd4951b5..c3efdabc3ad 100644 --- a/suite-common/wallet-core/src/device/deviceActions.ts +++ b/suite-common/wallet-core/src/device/deviceActions.ts @@ -2,7 +2,7 @@ import { createAction } from '@reduxjs/toolkit'; import { ButtonRequest, TrezorDevice } from '@suite-common/suite-types'; import { WalletType } from '@suite-common/wallet-types'; -import { DEVICE, Device } from '@trezor/connect'; +import { DEVICE, Device, DeviceVersionChanged } from '@trezor/connect'; export const DEVICE_MODULE_PREFIX = '@suite/device'; @@ -18,7 +18,7 @@ const connectDevice = createAction(DEVICE.CONNECT, (payload: DeviceConnectAction const connectUnacquiredDevice = createAction( DEVICE.CONNECT_UNACQUIRED, - (payload: { device: Device; settings: ConnectDeviceSettings }) => ({ payload }), + (payload: DeviceConnectActionPayload) => ({ payload }), ); const deviceChanged = createAction(DEVICE.CHANGED, (payload: Device | TrezorDevice) => ({ @@ -29,6 +29,16 @@ const deviceDisconnect = createAction(DEVICE.DISCONNECT, (payload: TrezorDevice) payload, })); +// this action is not used but is required because of the typings +// changed here: https://github.com/trezor/trezor-suite/commit/c02412bccf80da7c827f624b7a7c85cdedf278c5#diff-2e9d057f0bfe2cc92fe50d4ce28838622d9e79fcca010ab8847a0fa288da13fd +// in fact action is dispatched from connectInitThunk same as the rest of events +const deviceFirmwareVersionChanged = createAction( + DEVICE.FIRMWARE_VERSION_CHANGED, + (payload: DeviceVersionChanged['payload']) => ({ + payload, + }), +); + const updatePassphraseMode = createAction( `${DEVICE_MODULE_PREFIX}/updatePassphraseMode`, (payload: { device: TrezorDevice; hidden: boolean; alwaysOnDevice?: boolean }) => ({ payload }), @@ -108,4 +118,5 @@ export const deviceActions = { updateSelectedDevice, removeButtonRequests, setEntropyCheckFail, + deviceFirmwareVersionChanged, };