Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
2d423267
Commit
2d423267
authored
Oct 06, 2018
by
Chi Kei Chan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to ducks-modular-redux pattern for reducers/actions
parent
5ef5135b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
199 additions
and
230 deletions
+199
-230
App.js
src/App.js
+4
-4
exchange-actions.js
src/actions/exchange-actions.js
+0
-152
exchangeContract-actions.js
src/actions/exchangeContract-actions.js
+0
-9
tokenContract-actions.js
src/actions/tokenContract-actions.js
+0
-9
Exchange.js
src/components/Exchange.js
+2
-2
Invest.js
src/components/Invest.js
+1
-1
NetworkStatus.js
src/components/NetworkStatus.js
+1
-1
Purchase.js
src/components/Purchase.js
+2
-2
SharePurchase.js
src/components/SharePurchase.js
+2
-2
exchange-contract.js
src/ducks/exchange-contract.js
+6
-0
exchange.js
src/ducks/exchange.js
+126
-0
index.js
src/ducks/index.js
+13
-0
token-contract.js
src/ducks/token-contract.js
+6
-0
web3.js
src/ducks/web3.js
+35
-1
web3-reducer.js
src/reducers/web3-reducer.js
+0
-46
store.dev.js
src/store/store.dev.js
+1
-1
No files found.
src/App.js
View file @
2d423267
...
@@ -20,8 +20,8 @@ import { bindActionCreators } from 'redux'
...
@@ -20,8 +20,8 @@ import { bindActionCreators } from 'redux'
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
subscribe
}
from
'
redux-subscriber
'
;
import
{
subscribe
}
from
'
redux-subscriber
'
;
// redux actions
// redux actions
import
{
exchangeContractReady
}
from
'
./
actions/exchangeContract-actions
'
;
import
{
exchangeContractReady
}
from
'
./
ducks/exchange-contract
'
;
import
{
tokenContractReady
}
from
'
./
actions/tokenContract-actions
'
;
import
{
tokenContractReady
}
from
'
./
ducks/token-contract
'
;
import
{
initializeGlobalWeb3
,
import
{
initializeGlobalWeb3
,
setWeb3ConnectionStatus
,
setWeb3ConnectionStatus
,
setCurrentMaskAddress
,
setCurrentMaskAddress
,
...
@@ -30,7 +30,7 @@ import { initializeGlobalWeb3,
...
@@ -30,7 +30,7 @@ import { initializeGlobalWeb3,
setInteractionState
,
setInteractionState
,
factoryContractReady
,
factoryContractReady
,
toggleAbout
,
toggleAbout
,
toggleInvest
}
from
'
./
actions/web3-actions
'
;
toggleInvest
}
from
'
./
ducks/web3
'
;
import
{
setInputBalance
,
import
{
setInputBalance
,
setOutputBalance
,
setOutputBalance
,
setEthPool1
,
setEthPool1
,
...
@@ -45,7 +45,7 @@ import { setInputBalance,
...
@@ -45,7 +45,7 @@ import { setInputBalance,
setInvestShares
,
setInvestShares
,
setUserShares
,
setUserShares
,
setInvestTokenBalance
,
setInvestTokenBalance
,
setInvestEthBalance
}
from
'
./
actions/exchange-actions
'
;
setInvestEthBalance
}
from
'
./
ducks/exchange
'
;
import
'
./App.css
'
;
import
'
./App.css
'
;
import
scrollToComponent
from
'
react-scroll-to-component
'
;
import
scrollToComponent
from
'
react-scroll-to-component
'
;
...
...
src/actions/exchange-actions.js
deleted
100644 → 0
View file @
5ef5135b
import
{
SET_INPUT_BALANCE
,
SET_OUTPUT_BALANCE
,
SET_INPUT_TOKEN
,
SET_OUTPUT_TOKEN
,
SET_ETH_POOL_1
,
SET_ETH_POOL_2
,
SET_TOKEN_POOL_1
,
SET_TOKEN_POOL_2
,
SET_ALLOWANCE_APPROVAL_STATE
,
SET_EXCHANGE_INPUT_VALUE
,
SET_EXCHANGE_OUTPUT_VALUE
,
SET_EXCHANGE_RATE
,
SET_EXCHANGE_FEE
,
SET_INVEST_TOKEN
,
SET_INVEST_ETH_POOL
,
SET_INVEST_TOKEN_POOL
,
SET_INVEST_SHARES
,
SET_USER_SHARES
,
SET_INVEST_TOKEN_BALANCE
,
SET_INVEST_ETH_BALANCE
,
SET_INVEST_TOKEN_ALLOWANCE
,
SET_INVEST_SHARES_INPUT
,
SET_INVEST_ETH_REQUIRED
,
SET_INVEST_TOKENS_REQUIRED
,
SET_INVEST_CHECKED
}
from
'
../constants
'
;
export
const
setInputBalance
=
(
inputBalance
)
=>
({
type
:
SET_INPUT_BALANCE
,
inputBalance
});
export
const
setOutputBalance
=
(
outputBalance
)
=>
({
type
:
SET_OUTPUT_BALANCE
,
outputBalance
})
export
const
setInputToken
=
(
inputToken
)
=>
({
type
:
SET_INPUT_TOKEN
,
inputToken
});
export
const
setOutputToken
=
(
outputToken
)
=>
({
type
:
SET_OUTPUT_TOKEN
,
outputToken
});
export
const
setEthPool1
=
(
ethPool1
)
=>
({
type
:
SET_ETH_POOL_1
,
ethPool1
});
export
const
setEthPool2
=
(
ethPool2
)
=>
({
type
:
SET_ETH_POOL_2
,
ethPool2
});
export
const
setTokenPool1
=
(
tokenPool1
)
=>
({
type
:
SET_TOKEN_POOL_1
,
tokenPool1
});
export
const
setTokenPool2
=
(
tokenPool2
)
=>
({
type
:
SET_TOKEN_POOL_2
,
tokenPool2
});
export
const
setAllowanceApprovalState
=
(
allowanceApproved
)
=>
({
type
:
SET_ALLOWANCE_APPROVAL_STATE
,
allowanceApproved
});
export
const
setExchangeInputValue
=
(
inputValue
)
=>
({
type
:
SET_EXCHANGE_INPUT_VALUE
,
inputValue
});
export
const
setExchangeOutputValue
=
(
outputValue
)
=>
({
type
:
SET_EXCHANGE_OUTPUT_VALUE
,
outputValue
});
export
const
setExchangeRate
=
(
rate
)
=>
({
type
:
SET_EXCHANGE_RATE
,
rate
});
export
const
setExchangeFee
=
(
fee
)
=>
({
type
:
SET_EXCHANGE_FEE
,
fee
});
export
const
setInvestToken
=
(
investToken
)
=>
({
type
:
SET_INVEST_TOKEN
,
investToken
});
export
const
setInvestEthPool
=
(
investEthPool
)
=>
({
type
:
SET_INVEST_ETH_POOL
,
investEthPool
});
export
const
setInvestTokenPool
=
(
investTokenPool
)
=>
({
type
:
SET_INVEST_TOKEN_POOL
,
investTokenPool
});
export
const
setInvestShares
=
(
investShares
)
=>
({
type
:
SET_INVEST_SHARES
,
investShares
});
export
const
setUserShares
=
(
userShares
)
=>
({
type
:
SET_USER_SHARES
,
userShares
});
export
const
setInvestTokenBalance
=
(
investTokenBalance
)
=>
({
type
:
SET_INVEST_TOKEN_BALANCE
,
investTokenBalance
});
export
const
setInvestEthBalance
=
(
investEthBalance
)
=>
({
type
:
SET_INVEST_ETH_BALANCE
,
investEthBalance
});
export
const
setInvestTokenAllowance
=
(
investTokenAllowance
)
=>
({
type
:
SET_INVEST_TOKEN_ALLOWANCE
,
investTokenAllowance
});
export
const
setInvestSharesInput
=
(
investSharesInput
)
=>
({
type
:
SET_INVEST_SHARES_INPUT
,
investSharesInput
});
export
const
setInvestEthRequired
=
(
investEthRequired
)
=>
({
type
:
SET_INVEST_ETH_REQUIRED
,
investEthRequired
});
export
const
setInvestTokensRequired
=
(
investTokensRequired
)
=>
({
type
:
SET_INVEST_TOKENS_REQUIRED
,
investTokensRequired
});
export
const
setInvestChecked
=
(
investChecked
)
=>
({
type
:
SET_INVEST_CHECKED
,
investChecked
});
src/actions/exchangeContract-actions.js
deleted
100644 → 0
View file @
5ef5135b
import
{
EXCHANGE_CONTRACT_READY
}
from
'
../constants
'
;
// definitely needs to be redux thunk
export
const
exchangeContractReady
=
(
symbol
,
exchangeContract
)
=>
({
type
:
EXCHANGE_CONTRACT_READY
,
payload
:
{
[
symbol
]:
exchangeContract
}
});
src/actions/tokenContract-actions.js
deleted
100644 → 0
View file @
5ef5135b
import
{
TOKEN_CONTRACT_READY
}
from
'
../constants
'
;
// again, needs to be redux thunk
export
const
tokenContractReady
=
(
symbol
,
tokenContract
)
=>
({
type
:
TOKEN_CONTRACT_READY
,
payload
:
{
[
symbol
]:
tokenContract
}
});
src/components/Exchange.js
View file @
2d423267
...
@@ -2,8 +2,8 @@ import React, { Component }from 'react';
...
@@ -2,8 +2,8 @@ import React, { Component }from 'react';
import
SelectToken
from
'
./SelectToken
'
;
import
SelectToken
from
'
./SelectToken
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
setInteractionState
,
setExchangeType
}
from
'
../
actions/web3-actions
'
;
import
{
setInteractionState
,
setExchangeType
}
from
'
../
ducks/web3
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
,
setExchangeRate
,
setExchangeFee
,
setInputToken
,
setOutputToken
,
setInputBalance
,
setOutputBalance
,
setAllowanceApprovalState
}
from
'
../
actions/exchange-actions
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
,
setExchangeRate
,
setExchangeFee
,
setInputToken
,
setOutputToken
,
setInputBalance
,
setOutputBalance
,
setAllowanceApprovalState
}
from
'
../
ducks/exchange
'
;
class
Exchange
extends
Component
{
class
Exchange
extends
Component
{
onInputChange
=
async
(
event
)
=>
{
onInputChange
=
async
(
event
)
=>
{
...
...
src/components/Invest.js
View file @
2d423267
...
@@ -14,7 +14,7 @@ import { setInvestToken,
...
@@ -14,7 +14,7 @@ import { setInvestToken,
setUserShares
,
setUserShares
,
setInvestEthRequired
,
setInvestEthRequired
,
setInvestTokensRequired
,
setInvestTokensRequired
,
setInvestChecked
}
from
'
../
actions/exchange-actions
'
;
setInvestChecked
}
from
'
../
ducks/exchange
'
;
class
Invest
extends
Component
{
class
Invest
extends
Component
{
...
...
src/components/NetworkStatus.js
View file @
2d423267
...
@@ -2,7 +2,7 @@ import React, { Component }from 'react';
...
@@ -2,7 +2,7 @@ import React, { Component }from 'react';
import
{
bindActionCreators
}
from
'
redux
'
import
{
bindActionCreators
}
from
'
redux
'
import
{
connect
}
from
'
react-redux
'
import
{
connect
}
from
'
react-redux
'
import
{
subscribe
}
from
'
redux-subscriber
'
;
import
{
subscribe
}
from
'
redux-subscriber
'
;
import
{
setWeb3ConnectionStatus
,
setInteractionState
,
setNetworkMessage
,
metamaskLocked
}
from
'
../
actions/web3-actions
'
;
import
{
setWeb3ConnectionStatus
,
setInteractionState
,
setNetworkMessage
,
metamaskLocked
}
from
'
../
ducks/web3
'
;
class
NetworkStatus
extends
Component
{
class
NetworkStatus
extends
Component
{
componentDidMount
(){
componentDidMount
(){
...
...
src/components/Purchase.js
View file @
2d423267
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
{
bindActionCreators
}
from
'
redux
'
import
{
bindActionCreators
}
from
'
redux
'
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
setBlockTimestamp
,
setInteractionState
}
from
'
../
actions/web3-actions
'
;
import
{
setBlockTimestamp
,
setInteractionState
}
from
'
../
ducks/web3
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
}
from
'
../
actions/exchange-actions
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
}
from
'
../
ducks/exchange
'
;
class
Purchase
extends
Component
{
class
Purchase
extends
Component
{
purchaseTokens
=
async
()
=>
{
purchaseTokens
=
async
()
=>
{
...
...
src/components/SharePurchase.js
View file @
2d423267
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
{
bindActionCreators
}
from
'
redux
'
import
{
bindActionCreators
}
from
'
redux
'
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
setBlockTimestamp
,
setInteractionState
}
from
'
../
actions/web3-actions
'
;
import
{
setBlockTimestamp
,
setInteractionState
}
from
'
../
ducks/web3
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
}
from
'
../
actions/exchange-actions
'
;
import
{
setExchangeInputValue
,
setExchangeOutputValue
}
from
'
../
ducks/exchange
'
;
class
Purchase
extends
Component
{
class
Purchase
extends
Component
{
buyOrSellShares
=
async
()
=>
{
buyOrSellShares
=
async
()
=>
{
...
...
src/
reducers/exchangeContract-reducer
.js
→
src/
ducks/exchange-contract
.js
View file @
2d423267
...
@@ -2,6 +2,12 @@ import {
...
@@ -2,6 +2,12 @@ import {
EXCHANGE_CONTRACT_READY
EXCHANGE_CONTRACT_READY
}
from
'
../constants
'
}
from
'
../constants
'
// definitely needs to be redux thunk
export
const
exchangeContractReady
=
(
symbol
,
exchangeContract
)
=>
({
type
:
EXCHANGE_CONTRACT_READY
,
payload
:
{
[
symbol
]:
exchangeContract
}
});
export
default
(
state
=
{},
action
)
=>
{
export
default
(
state
=
{},
action
)
=>
{
const
{
payload
}
=
action
;
const
{
payload
}
=
action
;
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
...
...
src/
reducers/exchange-reducer
.js
→
src/
ducks/exchange
.js
View file @
2d423267
...
@@ -26,6 +26,132 @@ import {
...
@@ -26,6 +26,132 @@ import {
SET_INVEST_CHECKED
SET_INVEST_CHECKED
}
from
'
../constants
'
;
}
from
'
../constants
'
;
export
const
setInputBalance
=
(
inputBalance
)
=>
({
type
:
SET_INPUT_BALANCE
,
inputBalance
});
export
const
setOutputBalance
=
(
outputBalance
)
=>
({
type
:
SET_OUTPUT_BALANCE
,
outputBalance
})
export
const
setInputToken
=
(
inputToken
)
=>
({
type
:
SET_INPUT_TOKEN
,
inputToken
});
export
const
setOutputToken
=
(
outputToken
)
=>
({
type
:
SET_OUTPUT_TOKEN
,
outputToken
});
export
const
setEthPool1
=
(
ethPool1
)
=>
({
type
:
SET_ETH_POOL_1
,
ethPool1
});
export
const
setEthPool2
=
(
ethPool2
)
=>
({
type
:
SET_ETH_POOL_2
,
ethPool2
});
export
const
setTokenPool1
=
(
tokenPool1
)
=>
({
type
:
SET_TOKEN_POOL_1
,
tokenPool1
});
export
const
setTokenPool2
=
(
tokenPool2
)
=>
({
type
:
SET_TOKEN_POOL_2
,
tokenPool2
});
export
const
setAllowanceApprovalState
=
(
allowanceApproved
)
=>
({
type
:
SET_ALLOWANCE_APPROVAL_STATE
,
allowanceApproved
});
export
const
setExchangeInputValue
=
(
inputValue
)
=>
({
type
:
SET_EXCHANGE_INPUT_VALUE
,
inputValue
});
export
const
setExchangeOutputValue
=
(
outputValue
)
=>
({
type
:
SET_EXCHANGE_OUTPUT_VALUE
,
outputValue
});
export
const
setExchangeRate
=
(
rate
)
=>
({
type
:
SET_EXCHANGE_RATE
,
rate
});
export
const
setExchangeFee
=
(
fee
)
=>
({
type
:
SET_EXCHANGE_FEE
,
fee
});
export
const
setInvestToken
=
(
investToken
)
=>
({
type
:
SET_INVEST_TOKEN
,
investToken
});
export
const
setInvestEthPool
=
(
investEthPool
)
=>
({
type
:
SET_INVEST_ETH_POOL
,
investEthPool
});
export
const
setInvestTokenPool
=
(
investTokenPool
)
=>
({
type
:
SET_INVEST_TOKEN_POOL
,
investTokenPool
});
export
const
setInvestShares
=
(
investShares
)
=>
({
type
:
SET_INVEST_SHARES
,
investShares
});
export
const
setUserShares
=
(
userShares
)
=>
({
type
:
SET_USER_SHARES
,
userShares
});
export
const
setInvestTokenBalance
=
(
investTokenBalance
)
=>
({
type
:
SET_INVEST_TOKEN_BALANCE
,
investTokenBalance
});
export
const
setInvestEthBalance
=
(
investEthBalance
)
=>
({
type
:
SET_INVEST_ETH_BALANCE
,
investEthBalance
});
export
const
setInvestTokenAllowance
=
(
investTokenAllowance
)
=>
({
type
:
SET_INVEST_TOKEN_ALLOWANCE
,
investTokenAllowance
});
export
const
setInvestSharesInput
=
(
investSharesInput
)
=>
({
type
:
SET_INVEST_SHARES_INPUT
,
investSharesInput
});
export
const
setInvestEthRequired
=
(
investEthRequired
)
=>
({
type
:
SET_INVEST_ETH_REQUIRED
,
investEthRequired
});
export
const
setInvestTokensRequired
=
(
investTokensRequired
)
=>
({
type
:
SET_INVEST_TOKENS_REQUIRED
,
investTokensRequired
});
export
const
setInvestChecked
=
(
investChecked
)
=>
({
type
:
SET_INVEST_CHECKED
,
investChecked
});
export
default
(
state
=
{},
action
)
=>
{
export
default
(
state
=
{},
action
)
=>
{
const
{
const
{
inputBalance
,
inputBalance
,
...
...
src/
reducer
s/index.js
→
src/
duck
s/index.js
View file @
2d423267
import
{
combineReducers
}
from
'
redux
'
;
import
{
combineReducers
}
from
'
redux
'
;
// import global from './global-reducer';
// import global from './global-reducer';
import
web3Store
from
'
./web3
-reducer
'
;
import
web3Store
from
'
./web3
'
;
import
exchangeContracts
from
'
./exchange
Contract-reducer
'
;
import
exchangeContracts
from
'
./exchange
-contract
'
;
import
tokenContracts
from
'
./token
Contract-reducer
'
;
import
tokenContracts
from
'
./token
-contract
'
;
import
exchange
from
'
./exchange
-reducer
'
;
import
exchange
from
'
./exchange
'
;
export
default
combineReducers
({
export
default
combineReducers
({
web3Store
,
web3Store
,
...
...
src/
reducers/tokenContract-reducer
.js
→
src/
ducks/token-contract
.js
View file @
2d423267
...
@@ -2,6 +2,12 @@ import {
...
@@ -2,6 +2,12 @@ import {
TOKEN_CONTRACT_READY
TOKEN_CONTRACT_READY
}
from
'
../constants
'
;
}
from
'
../constants
'
;
// again, needs to be redux thunk
export
const
tokenContractReady
=
(
symbol
,
tokenContract
)
=>
({
type
:
TOKEN_CONTRACT_READY
,
payload
:
{
[
symbol
]:
tokenContract
}
});
export
default
(
state
=
{},
action
)
=>
{
export
default
(
state
=
{},
action
)
=>
{
const
{
payload
}
=
action
;
const
{
payload
}
=
action
;
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
...
...
src/
actions/web3-actions
.js
→
src/
ducks/web3
.js
View file @
2d423267
// these will take in an action, have a default state set in the arguments and return a new state
import
{
import
{
INITIALIZE_GLOBAL_WEB3
,
SET_WEB3_CONNECTION_STATUS
,
SET_WEB3_CONNECTION_STATUS
,
SET_CURRENT_MASK_ADDRESS
,
SET_CURRENT_MASK_ADDRESS
,
METAMASK_LOCKED
,
METAMASK_LOCKED
,
...
@@ -9,10 +9,12 @@ import {
...
@@ -9,10 +9,12 @@ import {
SET_NETWORK_MESSAGE
,
SET_NETWORK_MESSAGE
,
SET_BLOCK_TIMESTAMP
,
SET_BLOCK_TIMESTAMP
,
SET_EXCHANGE_TYPE
,
SET_EXCHANGE_TYPE
,
INITIALIZE_GLOBAL_WEB3
,
TOGGLE_ABOUT
,
TOGGLE_ABOUT
,
TOGGLE_INVEST
TOGGLE_INVEST
}
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
...
@@ -106,3 +108,35 @@ export const initializeGlobalWeb3 = (web3) => ({
...
@@ -106,3 +108,35 @@ export const initializeGlobalWeb3 = (web3) => ({
type
:
INITIALIZE_GLOBAL_WEB3
,
type
:
INITIALIZE_GLOBAL_WEB3
,
web3
web3
});
});
export
default
(
state
=
{},
action
)
=>
{
const
{
connected
,
currentMaskAddress
,
metamaskLocked
,
interaction
,
factoryContract
,
networkMessage
,
timestamp
,
exchangeType
,
web3
,
aboutToggle
,
investToggle
}
=
action
switch
(
action
.
type
)
{
case
INITIALIZE_GLOBAL_WEB3
:
return
Object
.
assign
({},
state
,
{
web3
:
web3
});
case
SET_WEB3_CONNECTION_STATUS
:
return
Object
.
assign
({},
state
,
{
connected
:
connected
});
case
SET_CURRENT_MASK_ADDRESS
:
return
Object
.
assign
({},
state
,
{
currentMaskAddress
:
currentMaskAddress
});
case
METAMASK_LOCKED
:
return
Object
.
assign
({},
state
,
{
metamaskLocked
:
metamaskLocked
});
case
METAMASK_UNLOCKED
:
return
Object
.
assign
({},
state
,
{
metamaskLocked
:
metamaskLocked
});
case
SET_INTERACTION_STATE
:
return
Object
.
assign
({},
state
,
{
interaction
:
interaction
});
case
FACTORY_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
factoryContract
:
factoryContract
});
case
SET_NETWORK_MESSAGE
:
return
Object
.
assign
({},
state
,
{
networkMessage
:
networkMessage
});
case
SET_BLOCK_TIMESTAMP
:
return
Object
.
assign
({},
state
,
{
blockTimestamp
:
timestamp
});
case
SET_EXCHANGE_TYPE
:
return
Object
.
assign
({},
state
,
{
exchangeType
:
exchangeType
});
case
TOGGLE_ABOUT
:
return
Object
.
assign
({},
state
,
{
aboutToggle
:
aboutToggle
})
case
TOGGLE_INVEST
:
return
Object
.
assign
({},
state
,
{
investToggle
:
investToggle
})
default
:
return
state
;
}
}
src/reducers/web3-reducer.js
deleted
100644 → 0
View file @
5ef5135b
// these will take in an action, have a default state set in the arguments and return a new state
import
{
SET_WEB3_CONNECTION_STATUS
,
SET_CURRENT_MASK_ADDRESS
,
METAMASK_LOCKED
,
METAMASK_UNLOCKED
,
SET_INTERACTION_STATE
,
FACTORY_CONTRACT_READY
,
SET_NETWORK_MESSAGE
,
SET_BLOCK_TIMESTAMP
,
SET_EXCHANGE_TYPE
,
INITIALIZE_GLOBAL_WEB3
,
TOGGLE_ABOUT
,
TOGGLE_INVEST
}
from
'
../constants
'
;
export
default
(
state
=
{},
action
)
=>
{
const
{
connected
,
currentMaskAddress
,
metamaskLocked
,
interaction
,
factoryContract
,
networkMessage
,
timestamp
,
exchangeType
,
web3
,
aboutToggle
,
investToggle
}
=
action
switch
(
action
.
type
)
{
case
INITIALIZE_GLOBAL_WEB3
:
return
Object
.
assign
({},
state
,
{
web3
:
web3
});
case
SET_WEB3_CONNECTION_STATUS
:
return
Object
.
assign
({},
state
,
{
connected
:
connected
});
case
SET_CURRENT_MASK_ADDRESS
:
return
Object
.
assign
({},
state
,
{
currentMaskAddress
:
currentMaskAddress
});
case
METAMASK_LOCKED
:
return
Object
.
assign
({},
state
,
{
metamaskLocked
:
metamaskLocked
});
case
METAMASK_UNLOCKED
:
return
Object
.
assign
({},
state
,
{
metamaskLocked
:
metamaskLocked
});
case
SET_INTERACTION_STATE
:
return
Object
.
assign
({},
state
,
{
interaction
:
interaction
});
case
FACTORY_CONTRACT_READY
:
return
Object
.
assign
({},
state
,
{
factoryContract
:
factoryContract
});
case
SET_NETWORK_MESSAGE
:
return
Object
.
assign
({},
state
,
{
networkMessage
:
networkMessage
});
case
SET_BLOCK_TIMESTAMP
:
return
Object
.
assign
({},
state
,
{
blockTimestamp
:
timestamp
});
case
SET_EXCHANGE_TYPE
:
return
Object
.
assign
({},
state
,
{
exchangeType
:
exchangeType
});
case
TOGGLE_ABOUT
:
return
Object
.
assign
({},
state
,
{
aboutToggle
:
aboutToggle
})
case
TOGGLE_INVEST
:
return
Object
.
assign
({},
state
,
{
investToggle
:
investToggle
})
default
:
return
state
;
}
}
src/store/store.dev.js
View file @
2d423267
import
{
applyMiddleware
,
compose
,
createStore
}
from
'
redux
'
;
import
{
applyMiddleware
,
compose
,
createStore
}
from
'
redux
'
;
import
reducer
from
'
../
reducer
s
'
;
import
reducer
from
'
../
duck
s
'
;
import
thunk
from
'
redux-thunk
'
import
thunk
from
'
redux-thunk
'
import
initSubscriber
from
'
redux-subscriber
'
;
import
initSubscriber
from
'
redux-subscriber
'
;
import
initialState
from
'
./initial-state
'
;
import
initialState
from
'
./initial-state
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment