Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Feature/nft tokens (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsakiv authored Aug 9, 2021
1 parent 1642e01 commit 0f0882e
Show file tree
Hide file tree
Showing 95 changed files with 5,055 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion Atomex.Client.Core
2 changes: 1 addition & 1 deletion Atomex.Client.Wpf.Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<?define Name = "Atomex Client" ?>
<?define Manufacturer = "Atomex.me" ?>
<?define Description = "Multicurrency HD wallet with built-in hybrid exchange based on atomic swap." ?>
<?define Version = "1.0.74" ?>
<?define Version = "1.1.0" ?>
<?define UpgradeCode = "DB7FCF8D-E0C6-4C99-A6B1-3FB6D703F97E" ?>
<?define ExeName = "Atomex.Client.Wpf.exe" ?>

Expand Down
2 changes: 1 addition & 1 deletion Atomex.Client.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static string CurrenciesConfigurationJson
var resourceName = "currencies.json";
var resourceNames = coreAssembly.GetManifestResourceNames();
var fullFileName = resourceNames.FirstOrDefault(n => n.EndsWith(resourceName));
var stream = coreAssembly.GetManifestResourceStream(fullFileName!);
var stream = coreAssembly.GetManifestResourceStream(fullFileName!);

using StreamReader reader = new(stream!);
return reader.ReadToEnd();
Expand Down
77 changes: 37 additions & 40 deletions Atomex.Client.Wpf/Atomex.Client.Wpf.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.props')" />
<Import Project="..\packages\cef.redist.x86.90.6.5\build\cef.redist.x86.props" Condition="Exists('..\packages\cef.redist.x86.90.6.5\build\cef.redist.x86.props')" />
<Import Project="..\packages\cef.redist.x64.90.6.5\build\cef.redist.x64.props" Condition="Exists('..\packages\cef.redist.x64.90.6.5\build\cef.redist.x64.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -70,15 +67,6 @@
<Reference Include="BouncyCastle.Crypto, Version=1.8.10.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.8.10\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="CefSharp, Version=90.6.50.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.90.6.50\lib\net452\CefSharp.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Core, Version=90.6.50.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.90.6.50\lib\net452\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Wpf, Version=90.6.50.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Wpf.90.6.50\lib\net452\CefSharp.Wpf.dll</HintPath>
</Reference>
<Reference Include="Common.Logging.Core, Version=3.4.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
<HintPath>..\packages\Common.Logging.Core.3.4.1\lib\net40\Common.Logging.Core.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -341,6 +329,7 @@
<Compile Include="Common\DecimalExtensions.cs" />
<Compile Include="Common\DesignTime.cs" />
<Compile Include="Common\Environment.cs" />
<Compile Include="Common\FileCache.cs" />
<Compile Include="Common\Msi\MsiApi.cs" />
<Compile Include="Common\Msi\MsiPackage.cs" />
<Compile Include="Common\Msi\MsiProduct.cs" />
Expand All @@ -362,9 +351,6 @@
<Compile Include="Controls\TransactionStateDataTemplateSelector.cs" />
<Compile Include="Controls\TransactionDataTemplateSelector.cs" />
<Compile Include="Controls\WalletDataTemplateSelector.cs" />
<Compile Include="Controls\WebBrowserWrapper.xaml.cs">
<DependentUpon>WebBrowserWrapper.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\AmountToStringConverter.cs" />
<Compile Include="Converters\BoolToVisibilityCollapsedConverter.cs" />
<Compile Include="Converters\BoolToVisibilityConverter.cs" />
Expand All @@ -376,7 +362,6 @@
<Compile Include="Helpers\AmountTextBoxHelper.cs" />
<Compile Include="Helpers\ComboBoxHelper.cs" />
<Compile Include="ViewModels\AddressesViewModel.cs" />
<Compile Include="ViewModels\BuyWithCardViewModel.cs" />
<Compile Include="ViewModels\ConversionConfirmationViewModel.cs" />
<Compile Include="ViewModels\CreateWalletViewModels\WalletTypeViewModel.cs" />
<Compile Include="ViewModels\CurrencyViewModels\FA2CurrencyViewModel.cs" />
Expand All @@ -399,23 +384,19 @@
<Compile Include="ViewModels\MessageViewModel.cs" />
<Compile Include="ViewModels\BakerViewModel.cs" />
<Compile Include="ViewModels\DelegateConfirmationViewModel.cs" />
<Compile Include="ViewModels\ReceiveViewModels\EthereumReceiveViewModel.cs" />
<Compile Include="ViewModels\ReceiveViewModels\ReceiveViewModelCreator.cs" />
<Compile Include="ViewModels\ReceiveViewModels\TezosReceiveViewModel.cs" />
<Compile Include="ViewModels\SendConfirmationViewModel.cs" />
<Compile Include="ViewModels\DelegateViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\BitcoinBasedSendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\Erc20SendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\EthereumSendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\Fa12SendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\FA2SendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\NYXSendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\TezosSendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\SendViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\SendViewModelCreator.cs" />
<Compile Include="ViewModels\TransactionViewModels\TezosFA12TransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\TezosFA2TransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\TezosNYXTransactionViewModel.cs" />
<Compile Include="ViewModels\SendViewModels\TezosTokensSendViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\ITransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\TezosTokenTransferViewModel.cs" />
<Compile Include="ViewModels\WalletAddressViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\SwapViewModel.cs" />
Expand All @@ -428,19 +409,19 @@
<Compile Include="ViewModels\CreateWalletViewModels\WalletNameViewModel.cs" />
<Compile Include="ViewModels\CreateWalletViewModels\WriteDerivedKeyPasswordViewModel.cs" />
<Compile Include="ViewModels\CreateWalletViewModels\WriteMnemonicViewModel.cs" />
<Compile Include="ViewModels\ReceiveViewModels\ReceiveViewModel.cs" />
<Compile Include="ViewModels\ReceiveViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\EthereumERC20TransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\TransactionViewModelCreator.cs" />
<Compile Include="ViewModels\TransactionViewModels\BitcoinBasedTransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\EthereumTransactionViewModel.cs" />
<Compile Include="ViewModels\TransactionViewModels\TezosTransactionViewModel.cs" />
<Compile Include="ViewModels\UnlockViewModel.cs" />
<Compile Include="Common\WalletInfo.cs" />
<Compile Include="ViewModels\WalletViewModels\IWalletViewModel.cs" />
<Compile Include="ViewModels\WalletViewModels\TezosTokensWalletViewModel.cs" />
<Compile Include="ViewModels\WalletViewModels\TezosWalletViewModel.cs" />
<Compile Include="ViewModels\WalletViewModels\Fa12WalletViewModel.cs" />
<Compile Include="ViewModels\WalletViewModels\WalletViewModelCreator.cs" />
<Compile Include="Views\BuyWithCardView.xaml.cs">
<DependentUpon>BuyWithCardView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ConversionView.xaml.cs">
<DependentUpon>ConversionView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -481,6 +462,9 @@
<Compile Include="Views\SendViews\BitcoinBasedSendPage.xaml.cs">
<DependentUpon>BitcoinBasedSendPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SendViews\TezosTokensSendPage.xaml.cs">
<DependentUpon>TezosTokensSendPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SendViews\SendPage.xaml.cs">
<DependentUpon>SendPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -533,6 +517,9 @@
<Compile Include="Views\TransactionDetailsViews\EthereumERC20TransactionDetailsView.xaml.cs">
<DependentUpon>EthereumERC20TransactionDetailsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TransactionDetailsViews\TezosTokenTransferDetailsView.xaml.cs">
<DependentUpon>TezosTokenTransferDetailsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TransactionDetailsViews\TezosTransactionDetailsView.xaml.cs">
<DependentUpon>TezosTransactionDetailsView.xaml</DependentUpon>
</Compile>
Expand All @@ -548,16 +535,18 @@
<Compile Include="Views\WalletsView.xaml.cs">
<DependentUpon>WalletsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\WalletViews\TezosTokensWalletView.xaml.cs">
<DependentUpon>TezosTokensWalletView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\WalletViews\TezosWalletView.xaml.cs">
<DependentUpon>TezosWalletView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\WalletViews\Fa12WalletView.xaml.cs">
<DependentUpon>Fa12WalletView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\WalletViews\WalletView.xaml.cs">
<DependentUpon>WalletView.xaml</DependentUpon>
</Compile>
<Page Include="Controls\WebBrowserWrapper.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\Icons.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -610,10 +599,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\BuyWithCardView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ConversionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -666,6 +651,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SendViews\TezosTokensSendPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SendViews\SendPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -799,6 +788,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TransactionDetailsViews\TezosTokenTransferDetailsView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\TransactionDetailsViews\TezosTransactionDetailsView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -819,10 +812,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\WalletViews\TezosTokensWalletView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\WalletViews\TezosWalletView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\WalletViews\Fa12WalletView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\WalletViews\WalletView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -986,21 +987,17 @@
<Resource Include="Resources\Images\kusd_90x90.png" />
<Resource Include="Resources\Images\kusd_mask.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
<Error Condition="!Exists('..\packages\cef.redist.x64.90.6.5\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.90.6.5\build\cef.redist.x64.props'))" />
<Error Condition="!Exists('..\packages\cef.redist.x86.90.6.5\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.90.6.5\build\cef.redist.x86.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.targets'))" />
</Target>
<ProjectExtensions />
<PropertyGroup>
<PostBuildEvent>powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)\reduce_output.ps1 $(TargetDir)</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.90.6.50\build\CefSharp.Common.targets')" />
</Project>
65 changes: 65 additions & 0 deletions Atomex.Client.Wpf/Common/FileCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.IO;
using System.Text;

