-
Notifications
You must be signed in to change notification settings - Fork 419
feat(clerk-js,react,localizations,shared,ui): Add Solana feature support to core 3 #7450
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
base: main
Are you sure you want to change the base?
Changes from all commits
c62d0d6
b81c67c
59e6799
bca9f40
9b31dbe
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/localizations': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| --- | ||
|
|
||
| Add Web3 Solana support to `<UserProfile />` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@clerk/localizations': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| '@clerk/react': minor | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Add support for Sign in with Solana. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import type { | |
| PreparePhoneNumberVerificationParams, | ||
| PrepareVerificationParams, | ||
| PrepareWeb3WalletVerificationParams, | ||
| SignUpAuthenticateWithSolanaParams, | ||
| SignUpAuthenticateWithWeb3Params, | ||
| SignUpCreateParams, | ||
| SignUpEnterpriseConnectionJSON, | ||
|
|
@@ -268,6 +269,7 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| unsafeMetadata, | ||
| strategy = 'web3_metamask_signature', | ||
| legalAccepted, | ||
| walletName, | ||
| } = params || {}; | ||
| const provider = strategy.replace('web3_', '').replace('_signature', '') as Web3Provider; | ||
|
|
||
|
|
@@ -287,7 +289,7 @@ export class SignUp extends BaseResource implements SignUpResource { | |
|
|
||
| let signature: string; | ||
| try { | ||
| signature = await generateSignature({ identifier, nonce: message, provider }); | ||
| signature = await generateSignature({ identifier, nonce: message, provider, walletName }); | ||
| } catch (err) { | ||
| // There is a chance that as a first time visitor when you try to setup and use the | ||
| // Coinbase Wallet from scratch in order to authenticate, the initial generate | ||
|
|
@@ -322,9 +324,7 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| }; | ||
|
|
||
| public authenticateWithCoinbaseWallet = async ( | ||
| params?: SignUpAuthenticateWithWeb3Params & { | ||
| legalAccepted?: boolean; | ||
| }, | ||
| params?: SignUpAuthenticateWithWeb3Params, | ||
| ): Promise<SignUpResource> => { | ||
| const identifier = await web3().getCoinbaseWalletIdentifier(); | ||
| return this.authenticateWithWeb3({ | ||
|
|
@@ -336,11 +336,7 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| }); | ||
| }; | ||
|
|
||
| public authenticateWithBase = async ( | ||
| params?: SignUpAuthenticateWithWeb3Params & { | ||
| legalAccepted?: boolean; | ||
| }, | ||
| ): Promise<SignUpResource> => { | ||
| public authenticateWithBase = async (params?: SignUpAuthenticateWithWeb3Params): Promise<SignUpResource> => { | ||
| const identifier = await web3().getBaseIdentifier(); | ||
| return this.authenticateWithWeb3({ | ||
| identifier, | ||
|
|
@@ -351,11 +347,7 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| }); | ||
| }; | ||
|
|
||
| public authenticateWithOKXWallet = async ( | ||
| params?: SignUpAuthenticateWithWeb3Params & { | ||
| legalAccepted?: boolean; | ||
| }, | ||
| ): Promise<SignUpResource> => { | ||
| public authenticateWithOKXWallet = async (params?: SignUpAuthenticateWithWeb3Params): Promise<SignUpResource> => { | ||
| const identifier = await web3().getOKXWalletIdentifier(); | ||
| return this.authenticateWithWeb3({ | ||
| identifier, | ||
|
|
@@ -366,6 +358,18 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| }); | ||
| }; | ||
|
|
||
| public authenticateWithSolana = async (params: SignUpAuthenticateWithSolanaParams): Promise<SignUpResource> => { | ||
| const identifier = await web3().getSolanaIdentifier(params.walletName); | ||
| return this.authenticateWithWeb3({ | ||
| identifier, | ||
| generateSignature: p => web3().generateSignatureWithSolana({ ...p, walletName: params.walletName }), | ||
| unsafeMetadata: params?.unsafeMetadata, | ||
| strategy: 'web3_solana_signature', | ||
| legalAccepted: params?.legalAccepted, | ||
| walletName: params.walletName, | ||
| }); | ||
| }; | ||
|
Comment on lines
+361
to
+371
Contributor
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. 🛠️ Refactor suggestion | 🟠 Major Add JSDoc documentation for the new public API. The new As per coding guidelines, all public APIs must be documented with JSDoc. Add documentation like this: + /**
+ * Authenticates a user using a Solana Web3 wallet during sign-up.
+ *
+ * @param params - Configuration for Solana authentication
+ * @param params.walletName - The name of the Solana wallet to use (e.g., 'phantom', 'solflare')
+ * @param params.unsafeMetadata - Optional unsafe metadata to attach to the user
+ * @param params.legalAccepted - Optional flag indicating legal terms acceptance
+ * @returns A promise that resolves to the updated SignUp resource
+ * @throws {ClerkRuntimeError} If wallet connection fails
+ *
+ * @example
+ * ```typescript
+ * await signUp.authenticateWithSolana({
+ * walletName: 'phantom',
+ * legalAccepted: true
+ * });
+ * ```
+ */
public authenticateWithSolana = async (params: SignUpAuthenticateWithSolanaParams): Promise<SignUpResource> => {🤖 Prompt for AI Agents |
||
|
|
||
| private authenticateWithRedirectOrPopup = async ( | ||
| params: AuthenticateWithRedirectParams & { | ||
| unsafeMetadata?: SignUpUnsafeMetadata; | ||
|
|
||
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.
🛠️ Refactor suggestion | 🟠 Major
Add JSDoc documentation for the new public API.
The new
authenticateWithSolanamethod is a public API and should include JSDoc comments explaining parameters, return value, and usage.As per coding guidelines, all public APIs must be documented with JSDoc.
Add documentation like this:
🤖 Prompt for AI Agents