Skip to content

Commit

Permalink
chore: Change MigrateDelegationHeight as admin action
Browse files Browse the repository at this point in the history
  • Loading branch information
OnedgeLee committed Nov 25, 2024
1 parent 0444528 commit df449d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Lib9c/Action/Guild/Migration/LegacyModels/MigrationModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Bencodex.Types;
using Libplanet.Action.State;
using Libplanet.Crypto;
Expand All @@ -23,11 +22,6 @@ public static readonly Address DelegationMigrationHeight

public static IWorld SetDelegationMigrationHeight(this IWorld world, long height)
{
if (world.GetDelegationMigrationHeight() is long)
{
throw new InvalidOperationException("Cannot overwrite delegation migration index.");
}

return world
.MutateAccount(
Addresses.Migration,
Expand Down
11 changes: 11 additions & 0 deletions Lib9c/Action/Guild/Migration/MigrateDelegationHeight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Libplanet.Action;
using Libplanet.Action.State;
using Nekoyume.Action.Guild.Migration.LegacyModels;
using Nekoyume.Model.State;

namespace Nekoyume.Action.Guild.Migration
{
Expand Down Expand Up @@ -53,6 +54,16 @@ public override IWorld Execute(IActionContext context)

var world = context.PreviousState;

if (!TryGetAdminState(context, out AdminState adminState))
{
throw new InvalidOperationException("Couldn't find admin state");
}

if (context.Signer != adminState.AdminAddress)
{
throw new PermissionDeniedException(adminState, context.Signer);
}

return world.SetDelegationMigrationHeight(Height);
}
}
Expand Down

0 comments on commit df449d9

Please sign in to comment.