diff --git a/.changeset/busy-frogs-type.md b/.changeset/busy-frogs-type.md new file mode 100644 index 00000000000..e7dd1713db6 --- /dev/null +++ b/.changeset/busy-frogs-type.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Fix Web3 connection error handling in `` diff --git a/packages/ui/src/components/UserProfile/Web3Form.tsx b/packages/ui/src/components/UserProfile/Web3Form.tsx index 942986707ba..a2765b22f44 100644 --- a/packages/ui/src/components/UserProfile/Web3Form.tsx +++ b/packages/ui/src/components/UserProfile/Web3Form.tsx @@ -2,16 +2,15 @@ import { createWeb3 } from '@clerk/shared/internal/clerk-js/web3'; import { useReverification, useUser } from '@clerk/shared/react'; import type { Web3Provider, Web3Strategy } from '@clerk/shared/types'; +import { useModuleManager } from '@/contexts'; +import { descriptors, Image, localizationKeys } from '@/customizables'; +import { useEnabledThirdPartyProviders } from '@/hooks'; import { Web3SelectSolanaWalletScreen } from '@/ui/components/UserProfile/Web3SelectSolanaWalletScreen'; import { Action } from '@/ui/elements/Action'; import { useActionContext } from '@/ui/elements/Action/ActionRoot'; import { useCardState } from '@/ui/elements/contexts'; import { ProfileSection } from '@/ui/elements/Section'; -import { getFieldError, handleError } from '@/ui/utils/errorHandler'; - -import { useModuleManager } from '../../contexts'; -import { descriptors, Image, localizationKeys, Text } from '../../customizables'; -import { useEnabledThirdPartyProviders } from '../../hooks'; +import { web3CallbackErrorHandler } from '@/ui/utils/web3CallbackErrorHandler'; export const AddWeb3WalletActionMenu = () => { const card = useCardState(); @@ -64,12 +63,7 @@ export const AddWeb3WalletActionMenu = () => { card.setIdle(); } catch (err: any) { card.setIdle(); - const fieldError = getFieldError(err); - if (fieldError) { - card.setError(fieldError.longMessage); - } else { - handleError(err, [], card.setError); - } + web3CallbackErrorHandler(err, card.setError); } }; @@ -116,18 +110,6 @@ export const AddWeb3WalletActionMenu = () => { - - {card.error && ( - ({ - padding: t.sizes.$1x5, - paddingLeft: t.sizes.$8x5, - })} - > - {card.error} - - )} ); }; diff --git a/packages/ui/src/components/UserProfile/Web3Section.tsx b/packages/ui/src/components/UserProfile/Web3Section.tsx index cbdd0934091..525246c6bd0 100644 --- a/packages/ui/src/components/UserProfile/Web3Section.tsx +++ b/packages/ui/src/components/UserProfile/Web3Section.tsx @@ -95,7 +95,10 @@ export const Web3Section = withCardStateProvider( - + @@ -115,7 +118,7 @@ export const Web3Section = withCardStateProvider( }, ); -const Web3WalletMenu = ({ walletId }: { walletId: string }) => { +const Web3WalletMenu = ({ walletId, isVerified }: { walletId: string; isVerified: boolean }) => { const card = useCardState(); const { open } = useActionContext(); const { user } = useUser(); @@ -126,7 +129,8 @@ const Web3WalletMenu = ({ walletId }: { walletId: string }) => { const actions = ( [ - !isPrimary + // Only allow setting as primary if the wallet is verified and not already primary + !isPrimary && isVerified ? { label: localizationKeys('userProfile.start.web3WalletsSection.detailsAction__nonPrimary'), onClick: () => { diff --git a/packages/ui/src/components/UserProfile/__tests__/PasswordSection.test.tsx b/packages/ui/src/components/UserProfile/__tests__/PasswordSection.test.tsx index 45a0b7f6afc..854fa978b27 100644 --- a/packages/ui/src/components/UserProfile/__tests__/PasswordSection.test.tsx +++ b/packages/ui/src/components/UserProfile/__tests__/PasswordSection.test.tsx @@ -139,6 +139,7 @@ describe('PasswordSection', () => { updated_at: 123, logo_public_url: null, protocol: 'saml', + enterprise_connection_id: 'ent_123', }, verification: { status: 'verified', @@ -155,6 +156,8 @@ describe('PasswordSection', () => { object: 'verification', }, id: 'eac_123', + last_authenticated_at: 123, + enterprise_connection_id: 'ent_123', }, ], }); @@ -212,6 +215,7 @@ describe('PasswordSection', () => { updated_at: 123, logo_public_url: null, protocol: 'saml', + enterprise_connection_id: null, }, verification: { status: 'verified', @@ -228,6 +232,8 @@ describe('PasswordSection', () => { object: 'verification', }, id: 'eac_123', + last_authenticated_at: null, + enterprise_connection_id: null, }, ], }); @@ -378,6 +384,7 @@ describe('PasswordSection', () => { updated_at: 123, logo_public_url: null, protocol: 'saml', + enterprise_connection_id: null, }, verification: { status: 'verified', @@ -394,6 +401,8 @@ describe('PasswordSection', () => { object: 'verification', }, id: 'eac_123', + last_authenticated_at: null, + enterprise_connection_id: null, }, ], }); @@ -452,6 +461,7 @@ describe('PasswordSection', () => { updated_at: 123, logo_public_url: null, protocol: 'saml', + enterprise_connection_id: null, }, verification: { status: 'verified', @@ -468,6 +478,8 @@ describe('PasswordSection', () => { object: 'verification', }, id: 'eac_123', + last_authenticated_at: null, + enterprise_connection_id: null, }, ], });