Beispiel #1
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);
        }
Beispiel #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>();

            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);
        }