Exemple #1
0
        //return whether we have sent to rabbit or not
        private async Task <bool> SendCompleteEvent(string transactionHash, string operationId, bool success, QueueTriggeringContext context, CoinTransactionMessage transaction)
        {
            try
            {
                var operation = await GetOperationAsync(transactionHash, operationId);

                if (operation == null)
                {
                    return(false);
                }

                string amount;
                Lykke.Job.EthereumCore.Contracts.Enums.HotWalletEventType type;
                switch (operation.OperationType)
                {
                case HotWalletOperationType.Cashout:
                    amount = operation.Amount.ToString();
                    type   = Lykke.Job.EthereumCore.Contracts.Enums.HotWalletEventType.CashoutCompleted;
                    break;

                case HotWalletOperationType.Cashin:
                    await _hotWalletService.RemoveCashinLockAsync(operation.TokenAddress, operation.FromAddress);

                    amount = (await _cashinEventRepository.GetAsync(transactionHash)).Amount;
                    type   = Lykke.Job.EthereumCore.Contracts.Enums.HotWalletEventType.CashinCompleted;
                    break;

                default:
                    return(false);
                }
                HotWalletEvent @event = new HotWalletEvent(operation.OperationId,
                                                           transactionHash,
                                                           operation.FromAddress,
                                                           operation.ToAddress,
                                                           amount,
                                                           operation.TokenAddress,
                                                           type);

                await _rabbitQueuePublisher.PublshEvent(@event);

                return(true);
            }
            catch (Exception e)
            {
                await _log.WriteErrorAsync(nameof(HotWalletMonitoringTransactionJob), "SendCompletedCoinEvent", $"trHash: {transactionHash}", e, DateTime.UtcNow);

                SendMessageToTheQueueEnd(context, transaction, 100);

                return(false);
            }
        }
        private Task <bool> SendHotWalletEventToCqrs(HotWalletEvent @event)
        {
            _cqrsEngine.SendCommand(new ProcessHotWalletErc20EventCommand
            {
                Amount          = @event.Amount,
                TransactionHash = @event.TransactionHash,
                ToAddress       = @event.ToAddress,
                OperationId     = @event.OperationId,
                FromAddress     = @event.FromAddress,
                EventTime       = @event.EventTime,
                EventType       = @event.EventType,
                TokenAddress    = @event.TokenAddress
            },
                                    BoundedContexts.EthereumCommands,
                                    BoundedContexts.EthereumCommands);

            return(Task.FromResult(true));
        }