< 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:45
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 DCL.Helpers.NFT;
 4using UnityEngine;
 5
 6public interface INFTInfoLoadHelper : IDisposable
 7{
 8    public event Action<NFTInfo> OnFetchInfoSuccess;
 9    public event Action OnFetchInfoFail;
 10    void FetchNFTInfo(string address, string id);
 11}
 12
 13public class NFTInfoLoadHelper : INFTInfoLoadHelper
 14{
 15    public event Action<NFTInfo> OnFetchInfoSuccess;
 16    public event Action OnFetchInfoFail;
 17    internal Coroutine fetchCoroutine;
 18
 19    public void Dispose()
 20    {
 321        if (fetchCoroutine != null)
 222            CoroutineStarter.Stop(fetchCoroutine);
 23
 324        fetchCoroutine = null;
 325    }
 26
 27    public void FetchNFTInfo(string address, string id)
 28    {
 529        if (fetchCoroutine != null)
 030            CoroutineStarter.Stop(fetchCoroutine);
 31
 532        fetchCoroutine = CoroutineStarter.Start(FetchNFTInfoCoroutine(address, id));
 533    }
 34
 35    private IEnumerator FetchNFTInfoCoroutine(string address, string id)
 36    {
 537        yield return NFTUtils.FetchNFTInfo(address, id,
 038            (info) => { OnFetchInfoSuccess?.Invoke(info); },
 39            (error) =>
 40            {
 041                Debug.LogError($"Couldn't fetch NFT: '{address}/{id}' {error}");
 042                OnFetchInfoFail?.Invoke();
 043            });
 344    }
 45}