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); }
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); }
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>(); if (account != null) { foreach (var nfToken in account.NonFungibleTokens) { var viewerURL = "https://nacho.men/luchador/$ID"; //todo invoke contracts appChain.InvokeContract("apps", "GetTokenViewer", nfToken.Symbol).ToString(); var existingVm = nftList.SingleOrDefault(vm => vm.Symbol == nfToken.TokenSymbol); if (existingVm != null) { existingVm.InfoList.Add(new NftInfoViewModel { ViewerUrl = viewerURL, Id = nfToken.Id, Info = "Mock info: " + nfToken.Id + existingVm.Symbol }); } else { var newVm = new NftViewModel { Address = inputAddress, Symbol = nfToken.TokenSymbol, InfoList = new List <NftInfoViewModel> { new NftInfoViewModel { ViewerUrl = viewerURL, Id = nfToken.Id, Info = "Test info: " + nfToken.Id + nfToken.TokenSymbol } } }; nftList.Add(newVm); } } } return(nftList); }