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
aac7268d
Unverified
Commit
aac7268d
authored
Jun 15, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just drop the git commit hash (more trouble than it's worth)
parent
fd162a72
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
23 deletions
+45
-23
package.json
package.json
+1
-1
index.tsx
src/components/Menu/index.tsx
+1
-3
reducer.test.ts
src/state/user/reducer.test.ts
+29
-0
reducer.ts
src/state/user/reducer.ts
+14
-19
No files found.
package.json
View file @
aac7268d
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
},
},
"scripts"
:
{
"scripts"
:
{
"start"
:
"react-scripts start"
,
"start"
:
"react-scripts start"
,
"build"
:
"
cross-env REACT_APP_GIT_COMMIT_HASH=$(git show -s --format=%H)
react-scripts build"
,
"build"
:
"react-scripts build"
,
"ipfs-build"
:
"cross-env PUBLIC_URL=
\"
.
\"
react-scripts build"
,
"ipfs-build"
:
"cross-env PUBLIC_URL=
\"
.
\"
react-scripts build"
,
"test"
:
"react-scripts test --env=jsdom"
,
"test"
:
"react-scripts test --env=jsdom"
,
"eject"
:
"react-scripts eject"
,
"eject"
:
"react-scripts eject"
,
...
...
src/components/Menu/index.tsx
View file @
aac7268d
...
@@ -77,9 +77,7 @@ const MenuItem = styled(ExternalLink)`
...
@@ -77,9 +77,7 @@ const MenuItem = styled(ExternalLink)`
}
}
`
`
const
CODE_LINK
=
!!
process
.
env
.
REACT_APP_GIT_COMMIT_HASH
const
CODE_LINK
=
'
https://github.com/Uniswap/uniswap-frontend
'
?
`https://github.com/Uniswap/uniswap-frontend/tree/
${
process
.
env
.
REACT_APP_GIT_COMMIT_HASH
}
`
:
'
https://github.com/Uniswap/uniswap-frontend
'
export
default
function
Menu
()
{
export
default
function
Menu
()
{
const
node
=
useRef
<
HTMLDivElement
>
()
const
node
=
useRef
<
HTMLDivElement
>
()
...
...
src/state/user/reducer.test.ts
0 → 100644
View file @
aac7268d
import
{
createStore
,
Store
}
from
'
redux
'
import
{
DEFAULT_DEADLINE_FROM_NOW
,
INITIAL_ALLOWED_SLIPPAGE
}
from
'
../../constants
'
import
{
updateVersion
}
from
'
./actions
'
import
reducer
,
{
initialState
,
UserState
}
from
'
./reducer
'
describe
(
'
swap reducer
'
,
()
=>
{
let
store
:
Store
<
UserState
>
beforeEach
(()
=>
{
store
=
createStore
(
reducer
,
initialState
)
})
describe
(
'
updateVersion
'
,
()
=>
{
it
(
'
has no timestamp originally
'
,
()
=>
{
expect
(
store
.
getState
().
lastUpdateVersionTimestamp
).
toBeUndefined
()
})
it
(
'
sets the lastUpdateVersionTimestamp
'
,
()
=>
{
const
time
=
new
Date
().
getTime
()
store
.
dispatch
(
updateVersion
())
expect
(
store
.
getState
().
lastUpdateVersionTimestamp
).
toBeGreaterThanOrEqual
(
time
)
})
it
(
'
sets allowed slippage and deadline
'
,
()
=>
{
store
=
createStore
(
reducer
,
{
...
initialState
,
userDeadline
:
undefined
,
userSlippageTolerance
:
undefined
})
store
.
dispatch
(
updateVersion
())
expect
(
store
.
getState
().
userDeadline
).
toEqual
(
DEFAULT_DEADLINE_FROM_NOW
)
expect
(
store
.
getState
().
userSlippageTolerance
).
toEqual
(
INITIAL_ALLOWED_SLIPPAGE
)
})
})
})
src/state/user/reducer.ts
View file @
aac7268d
import
{
INITIAL_ALLOWED_SLIPPAGE
,
DEFAULT_DEADLINE_FROM_NOW
}
from
'
.
/../../constants/index
'
import
{
INITIAL_ALLOWED_SLIPPAGE
,
DEFAULT_DEADLINE_FROM_NOW
}
from
'
.
./../constants
'
import
{
createReducer
}
from
'
@reduxjs/toolkit
'
import
{
createReducer
}
from
'
@reduxjs/toolkit
'
import
{
import
{
addSerializedPair
,
addSerializedPair
,
...
@@ -18,8 +18,9 @@ import {
...
@@ -18,8 +18,9 @@ import {
const
currentTimestamp
=
()
=>
new
Date
().
getTime
()
const
currentTimestamp
=
()
=>
new
Date
().
getTime
()
interface
UserState
{
export
interface
UserState
{
lastVersion
:
string
// the timestamp of the last updateVersion action
lastUpdateVersionTimestamp
?:
number
userDarkMode
:
boolean
|
null
// the user's choice for dark mode or light mode
userDarkMode
:
boolean
|
null
// the user's choice for dark mode or light mode
matchesDarkMode
:
boolean
// whether the dark mode media query matches
matchesDarkMode
:
boolean
// whether the dark mode media query matches
...
@@ -59,8 +60,7 @@ function pairKey(token0Address: string, token1Address: string) {
...
@@ -59,8 +60,7 @@ function pairKey(token0Address: string, token1Address: string) {
return
`
${
token0Address
}
;
${
token1Address
}
`
return
`
${
token0Address
}
;
${
token1Address
}
`
}
}
const
initialState
:
UserState
=
{
export
const
initialState
:
UserState
=
{
lastVersion
:
''
,
userDarkMode
:
null
,
userDarkMode
:
null
,
matchesDarkMode
:
false
,
matchesDarkMode
:
false
,
userExpertMode
:
false
,
userExpertMode
:
false
,
...
@@ -71,14 +71,9 @@ const initialState: UserState = {
...
@@ -71,14 +71,9 @@ const initialState: UserState = {
timestamp
:
currentTimestamp
()
timestamp
:
currentTimestamp
()
}
}
const
GIT_COMMIT_HASH
:
string
|
undefined
=
process
.
env
.
REACT_APP_GIT_COMMIT_HASH
export
default
createReducer
(
initialState
,
builder
=>
export
default
createReducer
(
initialState
,
builder
=>
builder
builder
.
addCase
(
updateVersion
,
state
=>
{
.
addCase
(
updateVersion
,
state
=>
{
if
(
GIT_COMMIT_HASH
&&
state
.
lastVersion
!==
GIT_COMMIT_HASH
)
{
state
.
lastVersion
=
GIT_COMMIT_HASH
// slippage isnt being tracked in local storage, reset to default
// slippage isnt being tracked in local storage, reset to default
if
(
typeof
state
.
userSlippageTolerance
!==
'
number
'
)
{
if
(
typeof
state
.
userSlippageTolerance
!==
'
number
'
)
{
state
.
userSlippageTolerance
=
INITIAL_ALLOWED_SLIPPAGE
state
.
userSlippageTolerance
=
INITIAL_ALLOWED_SLIPPAGE
...
@@ -88,8 +83,8 @@ export default createReducer(initialState, builder =>
...
@@ -88,8 +83,8 @@ export default createReducer(initialState, builder =>
if
(
typeof
state
.
userDeadline
!==
'
number
'
)
{
if
(
typeof
state
.
userDeadline
!==
'
number
'
)
{
state
.
userDeadline
=
DEFAULT_DEADLINE_FROM_NOW
state
.
userDeadline
=
DEFAULT_DEADLINE_FROM_NOW
}
}
}
state
.
t
imestamp
=
currentTimestamp
()
state
.
lastUpdateVersionT
imestamp
=
currentTimestamp
()
})
})
.
addCase
(
updateUserDarkMode
,
(
state
,
action
)
=>
{
.
addCase
(
updateUserDarkMode
,
(
state
,
action
)
=>
{
state
.
userDarkMode
=
action
.
payload
.
userDarkMode
state
.
userDarkMode
=
action
.
payload
.
userDarkMode
...
...
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