Skip to content

Commit

Permalink
refactor: Expose guild actions
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Dec 18, 2024
1 parent a85e174 commit 82204ca
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/BanGuildMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/JoinGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
23 changes: 9 additions & 14 deletions Lib9c/Action/Guild/MakeGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/MoveGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/QuitGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/RemoveGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Nekoyume.Action.Guild
/// An action to remove the guild.
/// </summary>
// TODO(GUILD-FEATURE): Enable again when Guild features are enabled.
// [ActionType(TypeIdentifier)]
[ActionType(TypeIdentifier)]
public class RemoveGuild : ActionBase
{
public const string TypeIdentifier = "remove_guild";
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/Guild/UnbanGuildMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Model/Guild/GuildRejoinCooldown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public GuildRejoinCooldown(AgentAddress agentAddress, long quitHeight)
}

public GuildRejoinCooldown(AgentAddress agentAddress, IValue bencoded)
: this(agentAddress, ((Integer)bencoded))
: this(agentAddress, (Integer)bencoded)
{
}

Expand All @@ -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)
Expand Down

0 comments on commit 82204ca

Please sign in to comment.