< Summary

Class:NFTInfoFetcher
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/NFTShape/NFTInfoFetcher.cs
Covered lines:11
Uncovered lines:4
Coverable lines:15
Total lines:51
Line coverage:73.3% (11 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Dispose()0%220100%
FetchNFTImage(...)0%2.062075%
FetchNFTImageCoroutine()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/NFTShape/NFTInfoFetcher.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.IO;
 5using DCL;
 6using DCL.Helpers.NFT;
 7using Newtonsoft.Json;
 8using NFTShape_Internal;
 9using UnityEngine;
 10using UnityGLTF.Loader;
 11
 12public interface INFTInfoFetcher
 13{
 14    void FetchNFTImage(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail);
 15    void Dispose();
 16}
 17
 18public class NFTInfoFetcher : INFTInfoFetcher
 19{
 20    internal Coroutine fetchCoroutine;
 21
 22    public void Dispose()
 23    {
 1824        if (fetchCoroutine != null)
 1225            CoroutineStarter.Stop(fetchCoroutine);
 26
 1827        fetchCoroutine = null;
 1828    }
 29
 30    public void FetchNFTImage(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail)
 31    {
 1232        if (fetchCoroutine != null)
 033            CoroutineStarter.Stop(fetchCoroutine);
 34
 1235        fetchCoroutine = CoroutineStarter.Start(FetchNFTImageCoroutine(address, id, OnSuccess, OnFail));
 1236    }
 37
 38    private IEnumerator FetchNFTImageCoroutine(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail)
 39    {
 1240        yield return NFTUtils.FetchNFTInfo(address, id,
 41            (info) =>
 42            {
 743                OnSuccess?.Invoke(info);
 744            },
 45            (error) =>
 46            {
 047                Debug.LogError($"Couldn't fetch NFT: '{address}/{id}' {error}");
 048                OnFail?.Invoke();
 049            });
 750    }
 51}