generated from CareBoo/UPMTemplate-2020
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(indexer): ✨ add
IndexerClientAsset
to store indexer info
- Loading branch information
1 parent
57b7374
commit 30fb9e9
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
Runtime/Algorand.Unity/Clients/Indexer/IndexerClientAsset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
} | ||
} | ||
} |