-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag '4.0.3' into merge/4.0.3-to-main
Libplanet 4.0.3
- Loading branch information
Showing
10 changed files
with
119 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#nullable disable | ||
using System; | ||
using System.Security.Cryptography; | ||
using GraphQL.Language.AST; | ||
using GraphQL.Types; | ||
using Libplanet.Common; | ||
|
||
namespace Libplanet.Explorer.GraphTypes | ||
{ | ||
public class HashDigestSHA256Type : StringGraphType | ||
{ | ||
public HashDigestSHA256Type() | ||
{ | ||
Name = "HashDigest_SHA256"; | ||
} | ||
|
||
public override object Serialize(object value) | ||
{ | ||
if (value is HashDigest<SHA256> hash) | ||
{ | ||
return hash.ToString(); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
public override object ParseValue(object value) => | ||
value switch | ||
{ | ||
null => null, | ||
string hex => HashDigest<SHA256>.FromString(hex), | ||
_ => throw new ArgumentException( | ||
$"Expected a hexadecimal string but {value}", nameof(value)), | ||
}; | ||
|
||
public override object ParseLiteral(IValue value) => | ||
value switch | ||
{ | ||
StringValue str => ParseValue(str.Value), | ||
_ => throw new ArgumentException( | ||
$"Expected a hexadecimal string but {value}", nameof(value)), | ||
}; | ||
} | ||
} |
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
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
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
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
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