-
Notifications
You must be signed in to change notification settings - Fork 13
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
[WIP] Switch chain button #396
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
26a32c8
feat: l2 fallback banner
solidovic 033503e
feat: unsupported chain button
solidovic cfa76fa
chore: reef-knot v5
solidovic 5dc988b
feat: add 'useChainIdWithoutAccount' hook
solidovic f806537
feat: use 'useChainIdWithoutAccount' for get chain id
solidovic bc4bed0
feat: show account (if connected) for known l2 chains
solidovic ce37db2
feat: switchChain
solidovic bf18061
Merge remote-tracking branch 'origin/feature/si-965-update-wagmi-to-l…
solidovic c9879b4
chore: add @wagmi/core
solidovic d24d3c9
feat: l2-wallet to wrap/unwrap and wq pages
solidovic 9abf9f6
fix: use chainId for SDK only from supportedChainIds
solidovic c97c2e5
feat: show account for unsupported chains
solidovic 55e7a67
refactor(rewards top-card): wallet block, unsupported chain block, co…
solidovic c52e5e3
feat(rewards top-card): connect handler
solidovic c6bbc01
feat: additional checks
solidovic 2c24e5e
feat(rewards): add addressError to AddressInput
solidovic c01691d
Merge branch 'develop' into feature/si-1310-unsupported-chain-banner-…
solidovic 4ac6574
feat(l2 chains): only Arbitrum_One
solidovic b8a085d
fix: l2 logos
solidovic 70434c3
fix(@playwright): tests
solidovic 0616cee
fix(forms): show 'connect button' in forms
solidovic c44aa92
fix(connect button): fullwidth
solidovic 6b38c51
feat(fallback): remove 'switch to mainnet' button
solidovic 9b53b69
fix(rewards connect): colors
solidovic 10b6636
feat: disabled forms for unsupported chains
solidovic 30f180b
fix: types
solidovic 1572c30
feat: add useIsSupportedChain and useIsConnectedWalletAndSupportedChain
solidovic f059523
refactor: l2 wallet fallback
solidovic 4a16c6f
refactor: remove chainIdWithoutAccount and useWeb3
solidovic 09abca5
refactor(stake form): disabled MAX button
solidovic ea342e4
refactor: remove Arbitrum_Nova and Arbitrum_One
solidovic 3da3726
refactor(reward top-card): simplify to read of source code and not us…
solidovic 3c19e24
refactor(stake-submit-button): not use web3-react
solidovic 033fe2b
refactor(header-wallet): not use web3-react
solidovic e3ab1b1
refactor(header-wallet): not use web3-react
solidovic 16b6d40
refactor: not use web3-react
solidovic 20d1905
refactor(wallet fallback): not use web3-react
solidovic bccbc4d
fix(header-wallet): chainName
solidovic ce8b82b
refactor: remove useChainIdWithoutAccount
solidovic 7410fad
Merge branch 'develop' into feature/si-1310-unsupported-chain-banner-…
solidovic c0809c5
fix: useErrorMessage
solidovic 9539a05
revert: useErrorMessage
solidovic 2f94a7a
refactor(rewards): styles
solidovic 9b5104e
fix: polygon name
solidovic 74f9bb4
fix(header wallet): address badge padding
solidovic cd572da
feat: add switchChain button
solidovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
export const enum CHAINS { | ||
export enum CHAINS { | ||
Mainnet = 1, | ||
Goerli = 5, | ||
Holesky = 17000, | ||
} | ||
|
||
export enum L2_CHAINS { | ||
zkSync = 324, | ||
Optimism = 10, | ||
Arbitrum = 42161, | ||
Polygon = 137, | ||
Base = 8453, | ||
Mantle = 5000, | ||
Linea = 59144, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { FC, useCallback } from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
import { useConnect } from 'reef-knot/core-react'; | ||
import { Button } from '@lidofinance/lido-ui'; | ||
import { wrapWithEventTrack } from '@lidofinance/analytics-matomo'; | ||
|
||
import { useUserConfig } from 'config/user-config'; | ||
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events'; | ||
import { WalletCardStyle } from 'shared/wallet/card/styles'; | ||
|
||
const ConnectWalletStyle = styled(WalletCardStyle)` | ||
padding: 27px 27px 47px 27px; | ||
text-align: center; | ||
|
||
${({ theme }) => | ||
theme.name === 'dark' | ||
? css` | ||
color: var(--lido-color-text); | ||
background: linear-gradient(48.34deg, #46464f -5.55%, #3b3b47 100%); | ||
` | ||
: css` | ||
color: var(--lido-color-secondary); | ||
background: linear-gradient(48.34deg, #d2ddff -5.55%, #e6e6e6 100%); | ||
`} | ||
`; | ||
|
||
const TextStyle = styled.p` | ||
margin-bottom: 12px; | ||
`; | ||
|
||
export const ConnectWallet: FC = () => { | ||
const { isWalletConnectionAllowed } = useUserConfig(); | ||
const { connect } = useConnect(); | ||
|
||
const handleClick = wrapWithEventTrack( | ||
MATOMO_CLICK_EVENTS.connectWallet, | ||
useCallback(() => { | ||
if (!isWalletConnectionAllowed) return; | ||
void connect(); | ||
}, [isWalletConnectionAllowed, connect]), | ||
); | ||
|
||
return ( | ||
<ConnectWalletStyle> | ||
<TextStyle>Connect your wallet to view staking stats</TextStyle> | ||
<Button | ||
color={'secondary'} | ||
variant={'outlined'} | ||
size={'sm'} | ||
disabled={!isWalletConnectionAllowed} | ||
onClick={handleClick} | ||
> | ||
Connect wallet | ||
</Button> | ||
</ConnectWalletStyle> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,28 @@ | ||
import { FC } from 'react'; | ||
import { Block, ThemeProvider, themeDark } from '@lidofinance/lido-ui'; | ||
import { InputDescription } from 'features/rewards/components/inputDescription'; | ||
import { AddressInput } from 'features/rewards/components/addressInput'; | ||
import { useAccount } from 'wagmi'; | ||
|
||
import { StatsWrapper } from 'features/rewards/components/statsWrapper'; | ||
import { Stats } from 'features/rewards/components/stats'; | ||
import { InputWrapper } from 'features/rewards/components/inputWrapper'; | ||
import { useRewardsHistory } from 'features/rewards/hooks'; | ||
import { Fallback } from 'shared/wallet'; | ||
import { useIsConnectedWalletAndSupportedChain } from 'shared/hooks/use-is-connected-wallet-and-supported-chain'; | ||
|
||
const INPUT_DESC_TEXT = | ||
'Current balance may differ from last balance in the table due to rounding.'; | ||
import { Wallet } from './wallet'; | ||
import { ConnectWallet } from './connect-wallet'; | ||
|
||
export const TopCard: FC = () => { | ||
const { | ||
address, | ||
addressError, | ||
isAddressResolving, | ||
inputValue, | ||
setInputValue, | ||
} = useRewardsHistory(); | ||
const { isConnected } = useAccount(); | ||
const isActiveWallet = useIsConnectedWalletAndSupportedChain(); | ||
|
||
return ( | ||
<Block color="accent" style={{ padding: 0 }}> | ||
<InputWrapper data-testid="inputSection" color="accent"> | ||
<ThemeProvider theme={themeDark}> | ||
<AddressInput | ||
address={address} | ||
addressError={addressError} | ||
inputValue={inputValue} | ||
handleInputChange={setInputValue} | ||
isAddressResolving={isAddressResolving} | ||
/> | ||
<InputDescription>{INPUT_DESC_TEXT}</InputDescription> | ||
</ThemeProvider> | ||
</InputWrapper> | ||
<> | ||
{!isConnected && <ConnectWallet />} | ||
|
||
{isConnected && !isActiveWallet && <Fallback />} | ||
|
||
{isConnected && isActiveWallet && <Wallet />} | ||
<StatsWrapper> | ||
<Stats /> | ||
</StatsWrapper> | ||
</Block> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { FC } from 'react'; | ||
import styled from 'styled-components'; | ||
import { ThemeProvider, themeDark } from '@lidofinance/lido-ui'; | ||
|
||
import { InputDescription } from 'features/rewards/components/inputDescription'; | ||
import { AddressInput } from 'features/rewards/components/addressInput'; | ||
import { InputWrapper } from 'features/rewards/components/inputWrapper'; | ||
import { useRewardsHistory } from 'features/rewards/hooks'; | ||
|
||
import { WalletCardStyle } from 'shared/wallet/card/styles'; | ||
|
||
const INPUT_DESC_TEXT = | ||
'Current balance may differ from last balance in the table due to rounding.'; | ||
|
||
const WalletStyle = styled(WalletCardStyle)` | ||
background: linear-gradient( | ||
52.01deg, | ||
#37394a 0%, | ||
#363749 0.01%, | ||
#40504f 100% | ||
); | ||
padding: 0 0 24px 0; | ||
`; | ||
|
||
export const Wallet: FC = () => { | ||
const { | ||
address, | ||
addressError, | ||
isAddressResolving, | ||
inputValue, | ||
setInputValue, | ||
} = useRewardsHistory(); | ||
|
||
return ( | ||
<WalletStyle> | ||
<InputWrapper data-testid="inputSection" color="accent"> | ||
<ThemeProvider theme={themeDark}> | ||
<AddressInput | ||
address={address} | ||
addressError={addressError} | ||
inputValue={inputValue} | ||
handleInputChange={setInputValue} | ||
isAddressResolving={isAddressResolving} | ||
/> | ||
<InputDescription>{INPUT_DESC_TEXT}</InputDescription> | ||
</ThemeProvider> | ||
</InputWrapper> | ||
</WalletStyle> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Reverse keys and values
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.
For what?