Esempio n. 1
0
        public Account(
            IHdWallet wallet,
            SecureString password,
            ICurrenciesProvider currenciesProvider,
            ClientType clientType,
            Action <MigrationActionType> migrationCompleteCallback = null)
        {
            Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet));

            Currencies = currenciesProvider.GetCurrencies(Network);

            DataRepository = new LiteDbAccountDataRepository(
                pathToDb: Path.Combine(Path.GetDirectoryName(Wallet.PathToWallet), DefaultDataFileName),
                password: password,
                currencies: Currencies,
                network: wallet.Network,
                migrationCompleteCallback);

            CurrencyAccounts = CurrencyAccountCreator.Create(Currencies, wallet, DataRepository);

            UserSettings = UserSettings.TryLoadFromFile(
                pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}",
                password: password) ?? UserSettings.DefaultSettings;

            _clientType = clientType;
        }
Esempio n. 2
0
        public Account(
            IHdWallet wallet,
            SecureString password,
            ICurrenciesProvider currenciesProvider,
            ISymbolsProvider symbolsProvider)
        {
            Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet));

            Currencies = currenciesProvider.GetCurrencies(Network);
            Symbols    = symbolsProvider.GetSymbols(Network);

            DataRepository = new LiteDbAccountDataRepository(
                pathToDb: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultDataFileName}",
                password: password,
                currencies: Currencies,
                network: wallet.Network);

            CurrencyAccounts = Currencies
                               .ToDictionary(
                c => c.Name,
                c => CurrencyAccountCreator.Create(
                    currency: c.Name,
                    wallet: Wallet,
                    dataRepository: DataRepository,
                    currencies: Currencies));

            UserSettings = UserSettings.TryLoadFromFile(
                pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}",
                password: password) ?? UserSettings.DefaultSettings;
        }
Esempio n. 3
0
 public static Account LoadFromFile(
     string pathToAccount,
     SecureString password,
     ICurrenciesProvider currenciesProvider,
     ISymbolsProvider symbolsProvider)
 {
     return(new Account(pathToAccount, password, currenciesProvider, symbolsProvider));
 }
Esempio n. 4
0
 public static Account LoadFromFile(
     string pathToAccount,
     SecureString password,
     ICurrenciesProvider currenciesProvider,
     ClientType clientType,
     Action <MigrationActionType> migrationCompleteCallback = null)
 {
     return(new Account(pathToAccount, password, currenciesProvider, clientType, migrationCompleteCallback));
 }
Esempio n. 5
0
 private Account(
     string pathToAccount,
     SecureString password,
     ICurrenciesProvider currenciesProvider,
     ISymbolsProvider symbolsProvider)
     : this(wallet : HdWallet.LoadFromFile(pathToAccount, password),
            password : password,
            currenciesProvider : currenciesProvider,
            symbolsProvider : symbolsProvider)
 {
 }
Esempio n. 6
0
 private Account(
     string pathToAccount,
     SecureString password,
     ICurrenciesProvider currenciesProvider,
     ClientType clientType,
     Action <MigrationActionType> migrationCompleteCallback = null)
     : this(wallet : HdWallet.LoadFromFile(pathToAccount, password),
            password : password,
            currenciesProvider : currenciesProvider,
            clientType : clientType,
            migrationCompleteCallback : migrationCompleteCallback)
 {
 }
        public SymbolsProvider(
            IConfiguration configuration,
            ICurrenciesProvider currenciesProvider)
        {
            foreach (var network in Networks)
            {
                var networkConfiguration = configuration.GetSection(network.ToString());

                if (networkConfiguration != null)
                {
                    _symbols.Add(network, new Symbols(
                                     configuration: networkConfiguration,
                                     currencies: currenciesProvider.GetCurrencies(network)));
                }
            }
        }
Esempio n. 8
0
        public Account(
            IHdWallet wallet,
            SecureString password,
            IAccountDataRepository dataRepository,
            ICurrenciesProvider currenciesProvider,
            ClientType clientType)
        {
            Wallet         = wallet ?? throw new ArgumentNullException(nameof(wallet));
            DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository));

            Currencies       = currenciesProvider.GetCurrencies(Network);
            CurrencyAccounts = CurrencyAccountCreator.Create(Currencies, wallet, DataRepository);

            UserSettings = UserSettings.TryLoadFromFile(
                pathToFile: $"{Path.GetDirectoryName(Wallet.PathToWallet)}/{DefaultUserSettingsFileName}",
                password: password) ?? UserSettings.DefaultSettings;

            _clientType = clientType;
        }
Esempio n. 9
0
        public static IAccount LoadFromConfiguration(
            IConfiguration configuration,
            SecureString password,
            ICurrenciesProvider currenciesProvider,
            ISymbolsProvider symbolsProvider)
        {
            var pathToAccount = configuration[DefaultAccountKey];

            if (string.IsNullOrEmpty(pathToAccount))
            {
                Log.Error("Path to default account is null or empty");
                return(null);
            }

            if (!File.Exists(PathEx.ToFullPath(pathToAccount)))
            {
                Log.Error("Default account not found");
                return(null);
            }

            return(LoadFromFile(pathToAccount, password, currenciesProvider, symbolsProvider));
        }
Esempio n. 10
0
 public IAtomexApp UseCurrenciesProvider(ICurrenciesProvider currenciesProvider)
 {
     CurrenciesProvider = currenciesProvider;
     return(this);
 }
Esempio n. 11
0
 public CurrenciesUpdater(ICurrenciesProvider currenciesProvider)
 {
     _currenciesProvider = currenciesProvider ?? throw new ArgumentNullException(nameof(currenciesProvider));
 }