-
Notifications
You must be signed in to change notification settings - Fork 407
feat(clerk-js,types,clerk-react): Support Coinbase Wallet web3 provider and authentication strategy #4082
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
feat(clerk-js,types,clerk-react): Support Coinbase Wallet web3 provider and authentication strategy #4082
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@clerk/clerk-js": minor | ||
| "@clerk/clerk-react": minor | ||
| "@clerk/types": minor | ||
| --- | ||
|
|
||
| Add support for the Coinbase Wallet web3 provider and authentication strategy. The Coinbase Wallet provider handles both Coinbase Wallet extension and Smart Wallet |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import type { | |
| __experimental_UserVerificationProps, | ||
| ActiveSessionResource, | ||
| AuthenticateWithCoinbaseParams, | ||
| AuthenticateWithCoinbaseWalletParams, | ||
| AuthenticateWithGoogleOneTapParams, | ||
| AuthenticateWithMetamaskParams, | ||
| Clerk as ClerkInterface, | ||
|
|
@@ -75,6 +76,7 @@ import { | |
| disabledOrganizationsFeature, | ||
| errorThrower, | ||
| generateSignatureWithCoinbase, | ||
| generateSignatureWithCoinbaseWallet, | ||
| generateSignatureWithMetamask, | ||
| getClerkQueryParam, | ||
| getWeb3Identifier, | ||
|
|
@@ -1403,6 +1405,10 @@ export class Clerk implements ClerkInterface { | |
| await this.authenticateWithWeb3({ ...props, strategy: 'web3_coinbase_signature' }); | ||
| }; | ||
|
|
||
| public authenticateWithCoinbaseWallet = async (props: AuthenticateWithCoinbaseWalletParams = {}): Promise<void> => { | ||
| await this.authenticateWithWeb3({ ...props, strategy: 'web3_coinbase_wallet_signature' }); | ||
| }; | ||
|
|
||
| public authenticateWithWeb3 = async ({ | ||
| redirectUrl, | ||
| signUpContinueUrl, | ||
|
|
@@ -1415,7 +1421,12 @@ export class Clerk implements ClerkInterface { | |
| } | ||
| const provider = strategy.replace('web3_', '').replace('_signature', '') as Web3Provider; | ||
| const identifier = await getWeb3Identifier({ provider }); | ||
| const generateSignature = provider === 'metamask' ? generateSignatureWithMetamask : generateSignatureWithCoinbase; | ||
| const generateSignature = | ||
| provider === 'metamask' | ||
| ? generateSignatureWithMetamask | ||
| : provider === 'coinbase' | ||
| ? generateSignatureWithCoinbase | ||
| : generateSignatureWithCoinbaseWallet; | ||
|
Comment on lines
+1424
to
+1429
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a follow up PR this will become simpler as we are dropping the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct, on the next PR we are dropping the Coinbase provider in favor of the new Coinbase Wallet |
||
| const navigate = (to: string) => | ||
| customNavigate && typeof customNavigate === 'function' ? customNavigate(to) : this.navigate(to); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -96,6 +96,10 @@ export const WEB3_PROVIDERS: Web3Providers = Object.freeze({ | |||||
| id: 'coinbase', | ||||||
| name: 'Coinbase Wallet', | ||||||
| }, | ||||||
| coinbase_wallet: { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙃 SW = smart wallet
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coinbase prefer to use the term Coinbase Wallet rather than Coinbase Smart Wallet |
||||||
| id: 'coinbase_wallet', | ||||||
| name: 'Coinbase Wallet', | ||||||
| }, | ||||||
| }); | ||||||
|
|
||||||
| export function getWeb3ProviderData(name: Web3Provider): Web3ProviderData | undefined | null { | ||||||
|
|
||||||
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.
Note to reviewers: For now this is lazy loaded with the help of @panteliselef