< Summary

Class:NFTInfoLoadHelper
Assembly:DCL.Components.NFT
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/NFTShape/NFTAsset/NFTInfoLoadHelper.cs
Covered lines:9
Uncovered lines:5
Coverable lines:14
Total lines:46
Line coverage:64.2% (9 of 14)
Covered branches:0
Total branches:0

Metrics

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

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/NFTShape/NFTAsset/NFTInfoLoadHelper.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;
 10
 11public interface INFTInfoLoadHelper : IDisposable
 12{
 13    void FetchNFTInfo(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail);
 14}
 15
 16public class NFTInfoLoadHelper : INFTInfoLoadHelper
 17{
 18    internal Coroutine fetchCoroutine;
 19
 20    public void Dispose()
 21    {
 322        if (fetchCoroutine != null)
 223            CoroutineStarter.Stop(fetchCoroutine);
 24
 325        fetchCoroutine = null;
 326    }
 27
 28    public void FetchNFTInfo(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail)
 29    {
 530        if (fetchCoroutine != null)
 031            CoroutineStarter.Stop(fetchCoroutine);
 32
 533        fetchCoroutine = CoroutineStarter.Start(FetchNFTInfoCoroutine(address, id, OnSuccess, OnFail));
 534    }
 35
 36    private IEnumerator FetchNFTInfoCoroutine(string address, string id, Action<NFTInfo> OnSuccess, Action OnFail)
 37    {
 538        yield return NFTUtils.FetchNFTInfo(address, id,
 039            (info) => { OnSuccess?.Invoke(info); },
 40            (error) =>
 41            {
 042                Debug.LogError($"Couldn't fetch NFT: '{address}/{id}' {error}");
 043                OnFail?.Invoke();
 044            });
 345    }
 46}