Skip to content

Conversation

@AlbertoElias
Copy link
Collaborator

Description

Our onAuthRequired callbacks were specific to email signer, this uses the OtpSigner naming to bring both email and phone under the same umbrella

Test plan

Tested with demo apps

Package updates

react-ui: minor
react-native: minor
wallets: minor

@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2025

🦋 Changeset detected

Latest commit: 26b7718

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@crossmint/client-sdk-react-native-ui Minor
@crossmint/client-sdk-react-ui Minor
@crossmint/wallets-sdk Minor
expo-demo Patch
@crossmint/auth-ssr-nextjs-demo Patch
@crossmint/client-sdk-react-ui-starter Patch
@crossmint/client-sdk-nextjs-starter Patch
@crossmint/wallets-quickstart-devkit Patch
@crossmint/client-sdk-smart-wallet-next-starter Patch
@crossmint/client-sdk-react-base Patch

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

@vercel
Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
smart-wallet-auth-demo ⬜️ Ignored (Inspect) Jul 24, 2025 4:33pm

}

if (!context.sendOtp || !context.verifyOtp || !context.reject) {
throw new Error("Otp signer functions are not available. Make sure you're using an otp signer wallet.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This error seems a bit hard to parse, do we call these "otp signer wallet" when you create a wallet?

Doesnt a wallet have multple signers? If so does only one of them need to have OTP?

Copy link
Contributor

Choose a reason for hiding this comment

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

Somehting like "The wallet in context doesn't have any OTP signer configured. Register an OTP signer first before initializing this hook."

throw new Error("useWalletOtpSigner must be used within CrossmintWalletProvider");
}

if (!context.sendOtp || !context.verifyOtp || !context.reject) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - re these nullable checks? If so, can you pls use context.sendOtp == null etc to be explicit (Crossmint code convention)

const loggedInUserEmail = experimental_customAuth?.email ?? null;
const { wallet, getOrCreateWallet, status: walletStatus } = useWallet();
const { needsAuth, sendEmailWithOtp, verifyOtp } = useWalletEmailSigner();
const { needsAuth, sendOtp, verifyOtp } = useWalletOtpSigner();
Copy link
Contributor

Choose a reason for hiding this comment

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

needsAuth -- dont use Auth, name it something like isInitialized (and invert it)

const loggedInUserEmail = experimental_customAuth?.email ?? null;
const { wallet, getOrCreateWallet, status: walletStatus } = useWallet();
const { needsAuth, sendEmailWithOtp, verifyOtp } = useWalletEmailSigner();
const { needsAuth, sendOtp, verifyOtp } = useWalletOtpSigner();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

walletSignerNeedsSetup
otpSignerNeedsSetup
otpSignerInitialized

const loggedInUserEmail = experimental_customAuth?.email ?? null;
const { wallet, getOrCreateWallet, status: walletStatus } = useWallet();
const { needsAuth, sendEmailWithOtp, verifyOtp } = useWalletEmailSigner();
const { needsAuth, sendOtp, verifyOtp } = useWalletOtpSigner();
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be wrong but iirc its an anti pattern to have read and write properties in the same hook

Copy link
Contributor

Choose a reason for hiding this comment

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

where does that come from? The most used hook in react has both a read and write state:

const [count, setCount] = useState(0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants