From 1556615931aa908b18308be90d2ecbcff0c8aea6 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <43042585+0xFirekeeper@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:43:48 +0000 Subject: [PATCH] [Docs] .NET Fix LoginWithOtp Example (#5843) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes TOOL-2863 --- ## PR-Codex overview This PR focuses on simplifying the OTP login process in the `InAppWallet` by removing the `canRetry` variable and related conditional logic, providing a more straightforward approach for handling OTP submissions. ### Detailed summary - Removed the `canRetry` variable from the `LoginWithOtp` method calls. - Simplified the OTP login logic by eliminating the retry checks. - Added comments to indicate where to implement error handling and retries if needed. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../wallets/providers/in-app-wallet/page.mdx | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx b/apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx index 3f59d7cb0f0..ee772449234 100644 --- a/apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx +++ b/apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx @@ -46,7 +46,7 @@ var isConnected = await wallet.IsConnected(); // Email & Phone (OTP) await wallet.SendOTP(); // and fetch the otp -var (address, canRetry) = await wallet.LoginWithOtp("userEnteredOTP"); +var address = await wallet.LoginWithOtp("userEnteredOTP"); // try catch and retry if needed // Socials (OAuth) var address = await wallet.LoginWithOauth( @@ -121,12 +121,8 @@ await wallet.SendOTP(); **Submit OTP:** Once the user receives the OTP, they submit it back to the application, which then calls LoginWithOtp on the InAppWallet instance to verify the OTP and complete the login process. ```csharp -var (address, canRetry) = await wallet.LoginWithOtp("userEnteredOTP"); -if (address != null) { - // Login successful -} else if (canRetry) { - // Ask user to retry entering OTP -} +var address = await wallet.LoginWithOtp("userEnteredOTP"); +// If this fails, feel free to catch and take in another OTP and retry the login process ``` ## Example @@ -143,18 +139,7 @@ if (!await inAppWallet.IsConnected()) await inAppWallet.SendOTP(); Console.WriteLine("Please submit the OTP."); var otp = Console.ReadLine(); - (var inAppWalletAddress, var canRetry) = await inAppWallet.LoginWithOtp(otp); - if (inAppWalletAddress == null && canRetry) - { - Console.WriteLine("Please submit the OTP again."); - otp = Console.ReadLine(); - (inAppWalletAddress, _) = await inAppWallet.LoginWithOtp(otp); - } - if (inAppWalletAddress == null) - { - Console.WriteLine("OTP login failed. Please try again."); - return; - } + var inAppWalletAddress = await inAppWallet.LoginWithOtp(otp); // try catch and retry if needed } Console.WriteLine($"InAppWallet address: {await inAppWallet.GetAddress()}");