Skip to content
Closed
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
17 changes: 13 additions & 4 deletions apps/wallets/smart-wallet/expo/components/headless-signing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function HeadlessSigning() {
const { user } = useCrossmintAuth();
const { createDeviceSigner, wallet } = useWallet();
const loggedInUserEmail = user?.email ?? null;
const { needsAuth, sendEmailWithOtp, verifyOtp, reject } = useWalletOtpSigner();
const { needsAuth, sendOtp, verifyOtp, reject } = useWalletOtpSigner();

const [isLoading, setIsLoading] = useState<boolean>(false);

Expand Down Expand Up @@ -40,8 +40,17 @@ export function HeadlessSigning() {
}
setIsLoading(true);
try {
const descriptor = await createDeviceSigner();
await wallet.addSigner(descriptor.locator);
const descriptor = await createDeviceSigner(wallet.address);
if (descriptor == null || descriptor.publicKey == null) {
throw new Error(
`Creating a device signer returned an invalid descriptor: ${descriptor == null ? String(descriptor) : JSON.stringify(descriptor, null, 2)}`
);
}
await wallet.addSigner({
type: "device",
publicKey: descriptor.publicKey,
name: descriptor.name,
});
} catch (error) {
console.error("Error initializing wallet:", error);
} finally {
Comment on lines 54 to 56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Errors silently swallowed in initWallet

The catch block in initWallet only calls console.error, but doesn't update the UI error state (setUiError) or show an Alert to the user. This is inconsistent with how handleAction works, and means the new validation error thrown at lines 45–48 will never be surfaced to the user — it will only appear in the console.

Consider refactoring initWallet to delegate to handleAction by extracting the core logic into the passed callback. That way setUiError and Alert.alert are triggered on failure, consistent with how handleSendOtpEmail and handleVerifyOtpInput work.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/wallets/smart-wallet/expo/components/headless-signing.tsx
Line: 54-56

Comment:
**Errors silently swallowed in `initWallet`**

The `catch` block in `initWallet` only calls `console.error`, but doesn't update the UI error state (`setUiError`) or show an `Alert` to the user. This is inconsistent with how `handleAction` works, and means the new validation error thrown at lines 45–48 will never be surfaced to the user — it will only appear in the console.

Consider refactoring `initWallet` to delegate to `handleAction` by extracting the core logic into the passed callback. That way `setUiError` and `Alert.alert` are triggered on failure, consistent with how `handleSendOtpEmail` and `handleVerifyOtpInput` work.

How can I resolve this? If you propose a fix, please make it concise.

Expand All @@ -55,7 +64,7 @@ export function HeadlessSigning() {
return;
}

await handleAction(sendEmailWithOtp);
await handleAction(sendOtp);
};

const handleVerifyOtpInput = async () => {
Expand Down
Loading