New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(L2): add Arbitrum UI #1912
Conversation
JFrankfurt
commented
Jun 24, 2021
•
edited
edited
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/uniswap/uniswap-interface/6kXJeRkM9fmFyehXwrBPdowpdaqG |
useOnClickOutside(node, open ? toggle : undefined) | ||
const { ethereum } = window | ||
const [implements3085, setImplements3085] = React.useState(false) | ||
React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we doing this on mount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to determine if the menu option for switching back to L1 is supported and should be visible. Switching to the current network is a noop and the promise returns null if it's supported, and it throws if the api is unavailable. Do you think we should run the check somewhere else? I could see doing a global check somewhere and retaining the support info for a check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just check provider.isMetaMask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thought occurred to me, but I figured this gave us better flexibility for supporting other clients that might support the EIP now (w/o me knowing of it) or support it in the future w/o code change. Admittedly, it is super gross and I hate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but sending this request while no op on metamask may produce a strange result in another wallet
src/pages/Swap/index.tsx
Outdated
React.useEffect(() => { | ||
const onArbitrum = chainId === SupportedChainId.ARBITRUM_ONE | ||
if (onArbitrum && account && library) { | ||
library.getBalance(account).then((balance) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use the balance fetching hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, didn't know this was a thing
src/pages/Swap/index.tsx
Outdated
@@ -68,7 +69,10 @@ const StyledInfo = styled(Info)` | |||
} | |||
` | |||
|
|||
const ARBITRUM_LOCAL_STORAGE_DISMISSED_KEY = 'HIDE_ARBITRUM_SWAP_ALERT' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use redux for storing this state, for which the user slice is already stored to localstorage
src/pages/Swap/index.tsx
Outdated
@@ -350,6 +353,31 @@ export default function Swap({ history }: RouteComponentProps) { | |||
|
|||
const priceImpactTooHigh = priceImpactSeverity > 3 && !isExpertMode | |||
|
|||
// arbitrum network alert | |||
const [arbitrumAlertVisible, setArbitrumAlertVisible] = React.useState(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why you need state for this, just store whether it's dismissed in redux, and you should show it if they're on arbitrum and haven't dismissed it yet
src/hooks/useChainIdBackground.ts
Outdated
React.useEffect(() => { | ||
const background = document.querySelector('#background-radial-gradient') | ||
if (background === null) { | ||
const background = document.querySelector('#background-radial-gradient') as HTMLDivElement | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, nit, document.getElementById('background-radial-gradient')
is faster (not that it matters at all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getElementById
is not faster than querySelector
unless maybe you're executing it thousands of times in a loop in IE7 in 2007. Then… maybe 😜
src/hooks/useChainIdBackground.ts
Outdated
import React from 'react' | ||
import { useActiveWeb3React } from './web3' | ||
|
||
export const useChainIdBackground = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't feel strongly about where it goes
useOnClickOutside(node, open ? toggle : undefined) | ||
const { ethereum } = window | ||
const [implements3085, setImplements3085] = React.useState(false) | ||
React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but sending this request while no op on metamask may produce a strange result in another wallet
13f04a8
to
00e3acd
Compare
00e3acd
to
26e4267
Compare
26e4267
to
105cf19
Compare
105cf19
to
49cfd9a
Compare