-
Notifications
You must be signed in to change notification settings - Fork 125
Conversation
SHOW2-770 RainbowKit
We are experiencing a lot of issues with bare WalletConnect, especially on mobile web (even if this is working very well sometimes) Let's try RainbowKit |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
It's not deploying because the yarn.lock
file is not in a good state. Not sure what's happening -- can't try the PR previews
@@ -0,0 +1,96 @@ | |||
import { ConnectButton as RainbotConnectButton } from "@rainbow-me/rainbowkit"; | |||
|
|||
import { Button, View } from "design-system"; |
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.
Even if this is working I think it's best to import individual packages from @showtime-xyz/universal.
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.
Fixed ✅ Realized that we don't use universal for buttons (@showtime-xyz/universal.button
) in the project. Does it have any special case?
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.
Oh I just fetched new commits, thats ok 👍🏽
|
||
export const ConnectButton = ({ handleSubmitWallet }: ConnectButtonProps) => { | ||
return ( | ||
<RainbotConnectButton.Custom> |
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.
Typo RainbotConnectButton
packages/app/lib/web3-modal.web.ts
Outdated
name: "Coinbase", | ||
description: "Use the Coinbase Wallet app on your mobile device", | ||
}, | ||
coinbasewallet: { |
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.
do we still need web3 modal?
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.
Yeah, I removed it ✅
@@ -2,12 +2,13 @@ import { useEffect, useMemo, useState } from "react"; | |||
import { Platform } from "react-native"; | |||
|
|||
import { Web3Provider as EthersWeb3Provider } from "@ethersproject/providers"; | |||
import "@rainbow-me/rainbowkit/styles.css"; |
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.
i think we should keep this import in _app.tsx, or might crash on native, no?
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.
Fixed ✅
const provider = await web3Modal.connect(); | ||
const ethersProvider = new EthersWeb3Provider(provider); | ||
setWeb3(ethersProvider); | ||
if (Platform.OS !== "web") { |
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.
i think magic wallet was on web and native both, right? Do we need this condition?
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.
Here I needed to refactor all providers for web and mobile usage because on mobile we use wallet connect and on the web we use Wagmi. This comment might be invalid.
Here is what I did; To use wagmi on same providers, I created provider wrappers for the web (web3-provider.web.tsx, auth-provider.web.tsx). And passed some props to the Web3Provider and AuthProvider. Because I didn't want to add the wagmi and rainbow packages to the mobile repo and wrap the mobile app with their providers.
Can you check them and give some feedback guys? @intergalacticspacehighway @axeldelafosse @alantoa
9731cf6
to
7fa087d
Compare
const useWallet = () => { | ||
const address = useMemo(async () => { | ||
const web3Modal = await getWeb3Modal(); | ||
const web3 = new ethers.providers.Web3Provider(await web3Modal.connect()); |
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.
i think here we should use useWeb3 hook as we already have the web3 provider so no need to recreate it I guess. We can delete the getWeb3modal from native as well
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.
But on mobile, don't we use getWeb3Modal to get this info as well?
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, actually it was not being used before. I think we added that file so import won't break on native. We always called getWeb3Modal
under Platform.OS web check (exception is buying NFT which was not implemented on native)
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.
I see, there is web3-modal.native.ts
file and I though that method uses this on native. I tried not to break something, I might use unnecessary implementations, thanks to mention 👍🏽
if we're on dev then we can switch to polygon testnet instead of polygon. There's an env NEXT_PUBLIC_CHAIN_ID which we can use. |
Oh yes, exactly! I was about to share it but forgot then. I'll share on the |
address: wagmiData?.address, | ||
connected, | ||
signed, | ||
loggedIn, |
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 there a reason we need loggedIn and connected both? Logged in might be a bit confusing as if it's a showtime user login or a wallet login.
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.
connected
is just used the indicate that if the wallet connection is done and the loggedIn
is used to indicate if the user logged in and have storage data (apart from wallet connection). I needed to use both separately to handle set web3 object and handle logins log outs while configure the effects in use-wallet-login.ts
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.
okay, but loggedIn is derived from connected so they'll always be same, right?
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.
Oh I see, I get it now, yes, here is the thing; loggedIn
is triggered when the connected
change, I needed to catch that to trigger something at once. This is because I used that way. Yeah that doesn't looks good approach, I try to refactor it.
Great work @enesozturk 👏 We might need to refactor or move some stuff for a better abstraction. I think we can have a single hook We can bring this up after merging this PR. I have some ideas on this. Will open a discussion or just do a PR ❇️ |
@intergalacticspacehighway yeah looks like there are more hooks than needed. You also added |
Today we got an issue with @intergalacticspacehighway; while switching the network on MetaMask, Wagmi disconnects us. We thought it was related to wagmi.sh but looks like it's not. Additionally, I tested drop NFT on both staging and production environments and here is the results; Rainbow Drop NFT Tests - Production
Rainbow Drop NFT Tests - Staging (Test APIs)
Also needed to update env keys because they were not consistent, there were some keys which are not included in all of them. |
@enesozturk LGTM ❇️ . can you look why CI stuff is failing? |
@intergalacticspacehighway Yeah I'm not sure, taking a look the logs now 👍🏽 |
PR Preview - StorybookThis pull request preview deployment is now available. ✅ Preview: exp+io.showtime.storybook://expo-development-client/?url=https://u.expo.dev/e77d5b68-bb27-45da-aa5c-96c1fdbf6706&channel-name=pr-1156 Comment ID: 1149588261 |
8a9e4f9
to
a47478b
Compare
Why
We want to use Rainbow Kit for login on the web instead of Magic.
How
After some discussion with the Rainbow team and some fixes, it's now working as expected. For this transition, I needed to totally refactor
useWalletLogin
because with the wagmi.sh, we get connection data with different hooks and that trigger different effects to handle login, log out, network change, etc.Additionally, I needed to add the wrong network button to the header because if the user doesn't realize they logged in with mainnet or something else, they won't be able to Mint, Buy, etc. When they press the Wrong Network button, they will need to select Poly gon and resign again, the button will disappear.
Test Plan
These changes should be well tested and I would appreciate if you help me and test these scenarios:
Login with the following wallets with Polygon Network
Try Minting
Login with the following wallets with Ethereum Network
You'll see the
Wrong Network
button on the header. Press it, Select PolygonIf you are logged with Rainbow or Coinbase, you'll get a notification on the mobile app. Confirm it.
Questions
useBuyNft
hook when I refactor it with Wagmi hooks. Should I consider it? @intergalacticspacehighwayAdditional Notes
Currently login business logic looks pretty messy including this one. It's hard to follow data, handle effects, etc. My previous PR was including some refactor. I'll handle them later to keep this PR smaller.