From 6ed6fcf6c7dd5aefa44e7d95733e6aadc48dbf41 Mon Sep 17 00:00:00 2001 From: s2quake Date: Wed, 18 Dec 2024 15:25:45 +0900 Subject: [PATCH] refactor: Expose guild actions --- Lib9c/Action/Guild/BanGuildMember.cs | 3 +-- Lib9c/Action/Guild/JoinGuild.cs | 3 +-- Lib9c/Action/Guild/MakeGuild.cs | 18 +++--------------- Lib9c/Action/Guild/MoveGuild.cs | 3 +-- Lib9c/Action/Guild/QuitGuild.cs | 4 +--- Lib9c/Action/Guild/RemoveGuild.cs | 4 +--- Lib9c/Action/Guild/UnbanGuildMember.cs | 3 +-- Lib9c/Model/Guild/GuildRejoinCooldown.cs | 4 ++-- 8 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Lib9c/Action/Guild/BanGuildMember.cs b/Lib9c/Action/Guild/BanGuildMember.cs index 897a251109..3403cc2d8d 100644 --- a/Lib9c/Action/Guild/BanGuildMember.cs +++ b/Lib9c/Action/Guild/BanGuildMember.cs @@ -9,8 +9,7 @@ namespace Nekoyume.Action.Guild { - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class BanGuildMember : ActionBase { public const string TypeIdentifier = "ban_guild_member"; diff --git a/Lib9c/Action/Guild/JoinGuild.cs b/Lib9c/Action/Guild/JoinGuild.cs index 38d4a256ac..bb22bf533e 100644 --- a/Lib9c/Action/Guild/JoinGuild.cs +++ b/Lib9c/Action/Guild/JoinGuild.cs @@ -9,8 +9,7 @@ namespace Nekoyume.Action.Guild { - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class JoinGuild : ActionBase { public const string TypeIdentifier = "join_guild"; diff --git a/Lib9c/Action/Guild/MakeGuild.cs b/Lib9c/Action/Guild/MakeGuild.cs index a5fac12d97..f956efd17c 100644 --- a/Lib9c/Action/Guild/MakeGuild.cs +++ b/Lib9c/Action/Guild/MakeGuild.cs @@ -6,7 +6,9 @@ using Nekoyume.Extensions; using Nekoyume.Model.Guild; using Nekoyume.Module.Guild; +using Nekoyume.Module.ValidatorDelegation; using Nekoyume.TypedAddress; +using Nekoyume.ValidatorDelegation; namespace Nekoyume.Action.Guild { @@ -44,32 +46,18 @@ rawValues is not Dictionary values || ValidatorAddress = new Address(rawValidatorAddress); } - // TODO: Replace this with ExecutePublic when to deliver features to users. public override IWorld Execute(IActionContext context) - { - var world = ExecutePublic(context); - - if (context.Signer != GuildConfig.PlanetariumGuildOwner) - { - throw new InvalidOperationException( - $"This action is not allowed for {context.Signer}."); - } - - return world; - } - - public IWorld ExecutePublic(IActionContext context) { GasTracer.UseGas(1); var world = context.PreviousState; var random = context.GetRandom(); - var repository = new GuildRepository(world, context); var guildAddress = new GuildAddress(random.GenerateAddress()); var validatorAddress = ValidatorAddress; repository.MakeGuild(guildAddress, validatorAddress); + return repository.World; } } diff --git a/Lib9c/Action/Guild/MoveGuild.cs b/Lib9c/Action/Guild/MoveGuild.cs index 84ede7baae..b3eac87b25 100644 --- a/Lib9c/Action/Guild/MoveGuild.cs +++ b/Lib9c/Action/Guild/MoveGuild.cs @@ -9,8 +9,7 @@ namespace Nekoyume.Action.Guild { - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class MoveGuild : ActionBase { public const string TypeIdentifier = "move_guild"; diff --git a/Lib9c/Action/Guild/QuitGuild.cs b/Lib9c/Action/Guild/QuitGuild.cs index d330ed86f8..261d4931f3 100644 --- a/Lib9c/Action/Guild/QuitGuild.cs +++ b/Lib9c/Action/Guild/QuitGuild.cs @@ -8,8 +8,7 @@ namespace Nekoyume.Action.Guild { - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class QuitGuild : ActionBase { public const string TypeIdentifier = "quit_guild"; @@ -36,7 +35,6 @@ public override IWorld Execute(IActionContext context) var repository = new GuildRepository(world, context); var signer = context.GetAgentAddress(); - // TODO: Do something to return 'Power' token; repository.LeaveGuild(signer); return repository.World; diff --git a/Lib9c/Action/Guild/RemoveGuild.cs b/Lib9c/Action/Guild/RemoveGuild.cs index 39bd0652e7..21ff4c5f63 100644 --- a/Lib9c/Action/Guild/RemoveGuild.cs +++ b/Lib9c/Action/Guild/RemoveGuild.cs @@ -11,8 +11,7 @@ namespace Nekoyume.Action.Guild /// /// An action to remove the guild. /// - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class RemoveGuild : ActionBase { public const string TypeIdentifier = "remove_guild"; @@ -38,7 +37,6 @@ public override IWorld Execute(IActionContext context) var world = context.PreviousState; var repository = new GuildRepository(world, context); - // TODO: Do something to return 'Power' token; repository.RemoveGuild(); return repository.World; } diff --git a/Lib9c/Action/Guild/UnbanGuildMember.cs b/Lib9c/Action/Guild/UnbanGuildMember.cs index b4641099ff..3b306e22ca 100644 --- a/Lib9c/Action/Guild/UnbanGuildMember.cs +++ b/Lib9c/Action/Guild/UnbanGuildMember.cs @@ -10,8 +10,7 @@ namespace Nekoyume.Action.Guild { - // TODO(GUILD-FEATURE): Enable again when Guild features are enabled. - // [ActionType(TypeIdentifier)] + [ActionType(TypeIdentifier)] public class UnbanGuildMember : ActionBase { public const string TypeIdentifier = "unban_guild_member"; diff --git a/Lib9c/Model/Guild/GuildRejoinCooldown.cs b/Lib9c/Model/Guild/GuildRejoinCooldown.cs index c2cbbc4fbc..18c512453f 100644 --- a/Lib9c/Model/Guild/GuildRejoinCooldown.cs +++ b/Lib9c/Model/Guild/GuildRejoinCooldown.cs @@ -16,7 +16,7 @@ public GuildRejoinCooldown(AgentAddress agentAddress, long quitHeight) } public GuildRejoinCooldown(AgentAddress agentAddress, IValue bencoded) - : this(agentAddress, ((Integer)bencoded)) + : this(agentAddress, (Integer)bencoded) { } @@ -40,7 +40,7 @@ public long Cooldown(long currentHeight) } public bool Equals(GuildRejoinCooldown? other) - { + { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return AgentAddress.Equals(other.AgentAddress)