UNPKG

@metamask/snaps-simulation

Version:

A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment

35 lines 1.39 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNotifications = exports.clearNotifications = exports.removeNotification = exports.addNotification = exports.notificationsSlice = void 0; const toolkit_1 = require("@reduxjs/toolkit"); /** * The initial notifications state. */ const INITIAL_STATE = { notifications: [], }; exports.notificationsSlice = (0, toolkit_1.createSlice)({ name: 'notifications', initialState: INITIAL_STATE, reducers: { addNotification: (state, action) => { state.notifications.push(action.payload); }, removeNotification: (state, action) => { state.notifications = state.notifications.filter((notification) => notification.id !== action.payload); }, clearNotifications: (state) => { state.notifications = []; }, }, }); _a = exports.notificationsSlice.actions, exports.addNotification = _a.addNotification, exports.removeNotification = _a.removeNotification, exports.clearNotifications = _a.clearNotifications; /** * Get the notifications from the state. * * @param state - The application state. * @returns An array of notifications. */ exports.getNotifications = (0, toolkit_1.createSelector)((state) => state.notifications, ({ notifications }) => notifications); //# sourceMappingURL=notifications.cjs.map