Пример #1
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;
        }
Пример #2
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;
        }
Пример #3
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;
        }
Пример #4
0
        public ICurrencyAccount GetTezosTokenAccount(
            string currency,
            string tokenContract,
            decimal tokenId)
        {
            var uniqueId = $"{currency}:{tokenContract}:{tokenId}";

            if (CurrencyAccounts.TryGetValue(uniqueId, out var account))
            {
                return(account);
            }

            return(CurrencyAccountCreator.CreateTezosTokenAccount(
                       currency,
                       tokenContract,
                       tokenId,
                       Currencies,
                       Wallet,
                       DataRepository,
                       CurrencyAccounts[TezosConfig.Xtz] as TezosAccount));
        }