Пример #1
0
 public AutoMapperProfile()
 {
     CreateMap <TransferredFromPublicNetworkEventDTO, TransferToInternalEventDto>()
     .ForMember(x => x.InternalAddress, opt => opt.MapFrom(p => p.InternalAccount))
     .ForMember(x => x.Amount, opt => opt.MapFrom(p => Money18.CreateFromAtto(p.Amount)))
     .ForMember(x => x.PublicAddress, opt => opt.MapFrom(p => p.PublicAccount));
     CreateMap <TransferredToPublicNetworkEventDTO, TransferToExternalEventDto>()
     .ForMember(x => x.InternalAddress, opt => opt.MapFrom(p => p.InternalAccount))
     .ForMember(x => x.Amount, opt => opt.MapFrom(p => Money18.CreateFromAtto(p.Amount)))
     .ForMember(x => x.PublicAddress, opt => opt.MapFrom(p => p.PublicAccount));
 }
 public AutoMapperProfile()
 {
     CreateMap <TransferReceivedEventDTO, TransferReceivedModel>()
     .ForMember(p => p.Amount, opt => opt.MapFrom(src => Money18.CreateFromAtto(src.Amount)));
     CreateMap <TransferAcceptedEventDTO, TransferAcceptedModel>();
     CreateMap <TransferRejectedEventDTO, TransferRejectedModel>();
     CreateMap <PaymentTransferRequest, PaymentTransferDto>()
     .ForMember(p => p.InvoiceId, opt => opt.Ignore())
     .ForMember(p => p.ReceiptNumber, opt => opt.Ignore())
     .ForMember(p => p.Timestamp, opt => opt.Ignore())
     .ForMember(p => p.Status, opt => opt.Ignore())
     .ForMember(p => p.TransferId, opt => opt.Ignore());
 }
        private Task ProcessTransferFromInternalNetworkEvent(IEnumerable <string> topics, string data)
        {
            var eventData = DecodeEvent <TransferredFromInternalNetworkEventDTO>(topics, data);

            var evt = new TransferToExternalCompletedEvent
            {
                PrivateAddress = eventData.InternalAccount,
                Amount         = Money18.CreateFromAtto(eventData.Amount),
                PublicAddress  = eventData.PublicAccount,
                Timestamp      = DateTime.UtcNow,
                EventId        = Guid.NewGuid().ToString()
            };

            return(_transferToExternalCompletedPublisher.PublishAsync(evt));
        }
        private async Task ProcessSeizeFromEvent(IEnumerable <string> topics, string data)
        {
            var eventData = DecodeEvent <SeizeFromEventDTO>(topics, data);

            var evt = new SeizeToInternalDetectedEvent
            {
                OperationId = Guid.NewGuid().ToString(),
                Account     = eventData.Account,
                Amount      = Money18.CreateFromAtto(eventData.Amount),
                Reason      = eventData.Reason,
                Timestamp   = DateTime.UtcNow
            };

            await _seizeToInternalDetectedPublisher.PublishAsync(evt);

            _log.Warning("Seize from event published",
                         context: $"account : {evt.Account}; amount: {evt.Amount}; reason: {evt.Reason}");
        }
Пример #5
0
        private async Task ProcessTransferEvents(TransactionReceipt transactionReceipt)
        {
            try
            {
                var events = DecodeAllEventsAndFilter <SentEventDTO>(transactionReceipt);

                foreach (var @event in events)
                {
                    if (string.IsNullOrEmpty(@event.Event.From) || string.IsNullOrEmpty(@event.Event.To))
                    {
                        continue;
                    }

                    var evt = new TransferEvent
                    {
                        SourceAddress   = @event.Event.From,
                        TargetAddress   = @event.Event.To,
                        Amount          = Money18.CreateFromAtto(@event.Event.Amount),
                        EventIndex      = (int)@event.Log.LogIndex.Value,
                        TransactionHash = @event.Log.TransactionHash,
                        ObservedAt      = DateTime.UtcNow,
                    };

                    await _transferEventPublishingService.PublishAsync(evt);

                    _log.Info($"{nameof(TransferEvent)} has been published", evt);
                }
            }
            catch (Exception e)
            {
                #region Logging

                _log.Error
                (
                    e,
                    $"Failed to process transfer events from transaction [{transactionReceipt.TransactionHash}].",
                    new { transactionHash = transactionReceipt.TransactionHash }
                );

                #endregion

                throw;
            }
        }
        public async Task <Money18> GetAsync(string walletAddress)
        {
            var cachedBalance = await GetCachedValue(walletAddress);

            if (cachedBalance != null)
            {
                return(cachedBalance.Value);
            }

            var blockNumber = await _ethereumNodeServiceClient.GetBlockNumberAsync();

            var value = await _tokenService.BalanceOfQueryAsync(walletAddress,
                                                                new BlockParameter((ulong)blockNumber));

            var balance = Money18.CreateFromAtto(value);

            await SetCacheValueAsync(walletAddress, balance);

            return(balance);
        }
 public AutoMapperProfile()
 {
     CreateMap <PaymentRequestModel, PaymentRequest>()
     .ForMember(x => x.PaymentRequestId, opt => opt.Ignore())
     .ForMember(x => x.CustomerActionExpirationTimestamp, opt => opt.Ignore())
     .ForMember(x => x.TokensToFiatConversionRate, opt => opt.Ignore());
     CreateMap <PaymentRequestResult, PaymentRequestResponseModel>();
     CreateMap <TransferAcceptedEventDTO, PaymentProcessedByPartnerModel>()
     .ForMember(x => x.Amount, opt => opt.Ignore())
     .ForMember(x => x.PaymentRequestId, opt => opt.MapFrom(x => x.TransferId));
     CreateMap <TransferRejectedEventDTO, PaymentProcessedByPartnerModel>()
     .ForMember(x => x.Amount, opt => opt.Ignore())
     .ForMember(x => x.PaymentRequestId, opt => opt.MapFrom(x => x.TransferId));
     CreateMap <TransferReceivedEventDTO, PaymentProcessedByPartnerModel>()
     .ForMember(x => x.Amount, opt => opt.MapFrom(src => Money18.CreateFromAtto(src.Amount)))
     .ForMember(x => x.PaymentRequestId, opt => opt.MapFrom(x => x.TransferId));
     CreateMap <PaymentModel, PaymentResponseModel>()
     .ForMember(x => x.Date, opt => opt.MapFrom(x => x.Timestamp))
     .ForMember(x => x.LastUpdatedDate, opt => opt.MapFrom(x => x.LastUpdatedTimestamp));
     CreateMap <PaymentModel, PaymentDetailsResponseModel>();
     CreateMap <PaginatedPaymentsModel, PaginatedPaymentRequestsResponse>();
 }
