@metamask/snaps-simulation
Version:
A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment
1 lines • 2.11 kB
Source Map (JSON)
{"version":3,"file":"mocks.cjs","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":";;;;AACA,8CAA+C;AAe/C;;GAEG;AACH,MAAM,aAAa,GAAe;IAChC,OAAO,EAAE,EAAE;CACZ,CAAC;AAEW,QAAA,UAAU,GAAG,IAAA,qBAAW,EAAC;IACpC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,cAAc,EAAE,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;YAC5D,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;gBACjC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc;gBAC7C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;aAC1B,CAAC;QACJ,CAAC;QACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAA6B,EAAE,EAAE;YAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;KACF;CACF,CAAC,CAAC;AAEU,KAAwC,kBAAU,CAAC,OAAO,EAAxD,sBAAc,sBAAE,yBAAiB,wBAAwB;AAExE;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AAAnE,QAAA,eAAe,mBAAoD","sourcesContent":["import type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\nimport type { JsonRpcMockImplementation } from '../types';\n\nexport type JsonRpcMock = {\n id: string;\n implementation: JsonRpcMockImplementation;\n once?: boolean;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Omit<JsonRpcMock, 'id'>>;\n};\n\n/**\n * The initial notifications state.\n */\nconst INITIAL_STATE: MocksState = {\n jsonRpc: {},\n};\n\nexport const mocksSlice = createSlice({\n name: 'mocks',\n initialState: INITIAL_STATE,\n reducers: {\n addJsonRpcMock: (state, action: PayloadAction<JsonRpcMock>) => {\n state.jsonRpc[action.payload.id] = {\n implementation: action.payload.implementation,\n once: action.payload.once,\n };\n },\n removeJsonRpcMock: (state, action: PayloadAction<string>) => {\n delete state.jsonRpc[action.payload];\n },\n },\n});\n\nexport const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;\n\n/**\n * Get the JSON-RPC mocks from the state.\n *\n * @param state - The application state.\n * @returns The JSON-RPC mocks.\n */\nexport const getJsonRpcMocks = (state: ApplicationState) => state.mocks.jsonRpc;\n"]}