chore: remove ens storage feature (#198)
This commit is contained in:
parent
f3f35bb19b
commit
f74c8bb569
|
|
@ -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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './fetch-ens-names';
|
|
||||||
|
|
@ -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;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from './ens-slice';
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
export * from './ens';
|
|
||||||
export * from './fleek-erc721';
|
export * from './fleek-erc721';
|
||||||
export * from './github';
|
export * from './github';
|
||||||
export * from './toasts';
|
export * from './toasts';
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import { configureStore } from '@reduxjs/toolkit';
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
import fleekERC721Reducer from './features/fleek-erc721/fleek-erc721-slice';
|
||||||
import githubReducer from './features/github/github-slice';
|
import githubReducer from './features/github/github-slice';
|
||||||
import toastsReducer from './features/toasts/toasts-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({
|
export const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
ens: ensReducer,
|
|
||||||
fleekERC721: fleekERC721Reducer,
|
fleekERC721: fleekERC721Reducer,
|
||||||
github: githubReducer,
|
github: githubReducer,
|
||||||
toasts: toastsReducer,
|
toasts: toastsReducer,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue