Example #1
0
 public AccountDomainRepository(
     IAccountDataRepository accountDataRepository,
     IDomainEventDispatcher domainEventDispatcher)
 {
     _accountDataRepository = accountDataRepository;
     _domainEventDispatcher = domainEventDispatcher;
 }
Example #2
0
 public TezosCurrencyAccount(
     Currency currency,
     IHdWallet wallet,
     IAccountDataRepository dataRepository)
     : base(currency, wallet, dataRepository)
 {
 }
Example #3
0
        public Account(
            IHdWallet wallet,
            SecureString password,
            IAccountDataRepository dataRepository,
            ICurrenciesProvider currenciesProvider,
            ISymbolsProvider symbolsProvider)
        {
            Wallet         = wallet ?? throw new ArgumentNullException(nameof(wallet));
            DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository));

            Currencies = currenciesProvider.GetCurrencies(Network);
            Symbols    = symbolsProvider.GetSymbols(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;
        }
        public static ICurrencyAccount Create(
            Currency currency,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
        {
            switch (currency)
            {
            case BitcoinBasedCurrency _:
                return(new BitcoinBasedCurrencyAccount(
                           currency,
                           wallet,
                           dataRepository));

            case Atomix.Ethereum _:
                return(new EthereumCurrencyAccount(
                           currency,
                           wallet,
                           dataRepository));

            case Atomix.Tezos _:
                return(new TezosCurrencyAccount(
                           currency,
                           wallet,
                           dataRepository));

            default:
                throw new NotSupportedException($"Not supported currency {currency.Name}");
            }
        }
 public BitcoinBasedCurrencyAccount(
     Currency currency,
     IHdWallet wallet,
     IAccountDataRepository dataRepository)
     : base(currency, wallet, dataRepository)
 {
 }
Example #6
0
 public AccountVrfCaseStatusRemindersCommandHandler(IAccountDataRepository accountDataRepository,
                                                    IApprenticeApplicationDataRepository applicationDataRepository,
                                                    ICommandDispatcher commandDispatcher)
 {
     _accountDataRepository     = accountDataRepository;
     _applicationDataRepository = applicationDataRepository;
     _commandDispatcher         = commandDispatcher;
 }
Example #7
0
 public EthereumAccount(
     string currency,
     ICurrencies currencies,
     IHdWallet wallet,
     IAccountDataRepository dataRepository)
     : base(currency, currencies, wallet, dataRepository)
 {
 }
Example #8
0
 public BitcoinBasedAccount(
     string currency,
     ICurrencies currencies,
     IHdWallet wallet,
     IAccountDataRepository dataRepository)
     : base(currency, currencies, wallet, dataRepository)
 {
 }
 public SendPaymentRequestsCommandHandler(
     IAccountDataRepository accountRepository,
     IPaymentsQueryRepository queryRepository,
     IBusinessCentralFinancePaymentsService businessCentralFinancePaymentsService)
 {
     _accountRepository = accountRepository;
     _queryRepository   = queryRepository;
     _businessCentralFinancePaymentsService = businessCentralFinancePaymentsService;
 }
Example #10
0
 public static ICurrencyAccount Create(
     string currency,
     IHdWallet wallet,
     IAccountDataRepository dataRepository,
     ICurrencies currencies)
 {
     return(currency switch
     {
         "BTC" => (ICurrencyAccount) new BitcoinBasedAccount(
             currency,
             currencies,
             wallet,
             dataRepository),
         "LTC" => (ICurrencyAccount) new BitcoinBasedAccount(
             currency,
             currencies,
             wallet,
             dataRepository),
         "USDT" => (ICurrencyAccount) new ERC20Account(
             currency,
             currencies,
             wallet,
             dataRepository),
         "USDC" => (ICurrencyAccount) new ERC20Account(
             currency,
             currencies,
             wallet,
             dataRepository),
         "ETH" => (ICurrencyAccount) new EthereumAccount(
             currency,
             currencies,
             wallet,
             dataRepository),
         "NYX" => (ICurrencyAccount) new NYXAccount(
             currency,
             currencies,
             wallet,
             dataRepository),
         "FA2" => (ICurrencyAccount) new FA2Account(
             currency,
             currencies,
             wallet,
             dataRepository),
         "TZBTC" => (ICurrencyAccount) new FA12Account(
             currency,
             currencies,
             wallet,
             dataRepository),
         "XTZ" => (ICurrencyAccount) new TezosAccount(
             currency,
             currencies,
             wallet,
             dataRepository),
         _ => throw new NotSupportedException($"Not supported currency {currency}"),
     });
Example #11
0
        protected CurrencyAccount(
            Currency currency,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
        {
            Currency       = currency;
            Wallet         = wallet;
            DataRepository = dataRepository;

            PreloadBalances();
        }
Example #12
0
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);

            _sut = new Data.AccountDataRepository(new Lazy <EmployerIncentivesDbContext>(_context));
        }
Example #13
0
        public TezosAccount(
            string currency,
            ICurrencies currencies,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
            : base(currency, currencies, wallet, dataRepository)
        {
            var xtz = Xtz;

            _tezosRevealChecker     = new TezosRevealChecker(xtz);
            _tezosAllocationChecker = new TezosAllocationChecker(xtz);
        }
        public TezosAccount(
            ICurrencies currencies,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
            : base(TezosConfig.Xtz, currencies, wallet, dataRepository)
        {
            var xtz = Config;

            _tezosRevealChecker     = new TezosRevealChecker(xtz);
            _tezosAllocationChecker = new TezosAllocationChecker(xtz);

            AddressLocker = new ResourceLocker <string>();
        }
        protected CurrencyAccount(
            string currency,
            ICurrencies currencies,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
        {
            Currency       = currency ?? throw new ArgumentNullException(nameof(currency));
            Currencies     = currencies ?? throw new ArgumentNullException(nameof(currencies));
            Wallet         = wallet ?? throw new ArgumentNullException(nameof(wallet));
            DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository));

            LoadBalances();
        }
Example #16
0
        public static ICurrencyAccount CreateCurrencyAccount(
            string currency,
            IHdWallet wallet,
            IAccountDataRepository dataRepository,
            ICurrencies currencies,
            ICurrencyAccount baseChainAccount = null)
        {
            return(currency switch
            {
                "BTC" or "LTC" => (ICurrencyAccount) new BitcoinBasedAccount(
                    currency,
                    currencies,
                    wallet,
                    dataRepository),

                "USDT" or "USDC" or "TBTC" or "WBTC" => new Erc20Account(
                    currency,
                    currencies,
                    wallet,
                    dataRepository),

                "ETH" => new EthereumAccount(
                    currency,
                    currencies,
                    wallet,
                    dataRepository),

                "TZBTC" or "KUSD" => new Fa12Account(
                    currency: currency,
                    tokenContract: currencies
                    .Get <Fa12Config>(currency)
                    .TokenContractAddress,
                    tokenId: 0,
                    currencies: currencies,
                    wallet: wallet,
                    dataRepository: dataRepository,
                    tezosAccount: baseChainAccount as TezosAccount),

                "XTZ" => new TezosAccount(
                    currencies,
                    wallet,
                    dataRepository),

                _ => throw new NotSupportedException($"Not supported currency {currency}."),
            });
Example #17
0
        protected Task TrackTransactionConfirmationAsync(
            Swap swap,
            CurrencyConfig currency,
            IAccountDataRepository dataRepository,
            string txId,
            Func <Swap, IBlockchainTransaction, CancellationToken, Task> confirmationHandler,
            CancellationToken cancellationToken = default)
        {
            return(Task.Run(async() =>
            {
                try
                {
                    while (!cancellationToken.IsCancellationRequested)
                    {
                        var tx = await dataRepository
                                 .GetTransactionByIdAsync(currency.Name, txId, currency.TransactionType)
                                 .ConfigureAwait(false);

                        if (tx == null)
                        {
                            break;
                        }

                        if (tx.IsConfirmed)
                        {
                            await confirmationHandler.Invoke(swap, tx, cancellationToken)
                            .ConfigureAwait(false);

                            break;
                        }

                        await Task.Delay(ConfirmationCheckInterval, cancellationToken)
                        .ConfigureAwait(false);
                    }
                }
                catch (OperationCanceledException)
                {
                    // nothing to do...
                }
                catch (Exception e)
                {
                    Log.Error(e, $"{Currency} TrackTransactionConfirmationAsync error");
                }
            }, cancellationToken));
        }
 public Fa2Account(
     string currency,
     string tokenContract,
     decimal tokenId,
     ICurrencies currencies,
     IHdWallet wallet,
     IAccountDataRepository dataRepository,
     TezosAccount tezosAccount)
     : base(currency,
            "FA2",
            tokenContract,
            tokenId,
            currencies,
            wallet,
            dataRepository,
            tezosAccount)
 {
 }
Example #19
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;
        }
Example #20
0
        public static IDictionary <string, ICurrencyAccount> Create(
            ICurrencies currencies,
            IHdWallet wallet,
            IAccountDataRepository dataRepository)
        {
            var accounts = new Dictionary <string, ICurrencyAccount>();

            foreach (var currency in currencies)
            {
                if (Currencies.IsTezosToken(currency.Name))
                {
                    if (!accounts.TryGetValue(TezosConfig.Xtz, out var tezosAccount))
                    {
                        tezosAccount = CreateCurrencyAccount(
                            currency: TezosConfig.Xtz,
                            wallet: wallet,
                            dataRepository: dataRepository,
                            currencies: currencies);

                        accounts.Add(TezosConfig.Xtz, tezosAccount);
                    }

                    accounts.Add(currency.Name, CreateCurrencyAccount(
                                     currency: currency.Name,
                                     wallet: wallet,
                                     dataRepository: dataRepository,
                                     currencies: currencies,
                                     baseChainAccount: tezosAccount));
                }
                else
                {
                    accounts.Add(currency.Name, CreateCurrencyAccount(
                                     currency: currency.Name,
                                     wallet: wallet,
                                     dataRepository: dataRepository,
                                     currencies: currencies));
                }
            }

            return(accounts);
        }
        public TezosTokenAccount(
            string currency,
            string tokenType,
            string tokenContract,
            decimal tokenId,
            ICurrencies currencies,
            IHdWallet wallet,
            IAccountDataRepository dataRepository,
            TezosAccount tezosAccount)
        {
            Currency       = currency ?? throw new ArgumentNullException(nameof(currency));
            TokenType      = tokenType ?? throw new ArgumentNullException(nameof(tokenType));
            Currencies     = currencies ?? throw new ArgumentNullException(nameof(currencies));
            Wallet         = wallet ?? throw new ArgumentNullException(nameof(wallet));
            DataRepository = dataRepository ?? throw new ArgumentNullException(nameof(dataRepository));

            _tokenContract = tokenContract ?? throw new ArgumentNullException(nameof(tokenContract));
            _tokenId       = tokenId;
            _tezosAccount  = tezosAccount ?? throw new ArgumentNullException(nameof(tezosAccount));

            ReloadBalances();
        }
 public GetApplicationsQueryHandler(IApprenticeApplicationDataRepository applicationRepository, IAccountDataRepository accountRepository)
 {
     _applicationRepository = applicationRepository;
     _accountRepository     = accountRepository;
 }
 public GetAccountsWithVrfCaseStatusQueryHandler(IAccountDataRepository accountDataRepository)
 {
     _accountDataRepository = accountDataRepository;
 }
Example #24
0
 public GetLatestVendorRegistrationCaseUpdateDateTimeQueryHandler(IAccountDataRepository repository)
 {
     _repository = repository;
 }