From 6328d39f62693662312485ce80a6fb42f199ede7 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.Tests/Action/StakeTest.cs | 2 +- .Lib9c.Tests/Util/DelegationUtil.cs | 19 ------- Lib9c/Action/Guild/ClaimGuildUnbonded.cs | 53 ------------------- Lib9c/Action/Guild/ClaimUnbonded.cs | 7 +-- .../ClaimValidatorUnbonded.cs | 53 ------------------- 5 files changed, 5 insertions(+), 129 deletions(-) delete mode 100644 Lib9c/Action/Guild/ClaimGuildUnbonded.cs delete mode 100644 Lib9c/Action/ValidatorDelegation/ClaimValidatorUnbonded.cs diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index e5a8c89232..f116515859 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -527,7 +527,7 @@ public void Execute_Success_When_Validator_Tries_To_Increase_Amount_Without_Clai Assert.Equal(3, nextStakeState.StateVersion); } - world = DelegationUtil.EnsureValidatorUnbondedClaimed( + world = DelegationUtil.EnsureUnbondedClaimed( nextState, _agentAddr, height + interval + ValidatorDelegatee.ValidatorUnbondingPeriod); var expectedBalance = _ncg * Math.Max(0, previousAmount - amount); diff --git a/.Lib9c.Tests/Util/DelegationUtil.cs b/.Lib9c.Tests/Util/DelegationUtil.cs index 13b319d742..afd79f9798 100644 --- a/.Lib9c.Tests/Util/DelegationUtil.cs +++ b/.Lib9c.Tests/Util/DelegationUtil.cs @@ -109,24 +109,5 @@ public static IWorld EnsureUnbondedClaimed( return claimUnbonded.Execute(actionContext); return world; } - - public static IWorld EnsureValidatorUnbondedClaimed( - IWorld world, Address agentAddress, long blockHeight) - { - if (blockHeight < 0) - { - throw new ArgumentOutOfRangeException(nameof(blockHeight)); - } - - var actionContext = new ActionContext - { - PreviousState = world, - Signer = agentAddress, - BlockIndex = blockHeight, - }; - var claimUnbonded = new ClaimValidatorUnbonded(); - return claimUnbonded.Execute(actionContext); - return world; - } } } 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; - } - } -}