Skip to content
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
wants to merge 46 commits into from

Conversation

solidovic
Copy link
Contributor

@solidovic solidovic commented Jul 11, 2024

Description

Switch chain (to defaultChainId) button on wallet fallback.

merge after #371

Demo

Снимок экрана 2024-07-11 в 11 34 06

Testing notes

Check all wallets;

Button use defaultChainId var.

Checklist:

  • Checked the changes locally.
  • Created / updated analytics events.
  • Created / updated the technical documentation (README.md / docs / etc.).
  • Affects / requires changes in other services (Matomo / Sentry / CloudFlare / etc.).

…atest-stable-version-2' into feature/si-1310-unsupported-chain-banner-rework

# Conflicts:
#	package.json
#	yarn.lock
@solidovic solidovic requested review from a team as code owners July 11, 2024 08:36
@preview-stands
Copy link

preview-stands bot commented Jul 11, 2024

Preview stand status

Stand was demolished

background: #ffffff1a;

&:not(:disabled):hover {
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What TODO?

Copy link
Contributor Author

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)[
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it optional?

Copy link
Contributor

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 = () => {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useConntectionStatus()

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse keys and values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what?

@Jeday Jeday closed this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants