Skip to content
Open
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
6 changes: 6 additions & 0 deletions .changeset/fix-otp-error-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@crossmint/client-sdk-wallets": patch
"@crossmint/client-sdk-react-ui": patch
---

Fix OTP verification error handling to properly propagate errors to UI. When users entered an incorrect OTP or hit rate limits, errors are now properly displayed instead of silently restarting the auth flow.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function CrossmintWalletProvider({
setEmailSignerDialogStep("otp");
} catch (error) {
console.error("Failed to send email OTP", error);
rejectRef.current(new Error("Failed to send email OTP"));
throw error;
}
};

Expand All @@ -112,7 +112,7 @@ export function CrossmintWalletProvider({
setEmailSignerDialogOpen(false);
} catch (error) {
console.error("Failed to verify OTP", error);
rejectRef.current(new Error("Failed to verify OTP"));
throw error;
}
};

Expand All @@ -123,7 +123,7 @@ export function CrossmintWalletProvider({
setPhoneSignerDialogStep("otp");
} catch (error) {
console.error("Failed to send phone OTP", error);
rejectRef.current(new Error("Failed to send phone OTP"));
throw error;
}
};

Expand All @@ -133,7 +133,7 @@ export function CrossmintWalletProvider({
setPhoneSignerDialogOpen(false);
} catch (error) {
console.error("Failed to verify phone OTP", error);
rejectRef.current(new Error("Failed to verify phone OTP"));
throw error;
}
};

Expand Down
4 changes: 3 additions & 1 deletion packages/wallets/src/signers/non-custodial/ncs-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export abstract class NonCustodialSigner implements Signer {

if (response?.status === "error") {
console.error("[sendMessageWithOtp] Failed to send OTP:", response);
this._authPromise?.reject(new Error(response.error || "Failed to initiate OTP process."));
const error = new Error(response.error || "Failed to initiate OTP process.");
this._authPromise?.reject(error);
throw error;
}
}

Expand Down