From b58c316be6b86d5714cafe3f460e6c5a16bd24b0 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Tue, 31 Dec 2024 13:30:40 +0900 Subject: [PATCH] Update UnlockFloor fee address --- .Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs | 8 +++++++- Lib9c/Action/AdventureBoss/UnlockFloor.cs | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs b/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs index 75019d0372..476059b574 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs @@ -12,6 +12,7 @@ namespace Lib9c.Tests.Action.AdventureBoss using Nekoyume; using Nekoyume.Action; using Nekoyume.Action.AdventureBoss; + using Nekoyume.Action.Guild.Migration.LegacyModels; using Nekoyume.Model.Item; using Nekoyume.Model.State; using Nekoyume.Module; @@ -84,7 +85,8 @@ public class UnlockFloorTest .SetAgentState(WantedAddress, WantedState) .SetAvatarState(TesterAvatarAddress, TesterAvatarState) .SetAgentState(TesterAddress, TesterState) - .MintAsset(new ActionContext(), WantedAddress, 1_000_000 * NCG); + .MintAsset(new ActionContext(), WantedAddress, 1_000_000 * NCG) + .SetDelegationMigrationHeight(0); [Theory] // Success @@ -217,6 +219,10 @@ Type exc var inventory = resultState.GetInventoryV2(TesterAvatarAddress); Assert.Null(inventory.Items.FirstOrDefault(i => i.item.Id == 600202)); } + else + { + Assert.True(resultState.GetBalance(Addresses.RewardPool, NCG) > 0 * NCG); + } Assert.Equal( expectedFloor, diff --git a/Lib9c/Action/AdventureBoss/UnlockFloor.cs b/Lib9c/Action/AdventureBoss/UnlockFloor.cs index fbebd0b082..37584e64ff 100644 --- a/Lib9c/Action/AdventureBoss/UnlockFloor.cs +++ b/Lib9c/Action/AdventureBoss/UnlockFloor.cs @@ -7,6 +7,7 @@ using Libplanet.Action.State; using Libplanet.Crypto; using Nekoyume.Action.Exceptions.AdventureBoss; +using Nekoyume.Action.Guild.Migration.LegacyModels; using Nekoyume.Data; using Nekoyume.Exceptions; using Nekoyume.Extensions; @@ -129,7 +130,7 @@ public override IWorld Execute(IActionContext context) var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); throw new FailedLoadStateException($"{addressesHex}Aborted as the avatar state of the signer was failed to load."); } - + var agentAddress = avatarState.agentAddress; var balance = states.GetBalance(agentAddress, currency); var exploreBoard = states.GetExploreBoard(Season); @@ -145,8 +146,15 @@ public override IWorld Execute(IActionContext context) explorer.UsedNcg += price.NcgPrice; exploreBoard.UsedNcg += price.NcgPrice; + var feeAddress = Addresses.RewardPool; + // TODO: [GuildMigration] Remove this after migration + if (states.GetDelegationMigrationHeight() is long migrationHeight + && context.BlockIndex < migrationHeight) + { + feeAddress = AdventureBossGameData.AdventureBossOperationalAddress; + } states = states.TransferAsset(context, agentAddress, - AdventureBossGameData.AdventureBossOperationalAddress, + feeAddress, price.NcgPrice * currency); } else // Use GoldenDust