Ejemplo n.º 1
0
 void GetStatusCallback(KinException ex, AccountStatus status)
 {
     //Called back returning the status of the account
     if (ex == null)
     {
         //If account is already onboarded (registered on the blockchain) it comes back as created
         if (status == AccountStatus.Created)
         {
             if (verbose)
             {
                 listenerCallback?.Invoke("Account created", "log");
             }
             PlayerPrefs.SetInt("UserAccountOnboarded", 1); //save this so we don't have to check next time
             InitializeKin();                               // continue with initialization of the wrapper (next step)
         }
         else
         {
             //The account was not yet onboarded, so we onboard it
             //Actually, to register it on the blockchain, we just need to fund it with some minimal Kin
             if (verbose)
             {
                 listenerCallback?.Invoke("Account doesn't exist", "log");
             }
             if (verbose)
             {
                 listenerCallback?.Invoke("Creating account (funding)", "log");
             }
             StartCoroutine(RequestPayment(10.00M, "Inital funding", FundAccountCallback, true));
         }
     }
     else
     {
         LogError("Get Account Status Failed. " + ex);
     }
 }
Ejemplo n.º 2
0
 void SendTransactionCallback(KinException ex, String transactionId)
 {
     if (ex == null)
     {
         //Success
     }
     else
     {
         LogError("Send Transaction Failed. " + ex);
     }
 }
Ejemplo n.º 3
0
    void GetBalanceCallback(KinException ex, decimal balance)
    {
        if (ex == null)
        {
            if (verbose)
            {
                listenerCallback?.Invoke("Account balance fetched", "log");
            }
            PlayerPrefs.SetFloat("KinBalanceUser", (float)(balance)); //save this so we can access it instantaneously
            fetchedUserBalance = true;
            InitializeKin();                                          // continue with initialization of the wrapper (next step)
        }
        else
        {
            LogError("Get Balance Failed. " + ex);

            StartCoroutine(WaitAndInitialize());
        }
    }
Ejemplo n.º 4
0
    void BuildTransactionCallBack(KinException ex, Transaction transaction)
    {
        //After building, we can store the transaction id to monitor the status in case of downtime (not implemented in this wrapper)
        if (ex == null)
        {
            if (verbose)
            {
                listenerCallback?.Invoke("Sending transaction", "log");
            }
            //We now send a transaction and fees are charged
            kinAccount.SendTransaction(transaction, SendTransactionCallback);

            //OPTIONAL: Your server account can be authorized by the Kin Foundation to whitelist transactions for zero fees
            //Once authorized, disable the above, and enable below to send whitelisted transactions
            //https://github.com/kinecosystem/kin-sdk-unity#transferring-kin-to-another-account-using-whitelist-service
            //StartCoroutine(WhitelistTransaction(transaction, WhitelistTransactionCallback));
        }
        else
        {
            LogError("Build Transaction Failed. " + ex);
        }
    }