From f74c8bb5695d12a53fa49136a4de9b79c8d7efba Mon Sep 17 00:00:00 2001 From: Felipe Mendes Date: Thu, 30 Mar 2023 15:55:06 -0300 Subject: [PATCH] chore: remove ens storage feature (#198) --- .../ens/async-thunk/fetch-ens-names.ts | 25 ---------- .../store/features/ens/async-thunk/index.ts | 1 - ui/src/store/features/ens/ens-slice.ts | 47 ------------------- ui/src/store/features/ens/index.ts | 1 - ui/src/store/features/index.ts | 1 - ui/src/store/store.ts | 5 +- 6 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 ui/src/store/features/ens/async-thunk/fetch-ens-names.ts delete mode 100644 ui/src/store/features/ens/async-thunk/index.ts delete mode 100644 ui/src/store/features/ens/ens-slice.ts delete mode 100644 ui/src/store/features/ens/index.ts diff --git a/ui/src/store/features/ens/async-thunk/fetch-ens-names.ts b/ui/src/store/features/ens/async-thunk/fetch-ens-names.ts deleted file mode 100644 index 389582d..0000000 --- a/ui/src/store/features/ens/async-thunk/fetch-ens-names.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Ethereum } from '@/integrations'; -import { RootState } from '@/store'; -import { createAsyncThunk } from '@reduxjs/toolkit'; -import { ensActions } from '../ens-slice'; - -//TODO maybe deprecate cause we uss the ENS graph -export const fetchEnsNamesThunk = createAsyncThunk( - 'ens/fetchEnsNames', - async (address, { dispatch, getState }) => { - const { state } = (getState() as RootState).ens; - if (state === 'loading') return; - - try { - dispatch(ensActions.setState('loading')); - - //fetch ens names for received addresses - const ensList = await Ethereum.getEnsName(address); - - dispatch(ensActions.setEnsNames(ensList)); - } catch (error) { - console.log(error); - dispatch(ensActions.setState('failed')); - } - } -); diff --git a/ui/src/store/features/ens/async-thunk/index.ts b/ui/src/store/features/ens/async-thunk/index.ts deleted file mode 100644 index e08e73a..0000000 --- a/ui/src/store/features/ens/async-thunk/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './fetch-ens-names'; diff --git a/ui/src/store/features/ens/ens-slice.ts b/ui/src/store/features/ens/ens-slice.ts deleted file mode 100644 index 0a9279d..0000000 --- a/ui/src/store/features/ens/ens-slice.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { RootState, useAppSelector } from '@/store'; -import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import * as asyncThunk from './async-thunk'; - -export namespace EnsState { - export type State = 'idle' | 'loading' | 'success' | 'failed'; - - export type EnsNames = string[]; -} - -export interface EnsState { - state: EnsState.State; - ensNames: EnsState.EnsNames; -} - -const initialState: EnsState = { - state: 'idle', - ensNames: [], -}; - -export const ensSlice = createSlice({ - name: 'ens', - initialState, - reducers: { - setEnsNames: (state, action: PayloadAction) => { - state.ensNames = action.payload; - state.state = 'success'; - }, - setState: ( - state, - action: PayloadAction> - ) => { - state.state = action.payload; - }, - }, -}); - -export const ensActions = { - ...ensSlice.actions, - ...asyncThunk, -}; - -const selectEnsState = (state: RootState): EnsState => state.ens; - -export const useEnsStore = (): EnsState => useAppSelector(selectEnsState); - -export default ensSlice.reducer; diff --git a/ui/src/store/features/ens/index.ts b/ui/src/store/features/ens/index.ts deleted file mode 100644 index c58c438..0000000 --- a/ui/src/store/features/ens/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ens-slice'; diff --git a/ui/src/store/features/index.ts b/ui/src/store/features/index.ts index 9cb174a..2e74368 100644 --- a/ui/src/store/features/index.ts +++ b/ui/src/store/features/index.ts @@ -1,4 +1,3 @@ -export * from './ens'; export * from './fleek-erc721'; export * from './github'; export * from './toasts'; diff --git a/ui/src/store/store.ts b/ui/src/store/store.ts index a8b801c..6144369 100644 --- a/ui/src/store/store.ts +++ b/ui/src/store/store.ts @@ -1,12 +1,11 @@ import { configureStore } from '@reduxjs/toolkit'; + +import fleekERC721Reducer from './features/fleek-erc721/fleek-erc721-slice'; import githubReducer from './features/github/github-slice'; import toastsReducer from './features/toasts/toasts-slice'; -import ensReducer from './features/ens/ens-slice'; -import fleekERC721Reducer from './features/fleek-erc721/fleek-erc721-slice'; export const store = configureStore({ reducer: { - ens: ensReducer, fleekERC721: fleekERC721Reducer, github: githubReducer, toasts: toastsReducer,