A reactive data-store for web3 and smart contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

71 lines
1.3 KiB

import * as Action from './web3Actions'
import { ACCOUNTS_FAILED } from '../accounts/accountsActions'
const initialState = {
status: 'initializing'
}
const web3Reducer = (state = initialState, action) => {
if (action.type === Action.WEB3_INITIALIZING) {
return {
...state,
status: 'initializing'
}
}
if (action.type === Action.WEB3_INITIALIZED) {
return {
...state,
status: 'initialized'
}
}
if (action.type === Action.WEB3_FAILED) {
return {
...state,
status: 'failed'
}
}
if (action.type === Action.WEB3_USER_DENIED) {
return {
...state,
status: 'UserDeniedAccess'
}
}
if (action.type === Action.WEB3_NETWORK_FETCHED) {
return {
...state,
networkId: action.networkInfo.networkId,
chainId: action.networkInfo.chainId,
nodeInfo: action.networkInfo.nodeInfo,
networkFailed: false,
networkMismatch: false
}
}
if (action.type === Action.WEB3_NETWORK_FAILED) {
return {
...state,
networkFailed: true
}
}
if (action.type === Action.WEB3_NETWORK_MISMATCH) {
return {
...state,
networkMismatch: true
}
}
if (action.type === ACCOUNTS_FAILED) {
return {
...state,
accountsFailed: true
}
}
return state
}
export default web3Reducer