diff --git a/.changeset/hot-emus-join.md b/.changeset/hot-emus-join.md new file mode 100644 index 000000000..db2cccf15 --- /dev/null +++ b/.changeset/hot-emus-join.md @@ -0,0 +1,5 @@ +--- +"@crossmint/client-sdk-react-native-ui": minor +--- + +Added new built-in UI for email and phone signers, can use 'headlessSigningFlow' to disable. diff --git a/.changeset/pink-owls-prove.md b/.changeset/pink-owls-prove.md new file mode 100644 index 000000000..5f1269cd6 --- /dev/null +++ b/.changeset/pink-owls-prove.md @@ -0,0 +1,5 @@ +--- +"@crossmint/client-sdk-react-base": patch +--- + +Consolidated UI state within base provider. diff --git a/.changeset/selfish-comics-grow.md b/.changeset/selfish-comics-grow.md new file mode 100644 index 000000000..1d184857d --- /dev/null +++ b/.changeset/selfish-comics-grow.md @@ -0,0 +1,5 @@ +--- +"@crossmint/client-sdk-react-ui": patch +--- + +Updated CrossmintWalletProvider to consume shared state management from base provider, improving consistency across React implementations. \ No newline at end of file diff --git a/apps/wallets/smart-wallet/expo/app/_layout.tsx b/apps/wallets/smart-wallet/expo/app/_layout.tsx index 752649585..5a8666878 100644 --- a/apps/wallets/smart-wallet/expo/app/_layout.tsx +++ b/apps/wallets/smart-wallet/expo/app/_layout.tsx @@ -20,7 +20,12 @@ function CrossmintProviders({ children }: { children: ReactNode }) { return ( - {children} + + {children} + ); diff --git a/apps/wallets/smart-wallet/expo/app/index.tsx b/apps/wallets/smart-wallet/expo/app/index.tsx index c4d80bd32..03987ccda 100644 --- a/apps/wallets/smart-wallet/expo/app/index.tsx +++ b/apps/wallets/smart-wallet/expo/app/index.tsx @@ -1,35 +1,25 @@ -import { - useCrossmintAuth, - useWallet, - useWalletEmailSigner, - useCrossmint, - type Balances, - ExportPrivateKeyButton, -} from "@crossmint/client-sdk-react-native-ui"; +import { useWallet, useAuth, type Balances } from "@crossmint/client-sdk-react-native-ui"; import { useEffect, useMemo, useState } from "react"; import { ActivityIndicator, Button, Text, View, TextInput, StyleSheet, ScrollView, Alert } from "react-native"; import * as Linking from "expo-linking"; import { fundUSDC } from "@/utils/usdcFaucet"; +import { HeadlessSigning } from "@/components/headless-signing"; export default function Index() { - const { loginWithOAuth, user, logout, createAuthSession, jwt } = useCrossmintAuth(); - const { experimental_customAuth } = useCrossmint(); - const loggedInUserEmail = experimental_customAuth?.email ?? null; - const { wallet, getOrCreateWallet, status: walletStatus } = useWallet(); - const { needsAuth, sendEmailWithOtp, verifyOtp, reject } = useWalletEmailSigner(); + const { loginWithOAuth, user, logout, createAuthSession, jwt } = useAuth(); + const { wallet, status: walletStatus } = useWallet(); const walletAddress = useMemo(() => wallet?.address, [wallet]); const url = Linking.useURL(); const [balances, setBalances] = useState(null); const [isLoading, setIsLoading] = useState(false); - // Email signer states - const [otp, setOtp] = useState(""); const [txLink, setTxLink] = useState(null); - const [uiError, setUiError] = useState(null); const [recipientAddress, setRecipientAddress] = useState(""); const [amount, setAmount] = useState(""); + console.log("wallet", wallet); + useEffect(() => { if (url != null) { createAuthSession(url); @@ -51,37 +41,6 @@ export default function Index() { fetchBalances(); }, [wallet]); - const handleAction = async (action: () => Promise | void) => { - setIsLoading(true); - setUiError(null); - setTxLink(null); - try { - await action(); - } catch (e: any) { - console.error(e); - const message = e.message || "An unexpected error occurred."; - setUiError(message); - Alert.alert("Error", message); - } finally { - setIsLoading(false); - } - }; - - async function initWallet() { - if (user == null) { - console.log("User not logged in"); - return; - } - setIsLoading(true); - try { - await getOrCreateWallet({ chain: "base-sepolia", signer: { type: "email" } }); - } catch (error) { - console.error("Error initializing wallet:", error); - } finally { - setIsLoading(false); - } - } - async function onHandleFundUSDC() { if (walletAddress == null) { console.log("Wallet address not found"); @@ -101,26 +60,6 @@ export default function Index() { } } - const handleSendOtpEmail = async () => { - if (typeof loggedInUserEmail !== "string") { - Alert.alert("Error", "User email is not available."); - return; - } - - await handleAction(sendEmailWithOtp); - }; - - const handleVerifyOtpInput = async () => { - if (!otp || !verifyOtp) { - Alert.alert("Error", "Please enter the OTP and ensure email signer is available."); - return; - } - await handleAction(async () => { - await verifyOtp(otp); - setOtp(""); - }); - }; - async function sendUSDC() { if (walletStatus !== "loaded" || wallet == null) { Alert.alert("Error", "Wallet is not loaded or is not a Solana smart wallet."); @@ -148,59 +87,47 @@ export default function Index() { User: {user?.email} Wallet: {walletAddress} Auth Status: {walletStatus} - Needs OTP Auth: {needsAuth ? "Yes" : "No"} Native Token Balance: ({balances?.nativeToken.symbol}) {balances?.nativeToken.amount} USDC Balance: {balances?.usdc.amount} - {uiError && Last Action Error: {uiError}} {txLink && Last Tx Link: {txLink}} -