From 82204caa6c259a493957ec6619415ed61f2560b6 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 | 2 +- Lib9c/Action/Guild/JoinGuild.cs | 2 +- Lib9c/Action/Guild/MakeGuild.cs | 23 +++++++++-------------- Lib9c/Action/Guild/MoveGuild.cs | 2 +- Lib9c/Action/Guild/QuitGuild.cs | 2 +- Lib9c/Action/Guild/RemoveGuild.cs | 2 +- Lib9c/Action/Guild/UnbanGuildMember.cs | 2 +- Lib9c/Model/Guild/GuildRejoinCooldown.cs | 4 ++-- 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Lib9c/Action/Guild/BanGuildMember.cs b/Lib9c/Action/Guild/BanGuildMember.cs index 897a251109..79574ad0ac 100644 --- a/Lib9c/Action/Guild/BanGuildMember.cs +++ b/Lib9c/Action/Guild/BanGuildMember.cs @@ -10,7 +10,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..3dda6a1f20 100644 --- a/Lib9c/Action/Guild/JoinGuild.cs +++ b/Lib9c/Action/Guild/JoinGuild.cs @@ -10,7 +10,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..ecf754fe29 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 { @@ -46,30 +48,23 @@ rawValues is not Dictionary values || // 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); + + // if (context.Signer != GuildConfig.PlanetariumGuildOwner) + // { + // throw new InvalidOperationException( + // $"This action is not allowed for {context.Signer}."); + // } + return repository.World; } } diff --git a/Lib9c/Action/Guild/MoveGuild.cs b/Lib9c/Action/Guild/MoveGuild.cs index 84ede7baae..6109f21716 100644 --- a/Lib9c/Action/Guild/MoveGuild.cs +++ b/Lib9c/Action/Guild/MoveGuild.cs @@ -10,7 +10,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..9d80772733 100644 --- a/Lib9c/Action/Guild/QuitGuild.cs +++ b/Lib9c/Action/Guild/QuitGuild.cs @@ -9,7 +9,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"; diff --git a/Lib9c/Action/Guild/RemoveGuild.cs b/Lib9c/Action/Guild/RemoveGuild.cs index 39bd0652e7..68553df99c 100644 --- a/Lib9c/Action/Guild/RemoveGuild.cs +++ b/Lib9c/Action/Guild/RemoveGuild.cs @@ -12,7 +12,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"; diff --git a/Lib9c/Action/Guild/UnbanGuildMember.cs b/Lib9c/Action/Guild/UnbanGuildMember.cs index b4641099ff..a91c59f00a 100644 --- a/Lib9c/Action/Guild/UnbanGuildMember.cs +++ b/Lib9c/Action/Guild/UnbanGuildMember.cs @@ -11,7 +11,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)