Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/planet context polishing #6640

Open
wants to merge 18 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#nullable enable

using System.Text.Json.Serialization;

namespace Nekoyume.GraphQL.GraphTypes
{
// TODO: 필요한 파라메터 추가 구현 필요
public class NodeStatusType
{
public class InnerType
{
[JsonPropertyName("tip")]
public TipType? Tip;

public override string ToString()
{
return $"Tip: {Tip}";
}
}

[JsonPropertyName("nodeStatus")]
public InnerType? NodeStatus;

[JsonPropertyName("isMining")]
public bool? IsMining;

[JsonPropertyName("informationalVersion")]
public string? InformationalVersion;

[JsonPropertyName("stagedTxIdsCount")]
public int? StagedTxIdsCount;

public override string ToString()
{
var nodeStatus = NodeStatus is null ? "null" : NodeStatus.ToString();
return $"NodeStatus: {{ {nodeStatus} }}, IsMining: {IsMining}, InformationalVersion: {InformationalVersion}, StagedTxIdsCount: {StagedTxIdsCount}";
}
}

public class NodeStatusResponse
{
public TipResultQuery NodeStatus;
}

public class TipResultQuery
{
public TipResult Tip;
}

public class TipResult
{
public string Id;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Text.Json.Serialization;
using Libplanet.Crypto;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#nullable enable

using System.Text.Json.Serialization;
using Libplanet.Crypto;

namespace Nekoyume.GraphQL.GraphTypes
{
public class TipType
{
public class InnerType
{
[JsonPropertyName("id")]
public string? id;

[JsonPropertyName("hash")]
public string? hash;

[JsonPropertyName("index")]
public int? index;

[JsonPropertyName("miner")]
public Address? miner;

public override string ToString()
{
return $"Id: {id}, Hash: {hash}, Index: {index}, Miner: {miner}";
}
}

[JsonPropertyName("tip")]
public InnerType? Tip;

public override string ToString()
{
var inner = Tip is null ? "null" : Tip.ToString();
return $"Tip: {{ {inner} }}";
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public static class GraphQlHttpClientExtensions
throw new ArgumentNullException(nameof(client));
}

var message = $" Endpoint: {client.Options.EndPoint?.AbsoluteUri ?? "null"}" +
$" Query: {query}";
var message = $" Endpoint: {client.Options.EndPoint?.AbsoluteUri ?? "null"} Query: {query}";
NcDebug.Log($"[GraphQl] StateQueryAsync()... {message}");
var request = new GraphQLRequest(query);
var response = await client.SendQueryAsync<StateQueryGraphType<T>>(request);
if (response.Errors != null)
if (response.Errors == null)
{
NcDebug.LogError("[GraphQl] StateQueryAsync()... request has errors." +
$" request: {message}");
foreach (var error in response.Errors)
{
NcDebug.LogError(error.Message);
}
return (response.Errors, response.Data.StateQuery);
}

NcDebug.LogError($"[GraphQl] StateQueryAsync()... request has errors. request: {message}");
foreach (var error in response.Errors)
{
NcDebug.LogError(error.Message);
}

return (response.Errors, response.Data.StateQuery);
Expand Down Expand Up @@ -102,9 +102,30 @@ public static class GraphQlHttpClientExtensions
{
Addresses.GetAvatarAddress(addr, 0).ToString(),
Addresses.GetAvatarAddress(addr, 1).ToString(),
Addresses.GetAvatarAddress(addr, 2).ToString()
Addresses.GetAvatarAddress(addr, 2).ToString(),
};
return await client.QueryAvatarsAsync(avatarAddresses);
}

public static async UniTask<(GraphQLError[]? errors, TipResultQuery result)> QueryNodeTipIndex(this GraphQLHttpClient client)
{
var query = "query{nodeStatus{tip{id}}}";
var message = $" Endpoint: {client.Options.EndPoint?.AbsoluteUri ?? "null"} Query: {query}";
NcDebug.Log($"[GraphQl] StateQueryAsync()... {message}");
var request = new GraphQLRequest(query);
var response = await client.SendQueryAsync<NodeStatusResponse>(request);
if (response.Errors == null)
{
return (response.Errors, response.Data.NodeStatus);
}

NcDebug.LogError($"[GraphQl] StateQueryAsync()... request has errors. request: {message}");
foreach (var error in response.Errors)
{
NcDebug.LogError(error.Message);
}

return (response.Errors, response.Data.NodeStatus);
}
}
}
Loading