3
3
using link . magic . unity . sdk . Relayer ;
4
4
using Nethereum . Web3 ;
5
5
using Nethereum . Web3 . Accounts ;
6
- using UnityEngine ;
7
6
8
7
namespace Thirdweb . Wallets
9
8
{
@@ -13,33 +12,30 @@ public class ThirdwebMagicLink : IThirdwebWallet
13
12
private WalletProvider _provider ;
14
13
private WalletProvider _signerProvider ;
15
14
private string _magicLinkApiKey ;
15
+ private Magic _magic ;
16
16
17
17
public ThirdwebMagicLink ( string magicLinkApiKey )
18
18
{
19
19
_web3 = null ;
20
20
_provider = WalletProvider . MagicLink ;
21
21
_signerProvider = WalletProvider . MagicLink ;
22
22
_magicLinkApiKey = magicLinkApiKey ;
23
+ _magic = null ;
23
24
}
24
25
25
26
public async Task < string > Connect ( WalletConnection walletConnection , string rpc )
26
27
{
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 ) ) ;
33
29
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 ) ;
36
32
37
33
return await GetAddress ( ) ;
38
34
}
39
35
40
36
public async Task Disconnect ( )
41
37
{
42
- await MagicUnity . Instance . DisableMagicAuth ( ) ;
38
+ await _magic . User . Logout ( ) ;
43
39
_web3 = null ;
44
40
}
45
41
@@ -50,7 +46,8 @@ public Account GetLocalAccount()
50
46
51
47
public async Task < string > GetAddress ( )
52
48
{
53
- var addy = await MagicUnity . Instance . GetAddress ( ) ;
49
+ var metadata = await _magic . User . GetMetadata ( ) ;
50
+ var addy = metadata . publicAddress ;
54
51
if ( addy != null )
55
52
addy = addy . ToChecksumAddress ( ) ;
56
53
return addy ;
0 commit comments