2017-06-26 22:27:55 +00:00
|
|
|
// @flow
|
|
|
|
import type { EnsAction, CacheEnsAddressAction } from 'actions/ens';
|
|
|
|
|
|
|
|
export type State = { [string]: string };
|
|
|
|
|
|
|
|
const initialState: State = {};
|
|
|
|
|
|
|
|
function cacheEnsAddress(state: State, action: CacheEnsAddressAction): State {
|
2017-07-02 05:49:06 +00:00
|
|
|
const { ensName, address } = action.payload;
|
|
|
|
return { ...state, [ensName]: address };
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function ens(state: State = initialState, action: EnsAction): State {
|
2017-07-02 05:49:06 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case 'ENS_CACHE':
|
|
|
|
return cacheEnsAddress(state, action);
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|