public AddressViewModel GetAddress(string addressText, int currentPage, int pageSize = AppSettings.PageSize)
        {
            var addressQueries = new AccountQueries(_context);
            var tokenQueries   = new TokenQueries(_context);

            var account = addressQueries.QueryAccount(addressText);

            if (account != null)
            {
                SoulRate = Explorer.GetSoulPrice();
                var addressVm = AddressViewModel.FromAddress(account, tokenQueries.QueryTokens().ToList());

                addressVm.Transactions = GetAddressTransactions(addressVm.Address, currentPage, pageSize);

                foreach (var addressVmNativeBalance in addressVm.NativeBalances)
                {
                    addressVmNativeBalance.TxnCount = GetTransactionCount(addressVm.Address);
                }

                CalculateAddressSoulValue(new List <AddressViewModel> {
                    addressVm
                });
                return(addressVm);
            }

            if (Address.IsValidAddress(addressText))
            {
                return(new AddressViewModel {
                    Address = addressText, Balance = 0, Name = "anonymous", Value = 0
                });
            }

            return(null);
        }
Ejemplo n.º 2
0
        public List <NftViewModel> GetNftListByAddress(string inputAddress) //todo redo this after rpc stuff
        {
            var accountQuery = new AccountQueries(_context);
            var account      = accountQuery.QueryAccount(inputAddress);
            var nftList      = new List <NftViewModel>();
            var tokensQuery  = new TokenQueries(_context);
            var tokenList    = tokensQuery.QueryTokens().ToList();

            if (account != null)
            {
                foreach (var nfToken in account.NonFungibleTokens)
                {
                    string viewerUrl = string.Empty, detailsUrl = string.Empty;

                    var tokenEntity = tokenList.SingleOrDefault(p => p.Symbol == nfToken.TokenSymbol);
                    if (tokenEntity.MetadataList.Count > 0)
                    {
                        viewerUrl  = GetViewerUrl(tokenEntity);
                        detailsUrl = GetDetailsUrl(tokenEntity);
                    }

                    var existingVm = nftList.SingleOrDefault(vm => vm.Symbol == nfToken.TokenSymbol);
                    if (existingVm != null)
                    {
                        existingVm.InfoList.Add(new NftInfoViewModel
                        {
                            ViewerUrl = viewerUrl,
                            Id        = nfToken.Id,
                            Info      = detailsUrl
                        });
                    }
                    else
                    {
                        var newVm = new NftViewModel
                        {
                            Address  = inputAddress,
                            Symbol   = nfToken.TokenSymbol,
                            InfoList = new List <NftInfoViewModel>
                            {
                                new NftInfoViewModel
                                {
                                    ViewerUrl = viewerUrl,
                                    Id        = nfToken.Id,
                                    Info      = detailsUrl
                                }
                            }
                        };

                        nftList.Add(newVm);
                    }
                }
            }

            return(nftList);
        }
Ejemplo n.º 3
0
        public async Task <MarketplaceViewModel> GetAuctions(string chain, int currentPage, int pageSize = AppSettings.PageSize, string tokenSymbol = null)
        {
            var tokenQueries = new TokenQueries(_context);
            var chainQueries = new ChainQueries(_context);
            var tokenList    = tokenQueries.QueryTokens();

            var chains = chainQueries.QueryChains();
            List <AuctionDto> auctions = new List <AuctionDto>();

            var auction = await _phantasmaRpcService.GetAuctions.SendRequestAsync(chain, "", currentPage, pageSize);

            auctions.AddRange(auction.AuctionsList);

            return(MarketplaceViewModel.FromAuctionList(auctions, tokenList));
        }
Ejemplo n.º 4
0
        public List <TokenViewModel> GetTokens()
        {
            var tokenQuery = new TokenQueries(_context);
            var tokenList  = tokenQuery.QueryTokens();
            var tokensList = new List <TokenViewModel>();

            SoulRate = Explorer.GetSoulPrice();

            foreach (var token in tokenList)
            {
                tokensList.Add(TokenViewModel.FromToken(token,
                                                        AppSettings.MockLogoUrl,
                                                        SoulRate));
            }

            return(tokensList);
        }
Ejemplo n.º 5
0
        public List <TokenViewModel> GetTokens()
        {
            var tokenQuery = new TokenQueries(_context);
            var tokenList  = tokenQuery.QueryTokens();
            var tokensList = new List <TokenViewModel>();

            SoulRate = CoinUtils.GetCoinRate(CoinUtils.SoulId);

            foreach (var token in tokenList)
            {
                SoulRate = token.Symbol == "SOUL" ? CoinUtils.GetCoinRate(CoinUtils.SoulId) : 0;
                tokensList.Add(TokenViewModel.FromToken(token,
                                                        AppSettings.MockLogoUrl,
                                                        SoulRate));
            }

            return(tokensList);
        }
        public List <AddressViewModel> GetAddressList()
        {
            var addressQueries = new AccountQueries(_context);
            var tokenQueries   = new TokenQueries(_context);

            var addressList = new List <AddressViewModel>();

            var list = addressQueries.QueryRichList(30);

            foreach (var account in list)
            {
                var addressVm = AddressViewModel.FromAddress(account, tokenQueries.QueryTokens().ToList());
                CalculateAddressSoulValue(new List <AddressViewModel> {
                    addressVm
                });
                addressList.Add(addressVm);
            }

            CalculateAddressSoulValue(addressList);

            return(addressList);
        }