private void SetNFT(NFTInfoSingleAsset info, string comment, bool shouldRefreshOwners) { lastNFTInfo = info; view.SetNFTInfo(info, comment); if (shouldRefreshOwners) { ownersInfoController.SetOwners(info.owners); } }
private IEnumerator FetchNFTImage(NFTInfoSingleAsset nftInfo) { spinnerNftImage.SetActive(true); bool imageFound = false; yield return(WrappedTextureUtils.Fetch(nftInfo.previewImageUrl, promise => { imagePromise = promise; imageFound = true; })); if (!imageFound) { yield return(WrappedTextureUtils.Fetch(nftInfo.originalImageUrl, promise => { imagePromise = promise; imageFound = true; })); } if (imageFound && imagePromise?.asset != null) { Texture2D texture = imagePromise.asset.texture; imageNft.texture = texture; if ((imagePromise.asset is Asset_Gif gif)) { SetupGifPlayer(gif); } else if (!backgroundColorSet) { SetSmartBackgroundColor(texture); } SetNFTImageSize(texture); imageNft.gameObject.SetActive(true); spinnerNftImage.SetActive(false); }
private NFTInfoSingleAsset ResponseToNFTInfo(SingleAssetResponse response) { NFTInfoSingleAsset ret = NFTInfoSingleAsset.defaultNFTInfoSingleAsset; ret.tokenId = response.token_id; ret.marketInfo = openSeaMarketInfo; ret.name = response.name; ret.description = response.description; ret.previewImageUrl = response.image_preview_url; ret.originalImageUrl = response.image_original_url; ret.assetLink = response.external_link; ret.marketLink = response.permalink; ret.assetContract.address = response.asset_contract.address; ret.assetContract.name = response.asset_contract.name; if (response.last_sale != null) { ret.lastSaleDate = response.last_sale.event_timestamp; if (response.last_sale.payment_token != null) { ret.lastSaleAmount = PriceToFloatingPointString(response.last_sale); ret.lastSaleToken = new NFT.PaymentTokenInfo() { symbol = response.last_sale.payment_token.symbol }; } } UnityEngine.Color backgroundColor; if (UnityEngine.ColorUtility.TryParseHtmlString("#" + response.background_color, out backgroundColor)) { ret.backgroundColor = backgroundColor; } OrderInfo sellOrder = GetSellOrder(response.orders, response.top_ownerships); if (sellOrder != null) { ret.currentPrice = PriceToFloatingPointString(sellOrder.current_price, sellOrder.payment_token_contract); ret.currentPriceToken = new NFT.PaymentTokenInfo() { symbol = sellOrder.payment_token_contract.symbol }; } ret.owners = new NFTInfoSingleAsset.Owners[response.top_ownerships.Length]; for (int i = 0; i < response.top_ownerships.Length; i++) { ret.owners[i] = new NFTInfoSingleAsset.Owners() { owner = response.top_ownerships[i].owner.address, }; float.TryParse(response.top_ownerships[i].quantity, out float quantity); ret.owners[i].quantity = quantity; } return(ret); }
void INFTPromptHUDView.SetNFTInfo(NFTInfoSingleAsset info, string comment) { Show(); spinnerGeneral.SetActive(false); imageNftBackground.color = Color.white; backgroundColorSet = info.backgroundColor != null; if (backgroundColorSet) { imageNftBackground.color = info.backgroundColor.Value; } textNftName.text = info.name; textNftName.gameObject.SetActive(true); bool hasMultipleOwners = info.owners.Length > 1; if (hasMultipleOwners) { textMultipleOwner.text = string.Format(MULTIPLE_OWNERS_FORMAT, info.owners.Length); } else { textOwner.text = info.owners.Length == 1 ? NFTPromptHUDController.FormatOwnerAddress(info.owners[0].owner, ADDRESS_MAX_CHARS) : NFTPromptHUDController.FormatOwnerAddress("0x0000000000000000000000000000000000000000", ADDRESS_MAX_CHARS); } textOwner.gameObject.SetActive(!hasMultipleOwners); multipleOwnersContainer.gameObject.SetActive(hasMultipleOwners); if (!string.IsNullOrEmpty(info.lastSaleAmount)) { textLastSalePrice.text = ShortDecimals(info.lastSaleAmount, 4); textLastSalePrice.gameObject.SetActive(true); } else { textLastSaleNeverSold.gameObject.SetActive(true); } if (!string.IsNullOrEmpty(info.currentPrice)) { textPrice.text = ShortDecimals(info.currentPrice, 4); textPrice.gameObject.SetActive(true); if (info.currentPriceToken != null) { SetTokenSymbol(textPriceSymbol, info.currentPriceToken.Value.symbol); } } else { textPriceNotForSale.gameObject.SetActive(true); } if (info.lastSaleToken != null) { SetTokenSymbol(textLastSaleSymbol, info.lastSaleToken.Value.symbol); } if (!string.IsNullOrEmpty(info.description)) { textDescription.text = info.description; containerDescription.SetActive(true); } if (!string.IsNullOrEmpty(comment)) { textComment.text = comment; containerComment.SetActive(true); } textOpenMarketButton.text = "VIEW"; if (info.marketInfo != null) { textOpenMarketButton.text = $"{textOpenMarketButton.text} ON {info.marketInfo.Value.name.ToUpper()}"; } marketUrl = null; if (!string.IsNullOrEmpty(info.marketLink)) { marketUrl = info.marketLink; } else if (!string.IsNullOrEmpty(info.assetLink)) { marketUrl = info.assetLink; } buttonCancel.gameObject.SetActive(true); buttonOpenMarket.gameObject.SetActive(true); fetchNFTImageRoutine = StartCoroutine(FetchNFTImage(info)); }