@metamask/snaps-simulation
Version:
A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment
36 lines • 1.18 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getJsonRpcMocks = exports.removeJsonRpcMock = exports.addJsonRpcMock = exports.mocksSlice = void 0;
const toolkit_1 = require("@reduxjs/toolkit");
/**
* The initial notifications state.
*/
const INITIAL_STATE = {
jsonRpc: {},
};
exports.mocksSlice = (0, toolkit_1.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];
},
},
});
_a = exports.mocksSlice.actions, exports.addJsonRpcMock = _a.addJsonRpcMock, exports.removeJsonRpcMock = _a.removeJsonRpcMock;
/**
* Get the JSON-RPC mocks from the state.
*
* @param state - The application state.
* @returns The JSON-RPC mocks.
*/
const getJsonRpcMocks = (state) => state.mocks.jsonRpc;
exports.getJsonRpcMocks = getJsonRpcMocks;
//# sourceMappingURL=mocks.cjs.map