Skip to content

Commit 046645b

Browse files
committed
Remove reliance on MagicUnity / related prefab
1 parent 7900941 commit 046645b

File tree

4 files changed

+8
-67
lines changed

4 files changed

+8
-67
lines changed

Assets/Thirdweb/Core/Prefabs/WalletProvider_MagicAuth.prefab

Lines changed: 0 additions & 46 deletions
This file was deleted.

Assets/Thirdweb/Core/Prefabs/WalletProvider_MagicAuth.prefab.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public class ThirdwebManager : MonoBehaviour
9393
[Tooltip("Instantiates the WalletConnect SDK for Native platforms.")]
9494
public GameObject WalletConnectPrefab;
9595

96-
[Tooltip("Instantiates the MagicAuth SDK for Native platforms.")]
97-
public GameObject MagicAuthPrefab;
98-
9996
[Tooltip("Instantiates the Metamask SDK for Native platforms.")]
10097
public GameObject MetamaskPrefab;
10198

Assets/Thirdweb/Core/Scripts/Wallets/ThirdwebMagicLink.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using link.magic.unity.sdk.Relayer;
44
using Nethereum.Web3;
55
using Nethereum.Web3.Accounts;
6-
using UnityEngine;
76

87
namespace Thirdweb.Wallets
98
{
@@ -13,33 +12,30 @@ public class ThirdwebMagicLink : IThirdwebWallet
1312
private WalletProvider _provider;
1413
private WalletProvider _signerProvider;
1514
private string _magicLinkApiKey;
15+
private Magic _magic;
1616

1717
public ThirdwebMagicLink(string magicLinkApiKey)
1818
{
1919
_web3 = null;
2020
_provider = WalletProvider.MagicLink;
2121
_signerProvider = WalletProvider.MagicLink;
2222
_magicLinkApiKey = magicLinkApiKey;
23+
_magic = null;
2324
}
2425

2526
public async Task<string> Connect(WalletConnection walletConnection, string rpc)
2627
{
27-
if (MagicUnity.Instance == null)
28-
{
29-
GameObject.Instantiate(ThirdwebManager.Instance.MagicAuthPrefab);
30-
await new WaitForSeconds(0.5f);
31-
MagicUnity.Instance.Initialize(_magicLinkApiKey, new CustomNodeConfiguration(rpc, walletConnection.chainId));
32-
}
28+
_magic = new Magic(_magicLinkApiKey, new CustomNodeConfiguration(rpc, walletConnection.chainId));
3329

34-
await MagicUnity.Instance.EnableMagicAuth(walletConnection.email);
35-
_web3 = new Web3(Magic.Instance.Provider);
30+
await _magic.Auth.LoginWithEmailOtp(walletConnection.email);
31+
_web3 = new Web3(_magic.Provider);
3632

3733
return await GetAddress();
3834
}
3935

4036
public async Task Disconnect()
4137
{
42-
await MagicUnity.Instance.DisableMagicAuth();
38+
await _magic.User.Logout();
4339
_web3 = null;
4440
}
4541

@@ -50,7 +46,8 @@ public Account GetLocalAccount()
5046

5147
public async Task<string> GetAddress()
5248
{
53-
var addy = await MagicUnity.Instance.GetAddress();
49+
var metadata = await _magic.User.GetMetadata();
50+
var addy = metadata.publicAddress;
5451
if (addy != null)
5552
addy = addy.ToChecksumAddress();
5653
return addy;

0 commit comments

Comments
 (0)