-
Couldn't load subscription status.
- Fork 402
chore(clerk-js,types,localizations): Improve error handling when web3 wallet is not installed #4845
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
chore(clerk-js,types,localizations): Improve error handling when web3 wallet is not installed #4845
Conversation
🦋 Changeset detectedLatest commit: 4c5fe2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 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 |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| export const web3CallbackErrorHandler: Web3CallbackErrorHandler = (err, setError) => { | ||
| if ( | ||
| isClerkAPIResponseError(err) && | ||
| err.errors[0].meta?.paramName === 'identifier' && | ||
| err.errors[0].code === 'form_param_nil' | ||
| ) { | ||
| const error = new ClerkRuntimeError('Please install a Web3 wallet.', { | ||
| code: 'web3_missing_identifier', | ||
| }); | ||
|
|
||
| return handleError(error, [], setError); | ||
| } | ||
| return handleError(err, [], setError); | ||
| }; |
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 introduced web3CallbackErrorHandler and avoid to throw an error in getWeb3Identifier and generateWeb3Signature because we don't want to introduce a break change
packages/clerk-js/src/utils/web3.ts
Outdated
| const { provider } = params; | ||
| const ethereum = await getEthereumProvider(provider); | ||
|
|
||
| // TODO: Improve error handling for the case when the provider is not found |
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.
Adding a TODO for core-3
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.
Can we include something in the todo comment that indicates it's a breaking change for core 3? 🤔
packages/clerk-js/src/utils/web3.ts
Outdated
| const { identifier, nonce, provider } = params; | ||
| const ethereum = await getEthereumProvider(provider); | ||
|
|
||
| // TODO: Improve error handling for the case when the provider is not found |
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.
Adding a TODO for core-3
| err.errors[0].meta?.paramName === 'identifier' && | ||
| err.errors[0].code === 'form_param_nil' | ||
| ) { | ||
| const error = new ClerkRuntimeError('Please install a Web3 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 mention the browser?
| const error = new ClerkRuntimeError('Please install a Web3 wallet.', { | |
| const error = new ClerkRuntimeError('Please install a Web3 wallet in your browser.', { |
| err.errors[0].meta?.paramName === 'identifier' && | ||
| err.errors[0].code === 'form_param_nil' | ||
| ) { | ||
| const error = new ClerkRuntimeError('Please install a Web3 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.
Maybe we can make the error a bit more user friendly
| const error = new ClerkRuntimeError('Please install a Web3 wallet.', { | |
| const error = new ClerkRuntimeError('A Web3 Wallet extension cannot be found. Please install one to continue.', { |
packages/localizations/src/en-US.ts
Outdated
| passkey_pa_not_supported: 'Registration requires a platform authenticator but the device does not support it.', | ||
| passkey_registration_cancelled: 'Passkey registration was cancelled or timed out.', | ||
| passkey_retrieval_cancelled: 'Passkey verification was cancelled or timed out.', | ||
| web3_missing_identifier: 'Please install a Web3 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.
| web3_missing_identifier: 'Please install a Web3 wallet.', | |
| web3_missing_identifier: 'A Web3 Wallet extension cannot be found. Please install one to continue.', |
6e6903e to
697cdcb
Compare
… wallet is not installed
697cdcb to
4c5fe2f
Compare
… wallet is not installed (#4845)
… wallet is not installed (#4845)
Description
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
After