-
Notifications
You must be signed in to change notification settings - Fork 455
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
Changes from 15 commits
06b934c
0c1878d
5323789
9ac851d
d4dba5a
dca9fc0
646f881
766e150
b2d2c62
fc7717b
956a603
31a164a
c61fb7d
26178c7
17a3bec
1fab9a4
94802ea
e0c16da
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,36 @@ export class SignUp extends BaseResource implements SignUpResource { | |
| }); | ||
| }; | ||
|
|
||
| /** | ||
| * 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') | ||
| * @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> => { | ||
| 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, | ||
| }); | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
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. [nit] It would be cleaner to destructure params directly in the signature for more consistency in property access (with or without ?) No need to change it now, but maybe we can do that as a follow up.
Contributor
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. We can update this to follow that pattern. 👍 |
||
|
|
||
| private authenticateWithRedirectOrPopup = async ( | ||
| params: AuthenticateWithRedirectParams & { | ||
| unsafeMetadata?: SignUpUnsafeMetadata; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.