Пример #8
0
        private async Task ProcessFeeCollectedEvents(TransactionReceipt transactionReceipt)
        {
            try
            {
                var events = DecodeAllEventsAndFilter <FeeCollectedEventDTO>(transactionReceipt);

                foreach (var @event in events)
                {
                    var evt = new FeeCollectedEvent
                    {
                        Amount          = Money18.CreateFromAtto(@event.Event.Amount),
                        WalletAddress   = @event.Event.From,
                        Reason          = @event.Event.Reason,
                        TransactionHash = transactionReceipt.TransactionHash,
                        ObservedAt      = DateTime.UtcNow,
                        EventId         = Guid.NewGuid().ToString()
                    };

                    await _feeCollectedPublishingService.PublishAsync(evt);

                    _log.Info($"{nameof(FeeCollectedEvent)} has been published", evt);
                }
            }
            catch (Exception e)
            {
                #region Logging

                _log.Error
                (
                    e,
                    $"Failed to process FeeCollectedEvent events from transaction [{transactionReceipt.TransactionHash}].",
                    new { transactionHash = transactionReceipt.TransactionHash }
                );

                #endregion
                throw;
            }
        }
Пример #9
0
        public async Task <EventListResponse> GetEventsAsync([FromQuery] EventListRequest request)
        {
            var result = await _quorumExplorerClient.EventsApi.GetFilteredAsync(new FilteredEventsRequest
            {
                EventName         = request.EventName,
                EventSignature    = request.EventSignature,
                Address           = request.Address,
                AffectedAddresses = request.AffectedAddresses ?? new List <string>(),
                PagingInfo        = new PaginationModel
                {
                    CurrentPage = request.PagedRequest.CurrentPage,
                    PageSize    = request.PagedRequest.PageSize
                }
            });

            result.Events.ForEach(e =>
            {
                e.Parameters.ForEach(p =>
                {
                    if (p.Type == "uint256" && _amountParamNames.Contains(p.Name))
                    {
                        var money = Money18.CreateFromAtto(BigInteger.Parse(p.Value));

                        p.Value = money.ToString();
                    }
                });
            });

            return(new EventListResponse
            {
                PagedResponse = new PagedResponseModel
                {
                    CurrentPage = result.CurrentPage,
                    TotalCount = result.TotalCount
                },
                Events = _mapper.Map <IReadOnlyCollection <EventModel> >(result.Events)
            });
        }
Пример #10
0
        private async Task ProcessStakeIncreasedEvents(TransactionReceipt transactionReceipt)
        {
            try
            {
                var events = DecodeAllEventsAndFilter <StakeIncreasedEventDTO>(transactionReceipt);

                foreach (var @event in events)
                {
                    var evt = new StakeIncreasedEvent
                    {
                        WalletAddress   = @event.Event.Account,
                        Amount          = Money18.CreateFromAtto(@event.Event.Amount),
                        TransactionHash = transactionReceipt.TransactionHash,
                        ObservedAt      = DateTime.UtcNow,
                    };

                    await _stakeIncreasedPublishingService.PublishAsync(evt);

                    _log.Info($"{nameof(StakeIncreasedEvent)} has been published", evt);
                }
            }
            catch (Exception e)
            {
                #region Logging

                _log.Error
                (
                    e,
                    $"Failed to process stake increased events from transaction [{transactionReceipt.TransactionHash}].",
                    new { transactionHash = transactionReceipt.TransactionHash }
                );

                #endregion

                throw;
            }
        }
        public async Task <Money18> GetTransferToPublicNetworkFeeAsync()
        {
            var result = await _blockchain.TokenGatewayService().TransferToPublicNetworkFeeQueryAsync();

            return(Money18.CreateFromAtto(result));
        }
        public async Task <Money18> GetTotalSupplyAsync()
        {
            var result = await _blockchain.TokenService().TotalSupplyQueryAsync();

            return(Money18.CreateFromAtto(result));
        }
        public async Task <Money18> GetStakedBalanceAsync(string address)
        {
            var result = await _blockchain.TokenService().StakeOfQueryAsync(address);

            return(Money18.CreateFromAtto(result));
        }