public async Task <CommandHandlingResult> Handle(UpdateEmployeeCredentialsCommand cmd, IEventPublisher publisher) { if (string.IsNullOrEmpty(cmd.Password)) { publisher.PublishEvent(new EmployeeUpdateCompletedEvent { Id = cmd.EmployeeId }); _chaosKitty.Meow("Issue with RabbitMq publishing EmployeeUpdateCompletedEvent"); return(CommandHandlingResult.Ok()); } await _employeeCredentialsService.UpdateAsync(new EmployeeCredentials { EmployeeId = cmd.EmployeeId, Email = cmd.Email, MerchantId = cmd.MerchantId, Password = cmd.Password, }); publisher.PublishEvent(new EmployeeCredentialsUpdatedEvent { EmployeeId = cmd.EmployeeId, MerchantId = cmd.MerchantId }); _chaosKitty.Meow("Issue with RabbitMq publishing EmployeeCredentialsUpdatedEvent"); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(ProcessEthCoinEventCommand command) { // we need only cashout completed events here if (command.CoinEventType != CoinEventType.CashoutCompleted) { return(CommandHandlingResult.Ok()); } if (!Utils.TryExtractGuid(command.OperationId, out var id)) { _logger.Warning($"Cannot parse OperationId: {command.OperationId}"); return(CommandHandlingResult.Ok()); } if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(id, command.TransactionHash)) { _logger.Warning($"Transaction hash was not set, ETH cashout", context: new { id, hash = command.TransactionHash }); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(CheckCashoutPreconditionsCommand command, IEventPublisher publisher) { var lastMoment = await _lastCashoutEventMomentRepository.GetLastEventMomentAsync(command.AssetId) ?? DateTime.MinValue; if (DateTime.UtcNow - lastMoment > command.MaxCashoutInactivePeriod) { publisher.PublishEvent(new CashoutPreconditionPassedEvent { OperationId = command.OperationId, Moment = DateTime.UtcNow }); } else { publisher.PublishEvent(new CashoutPreconditionRejectedEvent { OperationId = command.OperationId, Moment = DateTime.UtcNow }); } _chaosKitty.Meow(command.OperationId); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(GeneratePasswordResetTokenCommand cmd, IEventPublisher publisher) { ResetPasswordAccessToken token = await _accessTokenService.CreateAsync(cmd.EmployeeId, cmd.MerchantId); _chaosKitty.Meow("Issue with Azure repository when creating reset password token"); string resetPasswordUrl = string.Format(_resetPasswordUrlTemplate, token.PublicId); if (cmd.IsNewEmployee) { publisher.PublishEvent(new EmployeeRegistrationCompletedEvent { Id = token.EmployeeId, ResetPasswordUrl = resetPasswordUrl }); } else { publisher.PublishEvent(new EmployeeUpdateCompletedEvent { Id = token.EmployeeId, ResetPasswordUrl = resetPasswordUrl }); } _chaosKitty.Meow("Issue with RabbitMq publishing EmployeeRegistrationCompletedEvent and EmployeeUpdateCompletedEvent"); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(AcquireLockCommand command, IEventPublisher publisher) { var transactionExecution = await _repository.GetAsync(command.TransactionId); if (transactionExecution.LockAcquired) { _log.Info("Address lock command has been skipped, since lock already was performed earlier", command); return(CommandHandlingResult.Ok()); } if (await _locker.TryLockAsync(command.TransactionId)) { publisher.PublishEvent(new LockAcquiredEvent { TransactionId = command.TransactionId }); } else { publisher.PublishEvent(new LockRejectedEvent { TransactionId = command.TransactionId }); } _chaosKitty.Meow(command.TransactionId); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(UpdateLimitOrdersCountCommand command, IEventPublisher eventPublisher) { var sw = new Stopwatch(); sw.Start(); try { var activeLimitOrdersCount = await _limitOrdersRepository.GetActiveOrdersCountAsync(command.ClientId); await _clientCacheRepository.UpdateLimitOrdersCount(command.ClientId, activeLimitOrdersCount); ChaosKitty.Meow(); _log.Info(nameof(UpdateLimitOrdersCountCommand), $"Client {command.ClientId}. Limit orders cache updated: {activeLimitOrdersCount} active orders"); return(CommandHandlingResult.Ok()); } finally { sw.Stop(); _log.Info("Command execution time", context: new { TxHandler = new { Handler = nameof(HistoryCommandHandler), Command = nameof(UpdateLimitOrdersCountCommand), Time = sw.ElapsedMilliseconds } }); } }
public async Task <CommandHandlingResult> Handle(LockSourceAddressCommand command, IEventPublisher publisher) { var transactionExecution = await _transactionExecutionsRepository.GetAsync(command.TransactionId); if (transactionExecution.WasLocked) { _log.Info("Source address lock command has been skipped, since lock already was performed earlier", command); return(CommandHandlingResult.Ok()); } var isSourceAdressCaptured = await _sourceAddresLocksRepoistory.TryGetLockAsync( command.BlockchainType, command.FromAddress, command.TransactionId); if (!isSourceAdressCaptured) { return(CommandHandlingResult.Fail(_retryDelayProvider.SourceAddressLockingRetryDelay)); } _chaosKitty.Meow(command.TransactionId); publisher.PublishEvent(new SourceAddressLockedEvent { OperationId = command.OperationId, TransactionId = command.TransactionId }); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(WaitForBatchExpirationCommand command, IEventPublisher publisher) { var batch = await _cashoutsBatchRepository.GetAsync(command.BatchId); if (!batch.HaveToBeExpired && batch.IsStillFillingUp) { return(CommandHandlingResult.Fail(_batchExpirationMonitoringPeriod)); } var transitionResult = batch.Expire(); if (transitionResult.ShouldSaveAggregate()) { await _cashoutsBatchRepository.SaveAsync(batch); _chaosKitty.Meow(command.BatchId); } if (transitionResult.ShouldPublishEvents()) { publisher.PublishEvent ( new BatchExpiredEvent { BatchId = batch.BatchId } ); _chaosKitty.Meow(command.BatchId); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(CreateTradeCommand command, IEventPublisher eventPublisher) { var queueMessage = command.QueueMessage; var clientId = queueMessage.Order.ClientId; if (!queueMessage.Order.Status.Equals("matched", StringComparison.OrdinalIgnoreCase)) { _log.Info($"{nameof(TradeSaga)}:{nameof(TradeCommandHandler)}", "Message processing being aborted, due to order status is not matched", queueMessage.ToJson()); return(CommandHandlingResult.Ok()); } var context = await _transactionService.GetTransactionContext <SwapOffchainContextData>(queueMessage.Order.Id) ?? new SwapOffchainContextData(); await _contextFactory.FillTradeContext(context, queueMessage.Order, queueMessage.Trades, clientId); ChaosKitty.Meow(); await _transactionService.SetTransactionContext(queueMessage.Order.Id, context); ChaosKitty.Meow(); eventPublisher.PublishEvent(new TradeCreatedEvent { OrderId = queueMessage.Order.Id, IsTrustedClient = context.IsTrustedClient, MarketOrder = context.Order, ClientTrades = context.ClientTrades, QueueMessage = queueMessage }); return(CommandHandlingResult.Ok()); }
/// <summary> /// BIL cross client cashout event completed /// </summary> /// <param name="event"></param> /// <returns></returns> public async Task <CommandHandlingResult> Handle( Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent @event) { if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, _crossClientTransactionHashSubstituition)) { _logger.Warning($"Transaction hash was not set. " + $"OperationId: {@event.OperationId}, " + $"TxHash: {_crossClientTransactionHashSubstituition}", context: new { id = @event.OperationId, hash = _crossClientTransactionHashSubstituition }); return(CommandHandlingResult.Fail(TimeSpan.FromMinutes(1))); } if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.CashinOperationId, _crossClientTransactionHashSubstituition)) { _logger.Warning($"Transaction cashin hash was not set. " + $"OperationId: {@event.OperationId}, " + $"TxHash: {_crossClientTransactionHashSubstituition}", context: new { id = @event.OperationId, hash = _crossClientTransactionHashSubstituition }); return(CommandHandlingResult.Fail(TimeSpan.FromMinutes(1))); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(CloseBatchCommand command, IEventPublisher publisher) { var batch = await _cashoutsBatchRepository.GetAsync(command.BatchId); var transitionResult = await batch.CloseAsync(command.Reason, _closedBatchedCashoutRepository); _chaosKitty.Meow(command.BatchId); if (transitionResult.ShouldSaveAggregate()) { await _cashoutsBatchRepository.SaveAsync(batch); _chaosKitty.Meow(command.BatchId); } if (transitionResult.ShouldPublishEvents()) { publisher.PublishEvent ( new BatchClosedEvent { BatchId = batch.BatchId } ); _chaosKitty.Meow(command.BatchId); } return(CommandHandlingResult.Ok()); }
/// <summary> /// BIL batched cashout event /// </summary> /// <param name="event"></param> /// <returns></returns> public async Task <CommandHandlingResult> Handle( Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent @event) { if (@event.Cashouts == null || @event.Cashouts.Length == 0) { _logger.Warning($"BIL batched cashout event is empty, BatchId {@event.BatchId}", context: @event); return(CommandHandlingResult.Ok()); } foreach (var cashout in @event.Cashouts) { if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(cashout.OperationId, @event.TransactionHash)) { _logger.Warning($"Transaction hash was not set, BIL cashout", context: new { id = cashout.OperationId, hash = @event.TransactionHash }); return(CommandHandlingResult.Fail(TimeSpan.FromMinutes(1))); } } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(RequestConfirmationCommand command, IEventPublisher eventPublisher) { var sessionIds = _sessionCache.GetSessionIds(command.ClientId.ToString()); if (sessionIds.Length == 0) { return(CommandHandlingResult.Ok()); } _subject.OnNext(new WampEvent { Options = new PublishOptions { Eligible = sessionIds }, Arguments = new object[] { new OperationStatusChangedMessage { Status = OperationStatus.ConfirmationRequested, OperationId = command.OperationId } } }); return(CommandHandlingResult.Ok()); }
private async Task <CommandHandlingResult> Handle(GetPriceForSpecialLiquidationTimeoutInternalCommand command, IEventPublisher publisher) { var executionInfo = await _operationExecutionInfoRepository.GetAsync <SpecialLiquidationOperationData>( operationName : SpecialLiquidationSaga.OperationName, id : command.OperationId); if (executionInfo?.Data != null) { if (executionInfo.Data.State > SpecialLiquidationOperationState.PriceRequested || executionInfo.Data.RequestNumber > command.RequestNumber) { return(CommandHandlingResult.Ok()); } if (_dateService.Now() >= command.CreationTime.AddSeconds(command.TimeoutSeconds)) { publisher.PublishEvent(new SpecialLiquidationFailedEvent { OperationId = command.OperationId, CreationTime = _dateService.Now(), Reason = $"Timeout of {command.TimeoutSeconds} seconds from {command.CreationTime:s}", CanRetryPriceRequest = true }); return(CommandHandlingResult.Ok()); } } return(CommandHandlingResult.Fail(_marginTradingSettings.SpecialLiquidation.PriceRequestTimeoutCheckPeriod)); }
public async Task <CommandHandlingResult> Handle(RemoveEntryCommand command, IEventPublisher eventPublisher) { var forwardWithdrawal = await _repository.TryGetAsync(command.ClientId, command.Id); if (forwardWithdrawal == null) { return(CommandHandlingResult.Ok()); } _log.Info("Removing forward withdrawal record.", new { command.ClientId, command.Id }); var entryExisted = await _repository.DeleteIfExistsAsync(command.ClientId, command.Id); if (entryExisted) { _log.Info("Removed forward withdrawal record.", forwardWithdrawal.ToJson()); eventPublisher.PublishEvent(new PaymentEntryRemovedEvent { Id = forwardWithdrawal.Id, ClientId = forwardWithdrawal.ClientId, AssetId = forwardWithdrawal.AssetId, Amount = forwardWithdrawal.Amount, CashInId = forwardWithdrawal.CashInId }); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(SwiftCashoutCreateCommand command, IEventPublisher eventPublisher) { var amount = (double)command.Volume; var feeSize = (double)command.FeeSize; var model = new SwiftCashOutRequest { ClientId = command.ClientId, AssetId = command.AssetId, Amount = amount, FeeSize = feeSize, AccountId = command.AccountId, State = command.State, Status = CashoutRequestStatus.Pending, VolumeSize = await FillVolumeSize(command.AssetId, amount) }; var inserted = await _cashoutAttemptRepository.TryInsertAsync(command.Id, model, PaymentSystem.Swift, command.SwiftData, command.TradeSystem); if (inserted) { eventPublisher.PublishEvent(new SwiftCashoutCreatedEvent { Volume = command.Volume, FeeSize = command.FeeSize, AssetId = command.AssetId, ClientId = command.ClientId, TradeSystem = command.TradeSystem, RequestId = command.Id, VolumeSize = model.VolumeSize }); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(RevokeActiveBatchIdCommand command, IEventPublisher publisher) { var batch = await _cashoutsBatchRepository.GetAsync(command.BatchId); var transitionResult = await batch.RevokeIdAsync(_activeCashoutsBatchIdRepository); _chaosKitty.Meow(command.BatchId); if (transitionResult.ShouldSaveAggregate()) { await _cashoutsBatchRepository.SaveAsync(batch); _chaosKitty.Meow(command.BatchId); } if (transitionResult.ShouldPublishEvents()) { publisher.PublishEvent ( new ActiveBatchIdRevokedEvent { BatchId = batch.BatchId } ); _chaosKitty.Meow(command.BatchId); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(AcquireCashoutLockCommand command, IEventPublisher publisher) { var lockMoment = DateTime.UtcNow; if (await _cashoutLockRepository.TryLockAsync(command.AssetId, command.OperationId, lockMoment)) { _chaosKitty.Meow(command.OperationId); publisher.PublishEvent(new CashoutLockAcquiredEvent { OperationId = command.OperationId, Moment = lockMoment }); } else { _chaosKitty.Meow(command.OperationId); publisher.PublishEvent(new CashoutLockRejectedEvent { OperationId = command.OperationId, Moment = DateTime.UtcNow }); } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(RegisterEmployeeCredentialsCommand cmd, IEventPublisher publisher) { try { await _employeeCredentialsService.RegisterAsync(new EmployeeCredentials { EmployeeId = cmd.EmployeeId, MerchantId = cmd.MerchantId, Email = cmd.Email, Password = cmd.Password, ForcePasswordUpdate = true, ForcePinUpdate = true }); } catch (InvalidOperationException e) { // employee already exists _log.Warning(e.Message, context: $"Command details: {cmd.ToJson()}"); } publisher.PublishEvent(new EmployeeCredentialsRegisteredEvent { EmployeeId = cmd.EmployeeId, MerchantId = cmd.MerchantId }); _chaosKitty.Meow("Issue with RabbitMq publishing EmployeeCredentialsRegisteredEvent"); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(Commands.SegwitTransferCommand command) { var sw = new Stopwatch(); sw.Start(); try { var response = await _bitcoinApiClient.SegwitTransfer(Guid.Parse(command.Id), command.Address); if (response.HasError && response.Error.ErrorCode != ErrorCode.DuplicateTransactionId) { _log.Error($"{nameof(BitcoinCommandHandler)}:{nameof(Commands.SegwitTransferCommand)}", new Exception(response.ToJson()), context: command.ToJson()); return(CommandHandlingResult.Fail(_retryTimeout)); } ChaosKitty.Meow(); return(CommandHandlingResult.Ok()); } finally { sw.Stop(); _log.Info("Command execution time", context: new { TxHandler = new { Handler = nameof(BitcoinCommandHandler), Command = nameof(Commands.SegwitTransferCommand), Time = sw.ElapsedMilliseconds } }); } }
public async Task <CommandHandlingResult> Handle(SignTransactionCommand command, IEventPublisher publisher) { var transactionSigningResult = await _client.SignTransactionAsync ( blockchainType : command.NeoBlockchainType, request : new SignTransactionRequest { PublicAddresses = new[] { command.Address }, TransactionContext = command.UnsignedTransactionContext } ); _chaosKitty.Meow(command.TransactionId); if (string.IsNullOrWhiteSpace(transactionSigningResult?.SignedTransaction)) { throw new InvalidOperationException("Sign service returned the empty transaction"); } publisher.PublishEvent(new TransactionSignedEvent { TransactionId = command.TransactionId, SignedTransactionContext = transactionSigningResult.SignedTransaction }); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(RetrieveAssetInfoCommand command, IEventPublisher publisher) { var asset = await _assetsService.AssetGetAsync(command.AssetId); publisher.PublishEvent(new AssetInfoRetrievedEvent { DisplayId = asset.DisplayId, MultiplierPower = asset.MultiplierPower, AssetAddress = asset.AssetAddress, Accuracy = asset.Accuracy, BlockchainIntegrationLayerId = asset.BlockchainIntegrationLayerId, Blockchain = asset.Blockchain.ToString(), Type = asset.Type?.ToString(), IsTradable = asset.IsTradable, IsTrusted = asset.IsTrusted, KycNeeded = asset.KycNeeded, BlockchainWithdrawal = asset.BlockchainWithdrawal, CashoutMinimalAmount = (decimal)asset.CashoutMinimalAmount, LowVolumeAmount = (decimal?)asset.LowVolumeAmount ?? 0, LykkeEntityId = asset.LykkeEntityId, Moment = DateTime.UtcNow, OperationId = command.OperationId }); _chaosKitty.Meow(command.OperationId); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(AddToPassWhiteListCommand command, IEventPublisher eventPublisher) { try { string ticketId = await _blockPassService.AddToWhiteListAsync(command.Address); } catch (ClientSideException ex) { if (ex.ExceptionType == ExceptionType.EntityAlreadyExists || ex.ExceptionType == ExceptionType.OperationWithIdAlreadyExists) { _logger.WriteWarning(nameof(BlockPassCommandHandler), command, $"Address passed to BlockPass already, {command.Address}", ex); } else { _logger.WriteError(nameof(BlockPassCommandHandler), command, ex); throw; } } return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(Commands.DisableApiKeyCommand command, IEventPublisher eventPublisher) { _log.Info("Disable api key.", command); var existedApiKey = await _apiKeyRepository.Get(Guid.Parse(command.ApiKey)); if (existedApiKey != null) { existedApiKey.ValidTill = DateTime.UtcNow; await _apiKeyRepository.Update(existedApiKey); _chaosKitty.Meow("repository unavailable"); eventPublisher.PublishEvent(new ApiKeyUpdatedEvent { ApiKey = existedApiKey.Token ?? command.ApiKey, WalletId = existedApiKey.WalletId, Enabled = false, Apiv2Only = existedApiKey.Apiv2Only }); await _keysPublisher.PublishAsync(new KeyUpdatedEvent { Id = existedApiKey.Id.ToString(), IsDeleted = true, Apiv2Only = existedApiKey.Apiv2Only }); } return(CommandHandlingResult.Ok()); }
public async Task Test_that_Handle_call_results_in_Ok_If_no_exception_thrown_and_plan_exists() { // Arrange var distributionPlanServiceMock = new Mock <IDistributionPlanService>(); var eventPublisherMock = new Mock <IEventPublisher>(); // Setup distributionPlanServiceMock .Setup(x => x.ExecutePlanAsync(It.IsAny <Guid>())) .Returns(Task.CompletedTask); distributionPlanServiceMock .Setup(x => x.PlanExistsAsync(It.IsAny <Guid>())) .ReturnsAsync(true); // Act var handler = CreateHandler(distributionPlanServiceMock); var actualResult = await handler.Handle ( new ExecuteDistributionPlanCommand(), eventPublisherMock.Object ); // Assert var expectedResult = CommandHandlingResult.Ok(); actualResult .Should() .BeEquivalentTo(expectedResult); }
public async Task <CommandHandlingResult> Handle(Commands.SetTokensCommand command, IEventPublisher eventPublisher) { _log.Info("Set tokens", command); var noTokenKeys = _apiKeyRepository.FilterBy(x => string.IsNullOrEmpty(x.Token)); var tasks = new List <Task>(); foreach (var key in noTokenKeys) { key.Token = ApiKeyService.GenerateJwtToken(key.Id.ToString(), key.ClientId, key.WalletId, key.Apiv2Only, null); tasks.Add(_apiKeyRepository.Update(key)); eventPublisher.PublishEvent(new ApiKeyUpdatedEvent { ApiKey = key.Token ?? key.Id.ToString(), Token = key.Token, WalletId = key.WalletId, Enabled = key.ValidTill == null || key.ValidTill > DateTime.UtcNow, Apiv2Only = key.Apiv2Only }); } _log.Info($"Waiting for {tasks.Count} tokens to be added..."); await Task.WhenAll(tasks); _log.Info("Tokens were assigned"); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(ProcessSmsCommand command, IEventPublisher eventPublisher) { _log.WriteInfo(nameof(ProcessSmsCommand), new { Phone = command.Phone.SanitizePhone() }, "Processing sms"); var phone = command.Phone.GetValidPhone(); if (phone != null) { var phoneUtils = PhoneNumberUtil.GetInstance(); string countryCode = phoneUtils.GetRegionCodeForCountryCode(phone.CountryCode); var provider = await _settingsService.GetProviderByCountryAsync(countryCode); string id = await _smsRepository.AddAsync(new SmsMessage { CountryCode = countryCode, Message = command.Message, Phone = command.Phone, Provider = provider }); eventPublisher.PublishEvent(new SmsProviderProcessed { Phone = command.Phone, Message = command.Message, Provider = provider, CountryCode = countryCode, Id = id }); } return(CommandHandlingResult.Ok()); }
private async Task <CommandHandlingResult> Handle(UnsuspendAssetPairCommand command, IEventPublisher publisher) { //idempotency handling not required var updateResult = await _productsDiscontinueService.ChangeSuspendStatusAsync(command.AssetPairId, false, username, command.OperationId); if (!updateResult.IsSuccess) { return(CommandHandlingResult.Fail(_delay)); } _chaosKitty.Meow(command.OperationId); var assetPair = AssetPair.CreateFromProduct(updateResult.NewValue, _defaultLegalEntitySettings.DefaultLegalEntity); publisher.PublishEvent(new AssetPairChangedEvent { OperationId = command.OperationId, AssetPair = _convertService.Convert <IAssetPair, AssetPairContract>(assetPair), }); publisher.PublishEvent(CreateProductChangedEvent(updateResult.OldValue, updateResult.NewValue, username, command.OperationId)); return(CommandHandlingResult.Ok()); }
public async Task <CommandHandlingResult> Handle(ProcessHotWalletErc20EventCommand command, IEventPublisher eventPublisher) { try { switch (command.EventType) { case HotWalletEventType.CashinCompleted: await ProcessHotWalletCashin(command, eventPublisher); break; case HotWalletEventType.CashoutCompleted: await ProcessHotWalletCashout(command); break; default: throw new ArgumentOutOfRangeException($"{command.EventType} - is not supported for processing {command.ToJson()}. "); } return(CommandHandlingResult.Ok()); } catch (Exception e) { _log.Error(nameof(ProcessHotWalletErc20EventCommand), e, context: command); throw; } }
public async Task <CommandHandlingResult> Handle(ProcessCashInCommand command, IEventPublisher eventPublisher) { var id = command.CommandId; var asset = command.Asset; var amount = command.Amount; var transaction = command.Transaction; ChaosKitty.Meow(); var responseModel = await _matchingEngineClient.CashInOutAsync(id, transaction.ClientId, asset.Id, amount.TruncateDecimalPlaces(asset.Accuracy)); if (responseModel.Status != MeStatusCodes.Ok && responseModel.Status != MeStatusCodes.AlreadyProcessed && responseModel.Status != MeStatusCodes.Duplicate) { _log.WriteInfo(nameof(ProcessCashInCommand), command, responseModel.ToJson()); throw new ProcessingException(responseModel.ToJson()); } ChaosKitty.Meow(); eventPublisher.PublishEvent(new TransactionProcessedEvent { ClientId = command.Transaction.ClientId, Asset = command.Asset, Amount = command.Amount }); return(CommandHandlingResult.Ok()); }