Commit fbd78a5a authored by Hayden Adams's avatar Hayden Adams

rename web to web3Store, remove getBlock interval

parent 37d82f97
This diff is collapsed.
import { import {
WEB3_CONNECTION_SUCCESSFUL, WEB3_CONNECTION_SUCCESSFUL,
WEB3_CONNECTION_UNSUCCESSFUL, WEB3_CONNECTION_UNSUCCESSFUL,
SET_CURRENT_MASK_ADDRESS, SET_CURRENT_MASK_ADDRESS,
...@@ -7,12 +7,13 @@ import { ...@@ -7,12 +7,13 @@ import {
SET_INTERACTION_STATE, SET_INTERACTION_STATE,
FACTORY_CONTRACT_READY, FACTORY_CONTRACT_READY,
SET_NETWORK_MESSAGE, SET_NETWORK_MESSAGE,
SET_BLOCK_TIMESTAMP, SET_BLOCK_TIMESTAMP,
SET_EXCHANGE_TYPE SET_EXCHANGE_TYPE,
PUT_WEB3_IN_STORE
} from '../constants'; } from '../constants';
// this actions folder is actually full of action creators // this actions folder is actually full of action creators
// your asynchronous calls are going to be in redux-thunk style action creators // your asynchronous calls are going to be in redux-thunk style action creators
export const web3ConnectionSuccessful = () => ({ export const web3ConnectionSuccessful = () => ({
type: WEB3_CONNECTION_SUCCESSFUL, type: WEB3_CONNECTION_SUCCESSFUL,
...@@ -54,7 +55,7 @@ export const setNetworkMessage = (networkMessage) => ({ ...@@ -54,7 +55,7 @@ export const setNetworkMessage = (networkMessage) => ({
networkMessage networkMessage
}); });
export const setBlockTimestamp = (timestamp) => ({ export const setBlockTimestamp = (timestamp) => ({
type: SET_BLOCK_TIMESTAMP, type: SET_BLOCK_TIMESTAMP,
timestamp timestamp
}); });
...@@ -63,3 +64,8 @@ export const setExchangeType = (exchangeType) => ({ ...@@ -63,3 +64,8 @@ export const setExchangeType = (exchangeType) => ({
type: SET_EXCHANGE_TYPE, type: SET_EXCHANGE_TYPE,
exchangeType exchangeType
}); });
export const putWeb3InStore = (globalWeb3) => ({
type: PUT_WEB3_IN_STORE,
globalWeb3
})
// here is where we put the string literals for the actions // here is where we put the string literals for the actions
// maybe there's an action to see if you've been connected to web3 // maybe there's an action to see if you've been connected to web3
// web3 actions, all set from action creator to reducer to app // web3 actions, all set from action creator to reducer to app
export const CHECK_WEB3_CONNECTION = 'CHECK_WEB3_CONNECTION'; export const CHECK_WEB3_CONNECTION = 'CHECK_WEB3_CONNECTION';
export const WEB3_CONNECTION_SUCCESSFUL = 'WEB3_CONNECTION_SUCCESSFUL'; export const WEB3_CONNECTION_SUCCESSFUL = 'WEB3_CONNECTION_SUCCESSFUL';
export const WEB3_CONNECTION_UNSUCCESSFUL = 'WEB3_CONNECTION_UNSUCCESSFUL'; export const WEB3_CONNECTION_UNSUCCESSFUL = 'WEB3_CONNECTION_UNSUCCESSFUL';
...@@ -26,7 +26,7 @@ export const SWT_EXCHANGE_CONTRACT_READY = 'SWT_EXCHANGE_CONTRACT_READY'; ...@@ -26,7 +26,7 @@ export const SWT_EXCHANGE_CONTRACT_READY = 'SWT_EXCHANGE_CONTRACT_READY';
export const UNI_TOKEN_CONTRACT_READY = 'UNI_TOKEN_CONTRACT_READY'; export const UNI_TOKEN_CONTRACT_READY = 'UNI_TOKEN_CONTRACT_READY';
export const SWT_TOKEN_CONTRACT_READY = 'SWT_TOKEN_CONTRACT_READY'; export const SWT_TOKEN_CONTRACT_READY = 'SWT_TOKEN_CONTRACT_READY';
// actions for the exchange, all in one place // actions for the exchange, all in one place
export const SET_INPUT_BALANCE = 'SET_INPUT_BALANCE'; export const SET_INPUT_BALANCE = 'SET_INPUT_BALANCE';
export const SET_OUTPUT_BALANCE = 'SET_OUTPUT_BALANCE'; export const SET_OUTPUT_BALANCE = 'SET_OUTPUT_BALANCE';
export const SET_INPUT_TOKEN = 'SET_INPUT_TOKEN'; export const SET_INPUT_TOKEN = 'SET_INPUT_TOKEN';
...@@ -41,4 +41,7 @@ export const SET_ALLOWANCE_APPROVAL_STATE = 'SET_ALLOWANCE_APPROVAL_STATE'; ...@@ -41,4 +41,7 @@ export const SET_ALLOWANCE_APPROVAL_STATE = 'SET_ALLOWANCE_APPROVAL_STATE';
export const SET_EXCHANGE_INPUT_VALUE = 'SET_EXCHANGE_INPUT_VALUE'; export const SET_EXCHANGE_INPUT_VALUE = 'SET_EXCHANGE_INPUT_VALUE';
export const SET_EXCHANGE_OUTPUT_VALUE = 'SET_EXCHANGE_OUTPUT_VALUE'; export const SET_EXCHANGE_OUTPUT_VALUE = 'SET_EXCHANGE_OUTPUT_VALUE';
export const SET_EXCHANGE_RATE = 'SET_EXCHANGE_RATE'; export const SET_EXCHANGE_RATE = 'SET_EXCHANGE_RATE';
export const SET_EXCHANGE_FEE = 'SET_EXCHANGE_FEE'; export const SET_EXCHANGE_FEE = 'SET_EXCHANGE_FEE';
\ No newline at end of file
// test setInteractionState
export const PUT_WEB3_IN_STORE = 'PUT_WEB3_IN_STORE';
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import web3 from './web3-reducer'; import web3Store from './web3-reducer';
import exchangeContracts from './exchangeContract-reducer'; import exchangeContracts from './exchangeContract-reducer';
import tokenContracts from './tokenContract-reducer'; import tokenContracts from './tokenContract-reducer';
import exchange from './exchange-reducer'; import exchange from './exchange-reducer';
export default combineReducers({ export default combineReducers({
web3, web3Store,
exchangeContracts, exchangeContracts,
tokenContracts, tokenContracts,
exchange exchange
}); });
\ No newline at end of file
// these will take in an action, have a default state set in the arguments and return a new state // these will take in an action, have a default state set in the arguments and return a new state
import { import {
WEB3_CONNECTION_SUCCESSFUL, WEB3_CONNECTION_SUCCESSFUL,
WEB3_CONNECTION_UNSUCCESSFUL, WEB3_CONNECTION_UNSUCCESSFUL,
SET_CURRENT_MASK_ADDRESS, SET_CURRENT_MASK_ADDRESS,
METAMASK_LOCKED, METAMASK_LOCKED,
METAMASK_UNLOCKED, METAMASK_UNLOCKED,
SET_INTERACTION_STATE, SET_INTERACTION_STATE,
FACTORY_CONTRACT_READY, FACTORY_CONTRACT_READY,
SET_NETWORK_MESSAGE, SET_NETWORK_MESSAGE,
SET_BLOCK_TIMESTAMP, SET_BLOCK_TIMESTAMP,
SET_EXCHANGE_TYPE SET_EXCHANGE_TYPE,
PUT_WEB3_IN_STORE
} from '../constants'; } from '../constants';
export default (state = {}, action) => { export default (state = {}, action) => {
const { connected, currentMaskAddress, metamaskLocked, interaction, factoryContract, networkMessage, timestamp, exchangeType } = action const { connected, currentMaskAddress, metamaskLocked, interaction, factoryContract, networkMessage, timestamp, exchangeType, globalWeb3 } = action
switch (action.type) { switch (action.type) {
case WEB3_CONNECTION_SUCCESSFUL: case WEB3_CONNECTION_SUCCESSFUL:
return Object.assign({}, state, { connected: connected }); return Object.assign({}, state, { connected: connected });
...@@ -35,6 +36,8 @@ export default (state = {}, action) => { ...@@ -35,6 +36,8 @@ export default (state = {}, action) => {
return Object.assign({}, state, { blockTimestamp: timestamp }); return Object.assign({}, state, { blockTimestamp: timestamp });
case SET_EXCHANGE_TYPE: case SET_EXCHANGE_TYPE:
return Object.assign({}, state, { exchangeType: exchangeType }); return Object.assign({}, state, { exchangeType: exchangeType });
case PUT_WEB3_IN_STORE:
return Object.assign({}, state, { globalWeb3: globalWeb3 });
default: return state; default: return state;
} }
} }
// what states do you need upon initialization? // what states do you need upon initialization?
// connected: are you connnected? default state = false // connected: are you connnected? default state = false
// props.metamask --> maybe we should keep this in global state too? // props.metamask --> maybe we should keep this in global state too?
// both of these are set to false in the default state // both of these are set to false in the default state
// fire dispatch functions to check for installation and connection in the default store // fire dispatch functions to check for installation and connection in the default store
// you are probably going to be storing stuff like invariants and all that jazz here // you are probably going to be storing stuff like invariants and all that jazz here
export default { export default {
// lets check if metamask is installed // lets check if metamask is installed
// also, lets assume that we're disconnected initially // also, lets assume that we're disconnected initially
// we're going to need to include a seperate nest for exchange actions // we're going to need to include a seperate nest for exchange actions
web3: { web3Store: {
connected: false, connected: false,
currentMaskAddress: '', currentMaskAddress: '',
metamaskLocked: true, metamaskLocked: true,
...@@ -55,4 +55,4 @@ export default { ...@@ -55,4 +55,4 @@ export default {
rate: 0, rate: 0,
fee: 0, fee: 0,
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment