-
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
Conversation
…atest-stable-version-2' into feature/si-1310-unsupported-chain-banner-rework # Conflicts: # package.json # yarn.lock
…rework Signed-off-by: Anton Shalimov <[email protected]>
…rework Signed-off-by: Anton Shalimov <[email protected]>
Preview stand statusStand was demolished |
background: #ffffff1a; | ||
|
||
&:not(:disabled):hover { | ||
// TODO |
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.
What TODO?
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 are waiting the design updates
}, [defaultChain]); | ||
|
||
const chainName = useMemo(() => { | ||
return Object.keys(L2_CHAINS)[ |
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.
Use object.entries to find by value and return key
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.
Actually consider just reversing key and values in L2_CHAINS
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.
Is it optional?
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.
No. If you are L2_CHAINS only to find keys by value you must reverse object.
import { useAccount } from 'wagmi'; | ||
import { useUserConfig } from 'config/user-config'; | ||
|
||
export const useIsConnectedWalletAndSupportedChain = () => { |
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.
Too long hook name, maybe useSupportedChainActive
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.
A too-long hook name is not always bad.
TheuseSupportedChainActive
isn't clearly.
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.
IMO it bloats code and impacts readbility, let's consider joint hook
export const SubmitButton = () => { | ||
const { active } = useWeb3(); | ||
const { isConnected } = useAccount(); | ||
const isSupportedChain = useIsSupportedChain(); |
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.
What if we combine all chain and account hooks into one?
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.
useConntectionStatus()
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.
isConnected // for just wallet connection to show or not connect button
isSupportedChain // to show UnsupportedChainButton
isChainL2 // inside UnsupportedChainButton
isActiveWallet -> isDappActive // to know that we can use our dapp features like stake
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.
🤔
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.
good idea, let's leave it for refactoring (when we remove useWeb3)
Mainnet = 1, | ||
Goerli = 5, | ||
Holesky = 17000, | ||
} | ||
|
||
export enum L2_CHAINS { |
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?
Description
Switch chain (to defaultChainId) button on wallet fallback.
merge after #371
Demo
Testing notes
Check all wallets;
Button use
defaultChainId
var.Checklist: