@@ -191,9 +191,15 @@ protected override Task<Transaction[]> _SignAllTransactions(Transaction[] transa
191191 [ MonoPInvokeCallback ( typeof ( Action < string > ) ) ]
192192 private static void OnWalletConnected ( string walletPubKey )
193193 {
194+ if ( walletPubKey == null )
195+ {
196+ _loginTaskCompletionSource . TrySetException ( new Exception ( "Login cancelled" ) ) ;
197+ _loginTaskCompletionSource . TrySetResult ( null ) ;
198+ return ;
199+ }
194200 Debug . Log ( $ "Wallet { walletPubKey } connected!") ;
195201 _account = new Account ( "" , walletPubKey ) ;
196- _loginTaskCompletionSource . SetResult ( _account ) ;
202+ _loginTaskCompletionSource . TrySetResult ( _account ) ;
197203 }
198204
199205 /// <summary>
@@ -203,6 +209,12 @@ private static void OnWalletConnected(string walletPubKey)
203209 [ MonoPInvokeCallback ( typeof ( Action < string > ) ) ]
204210 public static void OnTransactionSigned ( string transaction )
205211 {
212+ if ( transaction == null )
213+ {
214+ _signedTransactionTaskCompletionSource . TrySetException ( new Exception ( "Transaction signing cancelled" ) ) ;
215+ _signedTransactionTaskCompletionSource . TrySetResult ( null ) ;
216+ return ;
217+ }
206218 var tx = Transaction . Deserialize ( Convert . FromBase64String ( transaction ) ) ;
207219 _signedTransactionTaskCompletionSource . SetResult ( tx ) ;
208220 }
@@ -214,6 +226,12 @@ public static void OnTransactionSigned(string transaction)
214226 [ MonoPInvokeCallback ( typeof ( Action < string > ) ) ]
215227 public static void OnAllTransactionsSigned ( string signatures )
216228 {
229+ if ( signatures == null )
230+ {
231+ _signedAllTransactionsTaskCompletionSource . TrySetException ( new Exception ( "Transactions signing cancelled" ) ) ;
232+ _signedAllTransactionsTaskCompletionSource . TrySetResult ( null ) ;
233+ return ;
234+ }
217235 string [ ] signaturesList = signatures . Split ( ',' ) ;
218236 for ( int i = 0 ; i < signaturesList . Length ; i ++ )
219237 {
@@ -234,6 +252,12 @@ public static void OnAllTransactionsSigned(string signatures)
234252 [ MonoPInvokeCallback ( typeof ( Action < string > ) ) ]
235253 public static void OnMessageSigned ( string signature )
236254 {
255+ if ( signature == null )
256+ {
257+ _signedMessageTaskCompletionSource . TrySetException ( new Exception ( "Message signing cancelled" ) ) ;
258+ _signedMessageTaskCompletionSource . TrySetResult ( null ) ;
259+ return ;
260+ }
237261 _signedMessageTaskCompletionSource . SetResult ( Convert . FromBase64String ( signature ) ) ;
238262 }
239263
0 commit comments