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 19, 2024
1 parent 34d6d26 commit 6ed6fcf
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 31 deletions.
3 changes: 1 addition & 2 deletions Lib9c/Action/Guild/BanGuildMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 1 addition & 2 deletions Lib9c/Action/Guild/JoinGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 3 additions & 15 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 @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions Lib9c/Action/Guild/MoveGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 1 addition & 3 deletions Lib9c/Action/Guild/QuitGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions Lib9c/Action/Guild/RemoveGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Nekoyume.Action.Guild
/// <summary>
/// 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 All @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions Lib9c/Action/Guild/UnbanGuildMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
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 6ed6fcf

Please sign in to comment.