From aae7b50b87818c67276e1ee983255d9f3675f32e Mon Sep 17 00:00:00 2001 From: s2quake Date: Tue, 30 Jul 2024 12:37:13 +0900 Subject: [PATCH 1/2] chore: Remove explorer mutation. --- .../Mutations/EvidenceMutation.cs | 58 ------------------- .../Mutations/ExplorerMutation.cs | 22 ------- .../Mutations/TestEvidence.cs | 43 -------------- .../Schemas/LibplanetExplorerSchema.cs | 1 - 4 files changed, 124 deletions(-) delete mode 100644 tools/Libplanet.Explorer/Mutations/EvidenceMutation.cs delete mode 100644 tools/Libplanet.Explorer/Mutations/ExplorerMutation.cs delete mode 100644 tools/Libplanet.Explorer/Mutations/TestEvidence.cs diff --git a/tools/Libplanet.Explorer/Mutations/EvidenceMutation.cs b/tools/Libplanet.Explorer/Mutations/EvidenceMutation.cs deleted file mode 100644 index c7a2cc7765c..00000000000 --- a/tools/Libplanet.Explorer/Mutations/EvidenceMutation.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using GraphQL; -using GraphQL.Types; -using Libplanet.Crypto; -using Libplanet.Explorer.GraphTypes; -using Libplanet.Explorer.Interfaces; - -namespace Libplanet.Explorer.Mutations -{ - public class EvidenceMutation : ObjectGraphType - { - private readonly IBlockChainContext _context; - - public EvidenceMutation(IBlockChainContext context) - { - _context = context ?? throw new ArgumentNullException(nameof(context)); - - Field>( - name: "add", - description: "Add Evidence to current chain", - arguments: new QueryArguments( - new QueryArgument - { - Name = "height", - Description = - "Indicates the block height that infraction has occurred", - }, - new QueryArgument> - { - Name = "address", - Description = - "Indicates the address of the target that caused the infraction", - } - ), - resolve: context => - { - var blockChain = _context.BlockChain; - var height = context.GetArgument("height") ?? blockChain.Tip.Index; - var address = context.GetArgument
("address"); - var timestamp = DateTimeOffset.UtcNow; - var evidence = new TestEvidence(height, address, timestamp); - try - { - blockChain.AddEvidence(evidence); - } - catch (Exception e) - { - throw new ExecutionError( - message: "Failed to add given evidence.", - exception: e); - } - - return evidence; - } - ); - } - } -} diff --git a/tools/Libplanet.Explorer/Mutations/ExplorerMutation.cs b/tools/Libplanet.Explorer/Mutations/ExplorerMutation.cs deleted file mode 100644 index 765dfc4adf1..00000000000 --- a/tools/Libplanet.Explorer/Mutations/ExplorerMutation.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using GraphQL.Types; -using Libplanet.Explorer.Interfaces; - -namespace Libplanet.Explorer.Mutations -{ - public class ExplorerMutation : ObjectGraphType - { - private readonly IBlockChainContext _context; - - public ExplorerMutation(IBlockChainContext context) - { - _context = context ?? throw new ArgumentNullException(nameof(context)); - - Field( - name: "evidence", - description: "Raise infraction to current chain", - resolve: context => new { } - ); - } - } -} diff --git a/tools/Libplanet.Explorer/Mutations/TestEvidence.cs b/tools/Libplanet.Explorer/Mutations/TestEvidence.cs deleted file mode 100644 index fe8c4f70eed..00000000000 --- a/tools/Libplanet.Explorer/Mutations/TestEvidence.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Bencodex.Types; -using Libplanet.Crypto; -using Libplanet.Types.Evidence; - -namespace Libplanet.Explorer.Mutations -{ - public sealed class TestEvidence : EvidenceBase, IEquatable - { - public TestEvidence( - long height, - Address validatorAddress, - DateTimeOffset timestamp) - : base(height, validatorAddress, timestamp) - { - } - - public TestEvidence(IValue bencoded) - : base(bencoded) - { - } - - public Address ValidatorAddress => TargetAddress; - - /// - public bool Equals(TestEvidence? other) => base.Equals(other); - - /// - public override bool Equals(object? obj) - => obj is TestEvidence other && Equals(other); - - /// - public override int GetHashCode() => base.GetHashCode(); - - protected override Dictionary OnBencoded(Dictionary dictionary) - => dictionary; - - protected override void OnVerify(IEvidenceContext evidenceContext) - { - // Do nothing. - } - } -} diff --git a/tools/Libplanet.Explorer/Schemas/LibplanetExplorerSchema.cs b/tools/Libplanet.Explorer/Schemas/LibplanetExplorerSchema.cs index 79cacbe3868..e424c192ba9 100644 --- a/tools/Libplanet.Explorer/Schemas/LibplanetExplorerSchema.cs +++ b/tools/Libplanet.Explorer/Schemas/LibplanetExplorerSchema.cs @@ -12,7 +12,6 @@ public LibplanetExplorerSchema(IServiceProvider serviceProvider) : base(serviceProvider) { Query = serviceProvider.GetRequiredService(); - Mutation = serviceProvider.GetRequiredService(); } } } From 8bb3f393a07249290fb1336da8077a28bbcbac97 Mon Sep 17 00:00:00 2001 From: s2quake Date: Tue, 30 Jul 2024 12:42:10 +0900 Subject: [PATCH 2/2] changelog --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 517442e8b56..44b8701d779 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,10 @@ Version 5.1.3 To be released. + - (Libplanet.Explorer) Removed code that was used in development. [[#3898]] + +[#3898]: https://github.com/planetarium/libplanet/pull/3898 + Version 5.1.2 -------------