33using link . magic . unity . sdk . Relayer ;
44using Nethereum . Web3 ;
55using Nethereum . Web3 . Accounts ;
6- using UnityEngine ;
76
87namespace 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