@metamask/snaps-simulation
Version:
A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment
32 lines • 927 B
JavaScript
import $reduxjstoolkit from "@reduxjs/toolkit";
const { createSlice } = $reduxjstoolkit;
/**
* The initial notifications state.
*/
const INITIAL_STATE = {
jsonRpc: {},
};
export const mocksSlice = createSlice({
name: 'mocks',
initialState: INITIAL_STATE,
reducers: {
addJsonRpcMock: (state, action) => {
state.jsonRpc[action.payload.id] = {
implementation: action.payload.implementation,
once: action.payload.once,
};
},
removeJsonRpcMock: (state, action) => {
delete state.jsonRpc[action.payload];
},
},
});
export const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;
/**
* Get the JSON-RPC mocks from the state.
*
* @param state - The application state.
* @returns The JSON-RPC mocks.
*/
export const getJsonRpcMocks = (state) => state.mocks.jsonRpc;
//# sourceMappingURL=mocks.mjs.map