public static IWalletViewModel CreateViewModel( IAtomexApp app, IDialogViewer dialogViewer, IMenuSelector menuSelector, IConversionViewModel conversionViewModel, CurrencyConfig currency) { return(currency switch { BitcoinBasedConfig _ or Erc20Config _ or EthereumConfig _ => new WalletViewModel( app: app, dialogViewer: dialogViewer, menuSelector: menuSelector, conversionViewModel: conversionViewModel, currency: currency), Fa12Config _ => new Fa12WalletViewModel( app: app, dialogViewer: dialogViewer, menuSelector: menuSelector, conversionViewModel: conversionViewModel, currency: currency), TezosConfig _ => new TezosWalletViewModel( app: app, dialogViewer: dialogViewer, menuSelector: menuSelector, conversionViewModel: conversionViewModel, currency: currency), _ => throw new NotSupportedException($"Can't create wallet view model for {currency.Name}. This currency is not supported."), });
public RestoreDialogViewModel(IAtomexApp app, string[] currenies = null) { App = app ?? throw new ArgumentNullException(nameof(app)); cancellation = new CancellationTokenSource(); ScanCurrenciesAsync(currenies); }
public FA2SendViewModel( IAtomexApp app, IDialogViewer dialogViewer, CurrencyConfig currency) : base(app, dialogViewer, currency) { }
public MainViewModel(IAtomexApp app, IAccount account, string walletName, string appTheme = "light", bool restore = false) { var assembly = AppDomain.CurrentDomain .GetAssemblies() .First(a => a.GetName().Name == "atomex"); var configuration = new ConfigurationBuilder() .AddEmbeddedJsonFile(assembly, "configuration.json") .Build(); AtomexApp = app ?? throw new ArgumentNullException(nameof(AtomexApp)); SubscribeToServices(); var atomexClient = new WebSocketAtomexClient( configuration: configuration, account: account, symbolsProvider: AtomexApp.SymbolsProvider, quotesProvider: AtomexApp.QuotesProvider); AtomexApp.UseAtomexClient(atomexClient, restart: true); CurrenciesViewModel = new CurrenciesViewModel(AtomexApp, restore); SettingsViewModel = new SettingsViewModel(AtomexApp, this, walletName); ConversionViewModel = new ConversionViewModel(AtomexApp); PortfolioViewModel = new PortfolioViewModel(CurrenciesViewModel, appTheme); BuyViewModel = new BuyViewModel(AtomexApp); _ = TokenDeviceService.SendTokenToServerAsync(App.DeviceToken, App.FileSystem, AtomexApp); }
public App() { InitializeComponent(); LoadStyles(); DependencyService.Get <INotificationManager>().Initialize(); var currenciesProvider = new CurrenciesProvider(CurrenciesConfigurationJson); var symbolsProvider = new SymbolsProvider(SymbolsConfiguration); AtomexApp = new AtomexApp() .UseCurrenciesProvider(currenciesProvider) .UseSymbolsProvider(symbolsProvider) .UseCurrenciesUpdater(new CurrenciesUpdater(currenciesProvider)) .UseSymbolsUpdater(new SymbolsUpdater(symbolsProvider)) .UseQuotesProvider(new BitfinexQuotesProvider( currencies: currenciesProvider.GetCurrencies(Network.MainNet), baseCurrency: BitfinexQuotesProvider.Usd)); AtomexApp.Start(); StartViewModel startViewModel = new StartViewModel(AtomexApp); MainPage = new NavigationPage(new StartPage(startViewModel)); startViewModel.Navigation = MainPage.Navigation; Current.RequestedThemeChanged += (s, a) => { Device.BeginInvokeOnMainThread(SetAppTheme); }; SetAppTheme(); }
public CurrenciesViewModel(IAtomexApp app, bool restore = false) { AtomexApp = app ?? throw new ArgumentNullException(nameof(AtomexApp)); TezosTokensViewModel = new TezosTokensViewModel(app, restore); CurrencyViewModels = new List <CurrencyViewModel>(); _ = FillCurrenciesAsync(restore); }
public static WalletViewModel CreateViewModel( IAtomexApp app, Action <Currency> setConversionTab, Currency currency) { switch (currency) { case BitcoinBasedCurrency _: case ERC20 _: case Ethereum _: case NYX _: case FA2 _: case FA12 _: return(new WalletViewModel( app: app, setConversionTab: setConversionTab, currency: currency)); case Tezos _: return(new TezosWalletViewModel( app: app, setConversionTab: setConversionTab, currency: currency)); default: throw new NotSupportedException( $"Can't create wallet view model for {currency.Name}. This currency is not supported."); } }
public ConversionConfirmationViewModel( IAtomexApp app, IDialogViewer dialogViewer) { App = app ?? throw new ArgumentNullException(nameof(app)); DialogViewer = dialogViewer ?? throw new ArgumentNullException(nameof(dialogViewer)); }
public MyWalletsViewModel( IAtomexApp app, IDialogViewer dialogViewer) { AtomexApp = app ?? throw new ArgumentNullException(nameof(app)); DialogViewer = dialogViewer ?? throw new ArgumentNullException(nameof(dialogViewer)); Wallets = WalletInfo.AvailableWallets(); }
public MyWalletsViewModel( IAtomexApp app, Action <ViewModelBase> showContent) { AtomexApp = app ?? throw new ArgumentNullException(nameof(app)); Wallets = WalletInfo.AvailableWallets(); AtomexApp.TerminalChanged += OnTerminalChangedEventHandler; ShowContent += showContent; }
public DelegateConfirmationViewModel( IAtomexApp app, IDialogViewer dialogViewer, Action onDelegate = null) { App = app ?? throw new ArgumentNullException(nameof(app)); DialogViewer = dialogViewer ?? throw new ArgumentNullException(nameof(dialogViewer)); _onDelegate = onDelegate; }
public static SendViewModel CreateViewModel(IAtomexApp app, CurrencyViewModel currencyViewModel) { return(currencyViewModel.Currency switch { BitcoinBasedConfig _ => (SendViewModel) new BitcoinBasedSendViewModel(app, currencyViewModel), Erc20Config _ => (SendViewModel) new Erc20SendViewModel(app, currencyViewModel), EthereumConfig _ => (SendViewModel) new EthereumSendViewModel(app, currencyViewModel), Fa12Config _ => (SendViewModel) new Fa12SendViewModel(app, currencyViewModel), TezosConfig _ => (SendViewModel) new TezosSendViewModel(app, currencyViewModel), _ => throw new NotSupportedException($"Can't create send view model for {currencyViewModel.Currency.Name}. This currency is not supported."), });
private static async Task <string> GetAuthToken(IAtomexApp atomexApp, CancellationToken cancellationToken = default) { var securePublicKey = atomexApp.Account.Wallet.GetServicePublicKey(0); var publicKey = securePublicKey.ToUnsecuredBytes(); var timeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); var message = "Sign by Atomex Mobile Client"; var publicKeyHex = Hex.ToHexString(publicKey); var algorithm = "Sha256WithEcdsa:BtcMsg"; var signature = await atomexApp.Account.Wallet .SignByServiceKeyAsync(Encoding.UTF8.GetBytes($"{message}{timeStamp}"), 0) .ConfigureAwait(false); var signatureHex = Hex.ToHexString(signature); string baseUri = atomexApp.Account.Network == Atomex.Core.Network.MainNet ? "https://api.atomex.me/" : "https://api.test.atomex.me/"; var requestUri = "v1/token"; var jsonRequest = JsonConvert.SerializeObject(new { timeStamp = timeStamp, message = message, publicKey = publicKeyHex, signature = signatureHex, algorithm = algorithm }); var requestContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json"); try { var authTokenResult = await HttpHelper.PostAsyncResult <string>( baseUri : baseUri, requestUri : requestUri, content : requestContent, responseHandler : (response, responseContent) => JsonConvert.DeserializeObject <AuthToken>(responseContent).Token, cancellationToken : cancellationToken) .ConfigureAwait(false); return(authTokenResult?.Value); } catch (Exception e) { Log.Error(e, "Get auth token error"); return(null); } }
public WalletMainViewModel(IAtomexApp app) { AtomexApp = app ?? throw new ArgumentNullException(nameof(app)); PortfolioViewModel = new PortfolioViewModel(AtomexApp); ConversionViewModel = new ConversionViewModel(AtomexApp); WalletsViewModel = new WalletsViewModel(AtomexApp, SelectConversion); SettingsViewModel = new SettingsViewModel(AtomexApp); WertViewModel = new WertViewModel(AtomexApp); SelectPortfolio(); SubscribeToServices(); InstalledVersion = GetAssemblyFileVersion(); }
public static SendViewModel CreateViewModel( IAtomexApp app, Currency currency) { return(currency switch { BitcoinBasedCurrency _ => (SendViewModel) new BitcoinBasedSendViewModel(app, currency), ERC20 _ => (SendViewModel) new Erc20SendViewModel(app, currency), Ethereum _ => (SendViewModel) new EthereumSendViewModel(app, currency), NYX _ => (SendViewModel) new Fa12SendViewModel(app, currency), FA2 _ => (SendViewModel) new Fa12SendViewModel(app, currency), FA12 _ => (SendViewModel) new Fa12SendViewModel(app, currency), Tezos _ => (SendViewModel) new TezosSendViewModel(app, currency), _ => throw new NotSupportedException($"Can't create send view model for {currency.Name}. This currency is not supported."), });
public static ReceiveViewModel CreateViewModel( IAtomexApp app, Currency currency) { return(currency switch { BitcoinBasedCurrency _ => new ReceiveViewModel(app, currency), ERC20 _ => new ReceiveViewModel(app, currency), Ethereum _ => new EthereumReceiveViewModel(app, currency), NYX _ => new ReceiveViewModel(app, currency), FA2 _ => new ReceiveViewModel(app, currency), FA12 _ => new ReceiveViewModel(app, currency), Tezos _ => new TezosReceiveViewModel(app, currency), _ => throw new NotSupportedException($"Can't create receive view model for {currency.Name}. This currency is not supported."), });
public StartViewModel(Action <ViewModelBase> showContent, Action showStart, IAtomexApp app, MainWindowViewModel mainWindowWM) { #if DEBUG if (Env.IsInDesignerMode()) { DesignerMode(); } #endif AtomexApp = app ?? throw new ArgumentNullException(nameof(app)); HasWallets = WalletInfo.AvailableWallets().Count() > 0; MainWindowVM = mainWindowWM; ShowContent += showContent; ShowStart += showStart; }
public static CurrencyViewModel CreateViewModel( IAtomexApp app, CurrencyConfig currency, bool loadTransactions = true) { return(currency switch { BitcoinBasedConfig _ or Erc20Config _ or EthereumConfig _ => new CurrencyViewModel(app, currency, loadTransactions), Fa12Config _ => new Fa12CurrencyViewModel(app, currency), TezosConfig _ => new TezosCurrencyViewModel(app, currency), _ => throw new NotSupportedException($"Can't create currency view model for {currency.Name}. This currency is not supported."), });
public TezosSendViewModel( IAtomexApp app, CurrencyViewModel currencyViewModel) : base(app, currencyViewModel) { }
public MyWalletsViewModel(IAtomexApp app, INavigation navigation) { AtomexApp = app ?? throw new ArgumentNullException(nameof(AtomexApp)); Navigation = navigation; Wallets = WalletInfo.AvailableWallets().ToList(); }
public Fa12SendViewModel( IAtomexApp app, Currency currency) : base(app, currency) { }
public Fa12CurrencyViewModel( IAtomexApp app, CurrencyConfig currency) : base(app, currency) { }
public static async Task <bool> SendTokenToServerAsync(string deviceToken, string fileSystem, IAtomexApp atomexApp, CancellationToken cancellationToken = default) { string token = await GetAuthToken(atomexApp, cancellationToken); if (token == null) { return(false); } var headers = new HttpRequestHeaders { new KeyValuePair <string, IEnumerable <string> >("Authorization", new string[] { $"Bearer {token}" }) }; string baseUri = atomexApp.Account.Network == Atomex.Core.Network.MainNet ? "https://api.atomex.me/" : "https://api.test.atomex.me/"; var requestUri = $"v1/guard/push?token={deviceToken}&platform={fileSystem}"; try { var result = await HttpHelper.PostAsync( baseUri : baseUri, requestUri : requestUri, headers : headers, content : null, responseHandler : response => { if (!response.IsSuccessStatusCode) { return(false); } var responseContent = response .Content .ReadAsStringAsync() .Result; if (bool.TryParse(responseContent, out var result)) { return(result); } return(false); }, cancellationToken : cancellationToken) .ConfigureAwait(false); return(result); } catch (Exception e) { Log.Error(e, "Auth error"); return(false); } }
public SettingsViewModel(IAtomexApp app) { App = app ?? throw new ArgumentNullException(nameof(app)); // SubscribeToServices(); }
public ConversionConfirmationViewModel(IAtomexApp app) { App = app ?? throw new ArgumentNullException(nameof(app)); }