Skip to content

Commit

Permalink
Fix/testnet quotes (#90)
Browse files Browse the repository at this point in the history
* Testnet quotes disabled

* TestNet warning added

* Disabled currency purchase on iOS

* App version 1.26.0
  • Loading branch information
mismirnov authored Feb 16, 2024
1 parent 1c78111 commit 70027b1
Show file tree
Hide file tree
Showing 25 changed files with 216 additions and 20 deletions.
4 changes: 2 additions & 2 deletions atomex.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.25.0" package="com.atomex.android" android:versionCode="43">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.26.0" package="com.atomex.android" android:versionCode="44">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="33" />
<application android:label="Atomex" android:allowBackup="false" android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
Expand Down
4 changes: 2 additions & 2 deletions atomex.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<key>CFBundleIdentifier</key>
<string>com.atomex.ios</string>
<key>CFBundleVersion</key>
<string>1.25.0</string>
<string>1.26.0</string>
<key>UILaunchStoryboardName</key>
<string>AtomexLaunchScreen</string>
<key>CFBundleName</key>
Expand Down Expand Up @@ -89,7 +89,7 @@
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>CFBundleShortVersionString</key>
<string>1.25</string>
<string>1.26</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
Expand Down
9 changes: 5 additions & 4 deletions atomex.iOS/atomex.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<MtouchArch>x86_64</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<CodesignKey>Apple Development: Igor Matcak (572BY3ZBQR)</CodesignKey>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<CodesignProvision>VS: com.atomex.ios Development</CodesignProvision>
<CodesignProvision>Atomex Distribution</CodesignProvision>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
<LangVersion>8.0</LangVersion>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
Expand All @@ -43,9 +43,10 @@
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<CodesignKey>Apple Distribution: ATOMEX OU (BJT6S7XYJV)</CodesignKey>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
<LangVersion>8.0</LangVersion>
<CodesignProvision>Atomex Distribution</CodesignProvision>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -73,7 +74,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignKey>Apple Distribution: ATOMEX OU (BJT6S7XYJV)</CodesignKey>
<MtouchExtraArgs>--interpreter</MtouchExtraArgs>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchFloat32>true</MtouchFloat32>
Expand Down
6 changes: 6 additions & 0 deletions atomex/Resources/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions atomex/Resources/AppResources.fr.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions atomex/Resources/AppResources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1357,4 +1357,7 @@ NOTE: Do not sign out or close the application until the swap is completed, othe
<data name="CameraPermission" xml:space="preserve">
<value>Camera permission</value>
</data>
<data name="TestNetWalletWarning" xml:space="preserve">
<value>You are using a test wallet (TestNet), the coins on which have no real monetary value! Be careful and beware of scammers!</value>
</data>
</root>
3 changes: 3 additions & 0 deletions atomex/Resources/AppResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1360,4 +1360,7 @@ NOTE: Do not sign out or close the application until the swap is completed, othe
<data name="ReturnToAtomex" xml:space="preserve">
<value>Return back to Atomex</value>
</data>
<data name="TestNetWalletWarning" xml:space="preserve">
<value>You are using a test wallet (TestNet), the coins on which have no real monetary value! Be careful and beware of scammers!</value>
</data>
</root>
6 changes: 6 additions & 0 deletions atomex/Resources/AppResources.ru.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions atomex/Resources/AppResources.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1357,4 +1357,7 @@
<data name="CameraPermission" xml:space="preserve">
<value>Доступ к камере</value>
</data>
<data name="TestNetWalletWarning" xml:space="preserve">
<value>Вы используете тестовый кошелек (TestNet), монеты на котором не имеют реальной денежной стоимости! Будьте осторожны и остерегайтесь мошенников!</value>
</data>
</root>
6 changes: 6 additions & 0 deletions atomex/Resources/AppResources.tr.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions atomex/Resources/AppResources.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1357,4 +1357,7 @@ NOTE: Do not sign out or close the application until the swap is completed, othe
<data name="CameraPermission" xml:space="preserve">
<value>Camera permission</value>
</data>
<data name="TestNetWalletWarning" xml:space="preserve">
<value>You are using a test wallet (TestNet), the coins on which have no real monetary value! Be careful and beware of scammers!</value>
</data>
</root>
15 changes: 13 additions & 2 deletions atomex/ViewModels/CurrencyViewModels/CurrencyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class CurrencyViewModel : BaseViewModel, IDisposable
public bool HasCollectibles => CurrencyCode == TezosConfig.Xtz;
public bool HasTokens => CurrencyCode == TezosConfig.Xtz;
public bool HasDapps => CurrencyCode == TezosConfig.Xtz;
public bool CanBuy => BuyViewModel.Currencies.Contains(Currency?.Name);
public bool CanBuy => BuyViewModel.Currencies.Contains(Currency?.Name) &&
Device.RuntimePlatform != Device.iOS;

public bool IsOpenCurrency { get; set; }

Expand Down Expand Up @@ -160,6 +161,12 @@ public void SubscribeToServices()

public void SubscribeToRatesProvider(IQuotesProvider quotesProvider)
{
if (quotesProvider == null)
return;

if (App.Account?.Network == Network.TestNet)
return;

QuotesProvider = quotesProvider;
QuotesProvider.QuotesUpdated += OnQuotesUpdatedEventHandler;
}
Expand Down Expand Up @@ -233,7 +240,11 @@ private void OnQuotesUpdatedEventHandler(object sender, EventArgs args)

private void UpdateQuotesInBaseCurrency(IQuotesProvider quotesProvider)
{
if (quotesProvider == null) return;
if (quotesProvider == null)
return;

if (App.Account?.Network == Network.TestNet)
return;

try
{
Expand Down
11 changes: 10 additions & 1 deletion atomex/ViewModels/CurrencyViewModels/TezosTokenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Atomex;
using Atomex.Blockchain.Tezos;
using Atomex.Common;
using Atomex.Core;
using Atomex.MarketData.Abstract;
using atomex.Models;
using Atomex.TezosTokens;
Expand Down Expand Up @@ -469,14 +470,22 @@ public void SubscribeToUpdates()
{
_app.Account.BalanceUpdated += OnBalanceUpdatedEventHandler;

if (TokenBalance.IsNft) return;
if (_account.Wallet.Network == Network.TestNet)
return;

if (TokenBalance.IsNft)
return;

_app.QuotesProvider.QuotesUpdated += OnQuotesUpdatedEventHandler;
}

private void OnQuotesUpdatedEventHandler(object sender, EventArgs args)
{
if (sender is not IQuotesProvider quotesProvider)
return;

if (_app.Account?.Network == Network.TestNet)
return;

UpdateQuotesInBaseCurrency(quotesProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public DelegationContentViewModel()
Launcher.OpenAsync(new Uri(uri.ToString()));
});

protected override void OnQuotesUpdatedEventHandler(object? sender, EventArgs args)
protected override void OnQuotesUpdatedEventHandler(object sender, EventArgs args)
{
if (sender is not IQuotesProvider quotesProvider)
return;
Expand Down
10 changes: 9 additions & 1 deletion atomex/ViewModels/DelegateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Atomex.Blockchain.Tezos;
using Atomex.Blockchain.Tezos.Internal;
using Atomex.Common;
using Atomex.Core;
using Atomex.MarketData.Abstract;
using Atomex.Wallet;
using Atomex.Wallet.Tezos;
Expand Down Expand Up @@ -649,7 +650,11 @@ private async Task<Result<bool>> GetDelegate(

private void SubscribeToServices()
{
if (!_app.HasQuotesProvider) return;
if (!_app.HasQuotesProvider)
return;

if (_app.Account?.Network == Network.TestNet)
return;

_app.QuotesProvider.QuotesUpdated += OnQuotesUpdatedEventHandler;
_app.QuotesProvider.AvailabilityChanged += OnQuotesProviderAvailabilityChangedEventHandler;
Expand All @@ -659,6 +664,9 @@ private void OnQuotesUpdatedEventHandler(object sender, EventArgs args)
{
if (sender is not IQuotesProvider quotesProvider)
return;

if (_app.Account?.Network == Network.TestNet)
return;

try
{
Expand Down
30 changes: 29 additions & 1 deletion atomex/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using atomex.Common;
using Atomex.Core;
using atomex.ViewModels.ConversionViewModels;
using atomex.ViewModels.CurrencyViewModels;
using atomex.ViewModels.DappsViewModels;
using atomex.Views.Popup;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Xamarin.Essentials;
Expand All @@ -26,14 +29,16 @@ namespace atomex.ViewModels
public class MainViewModel : BaseViewModel
{
public IAtomexApp AtomexApp { get; }
[Reactive] private INavigationService NavigationService { get; set; }
public SettingsViewModel SettingsViewModel { get; }
public ConversionViewModel ConversionViewModel { get; }
public PortfolioViewModel PortfolioViewModel { get; }
public BuyViewModel BuyViewModel { get; }
[Reactive] public ConnectDappViewModel ConnectDappViewModel { get; set; }
public bool IsTestNet { get; set; }

public EventHandler Locked;

public MainViewModel(
IAtomexApp app,
IAccount account)
Expand Down Expand Up @@ -70,6 +75,7 @@ public MainViewModel(
BuyViewModel = new BuyViewModel(AtomexApp);
SettingsViewModel = new SettingsViewModel(AtomexApp, this);
PortfolioViewModel.CurrenciesLoaded += OnCurrenciesLoadedEventHandler;
IsTestNet = account?.Wallet.Network == Network.TestNet;

_ = TokenDeviceService.SendTokenToServerAsync(App.DeviceToken, App.FileSystem, AtomexApp);

Expand All @@ -83,6 +89,23 @@ public MainViewModel(
await ConnectDappViewModel.OnDeepLinkResult(deepLink);
await SecureStorage.SetAsync("DappDeepLink", string.Empty);
});

this.WhenAnyValue(vm => vm.NavigationService)
.WhereNotNull()
.SubscribeInMainThread(_ =>
{
if (!IsTestNet) return;
NavigationService.ShowPopup(new TestNetWalletPopup(this));
});
}

public void SetNavigationService(INavigationService service)
{
NavigationService = service ?? throw new ArgumentNullException(nameof(service));
PortfolioViewModel.SetNavigationService(service);
SettingsViewModel.SetNavigationService(service);
BuyViewModel.SetNavigationService(service);
ConversionViewModel.SetNavigationService(service);
}

private void OnCurrenciesLoadedEventHandler(object sender, EventArgs args)
Expand Down Expand Up @@ -179,5 +202,10 @@ private void OnAtomexClientServiceStatusChangedEventHandler(object sender, Servi
atomexClient.SubscribeToMarketData(SubscriptionType.DepthTwenty);
}
}

private ICommand _closePopupCommand;

public ICommand ClosePopupCommand => _closePopupCommand ??=
ReactiveCommand.Create(() => NavigationService?.ClosePopup());
}
}
5 changes: 4 additions & 1 deletion atomex/ViewModels/SendViewModels/Erc20SendViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using atomex.Resources;
using Atomex;
using Atomex.Blockchain.Abstract;
using atomex.Common;
using Atomex.Common;
using Atomex.Core;
using Atomex.MarketData.Abstract;
using atomex.ViewModels.CurrencyViewModels;
using Atomex.Wallet.Ethereum;
Expand Down Expand Up @@ -162,6 +162,9 @@ protected override void OnQuotesUpdatedEventHandler(object sender, EventArgs arg
{
if (sender is not IQuotesProvider quotesProvider)
return;

if (App.Account?.Network == Network.TestNet)
return;

var quote = quotesProvider.GetQuote(CurrencyCode, BaseCurrencyCode);
var ethQuote = quotesProvider.GetQuote(Currency.FeeCurrencyName, BaseCurrencyCode);
Expand Down
4 changes: 4 additions & 0 deletions atomex/ViewModels/SendViewModels/Fa12SendViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Atomex.Blockchain.Abstract;
using atomex.Common;
using Atomex.Common;
using Atomex.Core;
using Atomex.MarketData.Abstract;
using atomex.Models;
using Atomex.TezosTokens;
Expand Down Expand Up @@ -213,6 +214,9 @@ protected override void OnQuotesUpdatedEventHandler(object sender, EventArgs arg
if (sender is not IQuotesProvider quotesProvider)
return;

if (App.Account?.Network == Network.TestNet)
return;

try
{
var quote = quotesProvider.GetQuote(CurrencyCode, BaseCurrencyCode);
Expand Down
4 changes: 4 additions & 0 deletions atomex/ViewModels/SendViewModels/Fa2SendViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Atomex.Blockchain.Abstract;
using atomex.Common;
using Atomex.Common;
using Atomex.Core;
using Atomex.MarketData.Abstract;
using atomex.Models;
using Atomex.TezosTokens;
Expand Down Expand Up @@ -214,6 +215,9 @@ protected override void OnQuotesUpdatedEventHandler(object sender, EventArgs arg
{
if (sender is not IQuotesProvider quotesProvider)
return;

if (App.Account?.Network == Network.TestNet)
return;

var quote = quotesProvider.GetQuote(CurrencyCode, BaseCurrencyCode);
var xtzQuote = quotesProvider.GetQuote("XTZ", BaseCurrencyCode);
Expand Down
Loading

0 comments on commit 70027b1

Please sign in to comment.