11using System . Collections . Generic ;
22using System . IO ;
3+ using System . Linq ;
34using TMPro ;
45using UnityEngine ;
56
@@ -17,7 +18,7 @@ public class EcosystemWalletManager : MonoBehaviour
1718 public TMP_Text LogText ;
1819
1920 private ThirdwebClient _client ;
20- private EcosystemWallet _ecosystemWallet ;
21+ private IThirdwebWallet _ecosystemWallet ;
2122
2223 private void Awake ( )
2324 {
@@ -96,15 +97,16 @@ public async void Login()
9697 }
9798
9899 string address ;
99- if ( await _ecosystemWallet . IsConnected ( ) )
100+ if ( ! await _ecosystemWallet . IsConnected ( ) && _ecosystemWallet is EcosystemWallet )
100101 {
101- address = await _ecosystemWallet . GetAddress ( ) ;
102- Log ( $ "Connected with address: { address } ") ;
103- return ;
102+ _ = await ( _ecosystemWallet as EcosystemWallet ) . SendOTP ( ) ;
103+ _ecosystemWallet = await EcosystemWalletModal . LoginWithOtp ( _ecosystemWallet as EcosystemWallet ) ;
104104 }
105105
106- _ = await _ecosystemWallet . SendOTP ( ) ;
107- _ecosystemWallet = await EcosystemWalletModal . LoginWithOtp ( _ecosystemWallet ) ;
106+ if ( _ecosystemWallet is not SmartWallet )
107+ {
108+ _ecosystemWallet = await SmartWallet . Create ( _ecosystemWallet , 421614 , gasless : true ) ;
109+ }
108110
109111 address = await _ecosystemWallet . GetAddress ( ) ;
110112 Log ( $ "Connected with address: { address } ") ;
@@ -132,10 +134,9 @@ public async void SignTransaction()
132134 }
133135
134136 var address = await _ecosystemWallet . GetAddress ( ) ;
135- var nonce = await _ecosystemWallet . GetTransactionCount ( chainId : 421614 , blocktag : "pending" ) ;
136- var tx = new ThirdwebTransactionInput ( chainId : 421614 , from : address , to : address , nonce : nonce , gas : 100000 , gasPrice : 200000000 , value : 0 , data : "0x" ) ;
137- var signature = await _ecosystemWallet . SignTransaction ( tx ) ;
138- Log ( $ "Transaction Signed: { signature } ") ;
137+ var contract = await ThirdwebContract . Create ( _client , "0xEBB8a39D865465F289fa349A67B3391d8f910da9" , 421614 ) ;
138+ var receipt = await contract . DropERC20_Claim ( _ecosystemWallet , address , "1" ) ;
139+ Log ( $ "Hash: { receipt . TransactionHash } ") ;
139140 }
140141
141142 private void Log ( string message )
0 commit comments