mirror of
https://github.com/status-im/keycard-redeem.git
synced 2025-03-01 04:10:31 +00:00
48 lines
792 B
JavaScript
48 lines
792 B
JavaScript
import {
|
|
WEB3_INITIALIZED,
|
|
WEB3_ERROR,
|
|
WEB3_NETWORK_ID_LOADED,
|
|
WEB3_ACCOUNT_LOADED,
|
|
} from '../actions/web3';
|
|
|
|
const initialState: Web3State = {
|
|
initialized: false,
|
|
networkID: undefined,
|
|
error: undefined,
|
|
account: undefined,
|
|
};
|
|
|
|
export const web3Reducer = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case WEB3_INITIALIZED: {
|
|
return {
|
|
...state,
|
|
initialized: true,
|
|
}
|
|
}
|
|
|
|
case WEB3_ERROR: {
|
|
return {
|
|
...state,
|
|
error: action.error,
|
|
}
|
|
}
|
|
|
|
case WEB3_NETWORK_ID_LOADED: {
|
|
return {
|
|
...state,
|
|
networkID: action.networkID,
|
|
}
|
|
}
|
|
|
|
case WEB3_ACCOUNT_LOADED: {
|
|
return {
|
|
...state,
|
|
account: action.account,
|
|
}
|
|
}
|
|
}
|
|
|
|
return state;
|
|
}
|