-
Notifications
You must be signed in to change notification settings - Fork 629
allow wallet config #808
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
allow wallet config #808
Conversation
🦋 Changeset detectedLatest commit: 2f4e1e5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
/release-pr |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
=======================================
Coverage 69.60% 69.60%
=======================================
Files 227 227
Lines 10602 10602
Branches 1298 1298
=======================================
Hits 7380 7380
Misses 2515 2515
Partials 707 707 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx
Outdated
Show resolved
Hide resolved
| } | ||
| dappMetadata: { | ||
| ...walletOptions.dappMetadata, | ||
| isDarkMode: theme === "dark", |
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.
Does this have to be part of the dappMetadata? I don't think this is used by any of the wallets/connectors we have right? We should be able to remove it also from WalletOptions/DAppMetaData
packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx
Outdated
Show resolved
Hide resolved
| appName: this.options.dappMetadata.name, | ||
| reloadOnDisconnect: false, | ||
| darkMode: this.options.theme === "dark", | ||
| darkMode: this.options.dappMetadata.isDarkMode, |
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.
darkMode is specific to CoinbaseWallet in web, what do you think if we remove it from the dappMetadata and pass it as a special option for CoinbaseWallet instead?
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 thought Wallet Connect has color schemes, too?
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 don't think I've seen it in the connectors
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.
v1 definitely had it I wonder if they got rid of it with v2? but I've seen dark and light mode wc v2 UI in the wild...
|
/release-pr |
|
/release-pr |
|
/release-pr |
|
./release-pr |
|
./release-pr |
jnsdls
left a comment
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 there's more to clean up here to get it to a good point
| * ``` | ||
| */ | ||
| supportedWallets: SupportedWallet[]; | ||
| supportedWallets: Wallet[]; |
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.
should we rename this to wallets?
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 also have a supportedChains prop here, I think it's good to have some consistency, should we rename supportedChains as well?
packages/react-core/src/core/providers/thirdweb-wallet-provider.tsx
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| export const coinbaseWallet = (config?: {callbackURL?: URL}) => { | ||
| const callbackURLNonNull = config?.callbackURL || new URL("https://thirdweb.com/wsegue"); |
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's this fallback URL?
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.
@jnsdls that URL is required by the Coinbase Wallet SDK as a UniversalLink to talk back to iOS apps: https://coinbase.github.io/wallet-mobile-sdk/docs/client-sdk/rn-setup/#configuration.
I'm voting for removing the Coinbase wallet as a default wallet and figure out tree-shaking. Adding UniversalLinks is another friction point to build a new app + breaking Expo Go support. I opened a ticket with them as well: https://github.com/coinbase/wallet-mobile-sdk/issues/213.
| export function usePaperWalletUserEmail() { | ||
| const wallet = useWallet(); | ||
| const [email, setEmail] = useState<string | undefined>(undefined); | ||
|
|
||
| useEffect(() => { | ||
| if (wallet?.walletId !== "PaperWallet") { | ||
| setEmail(undefined); | ||
| return; | ||
| } | ||
| (wallet as PaperWallet).getEmail().then((_email) => { | ||
| setEmail(_email); | ||
| }); | ||
| }, [wallet]); | ||
|
|
||
| return email; | ||
| } |
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 don't think we need to expose this explicitly, I'd also prefer to do this in a useQuery instead of a custom useEffect + state hook if we were to offer this
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've replaced the state+effect with react-query for now.
But let me know if it makes more sense to just remove the hook
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 it feels odd as a "wallet connector" to have an "email" hook?
| export { | ||
| MetamaskWallet, | ||
| CoinbaseWallet, | ||
| DeviceWallet, | ||
| WalletConnect, | ||
| WalletConnectV1, | ||
| PaperWallet, | ||
| SafeWallet, | ||
| } from "./wallet/wallets"; |
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.
thank you!
| id: MetaMask.id, | ||
| meta: MetaMask.meta, |
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.
let's invert this, the object should drive the ID + meta and the wallet can inherit it / be passed it during construction time (so we do not need to import the full wallet class just to have the metadata object)
| @@ -0,0 +1,13 @@ | |||
| import { TW_WC_PROJECT_ID } from "@thirdweb-dev/react-core"; | |||
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 feels weird that this is driven by react-core and not by wallets, why would this not live in the wallet package?
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, this shouldn't live in react-core. RN is using one in the react-native package. We could set a default one in the wallets package as well but passing one down from RN/React I think makes sense, it's another tracking indicator we could use.
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.
Ok, moved into React, will also create it in the wallets package when we polish the wallets package (this week)
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.
this should live in wallets not react or react-core
| export const walletConnect = (config?: { projectId?: string }) => { | ||
| const projectId = config?.projectId || TW_WC_PROJECT_ID; | ||
| return { | ||
| id: WalletConnect.id, | ||
| meta: WalletConnect.meta, | ||
| create: (options: WalletOptions) => | ||
| new WalletConnect({ ...options, qrcode: true, projectId }), | ||
| } satisfies Wallet; | ||
| }; |
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 just realized that these functions live in react - why would they the not live in wallets?
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.
Because it's only required for react,react-core - if anyone wants to use the wallets directly - they don't need this
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.
so if it's required for react-core then at the very least it should live in react-core
| appName: this.options.dappMetadata.name, | ||
| reloadOnDisconnect: false, | ||
| darkMode: this.options.theme === "dark", | ||
| darkMode: this.options.dappMetadata.isDarkMode, |
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.
v1 definitely had it I wonder if they got rid of it with v2? but I've seen dark and light mode wc v2 UI in the wild...
|
Wallet connect v2 allows to set theme using but looks like it's not available in the version we are using of I can't find any mention of configuring the theme in wallet connect v1 docs Should we remove |
I think that makes sense, that way we'd pass it just to the wallets that support it. |
|
/release-pr |
|
/release-pr |
- [RN] only exports wallet creator functions - [RN] remove coinbase wallet as a default wallet - [React] only export wallet creator functions - [React] Move WC projectId into react and out of react-core
|
@jnsdls we worked on some of the comments you made and we answered others. I created a ticket to track the ones we didn't cover here (SDK-870). I'm merging this now since we need these changes to write the RN SDK guides + we can't keep letting this PR grow |
|
./release-pr |

New API allows configuring wallet config like this: