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
fbd78a5a
Commit
fbd78a5a
authored
Mar 15, 2018
by
Hayden Adams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename web to web3Store, remove getBlock interval
parent
37d82f97
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
86 deletions
+101
-86
App.js
src/App.js
+63
-60
web3-actions.js
src/actions/web3-actions.js
+12
-6
constants.js
src/constants.js
+7
-4
index.js
src/reducers/index.js
+3
-3
web3-reducer.js
src/reducers/web3-reducer.js
+8
-5
initial-state.js
src/store/initial-state.js
+8
-8
No files found.
src/App.js
View file @
fbd78a5a
This diff is collapsed.
Click to expand it.
src/actions/web3-actions.js
View file @
fbd78a5a
import
{
import
{
WEB3_CONNECTION_SUCCESSFUL
,
WEB3_CONNECTION_UNSUCCESSFUL
,
SET_CURRENT_MASK_ADDRESS
,
...
...
@@ -7,12 +7,13 @@ import {
SET_INTERACTION_STATE
,
FACTORY_CONTRACT_READY
,
SET_NETWORK_MESSAGE
,
SET_BLOCK_TIMESTAMP
,
SET_EXCHANGE_TYPE
SET_BLOCK_TIMESTAMP
,
SET_EXCHANGE_TYPE
,
PUT_WEB3_IN_STORE
}
from
'
../constants
'
;
// this actions folder is actually full of action creators
// your asynchronous calls are going to be in redux-thunk style action creators
// this actions folder is actually full of action creators
// your asynchronous calls are going to be in redux-thunk style action creators
export
const
web3ConnectionSuccessful
=
()
=>
({
type
:
WEB3_CONNECTION_SUCCESSFUL
,
...
...
@@ -54,7 +55,7 @@ export const setNetworkMessage = (networkMessage) => ({
networkMessage
});
export
const
setBlockTimestamp
=
(
timestamp
)
=>
({
export
const
setBlockTimestamp
=
(
timestamp
)
=>
({
type
:
SET_BLOCK_TIMESTAMP
,
timestamp
});
...
...
@@ -63,3 +64,8 @@ export const setExchangeType = (exchangeType) => ({
type
:
SET_EXCHANGE_TYPE
,
exchangeType
});
export
const
putWeb3InStore
=
(
globalWeb3
)
=>
({
type
:
PUT_WEB3_IN_STORE
,
globalWeb3
})
src/constants.js
View file @
fbd78a5a
// 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
// 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
WEB3_CONNECTION_SUCCESSFUL
=
'
WEB3_CONNECTION_SUCCESSFUL
'
;
export
const
WEB3_CONNECTION_UNSUCCESSFUL
=
'
WEB3_CONNECTION_UNSUCCESSFUL
'
;
...
...
@@ -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
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_OUTPUT_BALANCE
=
'
SET_OUTPUT_BALANCE
'
;
export
const
SET_INPUT_TOKEN
=
'
SET_INPUT_TOKEN
'
;
...
...
@@ -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_OUTPUT_VALUE
=
'
SET_EXCHANGE_OUTPUT_VALUE
'
;
export
const
SET_EXCHANGE_RATE
=
'
SET_EXCHANGE_RATE
'
;
export
const
SET_EXCHANGE_FEE
=
'
SET_EXCHANGE_FEE
'
;
\ No newline at end of file
export
const
SET_EXCHANGE_FEE
=
'
SET_EXCHANGE_FEE
'
;
// test setInteractionState
export
const
PUT_WEB3_IN_STORE
=
'
PUT_WEB3_IN_STORE
'
;
src/reducers/index.js
View file @
fbd78a5a
import
{
combineReducers
}
from
'
redux
'
;
import
web3
from
'
./web3-reducer
'
;
import
web3
Store
from
'
./web3-reducer
'
;
import
exchangeContracts
from
'
./exchangeContract-reducer
'
;
import
tokenContracts
from
'
./tokenContract-reducer
'
;
import
exchange
from
'
./exchange-reducer
'
;
export
default
combineReducers
({
web3
,
web3
Store
,
exchangeContracts
,
tokenContracts
,
exchange
});
\ No newline at end of file
});
src/reducers/web3-reducer.js
View file @
fbd78a5a
// these will take in an action, have a default state set in the arguments and return a new state
import
{
WEB3_CONNECTION_SUCCESSFUL
,
import
{
WEB3_CONNECTION_SUCCESSFUL
,
WEB3_CONNECTION_UNSUCCESSFUL
,
SET_CURRENT_MASK_ADDRESS
,
METAMASK_LOCKED
,
METAMASK_UNLOCKED
,
SET_INTERACTION_STATE
,
FACTORY_CONTRACT_READY
,
FACTORY_CONTRACT_READY
,
SET_NETWORK_MESSAGE
,
SET_BLOCK_TIMESTAMP
,
SET_EXCHANGE_TYPE
SET_EXCHANGE_TYPE
,
PUT_WEB3_IN_STORE
}
from
'
../constants
'
;
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
)
{
case
WEB3_CONNECTION_SUCCESSFUL
:
return
Object
.
assign
({},
state
,
{
connected
:
connected
});
...
...
@@ -35,6 +36,8 @@ export default (state = {}, action) => {
return
Object
.
assign
({},
state
,
{
blockTimestamp
:
timestamp
});
case
SET_EXCHANGE_TYPE
:
return
Object
.
assign
({},
state
,
{
exchangeType
:
exchangeType
});
case
PUT_WEB3_IN_STORE
:
return
Object
.
assign
({},
state
,
{
globalWeb3
:
globalWeb3
});
default
:
return
state
;
}
}
src/store/initial-state.js
View file @
fbd78a5a
// 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?
// both of these are set to false in the default state
// 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
// both of these are set to false in the default state
// 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
export
default
{
// lets check if metamask is installed
// also, lets assume that we're disconnected initially
// lets check if metamask is installed
// also, lets assume that we're disconnected initially
// we're going to need to include a seperate nest for exchange actions
web3
:
{
web3
Store
:
{
connected
:
false
,
currentMaskAddress
:
''
,
metamaskLocked
:
true
,
...
...
@@ -55,4 +55,4 @@ export default {
rate
:
0
,
fee
:
0
,
}
}
\ No newline at end of file
}
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