Skip to content

Commit

Permalink
Big refactoring & optimization (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsakiv authored Mar 16, 2023
1 parent 25a9315 commit bcc56fa
Show file tree
Hide file tree
Showing 109 changed files with 5,063 additions and 3,818 deletions.
17 changes: 9 additions & 8 deletions App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Atomex.Client.Desktop.Common;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input.Platform;
using Avalonia.Markup.Xaml;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Avalonia.Threading;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
using Sentry;

using Atomex.Client.Desktop.Services;
using Atomex.Client.Desktop.ViewModels;
using Atomex.Client.Desktop.Views;
Expand All @@ -34,8 +35,6 @@
using Atomex.MarketData.Bitfinex;
using Atomex.MarketData.TezTools;
using Atomex.Services;
using Avalonia.Threading;


namespace Atomex.Client.Desktop
{
Expand Down Expand Up @@ -76,6 +75,7 @@ public override void OnFrameworkInitializationCompleted()
var appAlreadyRunning = true;

using var tcpClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

try
{
tcpClient.Connect(IPAddress.Loopback, atomexTcpPort);
Expand Down Expand Up @@ -109,6 +109,7 @@ public override void OnFrameworkInitializationCompleted()
var bitfinexQuotesProvider = new BitfinexQuotesProvider(
currencies: currenciesProvider
.GetCurrencies(Network.MainNet)
.GetOrderedPreset()
.Select(c => c.Name),
baseCurrency: QuotesProvider.Usd,
log: LoggerFactory.CreateLogger<BitfinexQuotesProvider>());
Expand All @@ -121,7 +122,7 @@ public override void OnFrameworkInitializationCompleted()
bitfinexQuotesProvider, tezToolsQuotesProvider);

// init Atomex client app
AtomexApp = new AtomexApp()
AtomexApp = new AtomexApp(logger: LoggerFactory.CreateLogger("AtomexApp"))
.UseCurrenciesProvider(currenciesProvider)
.UseSymbolsProvider(symbolsProvider)
.UseCurrenciesUpdater(new CurrenciesUpdater(currenciesProvider))
Expand Down
10 changes: 5 additions & 5 deletions Atomex.Client.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<UseAppHost>true</UseAppHost>
<ApplicationIcon>Resources/Images/atomex_logo_256x256_ico.ico</ApplicationIcon>

<AssemblyVersion>1.2.63</AssemblyVersion>
<Version>1.2.63</Version>
<AssemblyVersion>1.3.0</AssemblyVersion>
<Version>1.3.0</Version>
</PropertyGroup>
<Choose>
<When Condition=" '$(Configuration)' == 'Debug' ">
Expand Down Expand Up @@ -37,6 +37,7 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.15" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.13.3" />
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.13" />
<PackageReference Include="Beacon.Sdk" Version="1.0.20" />
<PackageReference Include="DialogHost.Avalonia" Version="0.4.0" />
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.9.0" />
<PackageReference Include="NetSparkleUpdater.SparkleUpdater" Version="2.0.7" />
Expand All @@ -51,7 +52,6 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="ReactiveUI.Fody" Version="16.4.1" />
<PackageReference Include="AsyncImageLoader.Avalonia" Version="2.4.0" />
<PackageReference Include="Beacon.Sdk" Version="1.0.19" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -191,8 +191,8 @@
<DependentUpon>LinuxUpdateControls.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\TransactionViews\EthereumERC20TransactionDetailsView.axaml.cs">
<DependentUpon>EthereumERC20TransactionDetailsView.axaml</DependentUpon>
<Compile Update="Views\TransactionViews\Erc20TransactionDetailsView.axaml.cs">
<DependentUpon>Erc20TransactionDetailsView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Controls\IconButton.axaml.cs">
Expand Down
103 changes: 77 additions & 26 deletions Atomex.Client.Desktop.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Client.Desktop", "Atomex.Client.Desktop.csproj", "{C1323E2C-7DE2-4D2B-A5FF-72590F809842}"
EndProject
Expand Down Expand Up @@ -31,6 +31,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.MarketData", "atomex
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Atomex.Core", "Atomex.Core", "{6165844F-33D3-433A-91B8-62481908D2C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Blockchain", "atomex.client.core\Atomex.Blockchain\Atomex.Blockchain.csproj", "{2AF64F7F-E210-4749-8438-5C653BDBB425}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Blockchain.Bitcoin", "atomex.client.core\Atomex.Blockchain.Bitcoin\Atomex.Blockchain.Bitcoin.csproj", "{FEE071D9-795A-4CB0-93D2-E97B36B01111}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Blockchain.Ethereum", "atomex.client.core\Atomex.Blockchain.Ethereum\Atomex.Blockchain.Ethereum.csproj", "{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Blockchain.Tezos", "atomex.client.core\Atomex.Blockchain.Tezos\Atomex.Blockchain.Tezos.csproj", "{D8A24924-3C1D-4397-A9CF-1F1E99143481}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Atomex.Tests", "atomex.client.core\Atomex.Tests\Atomex.Tests.csproj", "{3907CA8F-3816-4CDA-BD04-FEB296C0002D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -194,30 +204,66 @@ Global
{6A38B71F-6E88-4A2B-BF1B-B39E7565BAB6}.Release|x64.Build.0 = Release|Any CPU
{6A38B71F-6E88-4A2B-BF1B-B39E7565BAB6}.Release|x86.ActiveCfg = Release|Any CPU
{6A38B71F-6E88-4A2B-BF1B-B39E7565BAB6}.Release|x86.Build.0 = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|x64.ActiveCfg = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|x64.Build.0 = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Debug|x86.Build.0 = Debug|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|Any CPU.Build.0 = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|x64.ActiveCfg = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|x64.Build.0 = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|x86.ActiveCfg = Release|Any CPU
{00D49D30-4373-4A8A-A3A8-9481F110A7F9}.Release|x86.Build.0 = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|x64.ActiveCfg = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|x64.Build.0 = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|x86.ActiveCfg = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Debug|x86.Build.0 = Debug|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|Any CPU.Build.0 = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|x64.ActiveCfg = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|x64.Build.0 = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|x86.ActiveCfg = Release|Any CPU
{973E3C65-B305-4DB3-AE78-7694E7F38A92}.Release|x86.Build.0 = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|x64.ActiveCfg = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|x64.Build.0 = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|x86.ActiveCfg = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Debug|x86.Build.0 = Debug|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|Any CPU.Build.0 = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|x64.ActiveCfg = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|x64.Build.0 = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|x86.ActiveCfg = Release|Any CPU
{2AF64F7F-E210-4749-8438-5C653BDBB425}.Release|x86.Build.0 = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|x64.ActiveCfg = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|x64.Build.0 = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|x86.ActiveCfg = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Debug|x86.Build.0 = Debug|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|Any CPU.Build.0 = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|x64.ActiveCfg = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|x64.Build.0 = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|x86.ActiveCfg = Release|Any CPU
{FEE071D9-795A-4CB0-93D2-E97B36B01111}.Release|x86.Build.0 = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|x64.ActiveCfg = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|x64.Build.0 = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|x86.ActiveCfg = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Debug|x86.Build.0 = Debug|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|Any CPU.Build.0 = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|x64.ActiveCfg = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|x64.Build.0 = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|x86.ActiveCfg = Release|Any CPU
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1}.Release|x86.Build.0 = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|x64.ActiveCfg = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|x64.Build.0 = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|x86.ActiveCfg = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Debug|x86.Build.0 = Debug|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|Any CPU.Build.0 = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|x64.ActiveCfg = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|x64.Build.0 = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|x86.ActiveCfg = Release|Any CPU
{D8A24924-3C1D-4397-A9CF-1F1E99143481}.Release|x86.Build.0 = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|x64.ActiveCfg = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|x64.Build.0 = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|x86.ActiveCfg = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Debug|x86.Build.0 = Debug|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|Any CPU.Build.0 = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|x64.ActiveCfg = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|x64.Build.0 = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|x86.ActiveCfg = Release|Any CPU
{3907CA8F-3816-4CDA-BD04-FEB296C0002D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -234,6 +280,11 @@ Global
{D892B42C-1C00-49F7-A4BE-8A11C14F73C6} = {6165844F-33D3-433A-91B8-62481908D2C7}
{241E2707-3CCD-40B8-890E-89FA1F0450D7} = {6165844F-33D3-433A-91B8-62481908D2C7}
{6A38B71F-6E88-4A2B-BF1B-B39E7565BAB6} = {6165844F-33D3-433A-91B8-62481908D2C7}
{2AF64F7F-E210-4749-8438-5C653BDBB425} = {6165844F-33D3-433A-91B8-62481908D2C7}
{FEE071D9-795A-4CB0-93D2-E97B36B01111} = {6165844F-33D3-433A-91B8-62481908D2C7}
{67D825D2-D5BC-4027-B5E5-7B7E3AD4C3A1} = {6165844F-33D3-433A-91B8-62481908D2C7}
{D8A24924-3C1D-4397-A9CF-1F1E99143481} = {6165844F-33D3-433A-91B8-62481908D2C7}
{3907CA8F-3816-4CDA-BD04-FEB296C0002D} = {6165844F-33D3-433A-91B8-62481908D2C7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8A77B597-6CC1-4B27-A6A6-F5740970481E}
Expand Down
9 changes: 7 additions & 2 deletions Common/KeyValExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ public static class KeyValExtension
{
public static T GetValueByKey<T>(IEnumerable<KeyValuePair<string, T>> collection, string value)
{
return collection.Where(kv => kv.Key == value).ToList()[0].Value;
return collection
.Where(kv => kv.Key == value)
.ToList()
[0].Value;
}

public static string GetKeyByValue<T>(IEnumerable<KeyValuePair<string, T>> collection, T value)
{
return collection.Where(kv => kv.Value.Equals(value)).ToList()[0].Key;
return collection.Where(kv => kv.Value.Equals(value))
.ToList()
[0].Key;
}
}
}
1 change: 0 additions & 1 deletion Common/ObservableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive.Concurrency;
using System.Reactive.Linq;

using ReactiveUI;
Expand Down
39 changes: 0 additions & 39 deletions Controls/SwapStateDataTemplateSelector.cs

This file was deleted.

17 changes: 8 additions & 9 deletions Controls/TransactionDescriptionDataTemplateSelector.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;

using Avalonia.Markup.Xaml.Templates;

using Atomex.Client.Desktop.Services;
using Atomex.Client.Desktop.ViewModels.TransactionViewModels;
using Avalonia.Markup.Xaml.Templates;

namespace Atomex.Client.Desktop.Controls
{
Expand All @@ -12,7 +14,7 @@ public class TransactionDescriptionDataTemplateSelector : IDataTemplate

public IControl Build(object data)
{
return GetTemplate(data)?.Build(data) ?? new TextBlock {Text = "Transaction Template Not Found"};
return GetTemplate(data)?.Build(data) ?? new TextBlock { Text = "Transaction Template Not Found" };
}

private static DataTemplate? GetTemplate(object data)
Expand All @@ -22,13 +24,10 @@ public IControl Build(object data)

return tx.Currency switch
{
BitcoinBasedConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate
.BtcBasedDescriptionTemplate),
TezosConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate
.XtzAdditionalDescriptionTemplate),
EthereumConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate
.EthAdditionalDescriptionTemplate),
_ => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate.BtcBasedDescriptionTemplate)
BitcoinBasedConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate.BtcBasedDescriptionTemplate),
TezosConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate.XtzAdditionalDescriptionTemplate),
EthereumConfig => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate.EthAdditionalDescriptionTemplate),
_ => App.TemplateService.GetTxDescriptionTemplate(TxDescriptionTemplate.BtcBasedDescriptionTemplate)
};
}

Expand Down
Loading

0 comments on commit bcc56fa

Please sign in to comment.