public async Task <IActionResult> GetTransaction([FromBody] AddressTransactions addressTransactions)
        {
            if (!ModelState.IsValid)
            {
                throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors()));
            }

            Lykke.Service.EthereumCore.BusinessModels.AddressTransaction request = new Lykke.Service.EthereumCore.BusinessModels.AddressTransaction()
            {
                Address = addressTransactions.Address,
                Count   = addressTransactions.Count,
                Start   = addressTransactions.Start,
            };

            IEnumerable <TransactionContentModel> transactions = await _ethereumIndexerService.GetTransactionHistory(request);

            IEnumerable <Models.Indexer.TransactionResponse> result = transactions.Select(transactionContent =>
            {
                return(MapTransactionModelContentToResponse(transactionContent));
            });

            return(Ok(new FilteredTransactionsResponse()
            {
                Transactions = result
            }));
        }
        public async Task <IActionResult> GetAddressHistory([FromBody] AddressTransactions addressTransactions)
        {
            if (!ModelState.IsValid)
            {
                throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors()));
            }

            Lykke.Service.EthereumCore.BusinessModels.AddressTransaction request = new Lykke.Service.EthereumCore.BusinessModels.AddressTransaction()
            {
                Address = addressTransactions.Address,
                Count   = addressTransactions.Count,
                Start   = addressTransactions.Start,
            };

            IEnumerable <AddressHistoryModel> history = await _ethereumIndexerService.GetAddressHistory(request);

            IEnumerable <AddressHistoryResponse> result = history.Select(item =>
            {
                return(new AddressHistoryResponse()
                {
                    BlockNumber = item.BlockNumber,
                    BlockTimestamp = item.BlockTimestamp,
                    BlockTimeUtc = item.BlockTimeUtc,
                    From = item.From,
                    HasError = item.HasError,
                    MessageIndex = item.MessageIndex,
                    To = item.To,
                    TransactionHash = item.TransactionHash,
                    TransactionIndexInBlock = item.TransactionIndexInBlock,
                    Value = item.Value,
                    GasPrice = item.GasPrice,
                    GasUsed = item.GasUsed,
                });
            });

            return(Ok(new FilteredAddressHistoryResponse()
            {
                History = result
            }));
        }
Beispiel #3
0
        public async Task <IActionResult> GetInternalMessages([FromBody] AddressTransactions addressTransactions)
        {
            if (!ModelState.IsValid)
            {
                throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors()));
            }

            Lykke.Service.EthereumCore.BusinessModels.AddressTransaction request = new Lykke.Service.EthereumCore.BusinessModels.AddressTransaction()
            {
                Address = addressTransactions.Address,
                Count   = addressTransactions.Count,
                Start   = addressTransactions.Start,
            };

            IEnumerable <InternalMessageModel> messages = await _ethereumIndexerService.GetInternalMessagesHistory(request);

            IEnumerable <Models.Indexer.InternalMessageResponse> result = messages.Select(message =>
                                                                                          MapInternalMessageModelToResponse(message));

            return(Ok(new FilteredInternalMessagessResponse()
            {
                Messages = result
            }));
        }