UNPKG

@metamask/snaps-simulation

Version:

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

1 lines 1.88 kB
{"version":3,"file":"ui.mjs","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":";;AAgBA,MAAM,aAAa,GAAY;IAC7B,OAAO,EAAE,IAAI;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC;IACjC,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,YAAY,CAAC,KAAK,EAAE,MAAgC;YAClD,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,cAAc,CAAC,KAAK;YAClB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAC1C,GAAG,OAAO,CAAC,IAAI,mBAAmB,CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;AAEhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAC/C,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,EACrC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CACnB,CAAC","sourcesContent":["import type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport type { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createAction, createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type Interface = {\n type: DialogApprovalTypes[DialogType | 'default'] | 'Notification';\n id: string;\n};\n\nexport type UiState = {\n current?: Interface | null;\n};\n\nconst INITIAL_STATE: UiState = {\n current: null,\n};\n\nexport const uiSlice = createSlice({\n name: 'ui',\n initialState: INITIAL_STATE,\n reducers: {\n setInterface(state, action: PayloadAction<Interface>) {\n state.current = action.payload;\n },\n closeInterface(state) {\n state.current = null;\n },\n },\n});\n\nexport const resolveInterface = createAction<unknown>(\n `${uiSlice.name}/resolveInterface`,\n);\n\nexport const { setInterface, closeInterface } = uiSlice.actions;\n\nexport const getCurrentInterface = createSelector(\n (state: ApplicationState) => state.ui,\n (ui) => ui.current,\n);\n"]}