@@ -97,6 +97,8 @@ public class Prefab_ConnectWallet : MonoBehaviour
9797 private WalletProvider _walletProvider ;
9898 private WalletProvider _personalWalletProvider ;
9999 private string _address ;
100+ private string _email ;
101+ private string _password ;
100102
101103 private void Start ( )
102104 {
@@ -134,6 +136,9 @@ private void Start()
134136 OrGameObject . SetActive ( usingEmailWallet && usingNormalWallet ) ;
135137
136138 _currentChainData = ThirdwebManager . Instance . supportedChains . Find ( x => x . identifier == ThirdwebManager . Instance . chain ) ;
139+ _address = null ;
140+ _email = null ;
141+ _password = null ;
137142 }
138143
139144 public void ToggleConnectPanel ( bool active )
@@ -147,8 +152,6 @@ private void ValidateConnection(WalletProvider walletProvider)
147152
148153 ConnectPanel . SetActive ( false ) ;
149154
150- string email = null ;
151- string password = null ;
152155 WalletProvider personalWallet = WalletProvider . LocalWallet ;
153156
154157 switch ( walletProvider )
@@ -163,7 +166,7 @@ private void ValidateConnection(WalletProvider walletProvider)
163166 }
164167 else
165168 {
166- email = SupportedWalletsUI [ walletProvider ] . emailInput . text ;
169+ _email = SupportedWalletsUI [ walletProvider ] . emailInput . text ;
167170 break ;
168171 }
169172 case WalletProvider . LocalWallet :
@@ -174,7 +177,7 @@ private void ValidateConnection(WalletProvider walletProvider)
174177 return ;
175178 }
176179
177- ConnectWallet ( walletProvider , password , email , personalWallet ) ;
180+ ConnectWallet ( walletProvider , _password , _email , personalWallet ) ;
178181 }
179182
180183 public void ToggleLocalWalletUISaved ( bool active )
@@ -183,17 +186,17 @@ public void ToggleLocalWalletUISaved(bool active)
183186 LocalWalletSavedConnectButton . onClick . RemoveAllListeners ( ) ;
184187 LocalWalletSavedConnectButton . onClick . AddListener ( ( ) =>
185188 {
186- string password = string . IsNullOrEmpty ( LocalWalletSavedPasswordInput . text ) ? null : LocalWalletSavedPasswordInput . text ;
189+ _password = string . IsNullOrEmpty ( LocalWalletSavedPasswordInput . text ) ? null : LocalWalletSavedPasswordInput . text ;
187190 try
188191 {
189- Utils . UnlockOrGenerateLocalAccount ( BigInteger . Parse ( _currentChainData . chainId ) , password ) ;
192+ Utils . UnlockOrGenerateLocalAccount ( BigInteger . Parse ( _currentChainData . chainId ) , _password ) ;
190193 }
191194 catch ( UnityException )
192195 {
193196 LocalWalletSavedPasswordWrong . SetActive ( true ) ;
194197 return ;
195198 }
196- ConnectWallet ( WalletProvider . LocalWallet , password , null , WalletProvider . LocalWallet ) ;
199+ ConnectWallet ( WalletProvider . LocalWallet , _password , null , WalletProvider . LocalWallet ) ;
197200 LocalWalletUISaved . SetActive ( false ) ;
198201 } ) ;
199202
@@ -216,8 +219,8 @@ public void ToggleLocalWalletUINew(bool active)
216219 if ( ! Utils . IsWebGLBuild ( ) && Utils . HasStoredAccount ( ) )
217220 Utils . DeleteLocalAccount ( ) ;
218221
219- string password = string . IsNullOrEmpty ( LocalWalletNewPasswordInput . text ) ? null : LocalWalletNewPasswordInput . text ;
220- ConnectWallet ( WalletProvider . LocalWallet , password , null , WalletProvider . LocalWallet ) ;
222+ _password = string . IsNullOrEmpty ( LocalWalletNewPasswordInput . text ) ? null : LocalWalletNewPasswordInput . text ;
223+ ConnectWallet ( WalletProvider . LocalWallet , _password , null , WalletProvider . LocalWallet ) ;
221224 LocalWalletUINew . SetActive ( false ) ;
222225 } ) ;
223226
@@ -372,7 +375,7 @@ private async void DisconnectWallet()
372375 private async void ExportWallet ( )
373376 {
374377 Debug . Log ( "Exporting wallet..." ) ;
375- string json = await ThirdwebManager . Instance . SDK . wallet . Export ( null ) ;
378+ string json = await ThirdwebManager . Instance . SDK . wallet . Export ( _password ) ;
376379 GUIUtility . systemCopyBuffer = json ;
377380 Debug . Log ( $ "Copied wallet to clipboard: { json } ") ;
378381 }
0 commit comments