using Serilog;

using Atomex.Common;
using Atomex.Cryptography;

namespace Atomex.Client.Wpf.Common
{
public static class FileCache
{
public const int MaxCacheFileSize = 1024 * 1024; // 1 Mb

public static string DefaultCacheFolder { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cache");

public static byte[] Get(string name, TimeSpan cachePeriod)
{
var key = Hex.ToHexString(Sha256.Compute(Encoding.UTF8.GetBytes(name)));
var fileExtension = "cache";
var fileName = $"{key}.{fileExtension}";
var filePath = Path.Combine(DefaultCacheFolder, fileName);

try
{
if (!Directory.Exists(DefaultCacheFolder))
Directory.CreateDirectory(DefaultCacheFolder);

var fileInfo = new FileInfo(filePath);

if (fileInfo.Length > MaxCacheFileSize)
return null;

if (cachePeriod != TimeSpan.MaxValue && fileInfo.LastWriteTimeUtc + cachePeriod < DateTime.UtcNow)
return null;

return File.ReadAllBytes(filePath);
}
catch (Exception e)
{
Log.Error(e, "FileCache.Get error.");
}

return null;
}

public static void Set(string name, byte[] data)
{
var key = Hex.ToHexString(Sha256.Compute(Encoding.UTF8.GetBytes(name)));
var fileExtension = "cache";
var fileName = $"{key}.{fileExtension}";
var filePath = Path.Combine(DefaultCacheFolder, fileName);

try
{
File.WriteAllBytes(filePath, data);
}
catch (Exception e)
{
Log.Error(e, "FileCache.Set error.");
}
}
}
}
25 changes: 23 additions & 2 deletions Atomex.Client.Wpf/Controls/IDialogViewer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using MahApps.Metro.Controls.Dialogs;

Expand All @@ -12,14 +13,34 @@ void ShowDialog(
Action loaded = null,
Action canceled = null,
int defaultPageId = 0);

void HideDialog(int dialogId);

void HideAllDialogs();

void PushPage(int dialogId, int pageId, object dataContext = null, Action closeAction = null);
void PushPage(
int dialogId,
int pageId,
object dataContext = null,
Action closeAction = null);

void PopPage(int dialogId);

void Back(int dialogId);

void ShowMessage(string title, string message);
Task<MessageDialogResult> ShowMessageAsync(string title, string message, MessageDialogStyle style);

Task<MessageDialogResult> ShowMessageAsync(
string title,
string message,
MessageDialogStyle style);

Task ShowProgressAsync(
string title,
string message,
Action canceled = null,
CancellationToken cancellationToken = default);

void HideProgress();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;

using Atomex.Blockchain.Abstract;
using Atomex.Client.Wpf.ViewModels.TransactionViewModels;

Expand All @@ -22,7 +23,7 @@ public class TransactionDataTemplateSelector : DataTemplateSelector

public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (!(item is TransactionViewModel tx))
if (!(item is ITransactionViewModel tx))
return null;

if (tx.Type.HasFlag(BlockchainTransactionType.SwapPayment))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Controls;

using Atomex.Blockchain.Abstract;
using Atomex.Client.Wpf.ViewModels.TransactionViewModels;

Expand All @@ -16,7 +17,7 @@ public class TransactionStateDataTemplateSelector : DataTemplateSelector

public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (!(item is TransactionViewModel transaction))
if (!(item is ITransactionViewModel transaction))
return null;

switch (transaction.State)
Expand Down
Loading

0 comments on commit 0f0882e

Please sign in to comment.