From d596287b293960c97747cd542e099b70f06ed620 Mon Sep 17 00:00:00 2001 From: ilgyu Date: Sun, 5 Jan 2025 23:22:16 +0900 Subject: [PATCH] chore: Remove unused actions --- Lib9c/Action/Guild/ClaimGuildUnbonded.cs | 53 ------------------- Lib9c/Action/Guild/ClaimUnbonded.cs | 7 +-- .../ClaimValidatorUnbonded.cs | 53 ------------------- 3 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 Lib9c/Action/Guild/ClaimGuildUnbonded.cs delete mode 100644 Lib9c/Action/ValidatorDelegation/ClaimValidatorUnbonded.cs diff --git a/Lib9c/Action/Guild/ClaimGuildUnbonded.cs b/Lib9c/Action/Guild/ClaimGuildUnbonded.cs deleted file mode 100644 index 0618d83897..0000000000 --- a/Lib9c/Action/Guild/ClaimGuildUnbonded.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Bencodex.Types; -using Libplanet.Action.State; -using Libplanet.Action; -using Nekoyume.Model.Guild; -using Nekoyume.ValidatorDelegation; - -namespace Nekoyume.Action.Guild -{ - [ActionType(TypeIdentifier)] - public sealed class ClaimGuildUnbonded : ActionBase - { - public const string TypeIdentifier = "claim_guild_unbonded"; - - public ClaimGuildUnbonded() { } - - public override IValue PlainValue => Dictionary.Empty - .Add("type_id", TypeIdentifier) - .Add("values", Null.Value); - - public override void LoadPlainValue(IValue plainValue) - { - var root = (Dictionary)plainValue; - if (plainValue is not Dictionary || - !root.TryGetValue((Text)"values", out var rawValues) || - rawValues is not Null) - { - throw new InvalidCastException(); - }; - } - - public override IWorld Execute(IActionContext context) - { - GasTracer.UseGas(1); - - var world = context.PreviousState; - var guildRepository = new GuildRepository(world, context); - - var guildParticipant = guildRepository.GetGuildParticipant(context.Signer); - var guild = guildRepository.GetGuild(guildParticipant.GuildAddress); - if (context.Signer != guild.GuildMasterAddress) - { - throw new InvalidOperationException("Signer is not a guild master."); - } - - var repository = new ValidatorRepository(guildRepository); - var validatorDelegator = repository.GetDelegator(guild.Address); - validatorDelegator.ReleaseUnbondings(context.BlockIndex); - - return repository.World; - } - } -} diff --git a/Lib9c/Action/Guild/ClaimUnbonded.cs b/Lib9c/Action/Guild/ClaimUnbonded.cs index fad105dc1f..7db809549a 100644 --- a/Lib9c/Action/Guild/ClaimUnbonded.cs +++ b/Lib9c/Action/Guild/ClaimUnbonded.cs @@ -6,6 +6,10 @@ namespace Nekoyume.Action.Guild { + /// + /// An action to claim unbonded assets. + /// This action can be executed only when the unbonding period is over. + /// [ActionType(TypeIdentifier)] public sealed class ClaimUnbonded : ActionBase { @@ -34,9 +38,6 @@ public override IWorld Execute(IActionContext context) var world = context.PreviousState; var repository = new GuildRepository(world, context); - - var guildParticipant = repository.GetGuildParticipant(context.Signer); - var guild = repository.GetGuild(guildParticipant.GuildAddress); var guildDelegator = repository.GetDelegator(context.Signer); guildDelegator.ReleaseUnbondings(context.BlockIndex); diff --git a/Lib9c/Action/ValidatorDelegation/ClaimValidatorUnbonded.cs b/Lib9c/Action/ValidatorDelegation/ClaimValidatorUnbonded.cs deleted file mode 100644 index 8020b6e2a4..0000000000 --- a/Lib9c/Action/ValidatorDelegation/ClaimValidatorUnbonded.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Bencodex.Types; -using Libplanet.Action.State; -using Libplanet.Action; -using Libplanet.Crypto; -using Nekoyume.ValidatorDelegation; -using Nekoyume.Model.Guild; - -namespace Nekoyume.Action.ValidatorDelegation -{ - [ActionType(TypeIdentifier)] - public sealed class ClaimValidatorUnbonded : ActionBase - { - public const string TypeIdentifier = "claim_validator_unbonded"; - - public ClaimValidatorUnbonded() { } - - public Address ValidatorDelegatee { get; private set; } - - public override IValue PlainValue => Dictionary.Empty - .Add("type_id", TypeIdentifier) - .Add("values", Null.Value); - - public override void LoadPlainValue(IValue plainValue) - { - var root = (Dictionary)plainValue; - if (plainValue is not Dictionary || - !root.TryGetValue((Text)"values", out var rawValues) || - rawValues is not Null) - { - throw new InvalidCastException(); - } - } - - public override IWorld Execute(IActionContext context) - { - GasTracer.UseGas(1); - - var world = context.PreviousState; - var repository = new ValidatorRepository(world, context); - var validatorDelegatee = repository.GetDelegatee(context.Signer); - var validatorDelegator = repository.GetDelegator(context.Signer); - validatorDelegator.ClaimReward(validatorDelegatee, context.BlockIndex); - - var guildRepository = new GuildRepository(repository); - var guildDelegatee = guildRepository.GetDelegatee(context.Signer); - var guildDelegator = guildRepository.GetDelegator(context.Signer); - guildDelegator.ClaimReward(guildDelegatee, context.BlockIndex); - - return guildRepository.World; - } - } -}