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

Group wallets by protocol and service #57

Merged
merged 56 commits into from
Jun 7, 2022

Conversation

nicomiicro
Copy link
Contributor

@nicomiicro nicomiicro commented May 25, 2022

This is still work in progress, publishing so that I get some feedback on the general direction since I feel I don't know what I'm doing :)

Notion ticket: https://www.notion.so/exsphere/Rearrange-MultiWalletModal-to-divide-by-protocol-f46bf54422254ef5bbbf0e7552bd3b08

TODO

  • Update EVM protocol icon
  • Update display name for each protocol
  • Decide if we want to keep displaying "4 wallets are connected" when we have only metamask connected (probably not) and update that
  • Find a way to avoid multiple notifications per wallet instance (once for each instance when connecting/disconnecting).
  • Single connect button (in pool page) has not been updated (reported by Arv - see question 1)
  • Multi-wallet connected state buggy in preview deployment (reported by Arv - cannot reproduce, probably a metamask network issue)

Questions

  1. One the ConnectButton, what should happen when someone disconnects for metamask/ethereum? Should all wallets with service metamask disconnect? Or just the ethereum wallet? Since it's the same instance, it will disconnect all.

@nicomiicro nicomiicro added improvement Improving an existing feature apps/ui labels May 25, 2022
@cloudflare-pages
Copy link

cloudflare-pages bot commented May 25, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: e3d7c31
Status: ✅  Deploy successful!
Preview URL: https://cbfaba7f.swim-ui.pages.dev

View logs

Copy link
Collaborator

@arvakr arvakr left a comment

Choose a reason for hiding this comment

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

Looks great! Only commenting the result, not the code:

  1. The ConnectButton isn't working properly yet, claims e.g. Ethereum is not connected
  2. The MultiConnectButton is now showing weird logos, might make sense to also work on this ticket at the same time

@nicomiicro nicomiicro self-assigned this May 25, 2022
@arvakr arvakr removed the apps/ui label May 25, 2022
@wormat wormat changed the title [UI] Group wallets by protocol and service Group wallets by protocol and service May 25, 2022
@wormat
Copy link
Collaborator

wormat commented May 25, 2022

Answering the question: it should disconnect for all EVM chains.

Copy link
Collaborator

@wormat wormat left a comment

Choose a reason for hiding this comment

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

Nice start.

apps/ui/src/config/ecosystem.ts Show resolved Hide resolved
apps/ui/src/config/ecosystem.ts Outdated Show resolved Hide resolved
apps/ui/src/config/ecosystem.ts Outdated Show resolved Hide resolved
apps/ui/src/contexts/evmWallet.tsx Outdated Show resolved Hide resolved
apps/ui/src/models/wallets/services.tsx Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Outdated Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Outdated Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Outdated Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Outdated Show resolved Hide resolved
@nicomiicro
Copy link
Contributor Author

@arvakr your requested changes have been updated. I don't know if you have any suggestion on the "Decide if we want to keep displaying "4 wallets are connected" when we have only metamask connected" UI/UX concern I have. See screenshot below:

Screenshot 2022-05-27 at 11 20 01 PM

@wormat @cyphertrace @ramenuncle this PR is missing a few things (the unchecked checkboxes in the description, tests and selectors for the new store) but I would like to get some feedback on the store implementation. Random people on the internet say it's OK for one store to access the other directly and not via a hook so I went with this approach but since this is a first I would like to hear if you have any concerns. I also avoided a useWallets refactor because this is already getting too big.

Copy link
Contributor

@cyphertrace cyphertrace left a comment

Choose a reason for hiding this comment

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

Nice refacto, keep it comin' ! ;)

apps/ui/src/core/store/useWalletService.ts Outdated Show resolved Hide resolved
apps/ui/src/core/store/useWalletService.ts Outdated Show resolved Hide resolved
) => Promise<void>;
}

export const useWalletService = create<WalletServiceState>(
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought also that these stores, that don't need persistence, should be just one of the slices of the global store.
Check this : https://github.com/pmndrs/zustand/wiki/Splitting-the-store-into-separate-slices

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a global store? Do we want one? Should we put notifications there too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it could be convenient to have one store, sliced per domain, so we can access all data easily.
Just persisted part of the store, we had to put as a separate store, as it's not possible to slice it and have it in global.
For the notification, I took approach to separate it also, cause I didn't feel the need to be in global, just rendered on it's own on the fly, when one component, page needs it.. better said, I didn't thing that we're going to need it in the other stores. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it probably makes sense to move the wallets context inside this one for sure but I would prefer to do it on a separate PR if that's OK since this is getting huge. Regarding one vs many stores, I think for now I would prefer to default to keep them separate unless they are coupled in some way but I definitely agree that many would be coupled.

So keeping it as is, adding tests for the stores and pinging you for a final review soon!

apps/ui/src/core/selectors/environment.ts Outdated Show resolved Hide resolved
apps/ui/src/core/store/useWalletService.ts Outdated Show resolved Hide resolved
apps/ui/src/hooks/wallets/useWalletService.ts Outdated Show resolved Hide resolved
apps/ui/src/core/store/useWalletAdapter.ts Outdated Show resolved Hide resolved
apps/ui/src/core/store/useWalletAdapter.ts Show resolved Hide resolved
@wormat
Copy link
Collaborator

wormat commented Jun 2, 2022

I would assume no since I didn't change the useWallets hook which is the primary method to access them, could you please point me to the relevant code to double check?

@nicomiicro It's all external to useWallets, so it should be fine.

@nicomiicro
Copy link
Contributor Author

@arvakr @wormat thoughts on reverting the UI part of this to match the existing master until we reach a consensus with product so that we can merge this and move on with the remaining wallet refactoring (e.g. ConnectionProvider/WalletProvider)? The only difference in UX would be that all metamask wallets will appear connected once one of the is clicked/connected.

I've also suggested another option today with this info icon button / popover

wallets

@nicomiicro nicomiicro requested a review from wormat June 6, 2022 18:41
Copy link
Collaborator

@wormat wormat left a comment

Choose a reason for hiding this comment

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

Looks very nice. Just one appearance request and one code request.

apps/ui/src/pages/HomePage.tsx Outdated Show resolved Hide resolved
apps/ui/src/components/MultiWalletModal.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@wormat wormat left a comment

Choose a reason for hiding this comment

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

LGTM. Just waiting on final appearance comments from testers and some devnet testing before merging.

@wormat wormat merged commit 3117393 into master Jun 7, 2022
@wormat wormat deleted the ui/rearrange-multiwalletmodal-to-divide-by-protocol branch June 7, 2022 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants