Skip to content

Commit

Permalink
Update UnlockFloor fee address
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Dec 31, 2024
1 parent 279d692 commit b58c316
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions Lib9c/Action/AdventureBoss/UnlockFloor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit b58c316

Please sign in to comment.