Exemplo n.º 1
0
        void BackupFailed(string json)
        {
            Debug.Log("In backup failed");
            var ex = KinException.FromNativeErrorJson(json);

            onBackup.FireActionInDict(ex.AccountId, ex, BackupRestoreResult.Failed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// attempts to delete the account at index. Throws an exception if it fails.
        /// </summary>
        /// <param name="index"></param>
        public void DeleteAccount(int index = 0)
        {
            var error = NativeBridge.Get().DeleteAccount(_clientId, index);

            if (!string.IsNullOrEmpty(error))
            {
                throw KinException.FromNativeErrorJson(error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// adds a new account to the KinClient. Throws an exception if any issues arise while adding it.
        /// </summary>
        /// <returns></returns>
        public KinAccount AddAccount()
        {
            var accountId = Utils.RandomString();
            var error     = NativeBridge.Get().AddAccount(_clientId, accountId);

            if (!string.IsNullOrEmpty(error))
            {
                throw KinException.FromNativeErrorJson(error);
            }
            return(new KinAccount(accountId));
        }
Exemplo n.º 4
0
        /// <summary>
        /// imports an account that was exported via the KinAccount.Export method
        /// </summary>
        /// <param name="exportedJson"></param>
        /// <param name="passphrase"></param>
        /// <returns></returns>
        public KinAccount ImportAccount(string exportedJson, string passphrase)
        {
            var accountId = Utils.RandomString();
            var error     = NativeBridge.Get().ImportAccount(_clientId, accountId, exportedJson, passphrase);

            if (!string.IsNullOrEmpty(error))
            {
                throw KinException.FromNativeErrorJson(error);
            }
            return(new KinAccount(accountId));
        }
Exemplo n.º 5
0
        /// <summary>
        /// exports an account. The returned JSON can be imported on a different device via KinClient.ImportAccount.
        /// </summary>
        /// <param name="passphrase"></param>
        /// <returns></returns>
        public string Export(string passphrase)
        {
            var json = NativeBridge.Get().Export(_accountId, passphrase);

            var exception = KinException.FromNativeErrorJson(json);

            if (exception != null)
            {
                UnityEngine.Debug.Log(exception);
                throw exception;
            }

            return(json);
        }
Exemplo n.º 6
0
        void SendTransactionFailed(string json)
        {
            var ex = KinException.FromNativeErrorJson(json);

            onSendTransaction.FireActionInDict(ex.AccountId, ex, null);
        }
Exemplo n.º 7
0
        void GetBalanceFailed(string json)
        {
            var ex = KinException.FromNativeErrorJson(json);

            onGetBalance.FireActionInDict(ex.AccountId, ex, default(decimal));
        }
Exemplo n.º 8
0
        void GetStatusFailed(string error)
        {
            var ex = KinException.FromNativeErrorJson(error);

            onGetStatus.FireActionInDict(ex.AccountId, ex, default(AccountStatus));
        }
Exemplo n.º 9
0
        void GetMinimumFeeFailed(string error)
        {
            var ex = KinException.FromNativeErrorJson(error);

            onGetMinimumFee.FireActionInDict(ex.AccountId, ex, -1);
        }
Exemplo n.º 10
0
        void RestoreFailed(string json)
        {
            var ex = KinException.FromNativeErrorJson(json);

            onRestore.FireActionInDict(ex.AccountId, ex, BackupRestoreResult.Failed, null);
        }