Esempio n. 1
0
    protected IEnumerator CheckAccountStatus(AccountStatus statusShouldBe)
    {
        var hasResult = false;

        _account.GetStatus((ex, status) =>
        {
            Assert.IsTrue(status == statusShouldBe);
            hasResult = true;
        });

        yield return(new WaitUntil(() => hasResult));
    }
 void InitializeKin()
 {
     /// Perform online functions by:
     /// 1. Checking if the user is onboarded (registered on the blockchain) and registering them
     /// 2. Fetching the user's current balance on the blockchain
     /// 3. Listening for any changes in the user's balance
     if (initializationRetries >= maxInitializes)
     {
         return;
     }
     //Check if the user has been onboarded (registered on the blockchain)
     //This will only be done once, then we persist it locally so we don't have to keep checking
     if (PlayerPrefs.GetInt("UserAccountOnboarded", 0) == 0)
     {
         //https://github.com/kinecosystem/kin-sdk-unity#query-account-status
         if (verbose)
         {
             listenerCallback?.Invoke("Initializing", "log");
         }
         if (verbose)
         {
             listenerCallback?.Invoke("Getting account status", "log");
         }
         kinAccount.GetStatus(GetStatusCallback); //check if onboarded and onboard if necessary
     }
     else if (fetchedUserBalance == false)
     {
         //https://github.com/kinecosystem/kin-sdk-unity#retrieving-balance
         if (verbose)
         {
             listenerCallback?.Invoke("Updating account balance", "log");
         }
         kinAccount.GetBalance(GetBalanceCallback); //Get the user's balance and persist it locally
     }
     else if (listenersActive == false)
     {
         //Listen for balance and payment changes and update the local value
         //This way, the local balance is always uptodate and immediately retrievable
         if (verbose)
         {
             listenerCallback?.Invoke("Finished initializing", "log");
         }
         AddListeners();
         isInitialized = true;
         if (verbose)
         {
             listenerCallback?.Invoke("Listening to blockchain", "log");
         }
     }
 }