Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Mar 27, 2023

New API allows configuring wallet config like this:

<ThirdwebProvider 
	supportedWallets={[
		metamaskWallet(),
		coinbaseWallet(),
		paperWallet({ clientId: 'some-id' })
	]}
/>

@MananTank MananTank requested a review from a team as a code owner March 27, 2023 15:45
@MananTank MananTank requested a review from a team March 27, 2023 15:45
@changeset-bot
Copy link

changeset-bot bot commented Mar 27, 2023

🦋 Changeset detected

Latest commit: 2f4e1e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@thirdweb-dev/react-native Patch
@thirdweb-dev/react-core Patch
@thirdweb-dev/wallets Patch
@thirdweb-dev/react Patch
@thirdweb-dev/auth Patch
@thirdweb-dev/unity-js-bridge Patch
thirdweb Patch
@thirdweb-dev/react-native-compat Patch

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

@MananTank
Copy link
Member Author

/release-pr

@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (e2ec70c) 69.60% compared to head (44b6282) 69.60%.

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

}
dappMetadata: {
...walletOptions.dappMetadata,
isDarkMode: theme === "dark",
Copy link
Contributor

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

appName: this.options.dappMetadata.name,
reloadOnDisconnect: false,
darkMode: this.options.theme === "dark",
darkMode: this.options.dappMetadata.isDarkMode,
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Contributor

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

Copy link
Member

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...

@MananTank
Copy link
Member Author

/release-pr

@MananTank
Copy link
Member Author

/release-pr

@MananTank MananTank changed the title allow wallet config, fix gnosis safe allow wallet config, Mar 27, 2023
@MananTank
Copy link
Member Author

/release-pr

@iketw
Copy link
Contributor

iketw commented Mar 27, 2023

./release-pr

@iketw
Copy link
Contributor

iketw commented Mar 28, 2023

./release-pr

Copy link
Member

@jnsdls jnsdls left a 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[];
Copy link
Member

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?

Copy link
Contributor

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?

}

export const coinbaseWallet = (config?: {callbackURL?: URL}) => {
const callbackURLNonNull = config?.callbackURL || new URL("https://thirdweb.com/wsegue");
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@iketw iketw Mar 28, 2023

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.

Comment on lines 18 to 33
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;
}
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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?

Comment on lines -4 to -12
export {
MetamaskWallet,
CoinbaseWallet,
DeviceWallet,
WalletConnect,
WalletConnectV1,
PaperWallet,
SafeWallet,
} from "./wallet/wallets";
Copy link
Member

Choose a reason for hiding this comment

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

thank you!

Comment on lines +13 to +14
id: MetaMask.id,
meta: MetaMask.meta,
Copy link
Member

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";
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Member

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

Comment on lines +5 to +13
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;
};
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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,
Copy link
Member

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...

@MananTank
Copy link
Member Author

Wallet connect v2 allows to set theme using qrModalOptions.themeMode
https://docs.walletconnect.com/2.0/javascript/providers/ethereum#supported-web3modal-options-qrmodaloptions

image

but looks like it's not available in the version we are using of @walletconnect/ethereum-provider ( ~2.4.6 ). latest version is 2.5.2 - but upgrading to that breaks a bunch of things.

I can't find any mention of configuring the theme in wallet connect v1 docs


Should we remove dAppMeta.isDarkMode from wallets and thirdweb-provider and only pass the theme instead to wallets?

@jnsdls @iketw

@iketw
Copy link
Contributor

iketw commented Mar 28, 2023

Wallet connect v2 allows to set theme using qrModalOptions.themeMode https://docs.walletconnect.com/2.0/javascript/providers/ethereum#supported-web3modal-options-qrmodaloptions

image

but looks like it's not available in the version we are using of @walletconnect/ethereum-provider ( ~2.4.6 ). latest version is 2.5.2 - but upgrading to that breaks a bunch of things.

I can't find any mention of configuring the theme in wallet connect v1 docs

Should we remove dAppMeta.isDarkMode from wallets and thirdweb-provider and only pass the theme instead to wallets?

@jnsdls @iketw

I think that makes sense, that way we'd pass it just to the wallets that support it.

@MananTank
Copy link
Member Author

/release-pr

@MananTank MananTank changed the title allow wallet config, allow wallet config Mar 28, 2023
@MananTank
Copy link
Member Author

/release-pr

ikethirdweb added 3 commits March 28, 2023 20:11
- [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
@iketw
Copy link
Contributor

iketw commented Mar 29, 2023

@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

@iketw
Copy link
Contributor

iketw commented Mar 29, 2023

./release-pr

@iketw iketw added this pull request to the merge queue Mar 29, 2023
Merged via the queue into main with commit e453e36 Mar 29, 2023
@iketw iketw deleted the allow-wallet-config branch March 29, 2023 00:32
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.

4 participants