Exemplo n.º 1
0
        private async Task SendExecute()
        {
            string tx = string.Empty;

            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                DialogService.ShowLoading();
                if (!string.IsNullOrEmpty(ToAddress) && Quantity > 0 && SelectedItem != null) //todo address validation
                {
                    var scriptHash = ToAddress.ToScriptHash();                                // throws exception if address is not valid
                    if (_assetsPicker.TryGetValue(SelectedItem, out var contractHash))
                    {
                        tx = await _walletService.TransferNep5(ToAddress, Quantity, contractHash);
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is RpcClientUnknownException || ex is RpcClientTimeoutException) //todo switch error message
                {
                    AppSettings.ChangeRpcServer();
                }
                await DialogService.ShowAlertAsync(ex.Message, AppResource.Alert_Error);
            }
            finally
            {
                IsBusy = false;
                DialogService.HideLoading();
                if (!string.IsNullOrEmpty(tx))
                {
                    await DialogService.ShowAlertAsync("Asset sent. It might take a few minutes for update balance.", "Success"); //todo localization

                    ToAddress = string.Empty;
                    Quantity  = 0;
                }
                else
                {
                    await DialogService.ShowAlertAsync(AppResource.Alert_SomethingWrong, AppResource.Alert_Error); //todo localization
                }
            }
        }