Skip to content

Commit 7b25ad8

Browse files
committed
Unified Identity - Account Linking
1 parent 71ffd8d commit 7b25ad8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
12.5 KB
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,11 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
273273
if (walletOptions.InAppWalletOptions.AuthProvider == AuthProvider.Default)
274274
{
275275
await inAppWallet.SendOTP();
276-
_ = await InAppWalletModal.VerifyOTP(inAppWallet);
276+
_ = await InAppWalletModal.LoginWithOtp(inAppWallet);
277277
}
278278
else if (walletOptions.InAppWalletOptions.AuthProvider == AuthProvider.Siwe)
279279
{
280-
var siweSigner = walletOptions.InAppWalletOptions.SiweSigner;
281-
_ = await inAppWallet.LoginWithSiwe(siweSigner, walletOptions.ChainId);
280+
_ = await inAppWallet.LoginWithSiwe(walletOptions.ChainId);
282281
}
283282
else
284283
{
@@ -356,6 +355,21 @@ public async Task<SmartWallet> UpgradeToSmartWallet(IThirdwebWallet personalWall
356355
return wallet;
357356
}
358357

358+
public async Task<List<LinkedAccount>> LinkAccount(InAppWallet mainWallet, InAppWallet walletToLink, string otp = null, BigInteger? chainId = null, string jwtOrPayload = null)
359+
{
360+
return await mainWallet.LinkAccount(
361+
walletToLink: walletToLink,
362+
otp: otp,
363+
isMobile: Application.isMobilePlatform,
364+
browserOpenAction: (url) => Application.OpenURL(url),
365+
mobileRedirectScheme: BundleId + "://",
366+
browser: new CrossPlatformUnityBrowser(),
367+
chainId: chainId,
368+
jwt: jwtOrPayload,
369+
payload: jwtOrPayload
370+
);
371+
}
372+
359373
private async void TrackUsage(string source, string action, string walletType, string walletAddress)
360374
{
361375
if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(action) || string.IsNullOrEmpty(walletType) || string.IsNullOrEmpty(walletAddress))

Assets/Thirdweb/Runtime/Unity/Wallets/UI/InAppWalletModal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class InAppWalletModal : MonoBehaviour
1616
[field: SerializeField]
1717
private Button SubmitButton { get; set; }
1818

19-
public static Task<InAppWallet> VerifyOTP(InAppWallet wallet)
19+
public static Task<InAppWallet> LoginWithOtp(InAppWallet wallet)
2020
{
2121
#if UNITY_6000_0_OR_NEWER
2222
var modal = FindAnyObjectByType<InAppWalletModal>();
@@ -47,7 +47,7 @@ public static Task<InAppWallet> VerifyOTP(InAppWallet wallet)
4747

4848
modal.OTPInputField.interactable = false;
4949
modal.SubmitButton.interactable = false;
50-
(var address, var canRetry) = await wallet.SubmitOTP(otp);
50+
(var address, var canRetry) = await wallet.LoginWithOtp(otp);
5151
if (address != null)
5252
{
5353
modal.InAppWalletCanvas.gameObject.SetActive(false);

0 commit comments

Comments
 (0)