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
66a20062
Unverified
Commit
66a20062
authored
Aug 27, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more strictness everywhere, fix a pair pricing issue in mint/hooks.ts
parent
610b7f44
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
116 additions
and
105 deletions
+116
-105
index.tsx
src/components/AccountDetails/index.tsx
+1
-0
index.tsx
src/components/AddressInputPanel/index.tsx
+0
-5
PopupItem.tsx
src/components/Popups/PopupItem.tsx
+1
-1
index.tsx
src/components/Web3Status/index.tsx
+81
-66
index.ts
src/hooks/index.ts
+1
-1
useCopyClipboard.ts
src/hooks/useCopyClipboard.ts
+1
-1
useInterval.ts
src/hooks/useInterval.ts
+1
-1
useIsWindowVisible.ts
src/hooks/useIsWindowVisible.ts
+1
-1
updater.ts
src/state/application/updater.ts
+1
-1
hooks.ts
src/state/mint/hooks.ts
+9
-9
hooks.ts
src/state/multicall/hooks.ts
+3
-2
hooks.ts
src/state/swap/hooks.ts
+2
-2
hooks.ts
src/state/wallet/hooks.ts
+3
-3
maxAmountSpend.ts
src/utils/maxAmountSpend.ts
+1
-1
parseENSAddress.ts
src/utils/parseENSAddress.ts
+1
-1
useUSDCPrice.ts
src/utils/useUSDCPrice.ts
+2
-2
tsconfig.json
tsconfig.json
+6
-3
tsconfig.strict.json
tsconfig.strict.json
+1
-5
No files found.
src/components/AccountDetails/index.tsx
View file @
66a20062
...
@@ -282,6 +282,7 @@ export default function AccountDetails({
...
@@ -282,6 +282,7 @@ export default function AccountDetails({
</>
</>
)
)
}
}
return
null
}
}
const
clearAllTransactionsCallback
=
useCallback
(
const
clearAllTransactionsCallback
=
useCallback
(
...
...
src/components/AddressInputPanel/index.tsx
View file @
66a20062
...
@@ -65,11 +65,6 @@ const Input = styled.input<{ error?: boolean }>`
...
@@ -65,11 +65,6 @@ const Input = styled.input<{ error?: boolean }>`
}
}
`
`
interface
Value
{
address
:
string
name
?:
string
}
export
default
function
AddressInputPanel
({
export
default
function
AddressInputPanel
({
id
,
id
,
value
,
value
,
...
...
src/components/Popups/PopupItem.tsx
View file @
66a20062
...
@@ -55,7 +55,7 @@ export default function PopupItem({
...
@@ -55,7 +55,7 @@ export default function PopupItem({
const
removePopup
=
useRemovePopup
()
const
removePopup
=
useRemovePopup
()
const
removeThisPopup
=
useCallback
(()
=>
removePopup
(
popKey
),
[
popKey
,
removePopup
])
const
removeThisPopup
=
useCallback
(()
=>
removePopup
(
popKey
),
[
popKey
,
removePopup
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
removeAfterMs
===
null
)
return
if
(
removeAfterMs
===
null
)
return
undefined
const
timeout
=
setTimeout
(()
=>
{
const
timeout
=
setTimeout
(()
=>
{
removeThisPopup
()
removeThisPopup
()
...
...
src/components/Web3Status/index.tsx
View file @
66a20062
import
React
,
{
useMemo
}
from
'
react
'
import
React
,
{
useMemo
}
from
'
react
'
import
{
AbstractConnector
}
from
'
@web3-react/abstract-connector
'
import
styled
,
{
css
}
from
'
styled-components
'
import
styled
,
{
css
}
from
'
styled-components
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useWeb3React
,
UnsupportedChainIdError
}
from
'
@web3-react/core
'
import
{
useWeb3React
,
UnsupportedChainIdError
}
from
'
@web3-react/core
'
...
@@ -132,10 +133,41 @@ const SOCK = (
...
@@ -132,10 +133,41 @@ const SOCK = (
</
span
>
</
span
>
)
)
export
default
function
Web3Status
()
{
// eslint-disable-next-line react/prop-types
function
StatusIcon
({
connector
}:
{
connector
:
AbstractConnector
})
{
if
(
connector
===
injected
)
{
return
<
Identicon
/>
}
else
if
(
connector
===
walletconnect
)
{
return
(
<
IconWrapper
size=
{
16
}
>
<
img
src=
{
WalletConnectIcon
}
alt=
{
''
}
/>
</
IconWrapper
>
)
}
else
if
(
connector
===
walletlink
)
{
return
(
<
IconWrapper
size=
{
16
}
>
<
img
src=
{
CoinbaseWalletIcon
}
alt=
{
''
}
/>
</
IconWrapper
>
)
}
else
if
(
connector
===
fortmatic
)
{
return
(
<
IconWrapper
size=
{
16
}
>
<
img
src=
{
FortmaticIcon
}
alt=
{
''
}
/>
</
IconWrapper
>
)
}
else
if
(
connector
===
portis
)
{
return
(
<
IconWrapper
size=
{
16
}
>
<
img
src=
{
PortisIcon
}
alt=
{
''
}
/>
</
IconWrapper
>
)
}
return
null
}
function
Web3StatusInner
()
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
active
,
account
,
connector
,
error
}
=
useWeb3React
()
const
{
account
,
connector
,
error
}
=
useWeb3React
()
const
contextNetwork
=
useWeb3React
(
NetworkContextName
)
const
{
ENSName
}
=
useENSName
(
account
)
const
{
ENSName
}
=
useENSName
(
account
)
...
@@ -147,75 +179,58 @@ export default function Web3Status() {
...
@@ -147,75 +179,58 @@ export default function Web3Status() {
},
[
allTransactions
])
},
[
allTransactions
])
const
pending
=
sortedRecentTransactions
.
filter
(
tx
=>
!
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
const
pending
=
sortedRecentTransactions
.
filter
(
tx
=>
!
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
const
confirmed
=
sortedRecentTransactions
.
filter
(
tx
=>
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
const
hasPendingTransactions
=
!!
pending
.
length
const
hasPendingTransactions
=
!!
pending
.
length
const
hasSocks
=
useHasSocks
()
const
hasSocks
=
useHasSocks
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
toggleWalletModal
=
useWalletModalToggle
()
// handle the logo we want to show with the account
if
(
account
)
{
function
getStatusIcon
()
{
return
(
if
(
connector
===
injected
)
{
<
Web3StatusConnected
id=
"web3-status-connected"
onClick=
{
toggleWalletModal
}
pending=
{
hasPendingTransactions
}
>
return
<
Identicon
/>
{
hasPendingTransactions
?
(
}
else
if
(
connector
===
walletconnect
)
{
<
RowBetween
>
return
(
<
Text
>
{
pending
?.
length
}
Pending
</
Text
>
<
Loader
stroke=
"white"
/>
<
IconWrapper
size=
{
16
}
>
</
RowBetween
>
<
img
src=
{
WalletConnectIcon
}
alt=
{
''
}
/>
)
:
(
</
IconWrapper
>
<
>
)
{
hasSocks
?
SOCK
:
null
}
}
else
if
(
connector
===
walletlink
)
{
<
Text
>
{
ENSName
||
shortenAddress
(
account
)
}
</
Text
>
return
(
</>
<
IconWrapper
size=
{
16
}
>
)
}
<
img
src=
{
CoinbaseWalletIcon
}
alt=
{
''
}
/>
{
!
hasPendingTransactions
&&
<
StatusIcon
connector=
{
connector
}
/>
}
</
IconWrapper
>
</
Web3StatusConnected
>
)
)
}
else
if
(
connector
===
fortmatic
)
{
}
else
if
(
error
)
{
return
(
return
(
<
IconWrapper
size=
{
16
}
>
<
Web3StatusError
onClick=
{
toggleWalletModal
}
>
<
img
src=
{
FortmaticIcon
}
alt=
{
''
}
/>
<
NetworkIcon
/>
<
/
IconWrapper
>
<
Text
>
{
error
instanceof
UnsupportedChainIdError
?
'
Wrong Network
'
:
'
Error
'
}
</
Text
>
)
</
Web3StatusError
>
}
else
if
(
connector
===
portis
)
{
)
return
(
}
else
{
<
IconWrapper
size=
{
16
}
>
return
(
<
img
src=
{
PortisIcon
}
alt=
{
''
}
/
>
<
Web3StatusConnect
id=
"connect-wallet"
onClick=
{
toggleWalletModal
}
faded=
{
!
account
}
>
<
/
IconWrapper
>
<
Text
>
{
t
(
'
Connect to a wallet
'
)
}
</
Text
>
)
</
Web3StatusConnect
>
}
)
}
}
}
function
getWeb3Status
()
{
export
default
function
Web3Status
()
{
if
(
account
)
{
const
{
active
,
account
}
=
useWeb3React
()
return
(
const
contextNetwork
=
useWeb3React
(
NetworkContextName
)
<
Web3StatusConnected
id=
"web3-status-connected"
onClick=
{
toggleWalletModal
}
pending=
{
hasPendingTransactions
}
>
{
hasPendingTransactions
?
(
const
{
ENSName
}
=
useENSName
(
account
)
<
RowBetween
>
<
Text
>
{
pending
?.
length
}
Pending
</
Text
>
<
Loader
stroke=
"white"
/>
const
allTransactions
=
useAllTransactions
()
</
RowBetween
>
)
:
(
const
sortedRecentTransactions
=
useMemo
(()
=>
{
<>
const
txs
=
Object
.
values
(
allTransactions
)
{
hasSocks
?
SOCK
:
null
}
return
txs
.
filter
(
recentTransactionsOnly
).
sort
(
newTranscationsFirst
)
<
Text
>
{
ENSName
||
shortenAddress
(
account
)
}
</
Text
>
},
[
allTransactions
])
</>
)
}
const
pending
=
sortedRecentTransactions
.
filter
(
tx
=>
!
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
{
!
hasPendingTransactions
&&
getStatusIcon
()
}
const
confirmed
=
sortedRecentTransactions
.
filter
(
tx
=>
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
</
Web3StatusConnected
>
)
}
else
if
(
error
)
{
return
(
<
Web3StatusError
onClick=
{
toggleWalletModal
}
>
<
NetworkIcon
/>
<
Text
>
{
error
instanceof
UnsupportedChainIdError
?
'
Wrong Network
'
:
'
Error
'
}
</
Text
>
</
Web3StatusError
>
)
}
else
{
return
(
<
Web3StatusConnect
id=
"connect-wallet"
onClick=
{
toggleWalletModal
}
faded=
{
!
account
}
>
<
Text
>
{
t
(
'
Connect to a wallet
'
)
}
</
Text
>
</
Web3StatusConnect
>
)
}
}
if
(
!
contextNetwork
.
active
&&
!
active
)
{
if
(
!
contextNetwork
.
active
&&
!
active
)
{
return
null
return
null
...
@@ -223,7 +238,7 @@ export default function Web3Status() {
...
@@ -223,7 +238,7 @@ export default function Web3Status() {
return
(
return
(
<>
<>
{
getWeb3Status
()
}
<
Web3StatusInner
/>
<
WalletModal
ENSName=
{
ENSName
}
pendingTransactions=
{
pending
}
confirmedTransactions=
{
confirmed
}
/>
<
WalletModal
ENSName=
{
ENSName
}
pendingTransactions=
{
pending
}
confirmedTransactions=
{
confirmed
}
/>
</>
</>
)
)
...
...
src/hooks/index.ts
View file @
66a20062
...
@@ -82,6 +82,6 @@ export function useInactiveListener(suppress = false) {
...
@@ -82,6 +82,6 @@ export function useInactiveListener(suppress = false) {
}
}
}
}
}
}
return
return
undefined
},
[
active
,
error
,
suppress
,
activate
])
},
[
active
,
error
,
suppress
,
activate
])
}
}
src/hooks/useCopyClipboard.ts
View file @
66a20062
...
@@ -19,7 +19,7 @@ export default function useCopyClipboard(timeout = 500): [boolean, (toCopy: stri
...
@@ -19,7 +19,7 @@ export default function useCopyClipboard(timeout = 500): [boolean, (toCopy: stri
clearTimeout
(
hide
)
clearTimeout
(
hide
)
}
}
}
}
return
return
undefined
},
[
isCopied
,
setIsCopied
,
timeout
])
},
[
isCopied
,
setIsCopied
,
timeout
])
return
[
isCopied
,
staticCopy
]
return
[
isCopied
,
staticCopy
]
...
...
src/hooks/useInterval.ts
View file @
66a20062
...
@@ -20,6 +20,6 @@ export default function useInterval(callback: () => void, delay: null | number,
...
@@ -20,6 +20,6 @@ export default function useInterval(callback: () => void, delay: null | number,
const
id
=
setInterval
(
tick
,
delay
)
const
id
=
setInterval
(
tick
,
delay
)
return
()
=>
clearInterval
(
id
)
return
()
=>
clearInterval
(
id
)
}
}
return
return
undefined
},
[
delay
,
leading
])
},
[
delay
,
leading
])
}
}
src/hooks/useIsWindowVisible.ts
View file @
66a20062
...
@@ -16,7 +16,7 @@ export default function useIsWindowVisible(): boolean {
...
@@ -16,7 +16,7 @@ export default function useIsWindowVisible(): boolean {
},
[
setFocused
])
},
[
setFocused
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
VISIBILITY_STATE_SUPPORTED
)
return
if
(
!
VISIBILITY_STATE_SUPPORTED
)
return
undefined
document
.
addEventListener
(
'
visibilitychange
'
,
listener
)
document
.
addEventListener
(
'
visibilitychange
'
,
listener
)
return
()
=>
{
return
()
=>
{
...
...
src/state/application/updater.ts
View file @
66a20062
...
@@ -31,7 +31,7 @@ export default function Updater() {
...
@@ -31,7 +31,7 @@ export default function Updater() {
// attach/detach listeners
// attach/detach listeners
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
library
||
!
chainId
||
!
windowVisible
)
return
if
(
!
library
||
!
chainId
||
!
windowVisible
)
return
undefined
setState
({
chainId
,
blockNumber
:
null
})
setState
({
chainId
,
blockNumber
:
null
})
...
...
src/state/mint/hooks.ts
View file @
66a20062
...
@@ -72,7 +72,7 @@ export function useDerivedMintInfo(
...
@@ -72,7 +72,7 @@ export function useDerivedMintInfo(
if
(
otherTypedValue
&&
currencies
[
dependentField
])
{
if
(
otherTypedValue
&&
currencies
[
dependentField
])
{
return
tryParseAmount
(
otherTypedValue
,
currencies
[
dependentField
])
return
tryParseAmount
(
otherTypedValue
,
currencies
[
dependentField
])
}
}
return
return
undefined
}
else
if
(
independentAmount
)
{
}
else
if
(
independentAmount
)
{
// we wrap the currencies just to get the price in terms of the other token
// we wrap the currencies just to get the price in terms of the other token
const
wrappedIndependentAmount
=
wrappedCurrencyAmount
(
independentAmount
,
chainId
)
const
wrappedIndependentAmount
=
wrappedCurrencyAmount
(
independentAmount
,
chainId
)
...
@@ -85,9 +85,9 @@ export function useDerivedMintInfo(
...
@@ -85,9 +85,9 @@ export function useDerivedMintInfo(
:
pair
.
priceOf
(
tokenB
).
quote
(
wrappedIndependentAmount
)
:
pair
.
priceOf
(
tokenB
).
quote
(
wrappedIndependentAmount
)
return
dependentCurrency
===
ETHER
?
CurrencyAmount
.
ether
(
dependentTokenAmount
.
raw
)
:
dependentTokenAmount
return
dependentCurrency
===
ETHER
?
CurrencyAmount
.
ether
(
dependentTokenAmount
.
raw
)
:
dependentTokenAmount
}
}
return
return
undefined
}
else
{
}
else
{
return
return
undefined
}
}
},
[
noLiquidity
,
otherTypedValue
,
currencies
,
dependentField
,
independentAmount
,
currencyA
,
chainId
,
currencyB
,
pair
])
},
[
noLiquidity
,
otherTypedValue
,
currencies
,
dependentField
,
independentAmount
,
currencyA
,
chainId
,
currencyB
,
pair
])
const
parsedAmounts
:
{
[
field
in
Field
]:
CurrencyAmount
|
undefined
}
=
{
const
parsedAmounts
:
{
[
field
in
Field
]:
CurrencyAmount
|
undefined
}
=
{
...
@@ -95,18 +95,18 @@ export function useDerivedMintInfo(
...
@@ -95,18 +95,18 @@ export function useDerivedMintInfo(
[
Field
.
CURRENCY_B
]:
independentField
===
Field
.
CURRENCY_A
?
dependentAmount
:
independentAmount
[
Field
.
CURRENCY_B
]:
independentField
===
Field
.
CURRENCY_A
?
dependentAmount
:
independentAmount
}
}
const
token0Price
=
pair
?.
token0Price
const
price
=
useMemo
(()
=>
{
const
price
=
useMemo
(()
=>
{
if
(
noLiquidity
)
{
if
(
noLiquidity
)
{
const
{
[
Field
.
CURRENCY_A
]:
currencyAAmount
,
[
Field
.
CURRENCY_B
]:
currencyBAmount
}
=
parsedAmounts
const
{
[
Field
.
CURRENCY_A
]:
currencyAAmount
,
[
Field
.
CURRENCY_B
]:
currencyBAmount
}
=
parsedAmounts
if
(
currencyAAmount
&&
currencyBAmount
)
{
if
(
currencyAAmount
&&
currencyBAmount
)
{
return
new
Price
(
currencyAAmount
.
currency
,
currencyBAmount
.
currency
,
currencyAAmount
.
raw
,
currencyBAmount
.
raw
)
return
new
Price
(
currencyAAmount
.
currency
,
currencyBAmount
.
currency
,
currencyAAmount
.
raw
,
currencyBAmount
.
raw
)
}
}
return
return
undefined
}
else
{
}
else
{
return
token0Price
const
wrappedCurrencyA
=
wrappedCurrency
(
currencyA
,
chainId
)
return
pair
&&
wrappedCurrencyA
?
pair
.
priceOf
(
wrappedCurrencyA
)
:
undefined
}
}
},
[
noLiquidity
,
token0Price
,
parsedAmounts
])
},
[
chainId
,
currencyA
,
noLiquidity
,
pair
,
parsedAmounts
])
// liquidity minted
// liquidity minted
const
liquidityMinted
=
useMemo
(()
=>
{
const
liquidityMinted
=
useMemo
(()
=>
{
...
@@ -118,7 +118,7 @@ export function useDerivedMintInfo(
...
@@ -118,7 +118,7 @@ export function useDerivedMintInfo(
if
(
pair
&&
totalSupply
&&
tokenAmountA
&&
tokenAmountB
)
{
if
(
pair
&&
totalSupply
&&
tokenAmountA
&&
tokenAmountB
)
{
return
pair
.
getLiquidityMinted
(
totalSupply
,
tokenAmountA
,
tokenAmountB
)
return
pair
.
getLiquidityMinted
(
totalSupply
,
tokenAmountA
,
tokenAmountB
)
}
else
{
}
else
{
return
return
undefined
}
}
},
[
parsedAmounts
,
chainId
,
pair
,
totalSupply
])
},
[
parsedAmounts
,
chainId
,
pair
,
totalSupply
])
...
@@ -126,7 +126,7 @@ export function useDerivedMintInfo(
...
@@ -126,7 +126,7 @@ export function useDerivedMintInfo(
if
(
liquidityMinted
&&
totalSupply
)
{
if
(
liquidityMinted
&&
totalSupply
)
{
return
new
Percent
(
liquidityMinted
.
raw
,
totalSupply
.
add
(
liquidityMinted
).
raw
)
return
new
Percent
(
liquidityMinted
.
raw
,
totalSupply
.
add
(
liquidityMinted
).
raw
)
}
else
{
}
else
{
return
return
undefined
}
}
},
[
liquidityMinted
,
totalSupply
])
},
[
liquidityMinted
,
totalSupply
])
...
...
src/state/multicall/hooks.ts
View file @
66a20062
...
@@ -30,7 +30,8 @@ function isMethodArg(x: unknown): x is MethodArg {
...
@@ -30,7 +30,8 @@ function isMethodArg(x: unknown): x is MethodArg {
function
isValidMethodArgs
(
x
:
unknown
):
x
is
MethodArgs
|
undefined
{
function
isValidMethodArgs
(
x
:
unknown
):
x
is
MethodArgs
|
undefined
{
return
(
return
(
x
===
undefined
||
(
Array
.
isArray
(
x
)
&&
x
.
every
(
y
=>
isMethodArg
(
y
)
||
(
Array
.
isArray
(
y
)
&&
y
.
every
(
isMethodArg
))))
x
===
undefined
||
(
Array
.
isArray
(
x
)
&&
x
.
every
(
xi
=>
isMethodArg
(
xi
)
||
(
Array
.
isArray
(
xi
)
&&
xi
.
every
(
isMethodArg
))))
)
)
}
}
...
@@ -67,7 +68,7 @@ function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): C
...
@@ -67,7 +68,7 @@ function useCallsData(calls: (Call | undefined)[], options?: ListenerOptions): C
// update listeners when there is an actual change that persists for at least 100ms
// update listeners when there is an actual change that persists for at least 100ms
useEffect
(()
=>
{
useEffect
(()
=>
{
const
callKeys
:
string
[]
=
JSON
.
parse
(
serializedCallKeys
)
const
callKeys
:
string
[]
=
JSON
.
parse
(
serializedCallKeys
)
if
(
!
chainId
||
callKeys
.
length
===
0
)
return
if
(
!
chainId
||
callKeys
.
length
===
0
)
return
undefined
const
calls
=
callKeys
.
map
(
key
=>
parseCallKey
(
key
))
const
calls
=
callKeys
.
map
(
key
=>
parseCallKey
(
key
))
dispatch
(
dispatch
(
addMulticallListeners
({
addMulticallListeners
({
...
...
src/state/swap/hooks.ts
View file @
66a20062
...
@@ -71,7 +71,7 @@ export function useSwapActionHandlers(): {
...
@@ -71,7 +71,7 @@ export function useSwapActionHandlers(): {
// try to parse a user entered amount for a given token
// try to parse a user entered amount for a given token
export
function
tryParseAmount
(
value
?:
string
,
currency
?:
Currency
):
CurrencyAmount
|
undefined
{
export
function
tryParseAmount
(
value
?:
string
,
currency
?:
Currency
):
CurrencyAmount
|
undefined
{
if
(
!
value
||
!
currency
)
{
if
(
!
value
||
!
currency
)
{
return
return
undefined
}
}
try
{
try
{
const
typedValueParsed
=
parseUnits
(
value
,
currency
.
decimals
).
toString
()
const
typedValueParsed
=
parseUnits
(
value
,
currency
.
decimals
).
toString
()
...
@@ -85,7 +85,7 @@ export function tryParseAmount(value?: string, currency?: Currency): CurrencyAmo
...
@@ -85,7 +85,7 @@ export function tryParseAmount(value?: string, currency?: Currency): CurrencyAmo
console
.
debug
(
`Failed to parse input amount: "
${
value
}
"`
,
error
)
console
.
debug
(
`Failed to parse input amount: "
${
value
}
"`
,
error
)
}
}
// necessary for all paths to return a value
// necessary for all paths to return a value
return
return
undefined
}
}
const
BAD_RECIPIENT_ADDRESSES
:
string
[]
=
[
const
BAD_RECIPIENT_ADDRESSES
:
string
[]
=
[
...
...
src/state/wallet/hooks.ts
View file @
66a20062
...
@@ -90,7 +90,7 @@ export function useTokenBalances(
...
@@ -90,7 +90,7 @@ export function useTokenBalances(
// get the balance for a single token/account combo
// get the balance for a single token/account combo
export
function
useTokenBalance
(
account
?:
string
,
token
?:
Token
):
TokenAmount
|
undefined
{
export
function
useTokenBalance
(
account
?:
string
,
token
?:
Token
):
TokenAmount
|
undefined
{
const
tokenBalances
=
useTokenBalances
(
account
,
[
token
])
const
tokenBalances
=
useTokenBalances
(
account
,
[
token
])
if
(
!
token
)
return
if
(
!
token
)
return
undefined
return
tokenBalances
[
token
.
address
]
return
tokenBalances
[
token
.
address
]
}
}
...
@@ -109,10 +109,10 @@ export function useCurrencyBalances(
...
@@ -109,10 +109,10 @@ export function useCurrencyBalances(
return
useMemo
(
return
useMemo
(
()
=>
()
=>
currencies
?.
map
(
currency
=>
{
currencies
?.
map
(
currency
=>
{
if
(
!
account
||
!
currency
)
return
if
(
!
account
||
!
currency
)
return
undefined
if
(
currency
instanceof
Token
)
return
tokenBalances
[
currency
.
address
]
if
(
currency
instanceof
Token
)
return
tokenBalances
[
currency
.
address
]
if
(
currency
===
ETHER
)
return
ethBalance
[
account
]
if
(
currency
===
ETHER
)
return
ethBalance
[
account
]
return
return
undefined
})
??
[],
})
??
[],
[
account
,
currencies
,
ethBalance
,
tokenBalances
]
[
account
,
currencies
,
ethBalance
,
tokenBalances
]
)
)
...
...
src/utils/maxAmountSpend.ts
View file @
66a20062
...
@@ -6,7 +6,7 @@ import { MIN_ETH } from '../constants'
...
@@ -6,7 +6,7 @@ import { MIN_ETH } from '../constants'
* @param currencyAmount to return max of
* @param currencyAmount to return max of
*/
*/
export
function
maxAmountSpend
(
currencyAmount
?:
CurrencyAmount
):
CurrencyAmount
|
undefined
{
export
function
maxAmountSpend
(
currencyAmount
?:
CurrencyAmount
):
CurrencyAmount
|
undefined
{
if
(
!
currencyAmount
)
return
if
(
!
currencyAmount
)
return
undefined
if
(
currencyAmount
.
currency
===
ETHER
)
{
if
(
currencyAmount
.
currency
===
ETHER
)
{
if
(
JSBI
.
greaterThan
(
currencyAmount
.
raw
,
MIN_ETH
))
{
if
(
JSBI
.
greaterThan
(
currencyAmount
.
raw
,
MIN_ETH
))
{
return
CurrencyAmount
.
ether
(
JSBI
.
subtract
(
currencyAmount
.
raw
,
MIN_ETH
))
return
CurrencyAmount
.
ether
(
JSBI
.
subtract
(
currencyAmount
.
raw
,
MIN_ETH
))
...
...
src/utils/parseENSAddress.ts
View file @
66a20062
...
@@ -2,6 +2,6 @@ const ENS_NAME_REGEX = /^(([a-zA-Z0-9]+\.)+)eth(\/.*)?$/
...
@@ -2,6 +2,6 @@ const ENS_NAME_REGEX = /^(([a-zA-Z0-9]+\.)+)eth(\/.*)?$/
export
function
parseENSAddress
(
ensAddress
:
string
):
{
ensName
:
string
;
ensPath
:
string
|
undefined
}
|
undefined
{
export
function
parseENSAddress
(
ensAddress
:
string
):
{
ensName
:
string
;
ensPath
:
string
|
undefined
}
|
undefined
{
const
match
=
ensAddress
.
match
(
ENS_NAME_REGEX
)
const
match
=
ensAddress
.
match
(
ENS_NAME_REGEX
)
if
(
!
match
)
return
if
(
!
match
)
return
undefined
return
{
ensName
:
`
${
match
[
1
].
toLowerCase
()}
eth`
,
ensPath
:
match
[
3
]
}
return
{
ensName
:
`
${
match
[
1
].
toLowerCase
()}
eth`
,
ensPath
:
match
[
3
]
}
}
}
src/utils/useUSDCPrice.ts
View file @
66a20062
...
@@ -27,7 +27,7 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined {
...
@@ -27,7 +27,7 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined {
return
useMemo
(()
=>
{
return
useMemo
(()
=>
{
if
(
!
currency
||
!
wrapped
||
!
chainId
)
{
if
(
!
currency
||
!
wrapped
||
!
chainId
)
{
return
return
undefined
}
}
// handle weth/eth
// handle weth/eth
if
(
wrapped
.
equals
(
WETH
[
chainId
]))
{
if
(
wrapped
.
equals
(
WETH
[
chainId
]))
{
...
@@ -61,6 +61,6 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined {
...
@@ -61,6 +61,6 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined {
return
new
Price
(
currency
,
USDC
,
usdcPrice
.
denominator
,
usdcPrice
.
numerator
)
return
new
Price
(
currency
,
USDC
,
usdcPrice
.
denominator
,
usdcPrice
.
numerator
)
}
}
}
}
return
return
undefined
},
[
chainId
,
currency
,
ethPair
,
ethPairState
,
usdcEthPair
,
usdcEthPairState
,
usdcPair
,
usdcPairState
,
wrapped
])
},
[
chainId
,
currency
,
ethPair
,
ethPairState
,
usdcEthPair
,
usdcEthPairState
,
usdcPair
,
usdcPairState
,
wrapped
])
}
}
tsconfig.json
View file @
66a20062
...
@@ -13,6 +13,10 @@
...
@@ -13,6 +13,10 @@
"noEmit"
:
true
,
"noEmit"
:
true
,
"esModuleInterop"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"module"
:
"esnext"
,
"noUnusedLocals"
:
true
,
"noFallthroughCasesInSwitch"
:
true
,
"noImplicitThis"
:
true
,
"noImplicitReturns"
:
true
,
"moduleResolution"
:
"node"
,
"moduleResolution"
:
"node"
,
"resolveJsonModule"
:
true
,
"resolveJsonModule"
:
true
,
"isolatedModules"
:
true
,
"isolatedModules"
:
true
,
...
@@ -29,8 +33,7 @@
...
@@ -29,8 +33,7 @@
"cypress"
"cypress"
],
],
"include"
:
[
"include"
:
[
"**/*.js"
,
"./src/**/*.ts"
,
"**/*.ts"
,
"./src/**/*.tsx"
"**/*.tsx"
]
]
}
}
tsconfig.strict.json
View file @
66a20062
...
@@ -4,10 +4,6 @@
...
@@ -4,10 +4,6 @@
"strict"
:
true
,
"strict"
:
true
,
"noImplicitAny"
:
true
,
"noImplicitAny"
:
true
,
"alwaysStrict"
:
true
,
"alwaysStrict"
:
true
,
"strictNullChecks"
:
true
,
"strictNullChecks"
:
true
"noImplicitReturns"
:
true
,
"noImplicitThis"
:
true
,
"noUnusedLocals"
:
true
,
"noFallthroughCasesInSwitch"
:
true
}
}
}
}
\ 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