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);
            }
        }
Exemple #2
0
        public async Task <ICashinEvent> GetCashinEvent(string transactionHash)
        {
            ICashinEvent @event = await _cashinEventRepository.GetAsync(transactionHash);

            return(@event);
        }