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
17eceebc
Unverified
Commit
17eceebc
authored
May 08, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final typescript migration push
parent
6112c8a2
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
140 additions
and
118 deletions
+140
-118
index.tsx
src/components/CurrencyInputPanel/index.tsx
+0
-1
index.tsx
src/components/SearchModal/index.tsx
+64
-50
index.tsx
src/components/TokenLogo/index.tsx
+3
-3
index.tsx
src/components/TxnPopup/index.tsx
+14
-35
Option.tsx
src/components/WalletModal/Option.tsx
+16
-16
PendingView.tsx
src/components/WalletModal/PendingView.tsx
+4
-4
WalletConnectData.tsx
src/components/WalletModal/WalletConnectData.tsx
+7
-2
index.tsx
src/components/WalletModal/index.tsx
+6
-7
useInterval.ts
src/hooks/useInterval.ts
+26
-0
No files found.
src/components/CurrencyInputPanel/index.tsx
View file @
17eceebc
...
@@ -261,7 +261,6 @@ export default function CurrencyInputPanel({
...
@@ -261,7 +261,6 @@ export default function CurrencyInputPanel({
}
}
}
}
filterType=
"tokens"
filterType=
"tokens"
urlAddedTokens=
{
urlAddedTokens
}
urlAddedTokens=
{
urlAddedTokens
}
field=
{
field
}
onTokenSelect=
{
onTokenSelection
}
onTokenSelect=
{
onTokenSelection
}
showSendWithSwap=
{
showSendWithSwap
}
showSendWithSwap=
{
showSendWithSwap
}
hiddenToken=
{
token
?.
address
}
hiddenToken=
{
token
?.
address
}
...
...
src/components/SearchModal/index.
js
→
src/components/SearchModal/index.
tsx
View file @
17eceebc
This diff is collapsed.
Click to expand it.
src/components/TokenLogo/index.
js
→
src/components/TokenLogo/index.
tsx
View file @
17eceebc
...
@@ -12,7 +12,7 @@ const TOKEN_ICON_API = address =>
...
@@ -12,7 +12,7 @@ const TOKEN_ICON_API = address =>
)}
/logo.png`
)}
/logo.png`
const
BAD_IMAGES
=
{}
const
BAD_IMAGES
=
{}
const
Image
=
styled
.
img
`
const
Image
=
styled
.
img
<
{
size
:
string
}
>
`
width:
${({
size
})
=>
size
}
;
width:
${({
size
})
=>
size
}
;
height:
${({
size
})
=>
size
}
;
height:
${({
size
})
=>
size
}
;
background-color: white;
background-color: white;
...
@@ -20,7 +20,7 @@ const Image = styled.img`
...
@@ -20,7 +20,7 @@ const Image = styled.img`
box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.075);
box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.075);
`
`
const
Emoji
=
styled
.
span
`
const
Emoji
=
styled
.
span
<
{
size
?:
string
}
>
`
display: flex;
display: flex;
align-items: center;
align-items: center;
justify-content: center;
justify-content: center;
...
@@ -30,7 +30,7 @@ const Emoji = styled.span`
...
@@ -30,7 +30,7 @@ const Emoji = styled.span`
margin-bottom: -4px;
margin-bottom: -4px;
`
`
const
StyledEthereumLogo
=
styled
(
EthereumLogo
)
`
const
StyledEthereumLogo
=
styled
(
EthereumLogo
)
<
{
size
:
string
}
>
`
width:
${({
size
})
=>
size
}
;
width:
${({
size
})
=>
size
}
;
height:
${({
size
})
=>
size
}
;
height:
${({
size
})
=>
size
}
;
`
`
...
...
src/components/TxnPopup/index.
js
→
src/components/TxnPopup/index.
tsx
View file @
17eceebc
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
Link
}
from
'
../../theme/components
'
import
{
AlertCircle
,
CheckCircle
}
from
'
react-feather
'
import
{
TYPE
}
from
'
../../theme
'
import
{
AutoColumn
}
from
'
../Column
'
import
{
AutoRow
}
from
'
../Row
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
styled
from
'
styled-components
'
import
{
getEtherscanLink
}
from
'
../../utils
'
import
{
usePopups
}
from
'
../../contexts/Application
'
import
{
usePopups
}
from
'
../../contexts/Application
'
import
{
CheckCircle
,
AlertCircle
}
from
'
react-feather
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
useInterval
from
'
../../hooks/useInterval
'
import
{
TYPE
}
from
'
../../theme
'
import
styled
from
'
styled-components
'
import
{
Link
}
from
'
../../theme/components
'
import
{
getEtherscanLink
}
from
'
../../utils
'
import
{
AutoColumn
}
from
'
../Column
'
import
{
AutoRow
}
from
'
../Row
'
const
Fader
=
styled
.
div
`
const
Fader
=
styled
.
div
<
{
count
:
number
}
>
`
position: absolute;
position: absolute;
bottom: 0px;
bottom: 0px;
left: 0px;
left: 0px;
...
@@ -23,28 +24,6 @@ const Fader = styled.div`
...
@@ -23,28 +24,6 @@ const Fader = styled.div`
transition: width 100ms linear;
transition: width 100ms linear;
`
`
function
useInterval
(
callback
,
delay
)
{
const
savedCallback
=
useRef
()
// Remember the latest callback.
useEffect
(()
=>
{
savedCallback
.
current
=
callback
return
()
=>
{}
},
[
callback
])
// Set up the interval.
useEffect
(()
=>
{
function
tick
()
{
savedCallback
.
current
()
}
if
(
delay
!==
null
)
{
let
id
=
setInterval
(
tick
,
delay
)
return
()
=>
clearInterval
(
id
)
}
return
()
=>
{}
},
[
delay
])
}
const
delay
=
100
const
delay
=
100
export
default
function
TxnPopup
({
hash
,
success
,
summary
,
popKey
})
{
export
default
function
TxnPopup
({
hash
,
success
,
summary
,
popKey
})
{
...
@@ -65,9 +44,9 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
...
@@ -65,9 +44,9 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
return
(
return
(
<
AutoRow
onMouseEnter=
{
()
=>
setIsRunning
(
false
)
}
onMouseLeave=
{
()
=>
setIsRunning
(
true
)
}
>
<
AutoRow
onMouseEnter=
{
()
=>
setIsRunning
(
false
)
}
onMouseLeave=
{
()
=>
setIsRunning
(
true
)
}
>
{
success
?
(
{
success
?
(
<
CheckCircle
color
=
{
'
#27AE60
'
}
size
=
{
24
}
style
=
{{
paddingRight
:
'
24px
'
}}
/
>
<
CheckCircle
color=
{
'
#27AE60
'
}
size=
{
24
}
style=
{
{
paddingRight
:
'
24px
'
}
}
/>
)
:
(
)
:
(
<
AlertCircle
color
=
{
'
#FF6871
'
}
size
=
{
24
}
style
=
{{
paddingRight
:
'
24px
'
}}
/
>
<
AlertCircle
color=
{
'
#FF6871
'
}
size=
{
24
}
style=
{
{
paddingRight
:
'
24px
'
}
}
/>
)
}
)
}
<
AutoColumn
gap=
"8px"
>
<
AutoColumn
gap=
"8px"
>
<
TYPE
.
body
fontWeight=
{
500
}
>
<
TYPE
.
body
fontWeight=
{
500
}
>
...
@@ -75,7 +54,7 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
...
@@ -75,7 +54,7 @@ export default function TxnPopup({ hash, success, summary, popKey }) {
</
TYPE
.
body
>
</
TYPE
.
body
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
View on Etherscan
</
Link
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
View on Etherscan
</
Link
>
</
AutoColumn
>
</
AutoColumn
>
<
Fader
count
=
{
count
}
/
>
<
Fader
count=
{
count
}
/>
</
AutoRow
>
</
AutoRow
>
)
)
}
}
src/components/WalletModal/Option.
js
→
src/components/WalletModal/Option.
tsx
View file @
17eceebc
...
@@ -2,7 +2,7 @@ import React from 'react'
...
@@ -2,7 +2,7 @@ import React from 'react'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
Link
}
from
'
../../theme
'
import
{
Link
}
from
'
../../theme
'
const
InfoCard
=
styled
.
button
`
const
InfoCard
=
styled
.
button
<
{
active
?:
boolean
}
>
`
background-color:
${({
theme
,
active
})
=>
(
active
?
theme
.
bg3
:
theme
.
bg2
)}
;
background-color:
${({
theme
,
active
})
=>
(
active
?
theme
.
bg3
:
theme
.
bg2
)}
;
padding: 1rem;
padding: 1rem;
outline: none;
outline: none;
...
@@ -30,7 +30,7 @@ const OptionCardLeft = styled.div`
...
@@ -30,7 +30,7 @@ const OptionCardLeft = styled.div`
height: 100%;
height: 100%;
`
`
const
OptionCardClickable
=
styled
(
OptionCard
)
`
const
OptionCardClickable
=
styled
(
OptionCard
)
<
{
clickable
?:
boolean
}
>
`
margin-top: 0;
margin-top: 0;
&:hover {
&:hover {
cursor:
${({
clickable
})
=>
(
clickable
?
'
pointer
'
:
''
)}
;
cursor:
${({
clickable
})
=>
(
clickable
?
'
pointer
'
:
''
)}
;
...
@@ -73,7 +73,7 @@ const SubHeader = styled.div`
...
@@ -73,7 +73,7 @@ const SubHeader = styled.div`
font-size: 12px;
font-size: 12px;
`
`
const
IconWrapper
=
styled
.
div
`
const
IconWrapper
=
styled
.
div
<
{
size
?:
number
}
>
`
${({
theme
})
=>
theme
.
flexColumnNoWrap
}
;
${({
theme
})
=>
theme
.
flexColumnNoWrap
}
;
align-items: center;
align-items: center;
justify-content: center;
justify-content: center;
...
@@ -88,16 +88,16 @@ const IconWrapper = styled.div`
...
@@ -88,16 +88,16 @@ const IconWrapper = styled.div`
`
`
export
default
function
Option
({
export
default
function
Option
({
link
=
null
,
link
=
null
,
clickable
=
true
,
clickable
=
true
,
size
=
null
,
size
=
null
,
onClick
=
null
,
onClick
=
null
,
color
,
color
,
header
,
header
,
subheader
=
null
,
subheader
=
null
,
icon
,
icon
,
active
=
false
active
=
false
})
{
})
{
const
content
=
(
const
content
=
(
<
OptionCardClickable
onClick=
{
onClick
}
clickable=
{
clickable
&&
!
active
}
active=
{
active
}
>
<
OptionCardClickable
onClick=
{
onClick
}
clickable=
{
clickable
&&
!
active
}
active=
{
active
}
>
<
OptionCardLeft
>
<
OptionCardLeft
>
...
@@ -106,7 +106,7 @@ export default function Option({
...
@@ -106,7 +106,7 @@ export default function Option({
{
active
?
(
{
active
?
(
<
CircleWrapper
>
<
CircleWrapper
>
<
GreenCircle
>
<
GreenCircle
>
<
div
/>
<
div
/>
</
GreenCircle
>
</
GreenCircle
>
</
CircleWrapper
>
</
CircleWrapper
>
)
:
(
)
:
(
...
@@ -116,8 +116,8 @@ export default function Option({
...
@@ -116,8 +116,8 @@ export default function Option({
</
HeaderText
>
</
HeaderText
>
{
subheader
&&
<
SubHeader
>
{
subheader
}
</
SubHeader
>
}
{
subheader
&&
<
SubHeader
>
{
subheader
}
</
SubHeader
>
}
</
OptionCardLeft
>
</
OptionCardLeft
>
<
IconWrapper
size
=
{
size
}
active
=
{
active
}
>
<
IconWrapper
size=
{
size
}
>
<
img
src
=
{
icon
}
alt
=
{
'
Icon
'
}
/
>
<
img
src=
{
icon
}
alt=
{
'
Icon
'
}
/>
</
IconWrapper
>
</
IconWrapper
>
</
OptionCardClickable
>
</
OptionCardClickable
>
)
)
...
...
src/components/WalletModal/PendingView.
js
→
src/components/WalletModal/PendingView.
tsx
View file @
17eceebc
...
@@ -28,7 +28,7 @@ const SpinnerWrapper = styled(Spinner)`
...
@@ -28,7 +28,7 @@ const SpinnerWrapper = styled(Spinner)`
}
}
`
`
const
LoadingMessage
=
styled
.
div
`
const
LoadingMessage
=
styled
.
div
<
{
error
?:
boolean
}
>
`
${({
theme
})
=>
theme
.
flexRowNoWrap
}
;
${({
theme
})
=>
theme
.
flexRowNoWrap
}
;
align-items: center;
align-items: center;
justify-content: flex-start;
justify-content: flex-start;
...
@@ -71,14 +71,14 @@ const LoadingWrapper = styled.div`
...
@@ -71,14 +71,14 @@ const LoadingWrapper = styled.div`
`
`
export
default
function
PendingView
({
uri
=
''
,
size
,
connector
,
error
=
false
,
setPendingError
,
tryActivation
})
{
export
default
function
PendingView
({
uri
=
''
,
size
,
connector
,
error
=
false
,
setPendingError
,
tryActivation
})
{
const
isMetamask
=
window
.
ethereum
&&
window
.
ethereum
.
isMetaMask
const
isMetamask
=
(
window
as
any
).
ethereum
&&
(
window
as
any
)
.
ethereum
.
isMetaMask
return
(
return
(
<
PendingSection
>
<
PendingSection
>
{
!
error
&&
connector
===
walletconnect
&&
<
WalletConnectData
size
=
{
size
}
uri
=
{
uri
}
/>
}
{
!
error
&&
connector
===
walletconnect
&&
<
WalletConnectData
size=
{
size
}
uri=
{
uri
}
/>
}
<
LoadingMessage
error=
{
error
}
>
<
LoadingMessage
error=
{
error
}
>
<
LoadingWrapper
>
<
LoadingWrapper
>
{
!
error
&&
<
SpinnerWrapper
src
=
{
Circle
}
/>
}
{
!
error
&&
<
SpinnerWrapper
src=
{
Circle
}
/>
}
{
error
?
(
{
error
?
(
<
ErrorGroup
>
<
ErrorGroup
>
<
div
>
Error connecting.
</
div
>
<
div
>
Error connecting.
</
div
>
...
...
src/components/WalletModal/WalletConnectData.
js
→
src/components/WalletModal/WalletConnectData.
tsx
View file @
17eceebc
...
@@ -11,12 +11,17 @@ const QRCodeWrapper = styled.div`
...
@@ -11,12 +11,17 @@ const QRCodeWrapper = styled.div`
margin-bottom: 20px;
margin-bottom: 20px;
`
`
export
default
function
WalletConnectData
({
uri
=
''
,
size
})
{
interface
WalletConnectDataProps
{
uri
?:
string
size
:
number
}
export
default
function
WalletConnectData
({
uri
=
''
,
size
}:
WalletConnectDataProps
)
{
const
[
isDark
]
=
useDarkModeManager
()
const
[
isDark
]
=
useDarkModeManager
()
return
(
return
(
<
QRCodeWrapper
>
<
QRCodeWrapper
>
{
uri
&&
(
{
uri
&&
(
<
QRCode
size
=
{
size
}
value
=
{
uri
}
bgColor
=
{
isDark
?
'
#333639
'
:
'
white
'
}
fgColor
=
{
isDark
?
'
white
'
:
'
black
'
}
/
>
<
QRCode
size=
{
size
}
value=
{
uri
}
bgColor=
{
isDark
?
'
#333639
'
:
'
white
'
}
fgColor=
{
isDark
?
'
white
'
:
'
black
'
}
/>
)
}
)
}
</
QRCodeWrapper
>
</
QRCodeWrapper
>
)
)
...
...
src/components/WalletModal/index.
js
→
src/components/WalletModal/index.
tsx
View file @
17eceebc
...
@@ -122,7 +122,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -122,7 +122,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
const
[
pendingWallet
,
setPendingWallet
]
=
useState
()
const
[
pendingWallet
,
setPendingWallet
]
=
useState
()
const
[
pendingError
,
setPendingError
]
=
useState
()
const
[
pendingError
,
setPendingError
]
=
useState
<
boolean
>
()
const
walletModalOpen
=
useWalletModalOpen
()
const
walletModalOpen
=
useWalletModalOpen
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
toggleWalletModal
=
useWalletModalToggle
()
...
@@ -200,7 +200,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -200,7 +200,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
// get wallets user can switch too, depending on device/browser
// get wallets user can switch too, depending on device/browser
function
getOptions
()
{
function
getOptions
()
{
const
isMetamask
=
window
.
ethereum
&&
window
.
ethereum
.
isMetaMask
const
isMetamask
=
(
window
as
any
).
ethereum
&&
(
window
as
any
)
.
ethereum
.
isMetaMask
return
Object
.
keys
(
SUPPORTED_WALLETS
).
map
(
key
=>
{
return
Object
.
keys
(
SUPPORTED_WALLETS
).
map
(
key
=>
{
const
option
=
SUPPORTED_WALLETS
[
key
]
const
option
=
SUPPORTED_WALLETS
[
key
]
// check for mobile options
// check for mobile options
...
@@ -210,7 +210,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -210,7 +210,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return
null
return
null
}
}
if
(
!
window
.
web3
&&
!
window
.
ethereum
&&
option
.
mobile
)
{
if
(
!
(
window
as
any
).
web3
&&
!
(
window
as
any
)
.
ethereum
&&
option
.
mobile
)
{
return
(
return
(
<
Option
<
Option
onClick=
{
()
=>
{
onClick=
{
()
=>
{
...
@@ -232,7 +232,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -232,7 +232,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
// overwrite injected when needed
// overwrite injected when needed
if
(
option
.
connector
===
injected
)
{
if
(
option
.
connector
===
injected
)
{
// don't show injected if there's no injected provider
// don't show injected if there's no injected provider
if
(
!
(
window
.
web3
||
window
.
ethereum
))
{
if
(
!
(
(
window
as
any
).
web3
||
(
window
as
any
)
.
ethereum
))
{
if
(
option
.
name
===
'
MetaMask
'
)
{
if
(
option
.
name
===
'
MetaMask
'
)
{
return
(
return
(
<
Option
<
Option
...
@@ -286,7 +286,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -286,7 +286,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return
(
return
(
<
UpperSection
>
<
UpperSection
>
<
CloseIcon
onClick=
{
toggleWalletModal
}
>
<
CloseIcon
onClick=
{
toggleWalletModal
}
>
<
CloseColor
alt
=
{
'
close icon
'
}
/
>
<
CloseColor
/>
</
CloseIcon
>
</
CloseIcon
>
<
HeaderRow
>
{
error
instanceof
UnsupportedChainIdError
?
'
Wrong Network
'
:
'
Error connecting
'
}
</
HeaderRow
>
<
HeaderRow
>
{
error
instanceof
UnsupportedChainIdError
?
'
Wrong Network
'
:
'
Error connecting
'
}
</
HeaderRow
>
<
ContentWrapper
>
<
ContentWrapper
>
...
@@ -313,7 +313,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -313,7 +313,7 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return
(
return
(
<
UpperSection
>
<
UpperSection
>
<
CloseIcon
onClick=
{
toggleWalletModal
}
>
<
CloseIcon
onClick=
{
toggleWalletModal
}
>
<
CloseColor
alt
=
{
'
close icon
'
}
/
>
<
CloseColor
/>
</
CloseIcon
>
</
CloseIcon
>
{
walletView
!==
WALLET_VIEWS
.
ACCOUNT
?
(
{
walletView
!==
WALLET_VIEWS
.
ACCOUNT
?
(
<
HeaderRow
color=
"blue"
>
<
HeaderRow
color=
"blue"
>
...
@@ -359,7 +359,6 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -359,7 +359,6 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
return
(
return
(
<
Modal
<
Modal
style
=
{{
userSelect
:
'
none
'
}}
isOpen=
{
walletModalOpen
}
isOpen=
{
walletModalOpen
}
onDismiss=
{
toggleWalletModal
}
onDismiss=
{
toggleWalletModal
}
minHeight=
{
null
}
minHeight=
{
null
}
...
...
src/hooks/useInterval.ts
0 → 100644
View file @
17eceebc
import
{
useEffect
,
useRef
}
from
'
react
'
export
default
function
useInterval
(
callback
:
()
=>
void
,
delay
:
null
|
number
)
{
const
savedCallback
=
useRef
<
()
=>
void
>
()
// Remember the latest callback.
useEffect
(()
=>
{
savedCallback
.
current
=
callback
return
()
=>
{
}
},
[
callback
])
// Set up the interval.
useEffect
(()
=>
{
function
tick
()
{
savedCallback
.
current
()
}
if
(
delay
!==
null
)
{
let
id
=
setInterval
(
tick
,
delay
)
return
()
=>
clearInterval
(
id
)
}
return
()
=>
{
}
},
[
delay
])
}
\ 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