From df449d9ab9a3503cc3742f0ff0f47e134c319a65 Mon Sep 17 00:00:00 2001 From: ilgyu Date: Tue, 26 Nov 2024 00:23:18 +0900 Subject: [PATCH] chore: Change MigrateDelegationHeight as admin action --- .../Guild/Migration/LegacyModels/MigrationModule.cs | 6 ------ .../Action/Guild/Migration/MigrateDelegationHeight.cs | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Lib9c/Action/Guild/Migration/LegacyModels/MigrationModule.cs b/Lib9c/Action/Guild/Migration/LegacyModels/MigrationModule.cs index 4d2724c6f5..493282e363 100644 --- a/Lib9c/Action/Guild/Migration/LegacyModels/MigrationModule.cs +++ b/Lib9c/Action/Guild/Migration/LegacyModels/MigrationModule.cs @@ -1,4 +1,3 @@ -using System; using Bencodex.Types; using Libplanet.Action.State; using Libplanet.Crypto; @@ -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, diff --git a/Lib9c/Action/Guild/Migration/MigrateDelegationHeight.cs b/Lib9c/Action/Guild/Migration/MigrateDelegationHeight.cs index 48d1ad2b9d..dfd5aaa531 100644 --- a/Lib9c/Action/Guild/Migration/MigrateDelegationHeight.cs +++ b/Lib9c/Action/Guild/Migration/MigrateDelegationHeight.cs @@ -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 { @@ -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); } }