Skip to content

Commit

Permalink
feat(indexer): ✨ add IndexerClientAsset to store indexer info
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonboukheir committed Oct 24, 2023
1 parent 57b7374 commit 30fb9e9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Runtime/Algorand.Unity/Clients/Indexer/IndexerClientAsset.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
using Cysharp.Threading.Tasks;
using UnityEngine;

namespace Algorand.Unity
{
[HelpURL(DocUrl.Api + "Algorand.Unity.IndexerClientAsset.html")]
[CreateAssetMenu(menuName = "Algorand/Indexer Client")]
public class IndexerClientAsset : ScriptableObject
{
public AlgorandNetwork network;

[ContextMenuItem("Test Connection", nameof(TestConnection))]
public IndexerClient client;

private void TestConnection()
{
TestConnectionAsync().Forget();
}

private async UniTaskVoid TestConnectionAsync()
{
var (error, resultWrapped) = await client.MakeHealthCheck();
var result = resultWrapped.WrappedValue;

if (error) Debug.LogError(error);
else
{
Debug.Log($"Indexer connection healthy. Version: {result.Version}");
if (result.Errors != null && result.Errors.Length > 0)
{
for (var i = 0; i < result.Errors.Length; i++)
{
Debug.LogWarning(result.Errors[i]);
}
Debug.LogWarning($"Got {result.Errors.Length} errors from the indexer.");
}
}
}
}
}

0 comments on commit 30fb9e9

Please sign in to comment.