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
a7a2a9ed
Commit
a7a2a9ed
authored
Aug 21, 2019
by
ian-jh
Browse files
Options
Browse Files
Download
Plain Diff
:quit
Merge branch 'beta' of
https://github.com/Uniswap/uniswap-frontend
into beta
parents
495fb062
81bc6926
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
21 deletions
+44
-21
index.js
src/components/Web3ReactManager/index.js
+15
-7
Application.js
src/contexts/Application.js
+29
-14
No files found.
src/components/Web3ReactManager/index.js
View file @
a7a2a9ed
...
...
@@ -32,8 +32,10 @@ const SpinnerWrapper = styled(Spinner)`
`
function
tryToSetConnector
(
setConnector
,
setError
)
{
setConnector
(
'
Injected
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(
error
=>
{
setConnector
(
'
Network
'
)
setConnector
(
'
Injected
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(()
=>
{
setConnector
(
'
Network
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(
error
=>
{
setError
(
error
)
})
})
}
...
...
@@ -54,25 +56,31 @@ export default function Web3ReactManager({ children }) {
if
(
accounts
.
length
>=
1
)
{
tryToSetConnector
(
setConnector
,
setError
)
}
else
{
setConnector
(
'
Network
'
)
setConnector
(
'
Network
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(
error
=>
{
setError
(
error
)
})
}
})
}
}
else
{
setConnector
(
'
Network
'
)
setConnector
(
'
Network
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(
error
=>
{
setError
(
error
)
})
}
}
}
,
[
active
,
error
,
setConnector
,
setError
]
)
})
// parse the error
useEffect
(()
=>
{
if
(
error
)
{
// if the user changes to the wrong network, unset the connector
if
(
error
.
code
===
Connector
.
errorCodes
.
UNSUPPORTED_NETWORK
)
{
setConnector
(
'
Network
'
)
setConnector
(
'
Network
'
,
{
suppressAndThrowErrors
:
true
}).
catch
(
error
=>
{
setError
(
error
)
})
}
}
}
,
[
error
,
setConnector
]
)
})
const
[
showLoader
,
setShowLoader
]
=
useState
(
false
)
useEffect
(()
=>
{
...
...
src/contexts/Application.js
View file @
a7a2a9ed
...
...
@@ -68,29 +68,44 @@ export default function Provider({ children }) {
}
export
function
Updater
()
{
const
{
networkId
,
library
}
=
useWeb3Context
()
const
{
networkId
,
library
,
connectorName
}
=
useWeb3Context
()
const
globalBlockNumber
=
useBlockNumber
()
const
[,
{
updateBlockNumber
,
updateUSDPrice
}]
=
useApplicationContext
()
// slow down polling interval
useEffect
(()
=>
{
let
stale
=
false
if
(
library
)
{
if
(
connectorName
===
'
Network
'
)
{
library
.
polling
=
false
}
else
{
library
.
pollingInterval
=
5
}
}
},
[
library
,
connectorName
])
getUSDPrice
(
library
)
.
then
(([
price
])
=>
{
if
(
!
stale
)
{
updateUSDPrice
(
networkId
,
price
)
}
})
.
catch
(()
=>
{
if
(
!
stale
)
{
updateUSDPrice
(
networkId
,
null
)
}
})
// update usd price
useEffect
(()
=>
{
if
(
library
)
{
let
stale
=
false
getUSDPrice
(
library
)
.
then
(([
price
])
=>
{
if
(
!
stale
)
{
updateUSDPrice
(
networkId
,
price
)
}
})
.
catch
(()
=>
{
if
(
!
stale
)
{
updateUSDPrice
(
networkId
,
null
)
}
})
}
},
[
globalBlockNumber
,
library
,
networkId
,
updateUSDPrice
])
// update block number
useEffect
(()
=>
{
if
(
(
networkId
||
networkId
===
0
)
&&
library
)
{
if
(
library
)
{
let
stale
=
false
function
update
()
{
...
...
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