示例#1
0
 IEnumerator SendWhitelistTransaction()
 {
     ShowProgressWindow("Prepare Whitelist Transaction");
     yield return(StartCoroutine(KinOnboarding.WhitelistTransaction(_transaction, whitelist =>
     {
         ShowProgressWindow("Prepare Whitelist Transaction");
         _account.SendWhitelistTransaction(_transaction.Id, whitelist, (ex, transactionId) =>
         {
             HideProgressWindow();
             _transaction = null;
             if (ex == null)
             {
                 Debug.Log("Send Whitelist Transaction: " + transactionId);
             }
             else
             {
                 Debug.LogError("Send  WhitelistTransaction Failed. " + ex);
             }
         });
     })));
 }
示例#2
0
        protected override void OnRightColumnGUI()
        {
            if (BottomButton("Show Logs"))
            {
                ToggleEditMode();
            }

            if (_account == null)
            {
                return;
            }

            GUILayout.Label("Onboarding");
            if (!_isAccountCreated && GUILayout.Button("Create Account"))
            {
                ShowProgressWindow("Create Account Onboarding");
                StartCoroutine(KinOnboarding.CreateAccount(_account.GetPublicAddress(), didSucceed =>
                {
                    _isAccountCreated = didSucceed;
                    HideProgressWindow();
                }));
            }
            else if (_isAccountCreated)
            {
                GUILayout.Label("Account Already Onboarded");
            }


            GUILayout.Space(40);
            GUILayout.Label("Account Information");
            if (GUILayout.Button("Get Public Address"))
            {
                Debug.Log("Public address: " + _account.GetPublicAddress());
            }


            if (GUILayout.Button("Query Account Status"))
            {
                ShowProgressWindow("GetStatus");
                _account.GetStatus((ex, status) =>
                {
                    HideProgressWindow();
                    if (ex == null)
                    {
                        Debug.Log("Account status: " + status);
                    }
                    else
                    {
                        Debug.LogError("Get Account Status Failed. " + ex);
                    }
                });
            }


            if (GUILayout.Button("Export Account"))
            {
                try
                {
                    _exportedAccountJson = _account.Export(_importExportPassphrase);
                    Debug.Log("exported account with passphrase: " + _importExportPassphrase);
                    Debug.Log("exported account json:\n" + _exportedAccountJson);
                }
                catch (KinException ex)
                {
                    Debug.LogError(ex);
                }
            }


            GUILayout.Space(40);
            GUILayout.Label("Retrieving Balance");
            if (GUILayout.Button("Get Balance"))
            {
                ShowProgressWindow("GetBalance");
                _account.GetBalance((ex, balance) =>
                {
                    HideProgressWindow();
                    if (ex == null)
                    {
                        Debug.Log("Balance: " + balance);
                    }
                    else
                    {
                        Debug.LogError("Get Balance Failed. " + ex);
                    }
                });
            }


            GUILayout.Space(40);
            GUILayout.Label("Transactions");

            GUILayout.Label("Send to:");
            _sendToAddress = GUILayout.TextField(_sendToAddress);

            if (!string.IsNullOrEmpty(_sendToAddress) && _isAccountCreated &&
                _transaction == null && GUILayout.Button("Build Transaction"))
            {
                ShowProgressWindow("BuildTransaction");
                _account.BuildTransaction(_sendToAddress, 100, _feeAmount, (ex, transaction) =>
                {
                    HideProgressWindow();
                    if (ex == null)
                    {
                        Debug.Log("Build Transaction: " + transaction);
                        _transaction = transaction;
                    }
                    else
                    {
                        Debug.LogError("Build Transaction Failed. " + ex);
                    }
                });
            }

            if (_transaction != null && GUILayout.Button("Send Transaction"))
            {
                ShowProgressWindow("SendTransaction");
                _account.SendTransaction(_transaction, (ex, transactionId) =>
                {
                    HideProgressWindow();
                    _transaction = null;
                    if (ex == null)
                    {
                        Debug.Log("Send Transaction: " + transactionId);
                    }
                    else
                    {
                        Debug.LogError("Send Transaction Failed. " + ex);
                    }
                });
            }

            if (_transaction != null && GUILayout.Button("Send Whitelist Transaction"))
            {
                StartCoroutine(SendWhitelistTransaction());
            }

            if (GUILayout.Button("Backup Account"))
            {
                _account.BackupAccount(_client,
                                       (KinException ex, BackupRestoreResult result) => {
                    switch (result)
                    {
                    case BackupRestoreResult.Success:
                        Debug.Log("Account backed up successfully");
                        break;

                    case BackupRestoreResult.Cancel:
                        Debug.Log("Account backup canceled");
                        break;

                    case BackupRestoreResult.Failed:
                        Debug.Log("Account backup failed");
                        Debug.LogError(ex);
                        break;
                    }
                });
            }
        }