diff --git a/packages/notification-services-controller/CHANGELOG.md b/packages/notification-services-controller/CHANGELOG.md index 5cd7324ed8..91924e3c7c 100644 --- a/packages/notification-services-controller/CHANGELOG.md +++ b/packages/notification-services-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Update `isOnChainRawNotification` to detect on-chain notifications using the v4 `notification_type` discriminator instead of legacy payload field checks, fixing web push notification handling after the v4 API migration ([#9407](https://github.com/MetaMask/core/pull/9407)) + ## [25.0.0] ### Added diff --git a/packages/notification-services-controller/src/shared/is-onchain-notification.ts b/packages/notification-services-controller/src/shared/is-onchain-notification.ts index 50107c5d30..a251882885 100644 --- a/packages/notification-services-controller/src/shared/is-onchain-notification.ts +++ b/packages/notification-services-controller/src/shared/is-onchain-notification.ts @@ -1,21 +1,17 @@ -import type { OnChainRawNotification } from '../NotificationServicesController'; +import type { + UnprocessedRawNotification, + OnChainNotification, +} from '../NotificationServicesController/types/notification-api'; +import { isOnChainNotification } from './notification-api-type-guards'; /** - * Checks if the given value is an OnChainRawNotification object. + * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator. * * @param notification - The value to check. - * @returns True if the value is an OnChainRawNotification object, false otherwise. + * @returns True if the value is an on-chain notification, false otherwise. */ export function isOnChainRawNotification( notification: unknown, -): notification is OnChainRawNotification { - const assumed = notification as OnChainRawNotification; - - // We don't have a validation/parsing library to check all possible types of an on chain notification - // It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad. - const isValidEnoughToBeOnChainNotification = [ - assumed?.id, - assumed?.payload?.data, - ].every((field) => field !== undefined); - return isValidEnoughToBeOnChainNotification; +): notification is OnChainNotification { + return isOnChainNotification(notification as UnprocessedRawNotification); }