Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-frogs-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Fix Web3 connection error handling in `<UserProfile />`
23 changes: 3 additions & 20 deletions packages/clerk-js/src/ui/components/UserProfile/Web3Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ 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 { web3CallbackErrorHandler } from '@/ui/utils/web3CallbackErrorHandler';

import { generateWeb3Signature, getWeb3Identifier } from '../../../utils/web3';
import { descriptors, Image, localizationKeys, Text } from '../../customizables';
import { descriptors, Image, localizationKeys } from '../../customizables';
import { useEnabledThirdPartyProviders } from '../../hooks';

export const AddWeb3WalletActionMenu = () => {
Expand Down Expand Up @@ -60,12 +60,7 @@ export const AddWeb3WalletActionMenu = () => {
card.setIdle();
} catch (err) {
card.setIdle();
const fieldError = getFieldError(err);
if (fieldError) {
card.setError(fieldError.longMessage);
} else {
handleError(err, [], card.setError);
}
web3CallbackErrorHandler(err, card.setError);
}
};

Expand Down Expand Up @@ -110,18 +105,6 @@ export const AddWeb3WalletActionMenu = () => {
<Web3SelectSolanaWalletScreen onConnect={connect} />
</Action.Card>
</Action.Open>

{card.error && (
<Text
colorScheme='danger'
sx={t => ({
padding: t.sizes.$1x5,
paddingLeft: t.sizes.$8x5,
})}
>
{card.error}
</Text>
)}
</>
);
};
10 changes: 7 additions & 3 deletions packages/clerk-js/src/ui/components/UserProfile/Web3Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export const Web3Section = withCardStateProvider(
</Flex>
</Box>
</Flex>
<Web3WalletMenu walletId={walletId} />
<Web3WalletMenu
walletId={walletId}
isVerified={wallet.verification.status === 'verified'}
/>
</ProfileSection.Item>

<Action.Open value={`remove-${walletId}`}>
Expand All @@ -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();
Expand All @@ -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: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ describe('PasswordSection', () => {
updated_at: 123,
logo_public_url: null,
protocol: 'saml',
enterprise_connection_id: 'ent_123',
},
verification: {
status: 'verified',
Expand All @@ -155,6 +156,8 @@ describe('PasswordSection', () => {
object: 'verification',
},
id: 'eac_123',
last_authenticated_at: 123,
enterprise_connection_id: 'ent_123',
},
],
});
Expand Down Expand Up @@ -212,6 +215,7 @@ describe('PasswordSection', () => {
updated_at: 123,
logo_public_url: null,
protocol: 'saml',
enterprise_connection_id: null,
},
verification: {
status: 'verified',
Expand All @@ -228,6 +232,8 @@ describe('PasswordSection', () => {
object: 'verification',
},
id: 'eac_123',
last_authenticated_at: null,
enterprise_connection_id: null,
},
],
});
Expand Down Expand Up @@ -378,6 +384,7 @@ describe('PasswordSection', () => {
updated_at: 123,
logo_public_url: null,
protocol: 'saml',
enterprise_connection_id: null,
},
verification: {
status: 'verified',
Expand All @@ -394,6 +401,8 @@ describe('PasswordSection', () => {
object: 'verification',
},
id: 'eac_123',
last_authenticated_at: null,
enterprise_connection_id: null,
},
],
});
Expand Down Expand Up @@ -452,6 +461,7 @@ describe('PasswordSection', () => {
updated_at: 123,
logo_public_url: null,
protocol: 'saml',
enterprise_connection_id: null,
},
verification: {
status: 'verified',
Expand All @@ -468,6 +478,8 @@ describe('PasswordSection', () => {
object: 'verification',
},
id: 'eac_123',
last_authenticated_at: null,
enterprise_connection_id: null,
},
],
});
Expand Down
Loading