chore: remove ens storage feature (#198)

This commit is contained in:
Felipe Mendes 2023-03-30 15:55:06 -03:00 committed by GitHub
parent f3f35bb19b
commit f74c8bb569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2 additions and 78 deletions

View File

@ -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<void, `0x${string}`>(
'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'));
}
}
);

View File

@ -1 +0,0 @@
export * from './fetch-ens-names';

View File

@ -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<EnsState.EnsNames>) => {
state.ensNames = action.payload;
state.state = 'success';
},
setState: (
state,
action: PayloadAction<Exclude<EnsState.State, 'success'>>
) => {
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;

View File

@ -1 +0,0 @@
export * from './ens-slice';

View File

@ -1,4 +1,3 @@
export * from './ens';
export * from './fleek-erc721';
export * from './github';
export * from './toasts';

View File

@ -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,