From c6258b743ea02bb456a321148f7690bcc52b1e12 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 11 Aug 2023 11:53:46 +0900 Subject: [PATCH 001/134] Backup grinding --- .Lib9c.Tests/Action/Grinding0Test.cs | 256 +++++++++++++++++++++++++++ Lib9c/Action/Grinding0.cs | 197 +++++++++++++++++++++ 2 files changed, 453 insertions(+) create mode 100644 .Lib9c.Tests/Action/Grinding0Test.cs create mode 100644 Lib9c/Action/Grinding0.cs diff --git a/.Lib9c.Tests/Action/Grinding0Test.cs b/.Lib9c.Tests/Action/Grinding0Test.cs new file mode 100644 index 000000000..2446bc6c2 --- /dev/null +++ b/.Lib9c.Tests/Action/Grinding0Test.cs @@ -0,0 +1,256 @@ +namespace Lib9c.Tests.Action +{ + using System; + using System.Collections.Generic; + using System.Linq; + using Libplanet.Action; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Libplanet.Types.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Model.Item; + using Nekoyume.Model.Mail; + using Nekoyume.Model.State; + using Nekoyume.TableData; + using Nekoyume.TableData.Crystal; + using Xunit; + using static Lib9c.SerializeKeys; + + public class Grinding0Test + { + private readonly IRandom _random; + private readonly TableSheets _tableSheets; + private readonly Address _agentAddress; + private readonly Address _avatarAddress; + private readonly AgentState _agentState; + private readonly AvatarState _avatarState; + private readonly Currency _crystalCurrency; + private readonly Currency _ncgCurrency; + private readonly IAccountStateDelta _initialState; + + public Grinding0Test() + { + _random = new TestRandom(); + var sheets = TableSheetsImporter.ImportSheets(); + _tableSheets = new TableSheets(sheets); + _agentAddress = new PrivateKey().ToAddress(); + _avatarAddress = new PrivateKey().ToAddress(); +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + _crystalCurrency = Currency.Legacy("CRYSTAL", 18, null); +#pragma warning restore CS0618 + var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); + + _agentState = new AgentState(_agentAddress); + _avatarState = new AvatarState( + _avatarAddress, + _agentAddress, + 0, + _tableSheets.GetAvatarSheets(), + gameConfigState, + default + ); + + _agentState.avatarAddresses.Add(0, _avatarAddress); + +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + _ncgCurrency = Currency.Legacy("NCG", 2, null); +#pragma warning restore CS0618 + var goldCurrencyState = new GoldCurrencyState(_ncgCurrency); + + _initialState = new MockStateDelta() + .SetState( + Addresses.GetSheetAddress(), + _tableSheets.CrystalMonsterCollectionMultiplierSheet.Serialize()) + .SetState( + Addresses.GetSheetAddress(), + _tableSheets.CrystalEquipmentGrindingSheet.Serialize()) + .SetState( + Addresses.GetSheetAddress(), + _tableSheets.MaterialItemSheet.Serialize()) + .SetState( + Addresses.GetSheetAddress(), + _tableSheets.StakeRegularRewardSheet.Serialize()) + .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) + .SetState(Addresses.GameConfig, gameConfigState.Serialize()); + } + + [Theory] + [InlineData(true, true, 120, false, false, true, 1, 0, false, false, false, 0, 10, 1, null)] + [InlineData(true, true, 120, false, false, true, 1, 2, false, false, false, 0, 40, 1, null)] + // Multiply by StakeState. + [InlineData(true, true, 120, false, false, true, 1, 2, false, true, false, 0, 40, 1, null)] + [InlineData(true, true, 120, false, false, true, 1, 0, false, true, false, 2, 15, 1, null)] + // Multiply by legacy MonsterCollectionState. + [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 40, 1, null)] + [InlineData(true, true, 120, false, false, true, 1, 0, false, false, true, 2, 15, 1, null)] + // Charge AP. + [InlineData(true, true, 0, true, true, true, 1, 0, false, false, false, 0, 10, 1, null)] + // Invalid equipment count. + [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 200, 0, typeof(InvalidItemCountException))] + [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 200, 11, typeof(InvalidItemCountException))] + // AgentState not exist. + [InlineData(false, true, 120, false, false, false, 1, 0, false, false, false, 0, 0, 1, typeof(FailedLoadStateException))] + // AvatarState not exist. + [InlineData(true, false, 120, false, false, false, 1, 0, false, false, false, 0, 0, 1, typeof(FailedLoadStateException))] + // Required more ActionPoint. + [InlineData(true, true, 0, false, false, false, 1, 0, false, false, false, 0, 0, 1, typeof(NotEnoughActionPointException))] + // Failed Charge AP. + [InlineData(true, true, 0, true, false, false, 1, 0, false, false, false, 0, 100, 1, typeof(NotEnoughMaterialException))] + // Equipment not exist. + [InlineData(true, true, 120, false, false, false, 1, 0, false, false, false, 0, 0, 1, typeof(ItemDoesNotExistException))] + // Locked equipment. + [InlineData(true, true, 120, false, false, true, 100, 0, false, false, false, 0, 0, 1, typeof(RequiredBlockIndexException))] + public void Execute( + bool agentExist, + bool avatarExist, + int ap, + bool chargeAp, + bool apStoneExist, + bool equipmentExist, + long requiredBlockIndex, + int itemLevel, + bool equipped, + bool stake, + bool monsterCollect, + int monsterCollectLevel, + int totalAsset, + int equipmentCount, + Type exc + ) + { + var context = new ActionContext(); + var state = _initialState; + if (agentExist) + { + state = state.SetState(_agentAddress, _agentState.Serialize()); + } + + if (avatarExist) + { + _avatarState.actionPoint = ap; + + if (equipmentExist) + { + var row = _tableSheets.EquipmentItemSheet.Values.First(r => r.Grade == 1); + var equipment = (Equipment)ItemFactory.CreateItemUsable(row, default, requiredBlockIndex, itemLevel); + equipment.equipped = equipped; + _avatarState.inventory.AddItem(equipment, count: 1); + } + else + { + var row = _tableSheets.ConsumableItemSheet.Values.First(r => r.Grade == 1); + var consumable = (Consumable)ItemFactory.CreateItemUsable(row, default, requiredBlockIndex, itemLevel); + _avatarState.inventory.AddItem(consumable, count: 1); + } + + if (chargeAp && apStoneExist) + { + var row = _tableSheets.MaterialItemSheet.Values.First(r => + r.ItemSubType == ItemSubType.ApStone); + var apStone = ItemFactory.CreateMaterial(row); + _avatarState.inventory.AddItem(apStone); + } + + state = state + .SetState(_avatarAddress.Derive(LegacyInventoryKey), _avatarState.inventory.Serialize()) + .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), _avatarState.worldInformation.Serialize()) + .SetState(_avatarAddress.Derive(LegacyQuestListKey), _avatarState.questList.Serialize()) + .SetState(_avatarAddress, _avatarState.SerializeV2()); + + Assert.Equal(0 * _crystalCurrency, state.GetBalance(_avatarAddress, _crystalCurrency)); + } + + if (stake || monsterCollect) + { + // StakeState; + var stakeStateAddress = StakeState.DeriveAddress(_agentAddress); + var stakeState = new StakeState(stakeStateAddress, 1); + var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows + .FirstOrDefault(r => r.Level == monsterCollectLevel)?.RequiredGold ?? 0; + + if (stake) + { + state = state.SetState(stakeStateAddress, stakeState.SerializeV2()); + + if (requiredGold > 0) + { + state = state.MintAsset( + context, + stakeStateAddress, + requiredGold * _ncgCurrency + ); + } + } + + if (monsterCollect) + { + var mcAddress = MonsterCollectionState.DeriveAddress(_agentAddress, 0); + state = state.SetState( + mcAddress, + new MonsterCollectionState(mcAddress, monsterCollectLevel, 1).Serialize() + ); + + if (requiredGold > 0) + { + state = state.MintAsset(context, mcAddress, requiredGold * _ncgCurrency); + } + } + } + + var equipmentIds = new List(); + for (int i = 0; i < equipmentCount; i++) + { + equipmentIds.Add(default); + } + + Assert.Equal(equipmentCount, equipmentIds.Count); + + var action = new Grinding0 + { + AvatarAddress = _avatarAddress, + EquipmentIds = equipmentIds, + ChargeAp = chargeAp, + }; + + if (exc is null) + { + var nextState = action.Execute(new ActionContext + { + PreviousState = state, + Signer = _agentAddress, + BlockIndex = 1, + Random = _random, + }); + + var nextAvatarState = nextState.GetAvatarStateV2(_avatarAddress); + FungibleAssetValue asset = totalAsset * _crystalCurrency; + + Assert.Equal(asset, nextState.GetBalance(_agentAddress, _crystalCurrency)); + Assert.False(nextAvatarState.inventory.HasNonFungibleItem(default)); + Assert.Equal(115, nextAvatarState.actionPoint); + + var mail = nextAvatarState.mailBox.OfType().First(i => i.id.Equals(action.Id)); + + Assert.Equal(1, mail.ItemCount); + Assert.Equal(asset, mail.Asset); + + var row = _tableSheets.MaterialItemSheet.Values.First(r => + r.ItemSubType == ItemSubType.ApStone); + Assert.False(nextAvatarState.inventory.HasItem(row.Id)); + } + else + { + Assert.Throws(exc, () => action.Execute(new ActionContext + { + PreviousState = state, + Signer = _agentAddress, + BlockIndex = 1, + Random = _random, + })); + } + } + } +} diff --git a/Lib9c/Action/Grinding0.cs b/Lib9c/Action/Grinding0.cs new file mode 100644 index 000000000..050706639 --- /dev/null +++ b/Lib9c/Action/Grinding0.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet.Action; +using Libplanet.Action.State; +using Libplanet.Crypto; +using Libplanet.Types.Assets; +using Nekoyume.Extensions; +using Nekoyume.Helper; +using Nekoyume.Model.Item; +using Nekoyume.Model.Mail; +using Nekoyume.Model.State; +using Nekoyume.TableData; +using Nekoyume.TableData.Crystal; +using Serilog; +using static Lib9c.SerializeKeys; + +namespace Nekoyume.Action +{ + [ActionType("grinding")] + public class Grinding0 : GameAction, IGrindingV1 + { + public const int CostAp = 5; + public const int Limit = 10; + public Address AvatarAddress; + public List EquipmentIds; + public bool ChargeAp; + + Address IGrindingV1.AvatarAddress => AvatarAddress; + List IGrindingV1.EquipmentsIds => EquipmentIds; + bool IGrindingV1.ChargeAp => ChargeAp; + + public override IAccountStateDelta Execute(IActionContext context) + { + context.UseGas(1); + IActionContext ctx = context; + IAccountStateDelta states = ctx.PreviousState; + var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); + var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); + var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); + if (ctx.Rehearsal) + { + states = EquipmentIds.Aggregate(states, + (current, guid) => + current.SetState(Addresses.GetItemAddress(guid), MarkChanged)); + return states + .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 0), MarkChanged) + .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 1), MarkChanged) + .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 2), MarkChanged) + .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 3), MarkChanged) + .SetState(AvatarAddress, MarkChanged) + .SetState(worldInformationAddress, MarkChanged) + .SetState(questListAddress, MarkChanged) + .SetState(inventoryAddress, MarkChanged) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer); + } + + var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); + var started = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}Grinding exec started", addressesHex); + if (!EquipmentIds.Any() || EquipmentIds.Count > Limit) + { + throw new InvalidItemCountException(); + } + + if (!states.TryGetAgentAvatarStatesV2(ctx.Signer, AvatarAddress, out var agentState, + out var avatarState, out bool migrationRequired)) + { + throw new FailedLoadStateException(""); + } + + Address monsterCollectionAddress = MonsterCollectionState.DeriveAddress( + context.Signer, + agentState.MonsterCollectionRound + ); + + Dictionary sheets = states.GetSheets(sheetTypes: new[] + { + typeof(CrystalEquipmentGrindingSheet), + typeof(CrystalMonsterCollectionMultiplierSheet), + typeof(MaterialItemSheet), + typeof(StakeRegularRewardSheet) + }); + + Currency currency = states.GetGoldCurrency(); + FungibleAssetValue stakedAmount = 0 * currency; + if (states.TryGetStakeState(context.Signer, out StakeState stakeState)) + { + stakedAmount = states.GetBalance(stakeState.address, currency); + } + else + { + if (states.TryGetState(monsterCollectionAddress, out Dictionary _)) + { + stakedAmount = states.GetBalance(monsterCollectionAddress, currency); + } + } + + if (avatarState.actionPoint < CostAp) + { + switch (ChargeAp) + { + case false: + throw new NotEnoughActionPointException(""); + case true: + { + MaterialItemSheet.Row row = sheets.GetSheet() + .OrderedList + .First(r => r.ItemSubType == ItemSubType.ApStone); + if (!avatarState.inventory.RemoveFungibleItem(row.ItemId, context.BlockIndex)) + { + throw new NotEnoughMaterialException("not enough ap stone."); + } + GameConfigState gameConfigState = states.GetGameConfigState(); + avatarState.actionPoint = gameConfigState.ActionPointMax; + break; + } + } + } + + avatarState.actionPoint -= CostAp; + + List equipmentList = new List(); + foreach (var equipmentId in EquipmentIds) + { + if(avatarState.inventory.TryGetNonFungibleItem(equipmentId, out Equipment equipment)) + { + if (equipment.RequiredBlockIndex > context.BlockIndex) + { + throw new RequiredBlockIndexException($"{equipment.ItemSubType} / unlock on {equipment.RequiredBlockIndex}"); + } + } + else + { + // Invalid Item Type. + throw new ItemDoesNotExistException($"Can't find Equipment. {equipmentId}"); + } + + if (!avatarState.inventory.RemoveNonFungibleItem(equipmentId)) + { + throw new ItemDoesNotExistException($"Can't find Equipment. {equipmentId}"); + } + equipmentList.Add(equipment); + } + + FungibleAssetValue crystal = CrystalCalculator.CalculateCrystal( + context.Signer, + equipmentList, + stakedAmount, + false, + sheets.GetSheet(), + sheets.GetSheet(), + sheets.GetSheet() + ); + + var mail = new GrindingMail( + ctx.BlockIndex, + Id, + ctx.BlockIndex, + EquipmentIds.Count, + crystal + ); + avatarState.Update(mail); + + if (migrationRequired) + { + states = states + .SetState(worldInformationAddress, avatarState.worldInformation.Serialize()) + .SetState(questListAddress, avatarState.questList.Serialize()); + } + + var ended = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}Grinding Total Executed Time: {Elapsed}", addressesHex, ended - started); + return states + .SetState(AvatarAddress, avatarState.SerializeV2()) + .SetState(inventoryAddress, avatarState.inventory.Serialize()) + .MintAsset(context, context.Signer, crystal); + } + + protected override IImmutableDictionary PlainValueInternal => + new Dictionary + { + ["a"] = AvatarAddress.Serialize(), + ["e"] = new List(EquipmentIds.OrderBy(i => i).Select(i => i.Serialize())), + ["c"] = ChargeAp.Serialize(), + }.ToImmutableDictionary(); + protected override void LoadPlainValueInternal(IImmutableDictionary plainValue) + { + AvatarAddress = plainValue["a"].ToAddress(); + EquipmentIds = plainValue["e"].ToList(StateExtensions.ToGuid); + ChargeAp = plainValue["c"].ToBoolean(); + } + } +} From e4a25bb7d33d0b283f21bdf4f205c08cb52fe37f Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 11 Aug 2023 12:17:49 +0900 Subject: [PATCH 002/134] Increase grinding limit --- .Lib9c.Tests/Action/GrindingTest.cs | 2 +- Lib9c/Action/Grinding.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index 0fcc63255..1e5615bad 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -90,7 +90,7 @@ public GrindingTest() [InlineData(true, true, 0, true, true, true, 1, 0, false, false, false, 0, 10, 1, null)] // Invalid equipment count. [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 200, 0, typeof(InvalidItemCountException))] - [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 200, 11, typeof(InvalidItemCountException))] + [InlineData(true, true, 120, false, false, true, 1, 2, false, false, true, 0, 200, 51, typeof(InvalidItemCountException))] // AgentState not exist. [InlineData(false, true, 120, false, false, false, 1, 0, false, false, false, 0, 0, 1, typeof(FailedLoadStateException))] // AvatarState not exist. diff --git a/Lib9c/Action/Grinding.cs b/Lib9c/Action/Grinding.cs index 81ba6735a..7e83a7662 100644 --- a/Lib9c/Action/Grinding.cs +++ b/Lib9c/Action/Grinding.cs @@ -20,11 +20,11 @@ namespace Nekoyume.Action { - [ActionType("grinding")] + [ActionType("grinding2")] public class Grinding : GameAction, IGrindingV1 { public const int CostAp = 5; - public const int Limit = 10; + public const int Limit = 50; public Address AvatarAddress; public List EquipmentIds; public bool ChargeAp; From d60b08a47a7bbfd02c666c18407a0a57c6b7650f Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 11 Aug 2023 14:00:08 +0900 Subject: [PATCH 003/134] Aura grinding --- .../Action/Scenario/AuraScenarioTest.cs | 27 +++++++++++++++++++ .../Crystal/CrystalEquipmentGrindingSheet.csv | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index da5a6233c..f0200d22f 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -266,6 +266,33 @@ public void Arena() } } + [Fact] + public void Grinding() + { + var avatarState = _initialState.GetAvatarStateV2(_avatarAddress); + Assert.True(avatarState.inventory.TryGetNonFungibleItem(_aura.ItemId, out _)); + + var grinding = new Grinding + { + AvatarAddress = _avatarAddress, + EquipmentIds = new List + { + _aura.ItemId, + }, + }; + var nextState = grinding.Execute(new ActionContext + { + Signer = _agentAddress, + PreviousState = _initialState, + BlockIndex = 1L, + }); + + var nextAvatarState = nextState.GetAvatarStateV2(_avatarAddress); + Assert.False(nextAvatarState.inventory.TryGetNonFungibleItem(_aura.ItemId, out _)); + var previousCrystal = _initialState.GetBalance(_agentAddress, Currencies.Crystal); + Assert.True(nextState.GetBalance(_agentAddress, Currencies.Crystal) > previousCrystal); + } + private void Assert_Player(AvatarState avatarState, IAccountStateDelta state, Address avatarAddress, Address itemSlotStateAddress) { var nextAvatarState = state.GetAvatarStateV2(avatarAddress); diff --git a/Lib9c/TableCSV/Crystal/CrystalEquipmentGrindingSheet.csv b/Lib9c/TableCSV/Crystal/CrystalEquipmentGrindingSheet.csv index 93d8de14c..bef98b299 100644 --- a/Lib9c/TableCSV/Crystal/CrystalEquipmentGrindingSheet.csv +++ b/Lib9c/TableCSV/Crystal/CrystalEquipmentGrindingSheet.csv @@ -173,4 +173,5 @@ id,enchant_base_id,gain_crystal 10451001,10451001,1000000 10452001,10451001,1000000 10453001,10451001,2000000 -10454001,10451001,2000000 \ No newline at end of file +10454001,10451001,2000000 +13001000,13001000,1 From d5a20513a2c3715e7444d46ae0af80d96fe6545b Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 14 Aug 2023 15:48:53 +0900 Subject: [PATCH 004/134] Move ITradableItem from ItemUsable to each items --- .Lib9c.Tests/Action/Buy10Test.cs | 2 +- .Lib9c.Tests/Action/Buy11Test.cs | 2 +- .Lib9c.Tests/Action/Buy2Test.cs | 2 +- .Lib9c.Tests/Action/Buy3Test.cs | 4 +- .Lib9c.Tests/Action/Buy4Test.cs | 4 +- .Lib9c.Tests/Action/Buy5Test.cs | 6 +-- .Lib9c.Tests/Action/Buy6Test.cs | 4 +- .Lib9c.Tests/Action/Buy7Test.cs | 4 +- .Lib9c.Tests/Action/Buy8Test.cs | 2 +- .Lib9c.Tests/Action/Buy9Test.cs | 2 +- .Lib9c.Tests/Action/BuyMultipleTest.cs | 6 +-- .Lib9c.Tests/Action/BuyProduct0Test.cs | 2 +- .Lib9c.Tests/Action/BuyProductTest.cs | 2 +- .Lib9c.Tests/Action/BuyTest.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 4 +- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 4 +- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 4 +- .Lib9c.Tests/Action/ReRegisterProduct0Test.cs | 2 +- .Lib9c.Tests/Action/ReRegisterProductTest.cs | 2 +- .Lib9c.Tests/Action/RegisterProduct0Test.cs | 4 +- .Lib9c.Tests/Action/RegisterProductTest.cs | 4 +- .../Action/Scenario/AuraScenarioTest.cs | 47 ++++++++++++++++++- .../Action/Scenario/MarketScenarioTest.cs | 22 ++++----- .Lib9c.Tests/Action/Sell10Test.cs | 4 +- .Lib9c.Tests/Action/Sell11Test.cs | 4 +- .Lib9c.Tests/Action/Sell4Test.cs | 2 +- .Lib9c.Tests/Action/Sell5Test.cs | 10 ++-- .Lib9c.Tests/Action/Sell6Test.cs | 14 +++--- .Lib9c.Tests/Action/Sell7Test.cs | 4 +- .Lib9c.Tests/Action/Sell8Test.cs | 4 +- .Lib9c.Tests/Action/Sell9Test.cs | 4 +- .Lib9c.Tests/Action/SellCancellation0Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation2Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation3Test.cs | 4 +- .Lib9c.Tests/Action/SellCancellation4Test.cs | 4 +- .Lib9c.Tests/Action/SellCancellation5Test.cs | 8 ++-- .Lib9c.Tests/Action/SellCancellation6Test.cs | 6 +-- .Lib9c.Tests/Action/SellCancellation7Test.cs | 8 ++-- .Lib9c.Tests/Action/SellCancellation8Test.cs | 10 ++-- .Lib9c.Tests/Action/SellCancellationTest.cs | 10 ++-- .Lib9c.Tests/Action/SellTest.cs | 4 +- .Lib9c.Tests/Action/UpdateSell0Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell2Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell3Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell4Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSellTest.cs | 2 +- .Lib9c.Tests/Model/Item/InventoryTest.cs | 4 +- .Lib9c.Tests/Model/Item/ShopItemTest.cs | 20 ++++---- .../Model/Order/NonFungibleOrderTest.cs | 2 +- .Lib9c.Tests/Model/Order/OrderFactoryTest.cs | 8 ++-- Lib9c/Action/Buy6.cs | 2 +- Lib9c/Action/Buy7.cs | 2 +- Lib9c/Action/RegisterProduct.cs | 2 +- Lib9c/Action/Sell0.cs | 2 +- Lib9c/Action/Sell2.cs | 2 +- Lib9c/Action/Sell3.cs | 2 +- Lib9c/Action/Sell4.cs | 2 +- Lib9c/Action/SellCancellation6.cs | 2 +- Lib9c/Battle/CPHelper.cs | 2 +- Lib9c/Model/Item/Armor.cs | 4 +- Lib9c/Model/Item/Belt.cs | 4 +- Lib9c/Model/Item/Consumable.cs | 4 +- Lib9c/Model/Item/Costume.cs | 2 +- Lib9c/Model/Item/INonFungibleItem.cs | 3 +- Lib9c/Model/Item/ItemUsable.cs | 1 - Lib9c/Model/Item/Necklace.cs | 4 +- Lib9c/Model/Item/Ring.cs | 4 +- Lib9c/Model/Item/Weapon.cs | 4 +- Lib9c/Model/Order/FungibleOrder.cs | 4 +- Lib9c/Model/Order/NonFungibleOrder.cs | 6 +-- 70 files changed, 200 insertions(+), 143 deletions(-) diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 11410af01..7ca2769f7 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -239,7 +239,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index 8e29e06c5..8eec859fc 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -245,7 +245,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index 5aeb37272..efe20dbe1 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -98,7 +98,7 @@ public Buy2Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); var result = new CombinationConsumable5.ResultModel() { diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index bc131c380..0aa7c0188 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -108,14 +108,14 @@ public Buy3Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _sellerAgentAddress, _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _sellerAgentAddress, diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index 4210222b1..a1f6a85cd 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -110,14 +110,14 @@ public Buy4Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _sellerAgentAddress, _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _sellerAgentAddress, diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index 5986afb61..130cc6d93 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -210,7 +210,7 @@ public void Execute(params ShopItemData[] shopItemMembers) productId, new FungibleAssetValue(_goldCurrencyState.Currency, shopItemData.Price, 0), requiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); // Case for backward compatibility. if (shopItemData.ContainsInInventory) @@ -454,7 +454,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); @@ -506,7 +506,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index c43688721..f4c6bdb9e 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -213,7 +213,7 @@ public void Execute(params ShopItemData[] shopItemMembers) _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (shopItemData.ItemType == ItemType.Costume) @@ -581,7 +581,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index e565bbcdc..b49c5e658 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -213,7 +213,7 @@ public void Execute(params ShopItemData[] shopItemMembers) _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (shopItemData.ItemType == ItemType.Costume) @@ -652,7 +652,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index c11c8da02..1d772d1f5 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -207,7 +207,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index 27401158a..91067cff5 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -294,7 +294,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index 7be32d6d8..889e0e269 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -275,7 +275,7 @@ public void Execute(params ShopItemData[] productDatas) shopItemId, new FungibleAssetValue(_goldCurrencyState.Currency, product.Price, 0), product.RequiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); shopState.Register(shopItem); if (product.Buy) @@ -504,7 +504,7 @@ public void ExecuteInsufficientBalanceError() Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, 1, 0), 100, - equipment)); + (ITradableItem)equipment)); var costume = ItemFactory.CreateCostume( _tableSheets.CostumeItemSheet.First, @@ -574,7 +574,7 @@ public void ExecuteThrowShopItemExpiredError() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), 10, - equipment)); + (ITradableItem)equipment)); previousStates = previousStates .SetState(Addresses.Shop, shopState.Serialize()); diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index 81f97d56d..b690173d0 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -28,7 +28,7 @@ public class BuyProduct0Test private static readonly Currency Gold = Currency.Legacy("NCG", 2, null); private static readonly TableSheets TableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); private static readonly ITradableItem TradableItem = - ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); + (ITradableItem)ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); private readonly Address _sellerAgentAddress2; private readonly Address _sellerAvatarAddress2; diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index b6c96ff91..5c1b9a89f 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -28,7 +28,7 @@ public class BuyProductTest private static readonly Currency Gold = Currency.Legacy("NCG", 2, null); private static readonly TableSheets TableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); private static readonly ITradableItem TradableItem = - ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); + (ITradableItem)ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); private readonly Address _sellerAgentAddress2; private readonly Address _sellerAvatarAddress2; diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index ef905ddcc..883ac45b1 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -240,7 +240,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 2ce649177..742bbf99c 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -192,8 +192,8 @@ public void Execute(int level, int expectedGold, bool backward) break; } - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(costRow.Cost, slotResult.gold); } diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index 33643d534..70193822e 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -186,8 +186,8 @@ public void Execute(int level, int expectedGold, bool backward) break; } - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(costRow.Cost, slotResult.gold); } diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index d9e8c8cb3..f2ccf0214 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -225,8 +225,8 @@ bool stake break; } - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(costRow.Cost, slotResult.gold); Assert.Equal(expectedCrystal * CrystalCalculator.CRYSTAL, slotResult.CRYSTAL); } diff --git a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs index 8d52d22a4..95eed5bbb 100644 --- a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs @@ -120,7 +120,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index c46f45d37..e9c58dee1 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -120,7 +120,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index 8ed67b727..affe9346f 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -227,7 +227,7 @@ public void Execute() AvatarAddress = AvatarAddress, ItemCount = 1, Price = 1 * Gold, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -329,7 +329,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo { var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var id = Guid.NewGuid(); - tradableItem = ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); break; } diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 35a0a89c0..90be45ec6 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -227,7 +227,7 @@ public void Execute() AvatarAddress = AvatarAddress, ItemCount = 1, Price = 1 * Gold, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -330,7 +330,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo { var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var id = Guid.NewGuid(); - tradableItem = ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); break; } diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index f0200d22f..f8864e1cc 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -14,6 +14,7 @@ namespace Lib9c.Tests.Action.Scenario using Nekoyume.Model.BattleStatus.Arena; using Nekoyume.Model.EnumType; using Nekoyume.Model.Item; + using Nekoyume.Model.Market; using Nekoyume.Model.Skill; using Nekoyume.Model.Stat; using Nekoyume.Model.State; @@ -29,6 +30,7 @@ public class AuraScenarioTest private readonly IAccountStateDelta _initialState; private readonly Aura _aura; private readonly TableSheets _tableSheets; + private readonly Currency _currency; public AuraScenarioTest() { @@ -74,11 +76,12 @@ public AuraScenarioTest() avatarState.questList.Serialize()); } + _currency = Currency.Legacy("NCG", 2, minters: null); _initialState = _initialState .SetState(_agentAddress, agentState.Serialize()) .SetState( Addresses.GoldCurrency, - new GoldCurrencyState(Currency.Legacy("NCG", 2, minters: null)).Serialize()) + new GoldCurrencyState(_currency).Serialize()) .SetState(gameConfigState.address, gameConfigState.Serialize()) .MintAsset(new ActionContext(), _agentAddress, Currencies.Crystal * 2); foreach (var (key, value) in sheets) @@ -293,6 +296,48 @@ public void Grinding() Assert.True(nextState.GetBalance(_agentAddress, Currencies.Crystal) > previousCrystal); } + [Fact] + public void Market() + { + var avatarState = _initialState.GetAvatarStateV2(_avatarAddress); + avatarState.inventory.TryGetNonFungibleItem(_aura.ItemId, out Aura aura); + Assert.NotNull(aura); + Assert.IsAssignableFrom(aura); + Assert.Null(aura as ITradableItem); + for (int i = 0; i < GameConfig.RequireClearedStageLevel.ActionsInShop; i++) + { + avatarState.worldInformation.ClearStage(1, i + 1, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet); + } + + var previousState = _initialState.SetState( + _avatarAddress.Derive(LegacyWorldInformationKey), + avatarState.worldInformation.Serialize()); + + var register = new RegisterProduct + { + AvatarAddress = _avatarAddress, + RegisterInfos = new List + { + new RegisterInfo + { + AvatarAddress = _avatarAddress, + Price = 1 * _currency, + TradableId = _aura.ItemId, + ItemCount = 1, + Type = ProductType.NonFungible, + }, + }, + ChargeAp = false, + }; + // Because Aura is not ITradableItem. + Assert.Throws(() => register.Execute(new ActionContext + { + Signer = _agentAddress, + PreviousState = previousState, + BlockIndex = 0L, + })); + } + private void Assert_Player(AvatarState avatarState, IAccountStateDelta state, Address avatarAddress, Address itemSlotStateAddress) { var nextAvatarState = state.GetAvatarStateV2(avatarAddress); diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index cc7ea7e12..57f7d3213 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -219,7 +219,7 @@ public void Register_And_Buy() AvatarAddress = _sellerAvatarAddress2, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -376,7 +376,7 @@ public void Register_And_Cancel() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -464,7 +464,7 @@ public void Register_And_Cancel() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new FavProductInfo { @@ -548,7 +548,7 @@ public void Register_And_ReRegister() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -654,14 +654,14 @@ public void Register_And_ReRegister() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new RegisterInfo { AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, } ), @@ -875,7 +875,7 @@ public void HardFork() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -948,7 +948,7 @@ public void HardFork() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new FavProductInfo { @@ -975,7 +975,7 @@ public void HardFork() var avatarState = canceledState.GetAvatarStateV2(_sellerAvatarAddress); Assert.Equal(2, avatarState.inventory.Items.Count); Assert.True(avatarState.inventory.TryGetTradableItem(tradableMaterial.TradableId, 0L, 1, out var materialItem)); - Assert.True(avatarState.inventory.TryGetNonFungibleItem(equipment.TradableId, out var equipmentItem)); + Assert.True(avatarState.inventory.TryGetNonFungibleItem(equipment.ItemId, out var equipmentItem)); var canceledEquipment = Assert.IsAssignableFrom(equipmentItem.item); Assert.Equal(100L, canceledEquipment.RequiredBlockIndex); Assert.Equal( @@ -1018,14 +1018,14 @@ public void HardFork() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new RegisterInfo { AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 2 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, } ), diff --git a/.Lib9c.Tests/Action/Sell10Test.cs b/.Lib9c.Tests/Action/Sell10Test.cs index 286a4fbd0..5360a8d10 100644 --- a/.Lib9c.Tests/Action/Sell10Test.cs +++ b/.Lib9c.Tests/Action/Sell10Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell11Test.cs b/.Lib9c.Tests/Action/Sell11Test.cs index 6c307e5fd..9049597dd 100644 --- a/.Lib9c.Tests/Action/Sell11Test.cs +++ b/.Lib9c.Tests/Action/Sell11Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell4Test.cs b/.Lib9c.Tests/Action/Sell4Test.cs index edaa1f8c6..60ad5026a 100644 --- a/.Lib9c.Tests/Action/Sell4Test.cs +++ b/.Lib9c.Tests/Action/Sell4Test.cs @@ -135,7 +135,7 @@ public void Execute(ItemType itemType, bool shopItemExist, int blockIndex) productId, new FungibleAssetValue(currencyState, 100, 0), blockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); ShardedShopState shardedShopState = new ShardedShopState(shopAddress); shardedShopState.Register(si); diff --git a/.Lib9c.Tests/Action/Sell5Test.cs b/.Lib9c.Tests/Action/Sell5Test.cs index 26bf1ea94..4302a6271 100644 --- a/.Lib9c.Tests/Action/Sell5Test.cs +++ b/.Lib9c.Tests/Action/Sell5Test.cs @@ -105,7 +105,7 @@ int expectedProductsCount switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -116,7 +116,7 @@ int expectedProductsCount Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); @@ -211,7 +211,7 @@ int expectedProductsCount { case ItemType.Consumable: case ItemType.Equipment: - nextTradableItemInShopItem = nextShopItem.ItemUsable; + nextTradableItemInShopItem = (ITradableItem)nextShopItem.ItemUsable; break; case ItemType.Costume: nextTradableItemInShopItem = nextShopItem.Costume; @@ -242,8 +242,8 @@ int expectedProductsCount case ItemType.Consumable: case ItemType.Equipment: Assert.NotNull(mail.attachment.itemUsable); - attachmentItem = mail.attachment.itemUsable; - Assert.Equal(tradableItem, mail.attachment.itemUsable); + attachmentItem = (ITradableItem)mail.attachment.itemUsable; + Assert.Equal((ItemUsable)tradableItem, mail.attachment.itemUsable); break; case ItemType.Costume: Assert.NotNull(mail.attachment.costume); diff --git a/.Lib9c.Tests/Action/Sell6Test.cs b/.Lib9c.Tests/Action/Sell6Test.cs index 015b9fa44..b3392ca0d 100644 --- a/.Lib9c.Tests/Action/Sell6Test.cs +++ b/.Lib9c.Tests/Action/Sell6Test.cs @@ -105,7 +105,7 @@ int expectedProductsCount switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -116,7 +116,7 @@ int expectedProductsCount Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); @@ -212,7 +212,7 @@ int expectedProductsCount { case ItemType.Consumable: case ItemType.Equipment: - nextTradableItemInShopItem = nextShopItem.ItemUsable; + nextTradableItemInShopItem = (ITradableItem)nextShopItem.ItemUsable; break; case ItemType.Costume: nextTradableItemInShopItem = nextShopItem.Costume; @@ -244,8 +244,8 @@ int expectedProductsCount case ItemType.Consumable: case ItemType.Equipment: Assert.NotNull(mail.attachment.itemUsable); - attachmentItem = mail.attachment.itemUsable; - Assert.Equal(tradableItem, mail.attachment.itemUsable); + attachmentItem = (ITradableItem)mail.attachment.itemUsable; + Assert.Equal((ItemUsable)tradableItem, mail.attachment.itemUsable); break; case ItemType.Costume: Assert.NotNull(mail.attachment.costume); @@ -455,7 +455,7 @@ public void Execute_20210604( switch (itemSubType) { case ItemSubType.Weapon: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.OrderedList.First(row => row.ItemSubType == ItemSubType.Weapon), Guid.NewGuid(), 1); @@ -542,7 +542,7 @@ public void Execute_20210604( int fungibleCount = itemCount; if (itemSubType == ItemSubType.Weapon) { - innerShopItem = nextShopItem.ItemUsable; + innerShopItem = (ITradableItem)nextShopItem.ItemUsable; fungibleCount = 0; } diff --git a/.Lib9c.Tests/Action/Sell7Test.cs b/.Lib9c.Tests/Action/Sell7Test.cs index c8e670e9c..f68ea63e8 100644 --- a/.Lib9c.Tests/Action/Sell7Test.cs +++ b/.Lib9c.Tests/Action/Sell7Test.cs @@ -104,7 +104,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -115,7 +115,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell8Test.cs b/.Lib9c.Tests/Action/Sell8Test.cs index 3bbb6e772..ab8669a9e 100644 --- a/.Lib9c.Tests/Action/Sell8Test.cs +++ b/.Lib9c.Tests/Action/Sell8Test.cs @@ -104,7 +104,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -115,7 +115,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell9Test.cs b/.Lib9c.Tests/Action/Sell9Test.cs index f4a7122de..681fbdb7f 100644 --- a/.Lib9c.Tests/Action/Sell9Test.cs +++ b/.Lib9c.Tests/Action/Sell9Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/SellCancellation0Test.cs b/.Lib9c.Tests/Action/SellCancellation0Test.cs index ad5d0f6b2..9c8a4ba1b 100644 --- a/.Lib9c.Tests/Action/SellCancellation0Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation0Test.cs @@ -72,7 +72,7 @@ public SellCancellation0Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); _initialState = _initialState .SetState(GoldCurrencyState.Address, goldCurrencyState.Serialize()) diff --git a/.Lib9c.Tests/Action/SellCancellation2Test.cs b/.Lib9c.Tests/Action/SellCancellation2Test.cs index b49430c8d..c84b29449 100644 --- a/.Lib9c.Tests/Action/SellCancellation2Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation2Test.cs @@ -74,7 +74,7 @@ public SellCancellation2Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); var result = new CombinationConsumable5.ResultModel() { diff --git a/.Lib9c.Tests/Action/SellCancellation3Test.cs b/.Lib9c.Tests/Action/SellCancellation3Test.cs index e9948fffa..c6eab1a28 100644 --- a/.Lib9c.Tests/Action/SellCancellation3Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation3Test.cs @@ -82,14 +82,14 @@ public SellCancellation3Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _agentAddress, _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation4Test.cs b/.Lib9c.Tests/Action/SellCancellation4Test.cs index 36701f914..547f01426 100644 --- a/.Lib9c.Tests/Action/SellCancellation4Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation4Test.cs @@ -82,14 +82,14 @@ public SellCancellation4Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _agentAddress, _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation5Test.cs b/.Lib9c.Tests/Action/SellCancellation5Test.cs index e3efc82ca..08ab84ac7 100644 --- a/.Lib9c.Tests/Action/SellCancellation5Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation5Test.cs @@ -124,7 +124,7 @@ public void Execute(ItemType itemType, string guid, bool contain) productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), requiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); if (contain) { @@ -240,7 +240,7 @@ public void Execute_Throw_ItemDoesNotExistException() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); IAccountStateDelta prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); @@ -279,7 +279,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState @@ -319,7 +319,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState diff --git a/.Lib9c.Tests/Action/SellCancellation6Test.cs b/.Lib9c.Tests/Action/SellCancellation6Test.cs index 0d7a88eb8..ce6bd97ae 100644 --- a/.Lib9c.Tests/Action/SellCancellation6Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation6Test.cs @@ -98,7 +98,7 @@ public void Execute(ItemType itemType, string guid, bool contain, int itemCount, _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -365,7 +365,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState @@ -405,7 +405,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState diff --git a/.Lib9c.Tests/Action/SellCancellation7Test.cs b/.Lib9c.Tests/Action/SellCancellation7Test.cs index e1b287fc7..e0cb57252 100644 --- a/.Lib9c.Tests/Action/SellCancellation7Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation7Test.cs @@ -110,7 +110,7 @@ bool backward _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -411,7 +411,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -421,7 +421,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -439,7 +439,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/SellCancellation8Test.cs b/.Lib9c.Tests/Action/SellCancellation8Test.cs index 0099e84a9..5411e0706 100644 --- a/.Lib9c.Tests/Action/SellCancellation8Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation8Test.cs @@ -110,7 +110,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -429,7 +429,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -439,7 +439,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -460,7 +460,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() @@ -555,7 +555,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/SellCancellationTest.cs b/.Lib9c.Tests/Action/SellCancellationTest.cs index 9d024c43f..4f62d0c25 100644 --- a/.Lib9c.Tests/Action/SellCancellationTest.cs +++ b/.Lib9c.Tests/Action/SellCancellationTest.cs @@ -114,7 +114,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -464,7 +464,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -474,7 +474,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -495,7 +495,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() @@ -590,7 +590,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/SellTest.cs b/.Lib9c.Tests/Action/SellTest.cs index d9a511780..5285c766a 100644 --- a/.Lib9c.Tests/Action/SellTest.cs +++ b/.Lib9c.Tests/Action/SellTest.cs @@ -98,7 +98,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -109,7 +109,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/UpdateSell0Test.cs b/.Lib9c.Tests/Action/UpdateSell0Test.cs index 615537644..0e1e29f7b 100644 --- a/.Lib9c.Tests/Action/UpdateSell0Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell0Test.cs @@ -127,7 +127,7 @@ bool legacy _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell2Test.cs b/.Lib9c.Tests/Action/UpdateSell2Test.cs index 782e2fa65..366121f52 100644 --- a/.Lib9c.Tests/Action/UpdateSell2Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell2Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell3Test.cs b/.Lib9c.Tests/Action/UpdateSell3Test.cs index 27db78341..659e289f3 100644 --- a/.Lib9c.Tests/Action/UpdateSell3Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell3Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell4Test.cs b/.Lib9c.Tests/Action/UpdateSell4Test.cs index 453a015f1..d41643560 100644 --- a/.Lib9c.Tests/Action/UpdateSell4Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell4Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSellTest.cs b/.Lib9c.Tests/Action/UpdateSellTest.cs index e5f3b27d4..276a1a8da 100644 --- a/.Lib9c.Tests/Action/UpdateSellTest.cs +++ b/.Lib9c.Tests/Action/UpdateSellTest.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Model/Item/InventoryTest.cs b/.Lib9c.Tests/Model/Item/InventoryTest.cs index b01f818be..202085466 100644 --- a/.Lib9c.Tests/Model/Item/InventoryTest.cs +++ b/.Lib9c.Tests/Model/Item/InventoryTest.cs @@ -408,7 +408,7 @@ public void RemoveTradableItem() var equipment = (Equipment)ItemFactory.CreateItem(equipmentRow, random); inventory.AddItem(equipment); Assert.Equal(2, inventory.Items.Count); - tradableItems.Add(equipment); + tradableItems.Add((ITradableItem)equipment); Assert.Equal(2, tradableItems.Count); var costumeRow = TableSheets.CostumeItemSheet.First; @@ -464,7 +464,7 @@ public void RemoveTradableItem_INonFungibleItem() Assert.Empty(inventory.Items); inventory.AddItem(itemUsable); Assert.Single(inventory.Equipments); - var tradableId = nonFungibleItem.TradableId; + var tradableId = nonFungibleItem.NonFungibleId; Assert.False(inventory.RemoveTradableItem(tradableId, 1)); Assert.True(inventory.RemoveTradableItem(tradableId, 0)); Assert.Empty(inventory.Equipments); diff --git a/.Lib9c.Tests/Model/Item/ShopItemTest.cs b/.Lib9c.Tests/Model/Item/ShopItemTest.cs index f536f984e..dd1b86f90 100644 --- a/.Lib9c.Tests/Model/Item/ShopItemTest.cs +++ b/.Lib9c.Tests/Model/Item/ShopItemTest.cs @@ -55,14 +55,14 @@ public void SerializeBackup1() public void Serialize_With_ExpiredBlockIndex(long expiredBlockIndex, bool contain) { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); var shopItem = new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), expiredBlockIndex, - equipment); + (ITradableItem)equipment); Assert.Null(shopItem.Costume); Assert.NotNull(shopItem.ItemUsable); var serialized = (BxDictionary)shopItem.Serialize(); @@ -77,28 +77,28 @@ public void Serialize_With_ExpiredBlockIndex(long expiredBlockIndex, bool contai public void ThrowArgumentOurOfRangeException() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); Assert.Throws(() => new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), -1, - equipment)); + (ITradableItem)equipment)); } [Fact] public void DeserializeThrowArgumentOurOfRangeException() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); var shopItem = new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), 0, - equipment); + (ITradableItem)equipment); Dictionary serialized = (Dictionary)shopItem.Serialize(); serialized = serialized.SetItem(ShopItem.ExpiredBlockIndexKey, "-1"); Assert.Throws(() => new ShopItem(serialized)); @@ -114,7 +114,7 @@ private static ShopItem[] GetShopItems() => new[] private static ShopItem GetShopItemWithFirstCostume() { var costumeRow = _tableSheets.CostumeItemSheet.First; - var costume = new Costume(costumeRow, Guid.NewGuid()); + var costume = ItemFactory.CreateCostume(costumeRow, Guid.NewGuid()); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), @@ -126,19 +126,19 @@ private static ShopItem GetShopItemWithFirstCostume() private static ShopItem GetShopItemWithFirstEquipment() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), - equipment); + (ITradableItem)equipment); } private static ShopItem GetShopItemWithFirstMaterial() { var row = _tableSheets.MaterialItemSheet.First; - var tradableMaterial = new TradableMaterial(row); + var tradableMaterial = ItemFactory.CreateTradableMaterial(row); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), diff --git a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs index c9b72f198..9ceee101b 100644 --- a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs +++ b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs @@ -290,7 +290,7 @@ public void Digest(ItemSubType itemSubType, bool add, Type exc) if (exc is null) { - int cp = CPHelper.GetCP(tradableItem, _tableSheets.CostumeStatSheet); + int cp = tradableItem is INonFungibleItem nonFungibleItem ? CPHelper.GetCP(nonFungibleItem, _tableSheets.CostumeStatSheet) : 0; Assert.True(cp > 0); OrderDigest digest = order.Digest2(_avatarState, _tableSheets.CostumeStatSheet); diff --git a/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs b/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs index d40bd9cba..557968579 100644 --- a/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs +++ b/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs @@ -31,7 +31,7 @@ public void Create(ItemType itemType, long blockIndex, Order.OrderType orderType switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, itemId, 0); @@ -42,7 +42,7 @@ public void Create(ItemType itemType, long blockIndex, Order.OrderType orderType itemId); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, 0); @@ -109,7 +109,7 @@ public void Deserialize(ItemType itemType, long blockIndex, Order.OrderType orde switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -120,7 +120,7 @@ public void Deserialize(ItemType itemType, long blockIndex, Order.OrderType orde Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/Lib9c/Action/Buy6.cs b/Lib9c/Action/Buy6.cs index 4000559ea..9d552a777 100644 --- a/Lib9c/Action/Buy6.cs +++ b/Lib9c/Action/Buy6.cs @@ -251,7 +251,7 @@ public override IAccountStateDelta Execute(IActionContext context) int count = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Action/Buy7.cs b/Lib9c/Action/Buy7.cs index b77e5db77..4095cf8ad 100644 --- a/Lib9c/Action/Buy7.cs +++ b/Lib9c/Action/Buy7.cs @@ -378,7 +378,7 @@ public override IAccountStateDelta Execute(IActionContext context) int count = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index 358070c4a..2c59913a4 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -163,7 +163,7 @@ public static IAccountStateDelta Register(IActionContext context, IRegisterInfo out var item) && avatarState.inventory.RemoveNonFungibleItem(tradableId)) { - tradableItem = (ITradableItem) item.item; + tradableItem = item.item as ITradableItem; } break; diff --git a/Lib9c/Action/Sell0.cs b/Lib9c/Action/Sell0.cs index 821fe2cc8..897863369 100644 --- a/Lib9c/Action/Sell0.cs +++ b/Lib9c/Action/Sell0.cs @@ -123,7 +123,7 @@ public override IAccountStateDelta Execute(IActionContext context) sellerAvatarAddress, productId, price, - nonFungibleItem); + (ITradableItem)nonFungibleItem); IValue shopItemSerialized = shopItem.Serialize(); IKey productIdSerialized = (IKey)productId.Serialize(); diff --git a/Lib9c/Action/Sell2.cs b/Lib9c/Action/Sell2.cs index 59ae0a579..53c261e6e 100644 --- a/Lib9c/Action/Sell2.cs +++ b/Lib9c/Action/Sell2.cs @@ -117,7 +117,7 @@ public override IAccountStateDelta Execute(IActionContext context) sellerAvatarAddress, productId, price, - equipment); + (ITradableItem)equipment); } else if (avatarState.inventory.TryGetNonFungibleItem(itemId, out var costume)) { diff --git a/Lib9c/Action/Sell3.cs b/Lib9c/Action/Sell3.cs index b2a7f7dfe..0b7daa3b6 100644 --- a/Lib9c/Action/Sell3.cs +++ b/Lib9c/Action/Sell3.cs @@ -113,7 +113,7 @@ ShopItem PopShopItemFromInventory(ItemUsable itemUsable, Costume costume) avatarState.inventory.RemoveNonFungibleItem(itemId); return itemUsable is null ? new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, costume) - : new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, itemUsable); + : new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, (ITradableItem)itemUsable); } // Select an item to sell from the inventory and adjust the quantity. diff --git a/Lib9c/Action/Sell4.cs b/Lib9c/Action/Sell4.cs index 8e2faa8ab..4acea2266 100644 --- a/Lib9c/Action/Sell4.cs +++ b/Lib9c/Action/Sell4.cs @@ -130,7 +130,7 @@ public override IAccountStateDelta Execute(IActionContext context) } nonFungibleItem.RequiredBlockIndex = expiredBlockIndex; - ShopItem shopItem = new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, expiredBlockIndex, nonFungibleItem); + ShopItem shopItem = new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, expiredBlockIndex, (ITradableItem)nonFungibleItem); Address shardedShopAddress = ShardedShopState.DeriveAddress(itemSubType, productId); if (!states.TryGetState(shardedShopAddress, out Bencodex.Types.Dictionary shopStateDict)) { diff --git a/Lib9c/Action/SellCancellation6.cs b/Lib9c/Action/SellCancellation6.cs index 3d9af5980..6d8fb3e75 100644 --- a/Lib9c/Action/SellCancellation6.cs +++ b/Lib9c/Action/SellCancellation6.cs @@ -157,7 +157,7 @@ public override IAccountStateDelta Execute(IActionContext context) int itemCount = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Battle/CPHelper.cs b/Lib9c/Battle/CPHelper.cs index 4aede072d..a59e48a52 100644 --- a/Lib9c/Battle/CPHelper.cs +++ b/Lib9c/Battle/CPHelper.cs @@ -108,7 +108,7 @@ public static int GetCP(Costume costume, CostumeStatSheet sheet) } [Obsolete("Use GetCp")] - public static int GetCP(ITradableItem tradableItem, CostumeStatSheet sheet) + public static int GetCP(INonFungibleItem tradableItem, CostumeStatSheet sheet) { if (tradableItem is ItemUsable itemUsable) { diff --git a/Lib9c/Model/Item/Armor.cs b/Lib9c/Model/Item/Armor.cs index 7a56f69fd..a6b5cb689 100644 --- a/Lib9c/Model/Item/Armor.cs +++ b/Lib9c/Model/Item/Armor.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Armor : Equipment + public class Armor : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Armor(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) { diff --git a/Lib9c/Model/Item/Belt.cs b/Lib9c/Model/Item/Belt.cs index 799c82565..83e25814d 100644 --- a/Lib9c/Model/Item/Belt.cs +++ b/Lib9c/Model/Item/Belt.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Belt : Equipment + public class Belt : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Belt(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Consumable.cs b/Lib9c/Model/Item/Consumable.cs index 44589d00d..368c73686 100644 --- a/Lib9c/Model/Item/Consumable.cs +++ b/Lib9c/Model/Item/Consumable.cs @@ -10,8 +10,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Consumable : ItemUsable + public class Consumable : ItemUsable, ITradableItem { + public Guid TradableId => ItemId; + public StatType MainStat => Stats.Any() ? Stats[0].StatType : StatType.NONE; public List Stats { get; } diff --git a/Lib9c/Model/Item/Costume.cs b/Lib9c/Model/Item/Costume.cs index 41cc07f65..673f2f734 100644 --- a/Lib9c/Model/Item/Costume.cs +++ b/Lib9c/Model/Item/Costume.cs @@ -10,7 +10,7 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Costume : ItemBase, INonFungibleItem, IEquippableItem + public class Costume : ItemBase, INonFungibleItem, IEquippableItem, ITradableItem { // FIXME: Whether the equipment is equipped or not has no asset value and must be removed from the state. public bool equipped = false; diff --git a/Lib9c/Model/Item/INonFungibleItem.cs b/Lib9c/Model/Item/INonFungibleItem.cs index e38af07c1..4fde12959 100644 --- a/Lib9c/Model/Item/INonFungibleItem.cs +++ b/Lib9c/Model/Item/INonFungibleItem.cs @@ -2,8 +2,9 @@ namespace Nekoyume.Model.Item { - public interface INonFungibleItem: ITradableItem + public interface INonFungibleItem: IItem { Guid NonFungibleId { get; } + long RequiredBlockIndex { get; set; } } } diff --git a/Lib9c/Model/Item/ItemUsable.cs b/Lib9c/Model/Item/ItemUsable.cs index 60aa40962..7d0315095 100644 --- a/Lib9c/Model/Item/ItemUsable.cs +++ b/Lib9c/Model/Item/ItemUsable.cs @@ -28,7 +28,6 @@ public Guid ItemId } } - public Guid TradableId => ItemId; public Guid NonFungibleId => ItemId; public StatsMap StatsMap diff --git a/Lib9c/Model/Item/Necklace.cs b/Lib9c/Model/Item/Necklace.cs index 968165f02..78497d43e 100644 --- a/Lib9c/Model/Item/Necklace.cs +++ b/Lib9c/Model/Item/Necklace.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Necklace : Equipment + public class Necklace : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Necklace(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Ring.cs b/Lib9c/Model/Item/Ring.cs index 1d8efeb79..d66740c41 100644 --- a/Lib9c/Model/Item/Ring.cs +++ b/Lib9c/Model/Item/Ring.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Ring : Equipment + public class Ring : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Ring(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Weapon.cs b/Lib9c/Model/Item/Weapon.cs index accbd8dac..ea2756f83 100644 --- a/Lib9c/Model/Item/Weapon.cs +++ b/Lib9c/Model/Item/Weapon.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Weapon : Equipment + public class Weapon : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Weapon(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Order/FungibleOrder.cs b/Lib9c/Model/Order/FungibleOrder.cs index 438b40331..be5d94d85 100644 --- a/Lib9c/Model/Order/FungibleOrder.cs +++ b/Lib9c/Model/Order/FungibleOrder.cs @@ -213,7 +213,7 @@ public override OrderDigest Digest(AvatarState avatarState, CostumeStatSheet cos if (avatarState.inventory.TryGetLockedItem(new OrderLock(OrderId), out Inventory.Item inventoryItem)) { ItemBase item = inventoryItem.item; - int cp = CPHelper.GetCP((ITradableItem) item, costumeStatSheet); + int cp = 0; int level = item is Equipment equipment ? equipment.level : 0; return new OrderDigest( SellerAgentAddress, @@ -368,7 +368,7 @@ public override OrderDigest Digest2(AvatarState avatarState, CostumeStatSheet co out Inventory.Item inventoryItem)) { ItemBase item = inventoryItem.item; - int cp = CPHelper.GetCP((ITradableItem) item, costumeStatSheet); + int cp = 0; int level = item is Equipment equipment ? equipment.level : 0; return new OrderDigest( SellerAgentAddress, diff --git a/Lib9c/Model/Order/NonFungibleOrder.cs b/Lib9c/Model/Order/NonFungibleOrder.cs index cb351e660..0c56c791b 100644 --- a/Lib9c/Model/Order/NonFungibleOrder.cs +++ b/Lib9c/Model/Order/NonFungibleOrder.cs @@ -79,7 +79,7 @@ public override ITradableItem Sell(AvatarState avatarState) equippableItem.Unequip(); } - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( @@ -97,7 +97,7 @@ public override ITradableItem Sell2(AvatarState avatarState) equippableItem.Unequip(); } - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( @@ -313,7 +313,7 @@ public override ITradableItem Cancel2(AvatarState avatarState, long blockIndex) if (avatarState.inventory.TryGetNonFungibleItem(TradableId, out INonFungibleItem nonFungibleItem)) { nonFungibleItem.RequiredBlockIndex = blockIndex; - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( $"Aborted because the tradable item({TradableId}) was failed to load from avatar's inventory."); From e6cb7ee79a65b1afaccd7d8332d8956ef92d3d55 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 18 Aug 2023 12:47:57 +0900 Subject: [PATCH 005/134] Add aura buff test --- .Lib9c.Tests/Model/PlayerTest.cs | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.Lib9c.Tests/Model/PlayerTest.cs b/.Lib9c.Tests/Model/PlayerTest.cs index 499ccbf04..d735e07e3 100644 --- a/.Lib9c.Tests/Model/PlayerTest.cs +++ b/.Lib9c.Tests/Model/PlayerTest.cs @@ -211,6 +211,60 @@ public void UseAuraSkill() Assert.Equal(prevDef - prevDef * 0.2, player.DEF); } + [Fact] + public void UseAuraBuffWithFood() + { + var defaultAttack = SkillFactory.GetV1( + _tableSheets.SkillSheet.Values.First(r => r.Id == GameConfig.DefaultAttackId), + 100, + 100 + ); + var skillRow = _tableSheets.SkillSheet[800002]; + var skill = SkillFactory.Get(skillRow, 0, 100, 0, StatType.NONE); + var foodRow = _tableSheets.ConsumableItemSheet[201000]; + var food = ItemFactory.CreateItemUsable(foodRow, Guid.NewGuid(), 0); + _avatarState.inventory.AddItem(food); + var simulator = new StageSimulator( + _random, + _avatarState, + new List + { + food.ItemId, + }, + null, + new List(), + 1, + 1, + _tableSheets.StageSheet[1], + _tableSheets.StageWaveSheet[1], + false, + 20, + _tableSheets.GetSimulatorSheets(), + _tableSheets.EnemySkillSheet, + _tableSheets.CostumeStatSheet, + StageSimulator.GetWaveRewards( + _random, + _tableSheets.StageSheet[1], + _tableSheets.MaterialItemSheet) + ); + var player = simulator.Player; + var enemy = new Enemy(player, _tableSheets.CharacterSheet.Values.First(), 1); + player.Targets.Add(enemy); + simulator.Characters = new SimplePriorityQueue(); + simulator.Characters.Enqueue(enemy, 0); + player.InitAI(); + player.OverrideSkill(skill); + player.AddSkill(defaultAttack); + Assert.Equal(2, player.Skills.Count()); + var prevCri = player.CRI; + var enemyPrevCri = enemy.CRI; + player.Tick(); + Assert.NotEmpty(simulator.Log); + Assert.Equal(nameof(WaveTurnEnd), simulator.Log.Last().GetType().Name); + Assert.Equal(prevCri + prevCri * 0.2, player.CRI); + Assert.Equal(enemyPrevCri / 2, enemy.CRI); + } + [Fact] public void SetCostumeStat() { From 42dba7eabb8e56941ca10b709d949cff94411884 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 25 Aug 2023 13:45:06 +0900 Subject: [PATCH 006/134] Revert "Merge pull request #2096 from planetarium/revert-itradable" This reverts commit 0e4f6bc0586343789f176e7e897658bba9831011, reversing changes made to 8dd516f46e4eef977438590f7f4b07da7b57b6b0. --- .Lib9c.Tests/Action/Buy10Test.cs | 2 +- .Lib9c.Tests/Action/Buy11Test.cs | 2 +- .Lib9c.Tests/Action/Buy2Test.cs | 2 +- .Lib9c.Tests/Action/Buy3Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy4Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy5Test.cs | 6 ++--- .Lib9c.Tests/Action/Buy6Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy7Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy8Test.cs | 2 +- .Lib9c.Tests/Action/Buy9Test.cs | 2 +- .Lib9c.Tests/Action/BuyMultipleTest.cs | 6 ++--- .Lib9c.Tests/Action/BuyProduct0Test.cs | 2 +- .Lib9c.Tests/Action/BuyProductTest.cs | 2 +- .Lib9c.Tests/Action/BuyTest.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 4 ++-- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 4 ++-- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 5 +++-- .Lib9c.Tests/Action/ReRegisterProduct0Test.cs | 2 +- .Lib9c.Tests/Action/ReRegisterProductTest.cs | 2 +- .Lib9c.Tests/Action/RegisterProduct0Test.cs | 4 ++-- .Lib9c.Tests/Action/RegisterProductTest.cs | 4 ++-- .../Action/Scenario/AuraScenarioTest.cs | 5 ++++- .../Action/Scenario/MarketScenarioTest.cs | 22 +++++++++---------- .Lib9c.Tests/Action/Sell10Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell11Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell4Test.cs | 2 +- .Lib9c.Tests/Action/Sell5Test.cs | 10 ++++----- .Lib9c.Tests/Action/Sell6Test.cs | 14 ++++++------ .Lib9c.Tests/Action/Sell7Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell8Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell9Test.cs | 4 ++-- .Lib9c.Tests/Action/SellCancellation0Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation2Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation3Test.cs | 4 ++-- .Lib9c.Tests/Action/SellCancellation4Test.cs | 4 ++-- .Lib9c.Tests/Action/SellCancellation5Test.cs | 8 +++---- .Lib9c.Tests/Action/SellCancellation6Test.cs | 6 ++--- .Lib9c.Tests/Action/SellCancellation7Test.cs | 8 +++---- .Lib9c.Tests/Action/SellCancellation8Test.cs | 10 ++++----- .Lib9c.Tests/Action/SellCancellationTest.cs | 10 ++++----- .Lib9c.Tests/Action/SellTest.cs | 4 ++-- .Lib9c.Tests/Action/UpdateSell0Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell2Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell3Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell4Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSellTest.cs | 2 +- .Lib9c.Tests/Model/Item/InventoryTest.cs | 4 ++-- .Lib9c.Tests/Model/Item/ShopItemTest.cs | 20 ++++++++--------- .../Model/Order/NonFungibleOrderTest.cs | 2 +- .Lib9c.Tests/Model/Order/OrderFactoryTest.cs | 8 +++---- Lib9c/Action/Buy6.cs | 2 +- Lib9c/Action/Buy7.cs | 2 +- Lib9c/Action/RegisterProduct.cs | 2 +- Lib9c/Action/Sell0.cs | 2 +- Lib9c/Action/Sell2.cs | 2 +- Lib9c/Action/Sell3.cs | 2 +- Lib9c/Action/Sell4.cs | 2 +- Lib9c/Action/SellCancellation6.cs | 2 +- Lib9c/Battle/CPHelper.cs | 2 +- Lib9c/Model/Item/Armor.cs | 4 +++- Lib9c/Model/Item/Belt.cs | 4 +++- Lib9c/Model/Item/Consumable.cs | 4 +++- Lib9c/Model/Item/Costume.cs | 2 +- Lib9c/Model/Item/INonFungibleItem.cs | 3 ++- Lib9c/Model/Item/ItemUsable.cs | 1 - Lib9c/Model/Item/Necklace.cs | 4 +++- Lib9c/Model/Item/Ring.cs | 4 +++- Lib9c/Model/Item/Weapon.cs | 4 +++- Lib9c/Model/Order/FungibleOrder.cs | 4 ++-- Lib9c/Model/Order/NonFungibleOrder.cs | 6 ++--- 70 files changed, 159 insertions(+), 143 deletions(-) diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 11410af01..7ca2769f7 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -239,7 +239,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index 8e29e06c5..8eec859fc 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -245,7 +245,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index 5aeb37272..efe20dbe1 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -98,7 +98,7 @@ public Buy2Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); var result = new CombinationConsumable5.ResultModel() { diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index bc131c380..0aa7c0188 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -108,14 +108,14 @@ public Buy3Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _sellerAgentAddress, _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _sellerAgentAddress, diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index 4210222b1..a1f6a85cd 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -110,14 +110,14 @@ public Buy4Test(ITestOutputHelper outputHelper) _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _sellerAgentAddress, _sellerAvatarAddress, Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, ProductPrice, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _sellerAgentAddress, diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index 5986afb61..130cc6d93 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -210,7 +210,7 @@ public void Execute(params ShopItemData[] shopItemMembers) productId, new FungibleAssetValue(_goldCurrencyState.Currency, shopItemData.Price, 0), requiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); // Case for backward compatibility. if (shopItemData.ContainsInInventory) @@ -454,7 +454,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); @@ -506,7 +506,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index c43688721..f4c6bdb9e 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -213,7 +213,7 @@ public void Execute(params ShopItemData[] shopItemMembers) _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (shopItemData.ItemType == ItemType.Costume) @@ -581,7 +581,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index e565bbcdc..b49c5e658 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -213,7 +213,7 @@ public void Execute(params ShopItemData[] shopItemMembers) _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (shopItemData.ItemType == ItemType.Costume) @@ -652,7 +652,7 @@ public void Execute_ErrorCode_InsufficientBalance() _productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); ShardedShopState shopState = new ShardedShopState(shardedShopAddress); shopState.Register(shopItem); diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index c11c8da02..1d772d1f5 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -207,7 +207,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index 27401158a..91067cff5 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -294,7 +294,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index 7be32d6d8..889e0e269 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -275,7 +275,7 @@ public void Execute(params ShopItemData[] productDatas) shopItemId, new FungibleAssetValue(_goldCurrencyState.Currency, product.Price, 0), product.RequiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); shopState.Register(shopItem); if (product.Buy) @@ -504,7 +504,7 @@ public void ExecuteInsufficientBalanceError() Guid.NewGuid(), new FungibleAssetValue(_goldCurrencyState.Currency, 1, 0), 100, - equipment)); + (ITradableItem)equipment)); var costume = ItemFactory.CreateCostume( _tableSheets.CostumeItemSheet.First, @@ -574,7 +574,7 @@ public void ExecuteThrowShopItemExpiredError() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), 10, - equipment)); + (ITradableItem)equipment)); previousStates = previousStates .SetState(Addresses.Shop, shopState.Serialize()); diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index 81f97d56d..b690173d0 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -28,7 +28,7 @@ public class BuyProduct0Test private static readonly Currency Gold = Currency.Legacy("NCG", 2, null); private static readonly TableSheets TableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); private static readonly ITradableItem TradableItem = - ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); + (ITradableItem)ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); private readonly Address _sellerAgentAddress2; private readonly Address _sellerAvatarAddress2; diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index b6c96ff91..5c1b9a89f 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -28,7 +28,7 @@ public class BuyProductTest private static readonly Currency Gold = Currency.Legacy("NCG", 2, null); private static readonly TableSheets TableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); private static readonly ITradableItem TradableItem = - ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); + (ITradableItem)ItemFactory.CreateItemUsable(TableSheets.EquipmentItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Armor), Guid.NewGuid(), 1L); private readonly Address _sellerAgentAddress2; private readonly Address _sellerAvatarAddress2; diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index ef905ddcc..883ac45b1 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -240,7 +240,7 @@ public void Execute(params OrderData[] orderDataList) _tableSheets.EquipmentItemSheet.First, itemId, 0); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (orderData.ItemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 2ce649177..742bbf99c 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -192,8 +192,8 @@ public void Execute(int level, int expectedGold, bool backward) break; } - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(costRow.Cost, slotResult.gold); } diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index 0ac80e315..25ebf15f6 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -186,8 +186,8 @@ public void Execute(int level, int expectedGold, bool backward) break; } - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); Assert.Equal(costRow.Cost, slotResult.gold); } diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index fd91c171a..3a673cfb2 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -289,8 +289,9 @@ public void Execute( expectedBlockIndex + 1, // +1 for execution resultEquipment.RequiredBlockIndex ); - Assert.Equal(preItemUsable.TradableId, slotResult.preItemUsable.TradableId); - Assert.Equal(preItemUsable.TradableId, resultEquipment.TradableId); + Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); + Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); + Assert.Equal(targetRow.Cost - startRow.Cost, slotResult.gold); } } } diff --git a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs index 8d52d22a4..95eed5bbb 100644 --- a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs @@ -120,7 +120,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index c46f45d37..e9c58dee1 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -120,7 +120,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index 8ed67b727..affe9346f 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -227,7 +227,7 @@ public void Execute() AvatarAddress = AvatarAddress, ItemCount = 1, Price = 1 * Gold, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -329,7 +329,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo { var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var id = Guid.NewGuid(); - tradableItem = ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); break; } diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 35a0a89c0..90be45ec6 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -227,7 +227,7 @@ public void Execute() AvatarAddress = AvatarAddress, ItemCount = 1, Price = 1 * Gold, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -330,7 +330,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo { var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var id = Guid.NewGuid(); - tradableItem = ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable(equipmentRow, id, requiredBlockIndex); break; } diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index 9303d9e99..f8864e1cc 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -14,6 +14,7 @@ namespace Lib9c.Tests.Action.Scenario using Nekoyume.Model.BattleStatus.Arena; using Nekoyume.Model.EnumType; using Nekoyume.Model.Item; + using Nekoyume.Model.Market; using Nekoyume.Model.Skill; using Nekoyume.Model.Stat; using Nekoyume.Model.State; @@ -29,6 +30,7 @@ public class AuraScenarioTest private readonly IAccountStateDelta _initialState; private readonly Aura _aura; private readonly TableSheets _tableSheets; + private readonly Currency _currency; public AuraScenarioTest() { @@ -74,11 +76,12 @@ public AuraScenarioTest() avatarState.questList.Serialize()); } + _currency = Currency.Legacy("NCG", 2, minters: null); _initialState = _initialState .SetState(_agentAddress, agentState.Serialize()) .SetState( Addresses.GoldCurrency, - new GoldCurrencyState(Currency.Legacy("NCG", 2, minters: null)).Serialize()) + new GoldCurrencyState(_currency).Serialize()) .SetState(gameConfigState.address, gameConfigState.Serialize()) .MintAsset(new ActionContext(), _agentAddress, Currencies.Crystal * 2); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index cc7ea7e12..57f7d3213 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -219,7 +219,7 @@ public void Register_And_Buy() AvatarAddress = _sellerAvatarAddress2, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -376,7 +376,7 @@ public void Register_And_Cancel() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -464,7 +464,7 @@ public void Register_And_Cancel() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new FavProductInfo { @@ -548,7 +548,7 @@ public void Register_And_ReRegister() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -654,14 +654,14 @@ public void Register_And_ReRegister() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new RegisterInfo { AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, } ), @@ -875,7 +875,7 @@ public void HardFork() AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 1 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, }, new AssetInfo @@ -948,7 +948,7 @@ public void HardFork() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new FavProductInfo { @@ -975,7 +975,7 @@ public void HardFork() var avatarState = canceledState.GetAvatarStateV2(_sellerAvatarAddress); Assert.Equal(2, avatarState.inventory.Items.Count); Assert.True(avatarState.inventory.TryGetTradableItem(tradableMaterial.TradableId, 0L, 1, out var materialItem)); - Assert.True(avatarState.inventory.TryGetNonFungibleItem(equipment.TradableId, out var equipmentItem)); + Assert.True(avatarState.inventory.TryGetNonFungibleItem(equipment.ItemId, out var equipmentItem)); var canceledEquipment = Assert.IsAssignableFrom(equipmentItem.item); Assert.Equal(100L, canceledEquipment.RequiredBlockIndex); Assert.Equal( @@ -1018,14 +1018,14 @@ public void HardFork() ProductId = nonFungibleProductId, Type = ProductType.NonFungible, ItemSubType = equipment.ItemSubType, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, }, new RegisterInfo { AvatarAddress = _sellerAvatarAddress, ItemCount = 1, Price = 2 * _currency, - TradableId = equipment.TradableId, + TradableId = equipment.ItemId, Type = ProductType.NonFungible, } ), diff --git a/.Lib9c.Tests/Action/Sell10Test.cs b/.Lib9c.Tests/Action/Sell10Test.cs index 286a4fbd0..5360a8d10 100644 --- a/.Lib9c.Tests/Action/Sell10Test.cs +++ b/.Lib9c.Tests/Action/Sell10Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell11Test.cs b/.Lib9c.Tests/Action/Sell11Test.cs index 6c307e5fd..9049597dd 100644 --- a/.Lib9c.Tests/Action/Sell11Test.cs +++ b/.Lib9c.Tests/Action/Sell11Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell4Test.cs b/.Lib9c.Tests/Action/Sell4Test.cs index edaa1f8c6..60ad5026a 100644 --- a/.Lib9c.Tests/Action/Sell4Test.cs +++ b/.Lib9c.Tests/Action/Sell4Test.cs @@ -135,7 +135,7 @@ public void Execute(ItemType itemType, bool shopItemExist, int blockIndex) productId, new FungibleAssetValue(currencyState, 100, 0), blockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); ShardedShopState shardedShopState = new ShardedShopState(shopAddress); shardedShopState.Register(si); diff --git a/.Lib9c.Tests/Action/Sell5Test.cs b/.Lib9c.Tests/Action/Sell5Test.cs index 26bf1ea94..4302a6271 100644 --- a/.Lib9c.Tests/Action/Sell5Test.cs +++ b/.Lib9c.Tests/Action/Sell5Test.cs @@ -105,7 +105,7 @@ int expectedProductsCount switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -116,7 +116,7 @@ int expectedProductsCount Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); @@ -211,7 +211,7 @@ int expectedProductsCount { case ItemType.Consumable: case ItemType.Equipment: - nextTradableItemInShopItem = nextShopItem.ItemUsable; + nextTradableItemInShopItem = (ITradableItem)nextShopItem.ItemUsable; break; case ItemType.Costume: nextTradableItemInShopItem = nextShopItem.Costume; @@ -242,8 +242,8 @@ int expectedProductsCount case ItemType.Consumable: case ItemType.Equipment: Assert.NotNull(mail.attachment.itemUsable); - attachmentItem = mail.attachment.itemUsable; - Assert.Equal(tradableItem, mail.attachment.itemUsable); + attachmentItem = (ITradableItem)mail.attachment.itemUsable; + Assert.Equal((ItemUsable)tradableItem, mail.attachment.itemUsable); break; case ItemType.Costume: Assert.NotNull(mail.attachment.costume); diff --git a/.Lib9c.Tests/Action/Sell6Test.cs b/.Lib9c.Tests/Action/Sell6Test.cs index 015b9fa44..b3392ca0d 100644 --- a/.Lib9c.Tests/Action/Sell6Test.cs +++ b/.Lib9c.Tests/Action/Sell6Test.cs @@ -105,7 +105,7 @@ int expectedProductsCount switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -116,7 +116,7 @@ int expectedProductsCount Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); @@ -212,7 +212,7 @@ int expectedProductsCount { case ItemType.Consumable: case ItemType.Equipment: - nextTradableItemInShopItem = nextShopItem.ItemUsable; + nextTradableItemInShopItem = (ITradableItem)nextShopItem.ItemUsable; break; case ItemType.Costume: nextTradableItemInShopItem = nextShopItem.Costume; @@ -244,8 +244,8 @@ int expectedProductsCount case ItemType.Consumable: case ItemType.Equipment: Assert.NotNull(mail.attachment.itemUsable); - attachmentItem = mail.attachment.itemUsable; - Assert.Equal(tradableItem, mail.attachment.itemUsable); + attachmentItem = (ITradableItem)mail.attachment.itemUsable; + Assert.Equal((ItemUsable)tradableItem, mail.attachment.itemUsable); break; case ItemType.Costume: Assert.NotNull(mail.attachment.costume); @@ -455,7 +455,7 @@ public void Execute_20210604( switch (itemSubType) { case ItemSubType.Weapon: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.OrderedList.First(row => row.ItemSubType == ItemSubType.Weapon), Guid.NewGuid(), 1); @@ -542,7 +542,7 @@ public void Execute_20210604( int fungibleCount = itemCount; if (itemSubType == ItemSubType.Weapon) { - innerShopItem = nextShopItem.ItemUsable; + innerShopItem = (ITradableItem)nextShopItem.ItemUsable; fungibleCount = 0; } diff --git a/.Lib9c.Tests/Action/Sell7Test.cs b/.Lib9c.Tests/Action/Sell7Test.cs index c8e670e9c..f68ea63e8 100644 --- a/.Lib9c.Tests/Action/Sell7Test.cs +++ b/.Lib9c.Tests/Action/Sell7Test.cs @@ -104,7 +104,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -115,7 +115,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell8Test.cs b/.Lib9c.Tests/Action/Sell8Test.cs index 3bbb6e772..ab8669a9e 100644 --- a/.Lib9c.Tests/Action/Sell8Test.cs +++ b/.Lib9c.Tests/Action/Sell8Test.cs @@ -104,7 +104,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -115,7 +115,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/Sell9Test.cs b/.Lib9c.Tests/Action/Sell9Test.cs index f4a7122de..681fbdb7f 100644 --- a/.Lib9c.Tests/Action/Sell9Test.cs +++ b/.Lib9c.Tests/Action/Sell9Test.cs @@ -99,7 +99,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -110,7 +110,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/SellCancellation0Test.cs b/.Lib9c.Tests/Action/SellCancellation0Test.cs index ad5d0f6b2..9c8a4ba1b 100644 --- a/.Lib9c.Tests/Action/SellCancellation0Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation0Test.cs @@ -72,7 +72,7 @@ public SellCancellation0Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); _initialState = _initialState .SetState(GoldCurrencyState.Address, goldCurrencyState.Serialize()) diff --git a/.Lib9c.Tests/Action/SellCancellation2Test.cs b/.Lib9c.Tests/Action/SellCancellation2Test.cs index b49430c8d..c84b29449 100644 --- a/.Lib9c.Tests/Action/SellCancellation2Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation2Test.cs @@ -74,7 +74,7 @@ public SellCancellation2Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); var result = new CombinationConsumable5.ResultModel() { diff --git a/.Lib9c.Tests/Action/SellCancellation3Test.cs b/.Lib9c.Tests/Action/SellCancellation3Test.cs index e9948fffa..c6eab1a28 100644 --- a/.Lib9c.Tests/Action/SellCancellation3Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation3Test.cs @@ -82,14 +82,14 @@ public SellCancellation3Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _agentAddress, _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation4Test.cs b/.Lib9c.Tests/Action/SellCancellation4Test.cs index 36701f914..547f01426 100644 --- a/.Lib9c.Tests/Action/SellCancellation4Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation4Test.cs @@ -82,14 +82,14 @@ public SellCancellation4Test(ITestOutputHelper outputHelper) _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - equipment)); + (ITradableItem)equipment)); shopState.Register(new ShopItem( _agentAddress, _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), - consumable)); + (ITradableItem)consumable)); shopState.Register(new ShopItem( _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation5Test.cs b/.Lib9c.Tests/Action/SellCancellation5Test.cs index e3efc82ca..08ab84ac7 100644 --- a/.Lib9c.Tests/Action/SellCancellation5Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation5Test.cs @@ -124,7 +124,7 @@ public void Execute(ItemType itemType, string guid, bool contain) productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), requiredBlockIndex, - nonFungibleItem); + (ITradableItem)nonFungibleItem); if (contain) { @@ -240,7 +240,7 @@ public void Execute_Throw_ItemDoesNotExistException() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); IAccountStateDelta prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); @@ -279,7 +279,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState @@ -319,7 +319,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState diff --git a/.Lib9c.Tests/Action/SellCancellation6Test.cs b/.Lib9c.Tests/Action/SellCancellation6Test.cs index 0d7a88eb8..ce6bd97ae 100644 --- a/.Lib9c.Tests/Action/SellCancellation6Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation6Test.cs @@ -98,7 +98,7 @@ public void Execute(ItemType itemType, string guid, bool contain, int itemCount, _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -365,7 +365,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState @@ -405,7 +405,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() productId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), Sell6.ExpiredBlockIndex, - itemUsable); + (ITradableItem)itemUsable); shopState.Register(shopItem); IAccountStateDelta prevState = _initialState diff --git a/.Lib9c.Tests/Action/SellCancellation7Test.cs b/.Lib9c.Tests/Action/SellCancellation7Test.cs index e1b287fc7..e0cb57252 100644 --- a/.Lib9c.Tests/Action/SellCancellation7Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation7Test.cs @@ -110,7 +110,7 @@ bool backward _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -411,7 +411,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -421,7 +421,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -439,7 +439,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/SellCancellation8Test.cs b/.Lib9c.Tests/Action/SellCancellation8Test.cs index 0099e84a9..5411e0706 100644 --- a/.Lib9c.Tests/Action/SellCancellation8Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation8Test.cs @@ -110,7 +110,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -429,7 +429,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -439,7 +439,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -460,7 +460,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() @@ -555,7 +555,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/SellCancellationTest.cs b/.Lib9c.Tests/Action/SellCancellationTest.cs index 9d024c43f..4f62d0c25 100644 --- a/.Lib9c.Tests/Action/SellCancellationTest.cs +++ b/.Lib9c.Tests/Action/SellCancellationTest.cs @@ -114,7 +114,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) @@ -464,7 +464,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use avatarAddress, orderId, new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0), - itemUsable.TradableId, + itemUsable.ItemId, 0, itemUsable.ItemSubType, 1 @@ -474,7 +474,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use order.StartedBlockIndex, order.ExpiredBlockIndex, orderId, - itemUsable.TradableId, + itemUsable.ItemId, order.Price, 0, 0, @@ -495,7 +495,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use orderId = orderId, sellerAvatarAddress = _avatarAddress, itemSubType = itemUsable.ItemSubType, - tradableId = itemUsable.TradableId, + tradableId = itemUsable.ItemId, }; Assert.Throws(() => action.Execute(new ActionContext() @@ -590,7 +590,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; } else if (itemType == ItemType.Costume) diff --git a/.Lib9c.Tests/Action/SellTest.cs b/.Lib9c.Tests/Action/SellTest.cs index d9a511780..5285c766a 100644 --- a/.Lib9c.Tests/Action/SellTest.cs +++ b/.Lib9c.Tests/Action/SellTest.cs @@ -98,7 +98,7 @@ bool backward switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -109,7 +109,7 @@ bool backward Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/.Lib9c.Tests/Action/UpdateSell0Test.cs b/.Lib9c.Tests/Action/UpdateSell0Test.cs index 615537644..0e1e29f7b 100644 --- a/.Lib9c.Tests/Action/UpdateSell0Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell0Test.cs @@ -127,7 +127,7 @@ bool legacy _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell2Test.cs b/.Lib9c.Tests/Action/UpdateSell2Test.cs index 782e2fa65..366121f52 100644 --- a/.Lib9c.Tests/Action/UpdateSell2Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell2Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell3Test.cs b/.Lib9c.Tests/Action/UpdateSell3Test.cs index 27db78341..659e289f3 100644 --- a/.Lib9c.Tests/Action/UpdateSell3Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell3Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSell4Test.cs b/.Lib9c.Tests/Action/UpdateSell4Test.cs index 453a015f1..d41643560 100644 --- a/.Lib9c.Tests/Action/UpdateSell4Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell4Test.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Action/UpdateSellTest.cs b/.Lib9c.Tests/Action/UpdateSellTest.cs index e5f3b27d4..276a1a8da 100644 --- a/.Lib9c.Tests/Action/UpdateSellTest.cs +++ b/.Lib9c.Tests/Action/UpdateSellTest.cs @@ -116,7 +116,7 @@ bool fromPreviousAction _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); - tradableItem = itemUsable; + tradableItem = (ITradableItem)itemUsable; itemSubType = itemUsable.ItemSubType; break; } diff --git a/.Lib9c.Tests/Model/Item/InventoryTest.cs b/.Lib9c.Tests/Model/Item/InventoryTest.cs index b01f818be..202085466 100644 --- a/.Lib9c.Tests/Model/Item/InventoryTest.cs +++ b/.Lib9c.Tests/Model/Item/InventoryTest.cs @@ -408,7 +408,7 @@ public void RemoveTradableItem() var equipment = (Equipment)ItemFactory.CreateItem(equipmentRow, random); inventory.AddItem(equipment); Assert.Equal(2, inventory.Items.Count); - tradableItems.Add(equipment); + tradableItems.Add((ITradableItem)equipment); Assert.Equal(2, tradableItems.Count); var costumeRow = TableSheets.CostumeItemSheet.First; @@ -464,7 +464,7 @@ public void RemoveTradableItem_INonFungibleItem() Assert.Empty(inventory.Items); inventory.AddItem(itemUsable); Assert.Single(inventory.Equipments); - var tradableId = nonFungibleItem.TradableId; + var tradableId = nonFungibleItem.NonFungibleId; Assert.False(inventory.RemoveTradableItem(tradableId, 1)); Assert.True(inventory.RemoveTradableItem(tradableId, 0)); Assert.Empty(inventory.Equipments); diff --git a/.Lib9c.Tests/Model/Item/ShopItemTest.cs b/.Lib9c.Tests/Model/Item/ShopItemTest.cs index f536f984e..dd1b86f90 100644 --- a/.Lib9c.Tests/Model/Item/ShopItemTest.cs +++ b/.Lib9c.Tests/Model/Item/ShopItemTest.cs @@ -55,14 +55,14 @@ public void SerializeBackup1() public void Serialize_With_ExpiredBlockIndex(long expiredBlockIndex, bool contain) { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); var shopItem = new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), expiredBlockIndex, - equipment); + (ITradableItem)equipment); Assert.Null(shopItem.Costume); Assert.NotNull(shopItem.ItemUsable); var serialized = (BxDictionary)shopItem.Serialize(); @@ -77,28 +77,28 @@ public void Serialize_With_ExpiredBlockIndex(long expiredBlockIndex, bool contai public void ThrowArgumentOurOfRangeException() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); Assert.Throws(() => new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), -1, - equipment)); + (ITradableItem)equipment)); } [Fact] public void DeserializeThrowArgumentOurOfRangeException() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); var shopItem = new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), 0, - equipment); + (ITradableItem)equipment); Dictionary serialized = (Dictionary)shopItem.Serialize(); serialized = serialized.SetItem(ShopItem.ExpiredBlockIndexKey, "-1"); Assert.Throws(() => new ShopItem(serialized)); @@ -114,7 +114,7 @@ private static ShopItem[] GetShopItems() => new[] private static ShopItem GetShopItemWithFirstCostume() { var costumeRow = _tableSheets.CostumeItemSheet.First; - var costume = new Costume(costumeRow, Guid.NewGuid()); + var costume = ItemFactory.CreateCostume(costumeRow, Guid.NewGuid()); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), @@ -126,19 +126,19 @@ private static ShopItem GetShopItemWithFirstCostume() private static ShopItem GetShopItemWithFirstEquipment() { var equipmentRow = _tableSheets.EquipmentItemSheet.First; - var equipment = new Equipment(equipmentRow, Guid.NewGuid(), 0); + var equipment = ItemFactory.CreateItemUsable(equipmentRow, Guid.NewGuid(), 0); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), Guid.NewGuid(), new FungibleAssetValue(_currency, 100, 0), - equipment); + (ITradableItem)equipment); } private static ShopItem GetShopItemWithFirstMaterial() { var row = _tableSheets.MaterialItemSheet.First; - var tradableMaterial = new TradableMaterial(row); + var tradableMaterial = ItemFactory.CreateTradableMaterial(row); return new ShopItem( new PrivateKey().ToAddress(), new PrivateKey().ToAddress(), diff --git a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs index c9b72f198..9ceee101b 100644 --- a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs +++ b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs @@ -290,7 +290,7 @@ public void Digest(ItemSubType itemSubType, bool add, Type exc) if (exc is null) { - int cp = CPHelper.GetCP(tradableItem, _tableSheets.CostumeStatSheet); + int cp = tradableItem is INonFungibleItem nonFungibleItem ? CPHelper.GetCP(nonFungibleItem, _tableSheets.CostumeStatSheet) : 0; Assert.True(cp > 0); OrderDigest digest = order.Digest2(_avatarState, _tableSheets.CostumeStatSheet); diff --git a/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs b/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs index d40bd9cba..557968579 100644 --- a/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs +++ b/.Lib9c.Tests/Model/Order/OrderFactoryTest.cs @@ -31,7 +31,7 @@ public void Create(ItemType itemType, long blockIndex, Order.OrderType orderType switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, itemId, 0); @@ -42,7 +42,7 @@ public void Create(ItemType itemType, long blockIndex, Order.OrderType orderType itemId); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, 0); @@ -109,7 +109,7 @@ public void Deserialize(ItemType itemType, long blockIndex, Order.OrderType orde switch (itemType) { case ItemType.Consumable: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.ConsumableItemSheet.First, Guid.NewGuid(), 0); @@ -120,7 +120,7 @@ public void Deserialize(ItemType itemType, long blockIndex, Order.OrderType orde Guid.NewGuid()); break; case ItemType.Equipment: - tradableItem = ItemFactory.CreateItemUsable( + tradableItem = (ITradableItem)ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); diff --git a/Lib9c/Action/Buy6.cs b/Lib9c/Action/Buy6.cs index 4000559ea..9d552a777 100644 --- a/Lib9c/Action/Buy6.cs +++ b/Lib9c/Action/Buy6.cs @@ -251,7 +251,7 @@ public override IAccountStateDelta Execute(IActionContext context) int count = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Action/Buy7.cs b/Lib9c/Action/Buy7.cs index b77e5db77..4095cf8ad 100644 --- a/Lib9c/Action/Buy7.cs +++ b/Lib9c/Action/Buy7.cs @@ -378,7 +378,7 @@ public override IAccountStateDelta Execute(IActionContext context) int count = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index 358070c4a..2c59913a4 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -163,7 +163,7 @@ public static IAccountStateDelta Register(IActionContext context, IRegisterInfo out var item) && avatarState.inventory.RemoveNonFungibleItem(tradableId)) { - tradableItem = (ITradableItem) item.item; + tradableItem = item.item as ITradableItem; } break; diff --git a/Lib9c/Action/Sell0.cs b/Lib9c/Action/Sell0.cs index 821fe2cc8..897863369 100644 --- a/Lib9c/Action/Sell0.cs +++ b/Lib9c/Action/Sell0.cs @@ -123,7 +123,7 @@ public override IAccountStateDelta Execute(IActionContext context) sellerAvatarAddress, productId, price, - nonFungibleItem); + (ITradableItem)nonFungibleItem); IValue shopItemSerialized = shopItem.Serialize(); IKey productIdSerialized = (IKey)productId.Serialize(); diff --git a/Lib9c/Action/Sell2.cs b/Lib9c/Action/Sell2.cs index 59ae0a579..53c261e6e 100644 --- a/Lib9c/Action/Sell2.cs +++ b/Lib9c/Action/Sell2.cs @@ -117,7 +117,7 @@ public override IAccountStateDelta Execute(IActionContext context) sellerAvatarAddress, productId, price, - equipment); + (ITradableItem)equipment); } else if (avatarState.inventory.TryGetNonFungibleItem(itemId, out var costume)) { diff --git a/Lib9c/Action/Sell3.cs b/Lib9c/Action/Sell3.cs index b2a7f7dfe..0b7daa3b6 100644 --- a/Lib9c/Action/Sell3.cs +++ b/Lib9c/Action/Sell3.cs @@ -113,7 +113,7 @@ ShopItem PopShopItemFromInventory(ItemUsable itemUsable, Costume costume) avatarState.inventory.RemoveNonFungibleItem(itemId); return itemUsable is null ? new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, costume) - : new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, itemUsable); + : new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, (ITradableItem)itemUsable); } // Select an item to sell from the inventory and adjust the quantity. diff --git a/Lib9c/Action/Sell4.cs b/Lib9c/Action/Sell4.cs index 8e2faa8ab..4acea2266 100644 --- a/Lib9c/Action/Sell4.cs +++ b/Lib9c/Action/Sell4.cs @@ -130,7 +130,7 @@ public override IAccountStateDelta Execute(IActionContext context) } nonFungibleItem.RequiredBlockIndex = expiredBlockIndex; - ShopItem shopItem = new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, expiredBlockIndex, nonFungibleItem); + ShopItem shopItem = new ShopItem(ctx.Signer, sellerAvatarAddress, productId, price, expiredBlockIndex, (ITradableItem)nonFungibleItem); Address shardedShopAddress = ShardedShopState.DeriveAddress(itemSubType, productId); if (!states.TryGetState(shardedShopAddress, out Bencodex.Types.Dictionary shopStateDict)) { diff --git a/Lib9c/Action/SellCancellation6.cs b/Lib9c/Action/SellCancellation6.cs index 3d9af5980..6d8fb3e75 100644 --- a/Lib9c/Action/SellCancellation6.cs +++ b/Lib9c/Action/SellCancellation6.cs @@ -157,7 +157,7 @@ public override IAccountStateDelta Execute(IActionContext context) int itemCount = 1; if (!(shopItem.ItemUsable is null)) { - tradableItem = shopItem.ItemUsable; + tradableItem = (ITradableItem)shopItem.ItemUsable; } else if (!(shopItem.Costume is null)) { diff --git a/Lib9c/Battle/CPHelper.cs b/Lib9c/Battle/CPHelper.cs index 4aede072d..a59e48a52 100644 --- a/Lib9c/Battle/CPHelper.cs +++ b/Lib9c/Battle/CPHelper.cs @@ -108,7 +108,7 @@ public static int GetCP(Costume costume, CostumeStatSheet sheet) } [Obsolete("Use GetCp")] - public static int GetCP(ITradableItem tradableItem, CostumeStatSheet sheet) + public static int GetCP(INonFungibleItem tradableItem, CostumeStatSheet sheet) { if (tradableItem is ItemUsable itemUsable) { diff --git a/Lib9c/Model/Item/Armor.cs b/Lib9c/Model/Item/Armor.cs index 7a56f69fd..a6b5cb689 100644 --- a/Lib9c/Model/Item/Armor.cs +++ b/Lib9c/Model/Item/Armor.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Armor : Equipment + public class Armor : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Armor(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) { diff --git a/Lib9c/Model/Item/Belt.cs b/Lib9c/Model/Item/Belt.cs index 799c82565..83e25814d 100644 --- a/Lib9c/Model/Item/Belt.cs +++ b/Lib9c/Model/Item/Belt.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Belt : Equipment + public class Belt : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Belt(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Consumable.cs b/Lib9c/Model/Item/Consumable.cs index 44589d00d..368c73686 100644 --- a/Lib9c/Model/Item/Consumable.cs +++ b/Lib9c/Model/Item/Consumable.cs @@ -10,8 +10,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Consumable : ItemUsable + public class Consumable : ItemUsable, ITradableItem { + public Guid TradableId => ItemId; + public StatType MainStat => Stats.Any() ? Stats[0].StatType : StatType.NONE; public List Stats { get; } diff --git a/Lib9c/Model/Item/Costume.cs b/Lib9c/Model/Item/Costume.cs index 41cc07f65..673f2f734 100644 --- a/Lib9c/Model/Item/Costume.cs +++ b/Lib9c/Model/Item/Costume.cs @@ -10,7 +10,7 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Costume : ItemBase, INonFungibleItem, IEquippableItem + public class Costume : ItemBase, INonFungibleItem, IEquippableItem, ITradableItem { // FIXME: Whether the equipment is equipped or not has no asset value and must be removed from the state. public bool equipped = false; diff --git a/Lib9c/Model/Item/INonFungibleItem.cs b/Lib9c/Model/Item/INonFungibleItem.cs index e38af07c1..4fde12959 100644 --- a/Lib9c/Model/Item/INonFungibleItem.cs +++ b/Lib9c/Model/Item/INonFungibleItem.cs @@ -2,8 +2,9 @@ namespace Nekoyume.Model.Item { - public interface INonFungibleItem: ITradableItem + public interface INonFungibleItem: IItem { Guid NonFungibleId { get; } + long RequiredBlockIndex { get; set; } } } diff --git a/Lib9c/Model/Item/ItemUsable.cs b/Lib9c/Model/Item/ItemUsable.cs index 60aa40962..7d0315095 100644 --- a/Lib9c/Model/Item/ItemUsable.cs +++ b/Lib9c/Model/Item/ItemUsable.cs @@ -28,7 +28,6 @@ public Guid ItemId } } - public Guid TradableId => ItemId; public Guid NonFungibleId => ItemId; public StatsMap StatsMap diff --git a/Lib9c/Model/Item/Necklace.cs b/Lib9c/Model/Item/Necklace.cs index 968165f02..78497d43e 100644 --- a/Lib9c/Model/Item/Necklace.cs +++ b/Lib9c/Model/Item/Necklace.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Necklace : Equipment + public class Necklace : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Necklace(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Ring.cs b/Lib9c/Model/Item/Ring.cs index 1d8efeb79..d66740c41 100644 --- a/Lib9c/Model/Item/Ring.cs +++ b/Lib9c/Model/Item/Ring.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Ring : Equipment + public class Ring : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Ring(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Item/Weapon.cs b/Lib9c/Model/Item/Weapon.cs index accbd8dac..ea2756f83 100644 --- a/Lib9c/Model/Item/Weapon.cs +++ b/Lib9c/Model/Item/Weapon.cs @@ -6,8 +6,10 @@ namespace Nekoyume.Model.Item { [Serializable] - public class Weapon : Equipment + public class Weapon : Equipment, ITradableItem { + public Guid TradableId => ItemId; + public Weapon(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex, bool madeWithMimisbrunnrRecipe = false) : base(data, id, requiredBlockIndex, madeWithMimisbrunnrRecipe) diff --git a/Lib9c/Model/Order/FungibleOrder.cs b/Lib9c/Model/Order/FungibleOrder.cs index 438b40331..be5d94d85 100644 --- a/Lib9c/Model/Order/FungibleOrder.cs +++ b/Lib9c/Model/Order/FungibleOrder.cs @@ -213,7 +213,7 @@ public override OrderDigest Digest(AvatarState avatarState, CostumeStatSheet cos if (avatarState.inventory.TryGetLockedItem(new OrderLock(OrderId), out Inventory.Item inventoryItem)) { ItemBase item = inventoryItem.item; - int cp = CPHelper.GetCP((ITradableItem) item, costumeStatSheet); + int cp = 0; int level = item is Equipment equipment ? equipment.level : 0; return new OrderDigest( SellerAgentAddress, @@ -368,7 +368,7 @@ public override OrderDigest Digest2(AvatarState avatarState, CostumeStatSheet co out Inventory.Item inventoryItem)) { ItemBase item = inventoryItem.item; - int cp = CPHelper.GetCP((ITradableItem) item, costumeStatSheet); + int cp = 0; int level = item is Equipment equipment ? equipment.level : 0; return new OrderDigest( SellerAgentAddress, diff --git a/Lib9c/Model/Order/NonFungibleOrder.cs b/Lib9c/Model/Order/NonFungibleOrder.cs index cb351e660..0c56c791b 100644 --- a/Lib9c/Model/Order/NonFungibleOrder.cs +++ b/Lib9c/Model/Order/NonFungibleOrder.cs @@ -79,7 +79,7 @@ public override ITradableItem Sell(AvatarState avatarState) equippableItem.Unequip(); } - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( @@ -97,7 +97,7 @@ public override ITradableItem Sell2(AvatarState avatarState) equippableItem.Unequip(); } - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( @@ -313,7 +313,7 @@ public override ITradableItem Cancel2(AvatarState avatarState, long blockIndex) if (avatarState.inventory.TryGetNonFungibleItem(TradableId, out INonFungibleItem nonFungibleItem)) { nonFungibleItem.RequiredBlockIndex = blockIndex; - return nonFungibleItem; + return (ITradableItem)nonFungibleItem; } throw new ItemDoesNotExistException( $"Aborted because the tradable item({TradableId}) was failed to load from avatar's inventory."); From 66a0c4c7fdea5355a86467c40c92819e3f9b0cca Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Aug 2023 15:39:09 +0900 Subject: [PATCH 007/134] Add dummy data for aura summon --- Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv | 9 ++++++++- Lib9c/TableCSV/Item/EquipmentItemSheet.csv | 7 +++++++ Lib9c/TableCSV/Item/MaterialItemSheet.csv | 1 + Lib9c/TableCSV/Summon/AuraSummonSheet.csv | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Lib9c/TableCSV/Summon/AuraSummonSheet.csv diff --git a/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv b/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv index c9a2dc445..6336c1086 100644 --- a/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv +++ b/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv @@ -168,4 +168,11 @@ id,result_equipment_id,material_id,material_count,required_action_point,required 167,10451001,303304,360,0,0,3000,320,104510011,104510012,,500000,Necklace 168,10452001,303304,360,0,0,3000,320,104520011,104520012,104520013,1000000,Necklace 169,10453001,303304,360,0,0,3000,335,104530011,104530012,,1000000,Necklace -170,10454001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace \ No newline at end of file +170,10454001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +171,10620000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +172,10630000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +173,10640000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +174,10620001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +175,10630001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +176,10640001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +177,10650001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace diff --git a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv index 18ed960a0..de812fac6 100644 --- a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv +++ b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv @@ -168,6 +168,13 @@ id,_name,item_sub_type,grade,elemental_type,set_id,stat_type,stat_value,attack_r 10552000,고대의 반지(물),Ring,5,Water,13,DEF,1209,0,10552000 10553000,고대의 반지(땅),Ring,5,Land,14,DEF,1946,0,10553000 10554000,고대의 반지(바람),Ring,5,Wind,15,DEF,1946,0,10554000 +10620000,AuraSummon1,Ring,5,Wind,15,DEF,1946,0,10554000 +10620001,AuraSummon2,Ring,5,Wind,15,DEF,1946,0,10554000 +10630000,AuraSummon3,Ring,5,Wind,15,DEF,1946,0,10554000 +10630001,AuraSummon4,Ring,5,Wind,15,DEF,1946,0,10554000 +10640000,AuraSummon5,Ring,5,Wind,15,DEF,1946,0,10554000 +10640001,AuraSummon6,Ring,5,Wind,15,DEF,1946,0,10554000 +10650001,AuraSummon7,Ring,5,Wind,15,DEF,1946,0,10554000 11320000,블루 사파이어 벨트,Belt,2,Normal,6,SPD,176,2,11320000 11420000,블루 사파이어 목걸이,Necklace,2,Normal,6,HIT,227,0,11420000 11520000,블루 사파이어 반지,Ring,2,Normal,6,DEF,50,0,11520000 diff --git a/Lib9c/TableCSV/Item/MaterialItemSheet.csv b/Lib9c/TableCSV/Item/MaterialItemSheet.csv index d8471eaea..cccaac0aa 100644 --- a/Lib9c/TableCSV/Item/MaterialItemSheet.csv +++ b/Lib9c/TableCSV/Item/MaterialItemSheet.csv @@ -165,6 +165,7 @@ id,_name,item_sub_type,grade,elemental_type 600103,Special Crystal Ore,EquipmentMaterial,3,Normal 600104,Special Crystal Jewel,EquipmentMaterial,4,Normal 600201,황금 가루,EquipmentMaterial,4,Normal +600202,Aura 가루,EquipmentMaterial,4,Normal 700000,아레나 시즌0 메달,NormalMaterial,5,Normal 700001,아레나 시즌1 메달,NormalMaterial,5,Normal 700002,아레나 시즌2 메달,NormalMaterial,5,Normal diff --git a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv new file mode 100644 index 000000000..727e1164b --- /dev/null +++ b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv @@ -0,0 +1,4 @@ +groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe2ID,recipe2ratio,recipe3ID,recipe3ratio,recipe4ID,recipe4ratio,recipe5ID,recipe5ratio,recipe6ID,recipe6ratio +10001,600201,2,0,10620000,70,10630000,29,10640000,1,,,,,, +10002,600202,2,0,10620001,50,10630001,30,10640001,17,10650001,3,,,, +,, From 0a6c5f237a8238dfe08c64c4f9190b37d5612bcb Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Aug 2023 15:40:38 +0900 Subject: [PATCH 008/134] Add TableData for AuraSummon --- .Lib9c.Tests/TableSheets.cs | 3 + Lib9c/TableData/Summon/AuraSummonSheet.cs | 76 +++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 Lib9c/TableData/Summon/AuraSummonSheet.cs diff --git a/.Lib9c.Tests/TableSheets.cs b/.Lib9c.Tests/TableSheets.cs index 96e46ad40..b8db4c065 100644 --- a/.Lib9c.Tests/TableSheets.cs +++ b/.Lib9c.Tests/TableSheets.cs @@ -9,6 +9,7 @@ namespace Lib9c.Tests using Nekoyume.TableData.Garages; using Nekoyume.TableData.GrandFinale; using Nekoyume.TableData.Pet; + using Nekoyume.TableData.Summon; public class TableSheets { @@ -229,6 +230,8 @@ public StakeActionPointCoefficientSheet StakeActionPointCoefficientSheet public LoadIntoMyGaragesCostSheet LoadIntoMyGaragesCostSheet { get; private set; } + public AuraSummonSheet AuraSummonSheet { get; private set; } + public void ItemSheetInitialize() { ItemSheet ??= new ItemSheet(); diff --git a/Lib9c/TableData/Summon/AuraSummonSheet.cs b/Lib9c/TableData/Summon/AuraSummonSheet.cs new file mode 100644 index 000000000..4f2f05884 --- /dev/null +++ b/Lib9c/TableData/Summon/AuraSummonSheet.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using Bencodex.Types; +using static Nekoyume.TableData.TableExtensions; + +namespace Nekoyume.TableData.Summon +{ + public class AuraSummonSheet : Sheet + { + public class Row : SheetRow + { + public override int Key => GroupId; + + public int GroupId { get; private set; } + public int CostMaterial { get; private set; } + public int CostMaterialCount { get; private set; } + public int CostNcg { get; private set; } + public int Recipe1 { get; private set; } + public int Recipe2 { get; private set; } + public int Recipe3 { get; private set; } + public int Recipe4 { get; private set; } + public int Recipe5 { get; private set; } + public int Recipe6 { get; private set; } + public int Recipe1Ratio { get; private set; } + public int Recipe2Ratio { get; private set; } + public int Recipe3Ratio { get; private set; } + public int Recipe4Ratio { get; private set; } + public int Recipe5Ratio { get; private set; } + public int Recipe6Ratio { get; private set; } + + // For convenience + public int CumulativeRecipe1Ratio { get; private set; } + public int CumulativeRecipe2Ratio { get; private set; } + public int CumulativeRecipe3Ratio { get; private set; } + public int CumulativeRecipe4Ratio { get; private set; } + public int CumulativeRecipe5Ratio { get; private set; } + public int CumulativeRecipe6Ratio { get; private set; } + + public override void Set(IReadOnlyList fields) + { + GroupId = ParseInt(fields[0]); + CostMaterial = ParseInt(fields[1]); + CostMaterialCount = ParseInt(fields[2]); + CostNcg = ParseInt(fields[3]); + // WARNING: Be aware of fields index!! + Recipe1 = ParseInt(fields[4]); + Recipe2 = ParseInt(fields[6]); + Recipe3 = TryParseInt(fields[8], out _) ? ParseInt(fields[8]) : 0; + Recipe4 = TryParseInt(fields[10], out _) ? ParseInt(fields[10]) : 0; + Recipe5 = TryParseInt(fields[12], out _) ? ParseInt(fields[12]) : 0; + Recipe6 = TryParseInt(fields[14], out _) ? ParseInt(fields[14]) : 0; + Recipe1Ratio = ParseInt(fields[5]); + Recipe2Ratio = ParseInt(fields[7]); + Recipe3Ratio = TryParseInt(fields[9], out _) ? ParseInt(fields[9]) : 0; + Recipe4Ratio = TryParseInt(fields[11], out _) ? ParseInt(fields[11]) : 0; + Recipe5Ratio = TryParseInt(fields[13], out _) ? ParseInt(fields[13]) : 0; + Recipe6Ratio = TryParseInt(fields[15], out _) ? ParseInt(fields[15]) : 0; + + SetCumulativeRatio(); + } + + private void SetCumulativeRatio() + { + CumulativeRecipe1Ratio = Recipe1Ratio; + CumulativeRecipe2Ratio = CumulativeRecipe1Ratio + Recipe2Ratio; + CumulativeRecipe3Ratio = CumulativeRecipe2Ratio + Recipe3Ratio; + CumulativeRecipe4Ratio = CumulativeRecipe3Ratio + Recipe4Ratio; + CumulativeRecipe5Ratio = CumulativeRecipe4Ratio + Recipe5Ratio; + CumulativeRecipe6Ratio = CumulativeRecipe5Ratio + Recipe6Ratio; + } + } + + public AuraSummonSheet() : base(nameof(AuraSummonSheet)) + { + } + } +} From 1afe35c839822ad53dde863493a3d4a8bc6b66bd Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Aug 2023 15:41:17 +0900 Subject: [PATCH 009/134] Create SummonMail model for in-game mail notification --- Lib9c/Model/Mail/IMail.cs | 1 + Lib9c/Model/Mail/Mail.cs | 1 + Lib9c/Model/Mail/SummonMail.cs | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 Lib9c/Model/Mail/SummonMail.cs diff --git a/Lib9c/Model/Mail/IMail.cs b/Lib9c/Model/Mail/IMail.cs index 4ad564b63..5d4b87dfc 100644 --- a/Lib9c/Model/Mail/IMail.cs +++ b/Lib9c/Model/Mail/IMail.cs @@ -19,5 +19,6 @@ public interface IMail void Read(ProductSellerMail productSellerMail); void Read(ProductCancelMail productCancelMail); void Read(UnloadFromMyGaragesRecipientMail unloadFromMyGaragesRecipientMail); + void Read(SummonMail summonMail); } } diff --git a/Lib9c/Model/Mail/Mail.cs b/Lib9c/Model/Mail/Mail.cs index e584f4ecd..dc8984847 100644 --- a/Lib9c/Model/Mail/Mail.cs +++ b/Lib9c/Model/Mail/Mail.cs @@ -14,6 +14,7 @@ public enum MailType Auction, System, Grinding, + Summon, } [Serializable] public abstract class Mail : IState diff --git a/Lib9c/Model/Mail/SummonMail.cs b/Lib9c/Model/Mail/SummonMail.cs new file mode 100644 index 000000000..b8400c1ec --- /dev/null +++ b/Lib9c/Model/Mail/SummonMail.cs @@ -0,0 +1,33 @@ +using System; +using Bencodex.Types; +using Nekoyume.Model.State; + +namespace Nekoyume.Model.Mail +{ + [Serializable] + public class SummonMail : Mail + { + protected override string TypeId => nameof(SummonMail); + public override MailType MailType => MailType.Summon; + + public SummonMail(long blockIndex, Guid id, long requiredBlockIndex) : + base(blockIndex, id, requiredBlockIndex) + { + // TODO: Check what should be included in the summon mail + } + + public SummonMail(Dictionary serialized) : base(serialized) + { + // TODO: Check what should be included in the summon mail + } + + public override void Read(IMail mail) + { + mail.Read(this); + } + + // TODO: Check what should be included in the summon mail + public override IValue Serialize() => ((Dictionary)base.Serialize()) + .Add("key", 0.Serialize()); + } +} From fb8f89ab04f8f9407dfedd358dc061cb1d96b930 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Aug 2023 15:42:03 +0900 Subject: [PATCH 010/134] Introduce AuraSummon Action --- .Lib9c.Tests/Action/AuraSummonTest.cs | 165 +++++++++++++++++++ Lib9c.Abstractions/IAuraSummonV1.cs | 9 + Lib9c/Action/AuraSummon.cs | 228 ++++++++++++++++++++++++++ 3 files changed, 402 insertions(+) create mode 100644 .Lib9c.Tests/Action/AuraSummonTest.cs create mode 100644 Lib9c.Abstractions/IAuraSummonV1.cs create mode 100644 Lib9c/Action/AuraSummon.cs diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs new file mode 100644 index 000000000..2fd848f9c --- /dev/null +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -0,0 +1,165 @@ +namespace Lib9c.Tests.Action +{ + using System; + using System.Data; + using System.Linq; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Libplanet.Types.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Model.Item; + using Nekoyume.Model.State; + using Xunit; + using static SerializeKeys; + + public class AuraSummonTest + { + private readonly TableSheets _tableSheets; + private readonly Address _agentAddress; + private readonly Address _avatarAddress; + private readonly AvatarState _avatarState; + private readonly Currency _currency; + private IAccountStateDelta _initialState; + + public AuraSummonTest() + { + var sheets = TableSheetsImporter.ImportSheets(); + _tableSheets = new TableSheets(sheets); + var privateKey = new PrivateKey(); + _agentAddress = privateKey.PublicKey.ToAddress(); + var agentState = new AgentState(_agentAddress); + + _avatarAddress = _agentAddress.Derive("avatar"); + _avatarState = new AvatarState( + _avatarAddress, + _agentAddress, + 0, + _tableSheets.GetAvatarSheets(), + new GameConfigState(), + default + ); + + agentState.avatarAddresses.Add(0, _avatarAddress); + +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + _currency = Currency.Legacy("NCG", 2, null); +#pragma warning restore CS0618 + var gold = new GoldCurrencyState(_currency); + + var context = new ActionContext(); + _initialState = new MockStateDelta() + .SetState(_agentAddress, agentState.Serialize()) + .SetState(_avatarAddress, _avatarState.Serialize()) + .SetState(GoldCurrencyState.Address, gold.Serialize()) + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000) + .TransferAsset( + context, + Addresses.GoldCurrency, + _agentAddress, + gold.Currency * 1000 + ); + + Assert.Equal( + gold.Currency * 99999999000, + _initialState.GetBalance(Addresses.GoldCurrency, gold.Currency) + ); + Assert.Equal( + gold.Currency * 1000, + _initialState.GetBalance(_agentAddress, gold.Currency) + ); + + foreach (var (key, value) in sheets) + { + _initialState = + _initialState.SetState(Addresses.TableSheet.Derive(key), value.Serialize()); + } + } + + [Theory] + // success first group + [InlineData(10001, 600201, 2, 1, 10620000, null)] + // success second group + [InlineData(10002, 600202, 2, 1, 10620001, null)] + // fail by invalid group + [InlineData(100003, null, 0, 0, null, typeof(RowNotInTableException))] + // fail by not enough material + [InlineData(10001, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] + // TODO: Fail by not enough NCG + public void Execute( + int groupId, + int? materialId, + int materialCount, + int seed, + int? expectedEquipmentId, + Type expectedExc + ) + { + var random = new TestRandom(seed); + var state = _initialState; + + if (!(materialId is null)) + { + var materialSheet = _tableSheets.MaterialItemSheet; + var material = materialSheet.OrderedList.FirstOrDefault(m => m.Id == materialId); + _avatarState.inventory.AddItem( + ItemFactory.CreateItem(material, random), + materialCount + ); + state = state + .SetState(_avatarAddress, _avatarState.SerializeV2()) + .SetState( + _avatarAddress.Derive(LegacyInventoryKey), + _avatarState.inventory.Serialize() + ) + .SetState( + _avatarAddress.Derive(LegacyWorldInformationKey), + _avatarState.worldInformation.Serialize() + ) + .SetState( + _avatarAddress.Derive(LegacyQuestListKey), + _avatarState.questList.Serialize() + ) + ; + } + + var action = new AuraSummon + { + AvatarAddress = _avatarAddress, + GroupId = groupId, + }; + + if (expectedExc == null) + { + // Success + var nextState = action.Execute(new ActionContext + { + PreviousState = state, + Signer = _agentAddress, + BlockIndex = 1, + Random = random, + }); + + var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory.Equipments + .FirstOrDefault(e => e.Id == expectedEquipmentId); + Assert.NotNull(resultEquipment); + Assert.Equal(1, resultEquipment.RequiredBlockIndex); + } + else + { + // Failure + Assert.Throws(expectedExc, () => + { + action.Execute(new ActionContext + { + PreviousState = state, + Signer = _agentAddress, + BlockIndex = 1, + Random = random, + }); + }); + } + } + } +} diff --git a/Lib9c.Abstractions/IAuraSummonV1.cs b/Lib9c.Abstractions/IAuraSummonV1.cs new file mode 100644 index 000000000..cfacff463 --- /dev/null +++ b/Lib9c.Abstractions/IAuraSummonV1.cs @@ -0,0 +1,9 @@ +using Libplanet.Crypto; + +namespace Lib9c.Abstractions; + +public interface IAuraSummonV1 +{ + Address AvatarAddress { get; } + int GroupId { get; } +} diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs new file mode 100644 index 000000000..5d51294b5 --- /dev/null +++ b/Lib9c/Action/AuraSummon.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Data; +using System.Linq; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet.Action; +using Libplanet.Action.State; +using Libplanet.Crypto; +using Nekoyume.Extensions; +using Nekoyume.Model.Item; +using Nekoyume.Model.Mail; +using Nekoyume.Model.State; +using Nekoyume.TableData; +using Nekoyume.TableData.Summon; +using Serilog; +using static Lib9c.SerializeKeys; + +namespace Nekoyume.Action +{ + [Serializable] + [ActionType("aura_summon")] + public class AuraSummon : GameAction, IAuraSummonV1 + { + public const string AvatarAddressKey = "aa"; + public Address AvatarAddress; + + public const string GroupIdKey = "gid"; + public int GroupId; + + Address IAuraSummonV1.AvatarAddress => AvatarAddress; + int IAuraSummonV1.GroupId => GroupId; + + + protected override IImmutableDictionary PlainValueInternal => + new Dictionary + { + [AvatarAddressKey] = AvatarAddress.Serialize(), + [GroupIdKey] = GroupId.Serialize(), + }.ToImmutableDictionary(); + + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) + { + AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); + GroupId = plainValue[GroupIdKey].ToInteger(); + } + + public override IAccountStateDelta Execute(IActionContext context) + { + context.UseGas(1); + var states = context.PreviousState; + var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); + var worldInfoAddress = AvatarAddress.Derive(LegacyWorldInformationKey); + var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); + + if (context.Rehearsal) + { + return states; + } + + var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); + var started = DateTimeOffset.UtcNow; + Log.Debug($"{addressesHex} AuraSummon Exec. Started."); + + if (!states.TryGetAgentAvatarStatesV2(context.Signer, AvatarAddress, out var agentState, + out var avatarState, out _)) + { + throw new FailedLoadStateException( + $"{addressesHex} Aborted as the avatar state of the signer was failed to load."); + } + + + // Validate Work + Dictionary sheets = states.GetSheets(sheetTypes: new[] + { + typeof(AuraSummonSheet), + typeof(EquipmentItemRecipeSheet), + typeof(EquipmentItemSheet), + typeof(MaterialItemSheet), + typeof(EquipmentItemSubRecipeSheetV2), + typeof(EquipmentItemOptionSheet), + typeof(SkillSheet), + }); + + // Pick target recipe ID + var summonSheet = sheets.GetSheet(); + var summonRow = summonSheet.OrderedList.FirstOrDefault(row => row.GroupId == GroupId); + if (summonRow is null) + { + throw new RowNotInTableException( + $"{addressesHex} Failed to get {GroupId} in AuraSummonSheet"); + } + + // Validate requirements + var inventory = avatarState.inventory; + var itemCount = inventory.TryGetItem(summonRow.CostMaterial, out var item) + ? item.count + : 0; + if (itemCount < summonRow.CostMaterialCount) + { + throw new NotEnoughMaterialException( + $"{addressesHex} Not enough material to summon"); + } + + // Transfer Cost NCG first for fast-fail + if (summonRow.CostNcg > 0L) + { + var arenaSheet = states.GetSheet(); + var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); + var feeStoreAddress = + Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); + + states = states.TransferAsset( + context, + context.Signer, + feeStoreAddress, + states.GetGoldCurrency() * summonRow.CostNcg + ); + } + + var recipeValue = context.Random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); + int recipeId; + if (recipeValue <= summonRow.CumulativeRecipe1Ratio) + { + recipeId = summonRow.Recipe1; + } + else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) + { + recipeId = summonRow.Recipe2; + } + else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) + { + recipeId = summonRow.Recipe3; + } + else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) + { + recipeId = summonRow.Recipe4; + } + else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) + { + recipeId = summonRow.Recipe5; + } + else + { + recipeId = summonRow.Recipe6; + } + + // Validate RecipeId + var recipeSheet = sheets.GetSheet(); + var recipeRow = recipeSheet.OrderedList.FirstOrDefault( + r => r.ResultEquipmentId == recipeId + ); + if (recipeRow is null) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(EquipmentItemRecipeSheet), + recipeId); + } + + // Validate Recipe ResultEquipmentId + var equipmentItemSheet = sheets.GetSheet(); + if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, out var equipmentRow)) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(equipmentItemSheet), + recipeRow.ResultEquipmentId); + } + + // Use materials + var materialSheet = sheets.GetSheet(); + var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); + if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, + summonRow.CostMaterialCount)) + { + throw new NotEnoughMaterialException( + $"{addressesHex} Aborted as the player has no enough material ({summonRow.CostMaterial} * {summonRow.CostMaterialCount})"); + } + + // Transfer NCG cost + if (summonRow.CostNcg > 0) + { + var arenaSheet = states.GetSheet(); + var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); + var feeStoreAddress = + Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); + + states = states.TransferAsset( + context, + context.Signer, + feeStoreAddress, + states.GetGoldCurrency() * summonRow.CostNcg + ); + } + + // Create Equipment + var equipment = (Equipment)ItemFactory.CreateItemUsable( + equipmentRow, + context.Random.GenerateRandomGuid(), + context.BlockIndex + ); + + // Add or update equipment + avatarState.blockIndex = context.BlockIndex; + avatarState.updatedAt = context.BlockIndex; + avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); + avatarState.UpdateFromCombination(equipment); + avatarState.UpdateQuestRewards(sheets.GetSheet()); + + // Create Mail + var mail = new SummonMail( + context.BlockIndex, + Id, + context.BlockIndex + ); + avatarState.Update(mail); + // Set states + return states + .SetState(AvatarAddress, avatarState.SerializeV2()) + .SetState(inventoryAddress, avatarState.inventory.Serialize()) + .SetState(questListAddress, avatarState.questList.Serialize()) + .SetState(context.Signer, agentState.Serialize()); + } + } +} From 1791d6373e621630f6e67ab43e95fe07848f11c1 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 25 Aug 2023 16:50:55 +0900 Subject: [PATCH 011/134] Add missing dummy data --- Lib9c/TableCSV/Item/EquipmentItemSheet.csv | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv index f31ffe152..e419aafc1 100644 --- a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv +++ b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv @@ -168,6 +168,13 @@ id,_name,item_sub_type,grade,elemental_type,set_id,stat_type,stat_value,attack_r 10552000,고대의 반지(물),Ring,5,Water,13,DEF,1209,0,10552000,6760000 10553000,고대의 반지(땅),Ring,5,Land,14,DEF,1946,0,10553000,6760000 10554000,고대의 반지(바람),Ring,5,Wind,15,DEF,1946,0,10554000,6760000 +10620000,AuraSummon1,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10620001,AuraSummon2,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10630000,AuraSummon3,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10630001,AuraSummon4,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10640000,AuraSummon5,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10640001,AuraSummon6,Ring,5,Wind,15,DEF,1946,0,10554000,0 +10650001,AuraSummon7,Ring,5,Wind,15,DEF,1946,0,10554000,0 11320000,블루 사파이어 벨트,Belt,2,Normal,6,SPD,176,2,11320000,1496 11420000,블루 사파이어 목걸이,Necklace,2,Normal,6,HIT,227,0,11420000,1736 11520000,블루 사파이어 반지,Ring,2,Normal,6,DEF,50,0,11520000,216 From 90f8dc45a9fc5df09c341a16169cc1e0a6b8c977 Mon Sep 17 00:00:00 2001 From: area363 Date: Mon, 28 Aug 2023 21:34:38 +0900 Subject: [PATCH 012/134] fix publish action --- .github/workflows/publish.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 81138cdc0..345766be0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,15 +16,17 @@ jobs: - uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.100 - - name: bulid + - name: build run: | dotnet_args="-c Release -p:NoPackageAnalysis=true" if [[ ! "$GITHUB_REF" =~ ^refs/tags/* ]]; then project_suffix=dev.${{ github.sha }} dotnet_args="$dotnet_args --version-suffix $project_suffix" fi - dotnet build "$dotnet_args" - dotnet pack "$dotnet_args" + # shellcheck disable=SC2086 + dotnet build $dotnet_args + # shellcheck disable=SC2086 + dotnet pack $dotnet_args - name: push if: github.event_name != 'pull_request' run: | From 4b526fc3278a37e694384f23e91d2e9f38e77f6c Mon Sep 17 00:00:00 2001 From: area363 Date: Mon, 28 Aug 2023 21:40:04 +0900 Subject: [PATCH 013/134] fix release action --- .github/bin/dist-pack.sh | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/bin/dist-pack.sh b/.github/bin/dist-pack.sh index 08b55a3fd..3e909445e 100755 --- a/.github/bin/dist-pack.sh +++ b/.github/bin/dist-pack.sh @@ -7,7 +7,7 @@ for rid in "${rids[@]}"; do output_dir="./Release/$rid/" mkdir -p "$output_dir" - dotnet publish \ + dotnet publish Lib9c/Lib9c.csproj \ -c Release \ -r $rid \ -o $output_dir \ diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 097bb1501..c60b92676 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: release on: push: tags: - - v* + - "*" jobs: release: From 8a344b2b989005d1ed5d579da8b174ab09a57e2f Mon Sep 17 00:00:00 2001 From: area363 Date: Tue, 29 Aug 2023 10:36:17 +0900 Subject: [PATCH 014/134] revert tag condition --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c60b92676..097bb1501 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: release on: push: tags: - - "*" + - v* jobs: release: From 5c13db4f81465dbc42770f27a9127089234cc33a Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 15:24:16 +0900 Subject: [PATCH 015/134] Change namespace for Unity compatibility --- Lib9c.Abstractions/IAuraSummonV1.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib9c.Abstractions/IAuraSummonV1.cs b/Lib9c.Abstractions/IAuraSummonV1.cs index cfacff463..c849d4d9b 100644 --- a/Lib9c.Abstractions/IAuraSummonV1.cs +++ b/Lib9c.Abstractions/IAuraSummonV1.cs @@ -1,9 +1,10 @@ using Libplanet.Crypto; -namespace Lib9c.Abstractions; - -public interface IAuraSummonV1 +namespace Lib9c.Abstractions { - Address AvatarAddress { get; } - int GroupId { get; } + public interface IAuraSummonV1 + { + Address AvatarAddress { get; } + int GroupId { get; } + } } From e4c53da6577b6a61cc976b5977658f97410668a3 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 16:00:03 +0900 Subject: [PATCH 016/134] Add SummonCount --- Lib9c.Abstractions/IAuraSummonV1.cs | 2 ++ Lib9c/Action/AuraSummon.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Lib9c.Abstractions/IAuraSummonV1.cs b/Lib9c.Abstractions/IAuraSummonV1.cs index c849d4d9b..148ec4b98 100644 --- a/Lib9c.Abstractions/IAuraSummonV1.cs +++ b/Lib9c.Abstractions/IAuraSummonV1.cs @@ -6,5 +6,7 @@ public interface IAuraSummonV1 { Address AvatarAddress { get; } int GroupId { get; } + + int SummonCount { get; } } } diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 5d51294b5..c42e2c899 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -29,8 +29,12 @@ public class AuraSummon : GameAction, IAuraSummonV1 public const string GroupIdKey = "gid"; public int GroupId; + public const string SummonCountKey = "sc"; + public int SummonCount; + Address IAuraSummonV1.AvatarAddress => AvatarAddress; int IAuraSummonV1.GroupId => GroupId; + int IAuraSummonV1.SummonCount => SummonCount; protected override IImmutableDictionary PlainValueInternal => @@ -38,6 +42,7 @@ public class AuraSummon : GameAction, IAuraSummonV1 { [AvatarAddressKey] = AvatarAddress.Serialize(), [GroupIdKey] = GroupId.Serialize(), + [SummonCountKey] = SummonCount.Serialize(), }.ToImmutableDictionary(); protected override void LoadPlainValueInternal( @@ -45,6 +50,7 @@ protected override void LoadPlainValueInternal( { AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); GroupId = plainValue[GroupIdKey].ToInteger(); + SummonCount = plainValue[SummonCountKey].ToInteger(); } public override IAccountStateDelta Execute(IActionContext context) From 5cf9043bcfd8f5d8f926456481eae1abf1336571 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 16:01:09 +0900 Subject: [PATCH 017/134] Apply SummonCount in validation --- Lib9c/Action/AuraSummon.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index c42e2c899..f86d3a037 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -104,7 +104,7 @@ public override IAccountStateDelta Execute(IActionContext context) var itemCount = inventory.TryGetItem(summonRow.CostMaterial, out var item) ? item.count : 0; - if (itemCount < summonRow.CostMaterialCount) + if (itemCount < summonRow.CostMaterialCount * SummonCount) { throw new NotEnoughMaterialException( $"{addressesHex} Not enough material to summon"); @@ -122,7 +122,7 @@ public override IAccountStateDelta Execute(IActionContext context) context, context.Signer, feeStoreAddress, - states.GetGoldCurrency() * summonRow.CostNcg + states.GetGoldCurrency() * summonRow.CostNcg * SummonCount ); } From 24c90b7a10378c23542886eb2115479c0993d56b Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 16:01:49 +0900 Subject: [PATCH 018/134] Add helper function to multiple summon and resusability - Add SummonHelper - Remove redundant NCG transfer - Remove unused codes --- Lib9c/Action/AuraSummon.cs | 150 +++++++++++++---------------------- Lib9c/Helper/SummonHelper.cs | 37 +++++++++ 2 files changed, 93 insertions(+), 94 deletions(-) create mode 100644 Lib9c/Helper/SummonHelper.cs diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index f86d3a037..000541e93 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -9,6 +9,7 @@ using Libplanet.Action.State; using Libplanet.Crypto; using Nekoyume.Extensions; +using Nekoyume.Helper; using Nekoyume.Model.Item; using Nekoyume.Model.Mail; using Nekoyume.Model.State; @@ -58,7 +59,6 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); - var worldInfoAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); if (context.Rehearsal) @@ -77,7 +77,6 @@ public override IAccountStateDelta Execute(IActionContext context) $"{addressesHex} Aborted as the avatar state of the signer was failed to load."); } - // Validate Work Dictionary sheets = states.GetSheets(sheetTypes: new[] { @@ -90,7 +89,6 @@ public override IAccountStateDelta Execute(IActionContext context) typeof(SkillSheet), }); - // Pick target recipe ID var summonSheet = sheets.GetSheet(); var summonRow = summonSheet.OrderedList.FirstOrDefault(row => row.GroupId == GroupId); if (summonRow is null) @@ -126,103 +124,67 @@ public override IAccountStateDelta Execute(IActionContext context) ); } - var recipeValue = context.Random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); - int recipeId; - if (recipeValue <= summonRow.CumulativeRecipe1Ratio) - { - recipeId = summonRow.Recipe1; - } - else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) - { - recipeId = summonRow.Recipe2; - } - else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) - { - recipeId = summonRow.Recipe3; - } - else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) - { - recipeId = summonRow.Recipe4; - } - else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) + for (var i = 0; i < SummonCount; i++) { - recipeId = summonRow.Recipe5; - } - else - { - recipeId = summonRow.Recipe6; - } - - // Validate RecipeId - var recipeSheet = sheets.GetSheet(); - var recipeRow = recipeSheet.OrderedList.FirstOrDefault( - r => r.ResultEquipmentId == recipeId - ); - if (recipeRow is null) - { - throw new SheetRowNotFoundException( - addressesHex, - nameof(EquipmentItemRecipeSheet), - recipeId); - } + int recipeId = SummonHelper.PickAuraSummonRecipe(summonRow, context.Random); - // Validate Recipe ResultEquipmentId - var equipmentItemSheet = sheets.GetSheet(); - if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, out var equipmentRow)) - { - throw new SheetRowNotFoundException( - addressesHex, - nameof(equipmentItemSheet), - recipeRow.ResultEquipmentId); - } - - // Use materials - var materialSheet = sheets.GetSheet(); - var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); - if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, - summonRow.CostMaterialCount)) - { - throw new NotEnoughMaterialException( - $"{addressesHex} Aborted as the player has no enough material ({summonRow.CostMaterial} * {summonRow.CostMaterialCount})"); - } - - // Transfer NCG cost - if (summonRow.CostNcg > 0) - { - var arenaSheet = states.GetSheet(); - var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); - var feeStoreAddress = - Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); + // Validate RecipeId + var recipeSheet = sheets.GetSheet(); + var recipeRow = recipeSheet.OrderedList.FirstOrDefault( + r => r.ResultEquipmentId == recipeId + ); + if (recipeRow is null) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(EquipmentItemRecipeSheet), + recipeId); + } + + // Validate Recipe ResultEquipmentId + var equipmentItemSheet = sheets.GetSheet(); + if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, + out var equipmentRow)) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(equipmentItemSheet), + recipeRow.ResultEquipmentId); + } + + // Use materials + var materialSheet = sheets.GetSheet(); + var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); + if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, + summonRow.CostMaterialCount)) + { + throw new NotEnoughMaterialException( + $"{addressesHex} Aborted as the player has no enough material ({summonRow.CostMaterial} * {summonRow.CostMaterialCount})"); + } + + // Create Equipment + var equipment = (Equipment)ItemFactory.CreateItemUsable( + equipmentRow, + context.Random.GenerateRandomGuid(), + context.BlockIndex + ); - states = states.TransferAsset( - context, - context.Signer, - feeStoreAddress, - states.GetGoldCurrency() * summonRow.CostNcg + // Add or update equipment + avatarState.blockIndex = context.BlockIndex; + avatarState.updatedAt = context.BlockIndex; + avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); + avatarState.UpdateFromCombination(equipment); + avatarState.UpdateQuestRewards(sheets.GetSheet()); + + // Create Mail + var mail = new SummonMail( + context.BlockIndex, + Id, + context.BlockIndex ); + avatarState.Update(mail); } - // Create Equipment - var equipment = (Equipment)ItemFactory.CreateItemUsable( - equipmentRow, - context.Random.GenerateRandomGuid(), - context.BlockIndex - ); - - // Add or update equipment - avatarState.blockIndex = context.BlockIndex; - avatarState.updatedAt = context.BlockIndex; - avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); - avatarState.UpdateFromCombination(equipment); - avatarState.UpdateQuestRewards(sheets.GetSheet()); - - // Create Mail - var mail = new SummonMail( - context.BlockIndex, - Id, - context.BlockIndex - ); - avatarState.Update(mail); // Set states return states .SetState(AvatarAddress, avatarState.SerializeV2()) diff --git a/Lib9c/Helper/SummonHelper.cs b/Lib9c/Helper/SummonHelper.cs new file mode 100644 index 000000000..be4b0cc9c --- /dev/null +++ b/Lib9c/Helper/SummonHelper.cs @@ -0,0 +1,37 @@ +using Libplanet.Action; +using Nekoyume.TableData.Summon; + +namespace Nekoyume.Helper +{ + public class SummonHelper + { + public static int PickAuraSummonRecipe(AuraSummonSheet.Row summonRow, IRandom random) + { + var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); + if (recipeValue <= summonRow.CumulativeRecipe1Ratio) + { + return summonRow.Recipe1; + } + else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) + { + return summonRow.Recipe2; + } + else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) + { + return summonRow.Recipe3; + } + else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) + { + return summonRow.Recipe4; + } + else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) + { + return summonRow.Recipe5; + } + else + { + return summonRow.Recipe6; + } + } + } +} From c132c607a14ebf10fb0d872de296b16e5fc76ae9 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 16:17:00 +0900 Subject: [PATCH 019/134] Update tests: Add summonCount --- .Lib9c.Tests/Action/AuraSummonTest.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs index 2fd848f9c..4c80e9730 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -79,16 +79,20 @@ public AuraSummonTest() [Theory] // success first group - [InlineData(10001, 600201, 2, 1, 10620000, null)] + [InlineData(10001, 1, 600201, 2, 1, 10620000, null)] + [InlineData(10001, 2, 600201, 4, 1, 10620000, null)] // success second group - [InlineData(10002, 600202, 2, 1, 10620001, null)] + [InlineData(10002, 1, 600202, 2, 1, 10620001, null)] + [InlineData(10002, 2, 600202, 4, 1, 10620001, null)] // fail by invalid group - [InlineData(100003, null, 0, 0, null, typeof(RowNotInTableException))] + [InlineData(100003, 1, null, 0, 0, null, typeof(RowNotInTableException))] // fail by not enough material - [InlineData(10001, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] + [InlineData(10001, 1, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] + [InlineData(10001, 2, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] // TODO: Fail by not enough NCG public void Execute( int groupId, + int summonCount, int? materialId, int materialCount, int seed, @@ -128,6 +132,7 @@ Type expectedExc { AvatarAddress = _avatarAddress, GroupId = groupId, + SummonCount = summonCount, }; if (expectedExc == null) @@ -141,8 +146,8 @@ Type expectedExc Random = random, }); - var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory.Equipments - .FirstOrDefault(e => e.Id == expectedEquipmentId); + var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory + .Equipments.FirstOrDefault(e => e.Id == expectedEquipmentId); Assert.NotNull(resultEquipment); Assert.Equal(1, resultEquipment.RequiredBlockIndex); } From 5a33b7df98660c95db0e70a91c07210c28b39658 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 21:13:26 +0900 Subject: [PATCH 020/134] Update tests: test multiple summon --- .Lib9c.Tests/Action/AuraSummonTest.cs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs index 4c80e9730..92a3666c2 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -79,16 +79,16 @@ public AuraSummonTest() [Theory] // success first group - [InlineData(10001, 1, 600201, 2, 1, 10620000, null)] - [InlineData(10001, 2, 600201, 4, 1, 10620000, null)] + [InlineData(10001, 1, 600201, 2, 1, new[] { 10620000 }, null)] + [InlineData(10001, 2, 600201, 4, 0, new[] { 10630000, 10640000 }, null)] // success second group - [InlineData(10002, 1, 600202, 2, 1, 10620001, null)] - [InlineData(10002, 2, 600202, 4, 1, 10620001, null)] + [InlineData(10002, 1, 600202, 2, 1, new[] { 10620001 }, null)] + [InlineData(10002, 2, 600202, 4, 6, new[] { 10630001, 10640001 }, null)] // fail by invalid group - [InlineData(100003, 1, null, 0, 0, null, typeof(RowNotInTableException))] + [InlineData(100003, 1, null, 0, 0, new int[] { }, typeof(RowNotInTableException))] // fail by not enough material - [InlineData(10001, 1, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] - [InlineData(10001, 2, 600201, 1, 0, 10620000, typeof(NotEnoughMaterialException))] + [InlineData(10001, 1, 600201, 1, 0, new int[] { }, typeof(NotEnoughMaterialException))] + [InlineData(10001, 2, 600201, 1, 0, new int[] { }, typeof(NotEnoughMaterialException))] // TODO: Fail by not enough NCG public void Execute( int groupId, @@ -96,7 +96,7 @@ public void Execute( int? materialId, int materialCount, int seed, - int? expectedEquipmentId, + int[] expectedEquipmentId, Type expectedExc ) { @@ -146,10 +146,13 @@ Type expectedExc Random = random, }); - var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory - .Equipments.FirstOrDefault(e => e.Id == expectedEquipmentId); - Assert.NotNull(resultEquipment); - Assert.Equal(1, resultEquipment.RequiredBlockIndex); + foreach (var equipmentId in expectedEquipmentId) + { + var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory + .Equipments.FirstOrDefault(e => e.Id == equipmentId); + Assert.NotNull(resultEquipment); + Assert.Equal(1, resultEquipment.RequiredBlockIndex); + } } else { From e0c48d6a13ae8ff97ea1598715488ad1b1775458 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 29 Aug 2023 17:56:11 +0900 Subject: [PATCH 021/134] fix trigger conditions of "main" workflow (cherry picked from commit 258d2f3bf3d9d5dc0bb2e6f44c39d8b0df6e0212) --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c05802f6..904e0a4da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,12 +3,12 @@ name: main on: push: branches: - - "*" + - "**" tags: - - "*" + - "**" pull_request: branches: - - "*" + - "**" jobs: build-and-test: From bff5bc773c4c794843a0ed5ffa14d011b5292100 Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 25 Aug 2023 10:49:18 +0900 Subject: [PATCH 022/134] Block patching some table sheets twice Co-authored-by: Hyun Seungmin --- Lib9c/Action/PatchTableSheet.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Lib9c/Action/PatchTableSheet.cs b/Lib9c/Action/PatchTableSheet.cs index b0e18e02c..57a48c6b9 100644 --- a/Lib9c/Action/PatchTableSheet.cs +++ b/Lib9c/Action/PatchTableSheet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Immutable; +using System.Linq; using Bencodex.Types; using Lib9c.Abstractions; using Libplanet.Action; @@ -24,6 +25,13 @@ namespace Nekoyume.Action [ActionType("patch_table_sheet")] public class PatchTableSheet : GameAction, IPatchTableSheetV1 { + private static readonly string[] PrefixRules = new string[] { + "StakeRegularRewardSheet_", + "StakeRegularFixedRewardSheet_", + // "CrystalMonsterCollectionMultiplierSheet_", + // "StakeActionPointCoefficientSheet_", + }; + // FIXME: We should eliminate or justify this concept in another way after v100340. // (Until that) please consult Nine Chronicles Dev if you have any questions about this account. private static readonly Address Operator = @@ -65,8 +73,14 @@ public override IAccountStateDelta Execute(IActionContext context) } #endif - var sheets = states.GetState(sheetAddress); - var value = sheets is null ? string.Empty : sheets.ToDotnetString(); + var sheet = states.GetState(sheetAddress); + if (!(sheet is null) && PrefixRules.Any(TableName.StartsWith)) + { + var msg = $"{TableName} already exists."; + throw new ArgumentException(nameof(TableName), msg); + } + + var value = sheet is null ? string.Empty : sheet.ToDotnetString(); Log.Verbose( "{AddressesHex}{TableName} was patched\n" + From 94ebaa50cdd3fd356cf2dcec9f381c2b41183614 Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 25 Aug 2023 14:31:55 +0900 Subject: [PATCH 023/134] Introduce `StakePolicySheet` --- Lib9c/TableCSV/Stake/StakePolicySheet.csv | 2 ++ Lib9c/TableData/Stake/StakePolicySheet.cs | 28 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Lib9c/TableCSV/Stake/StakePolicySheet.csv create mode 100644 Lib9c/TableData/Stake/StakePolicySheet.cs diff --git a/Lib9c/TableCSV/Stake/StakePolicySheet.csv b/Lib9c/TableCSV/Stake/StakePolicySheet.csv new file mode 100644 index 000000000..0b4295a8d --- /dev/null +++ b/Lib9c/TableCSV/Stake/StakePolicySheet.csv @@ -0,0 +1,2 @@ +table_type_name,table_name +StakeRegularRewardSheet,StakeRegularRewardSheet_V1020100120110 diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs new file mode 100644 index 000000000..d8450e3a9 --- /dev/null +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; + +namespace Nekoyume.TableData.Stake +{ + public class StakePolicySheet : Sheet + { + [Serializable] + public class Row : SheetRow + { + public override string Key => TableName; + + public string TableTypeName { get; private set; } + + public string TableName { get; private set; } + + public override void Set(IReadOnlyList fields) + { + TableTypeName = fields[0]; + TableName = fields[1]; + } + } + + public StakePolicySheet() : base(nameof(StakePolicySheet)) + { + } + } +} From 0a5c332b059e752fd807b7afabcba031b487d4a2 Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 25 Aug 2023 14:49:24 +0900 Subject: [PATCH 024/134] Update Lib9c C# version to 9 --- Lib9c/Lib9c.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/Lib9c.csproj b/Lib9c/Lib9c.csproj index 23446b974..9a727488a 100644 --- a/Lib9c/Lib9c.csproj +++ b/Lib9c/Lib9c.csproj @@ -8,7 +8,7 @@ .bin .obj Nekoyume - 8 + 9 0.5.0 true Debug;Release From 0f19143078abbda94d45573c2296417c087d600f Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 25 Aug 2023 15:23:59 +0900 Subject: [PATCH 025/134] Deprecate `stake2` action --- .../Action/{StakeTest.cs => Stake2Test.cs} | 30 +++++++++---------- Lib9c/Action/{Stake.cs => Stake2.cs} | 11 +++++-- 2 files changed, 23 insertions(+), 18 deletions(-) rename .Lib9c.Tests/Action/{StakeTest.cs => Stake2Test.cs} (93%) rename Lib9c/Action/{Stake.cs => Stake2.cs} (94%) diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/Stake2Test.cs similarity index 93% rename from .Lib9c.Tests/Action/StakeTest.cs rename to .Lib9c.Tests/Action/Stake2Test.cs index a195d9c41..1675d01bb 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/Stake2Test.cs @@ -12,7 +12,7 @@ namespace Lib9c.Tests.Action using Xunit; using Xunit.Abstractions; - public class StakeTest + public class Stake2Test { private readonly IAccountStateDelta _initialState; private readonly Currency _currency; @@ -20,7 +20,7 @@ public class StakeTest private readonly TableSheets _tableSheets; private readonly Address _signerAddress; - public StakeTest(ITestOutputHelper outputHelper) + public Stake2Test(ITestOutputHelper outputHelper) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() @@ -54,7 +54,7 @@ public StakeTest(ITestOutputHelper outputHelper) [Fact] public void Execute_Throws_WhenNotEnoughBalance() { - var action = new Stake(200); + var action = new Stake2(200); Assert.Throws(() => action.Execute(new ActionContext { @@ -78,7 +78,7 @@ public void Execute_Throws_WhenThereIsMonsterCollection() .SetState( monsterCollectionAddress, new MonsterCollectionState(monsterCollectionAddress, 1, 0).SerializeV2()); - var action = new Stake(200); + var action = new Stake2(200); Assert.Throws(() => action.Execute(new ActionContext { @@ -96,7 +96,7 @@ public void Execute_Throws_WhenClaimableExisting() var states = _initialState .SetState(stakeStateAddress, new StakeState(stakeStateAddress, 0).Serialize()) .MintAsset(context, stakeStateAddress, _currency * 50); - var action = new Stake(100); + var action = new Stake2(100); Assert.Throws(() => action.Execute(new ActionContext { @@ -109,7 +109,7 @@ public void Execute_Throws_WhenClaimableExisting() [Fact] public void Execute_Throws_WhenCancelOrUpdateWhileLockup() { - var action = new Stake(51); + var action = new Stake2(51); var states = action.Execute(new ActionContext { PreviousState = _initialState, @@ -118,7 +118,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() }); // Cancel - var updateAction = new Stake(0); + var updateAction = new Stake2(0); Assert.Throws(() => updateAction.Execute(new ActionContext { PreviousState = states, @@ -127,7 +127,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() })); // Less - updateAction = new Stake(50); + updateAction = new Stake2(50); Assert.Throws(() => updateAction.Execute(new ActionContext { PreviousState = states, @@ -143,7 +143,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() new StakeState(stakeState.address, 4611070 - 100).Serialize()); } - updateAction = new Stake(51); + updateAction = new Stake2(51); Assert.Throws(() => updateAction.Execute(new ActionContext { PreviousState = states, @@ -164,7 +164,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() [Fact] public void Execute() { - var action = new Stake(100); + var action = new Stake2(100); var states = action.Execute(new ActionContext { PreviousState = _initialState, @@ -197,7 +197,7 @@ public void Execute() stakeState.CancellableBlockIndex, stakeState.Achievements); states = states.SetState(stakeState.address, producedStakeState.SerializeV2()); - var cancelAction = new Stake(0); + var cancelAction = new Stake2(0); states = cancelAction.Execute(new ActionContext { PreviousState = states, @@ -213,7 +213,7 @@ public void Execute() [Fact] public void Update() { - var action = new Stake(50); + var action = new Stake2(50); var states = action.Execute(new ActionContext { PreviousState = _initialState, @@ -228,7 +228,7 @@ public void Update() Assert.Equal(_currency * 50, states.GetBalance(stakeState.address, _currency)); Assert.Equal(_currency * 50, states.GetBalance(_signerAddress, _currency)); - var updateAction = new Stake(100); + var updateAction = new Stake2(100); states = updateAction.Execute(new ActionContext { PreviousState = states, @@ -247,8 +247,8 @@ public void Update() [Fact] public void Serialization() { - var action = new Stake(100); - var deserialized = new Stake(); + var action = new Stake2(100); + var deserialized = new Stake2(); deserialized.LoadPlainValue(action.PlainValue); Assert.Equal(action.Amount, deserialized.Amount); diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake2.cs similarity index 94% rename from Lib9c/Action/Stake.cs rename to Lib9c/Action/Stake2.cs index 81cc28892..159685ad6 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake2.cs @@ -14,20 +14,24 @@ namespace Nekoyume.Action { [ActionType("stake2")] - public class Stake : GameAction, IStakeV1 + [ActionObsolete(ObsoleteBlockIndex)] + public class Stake2 : GameAction, IStakeV1 { + public const long ObsoleteBlockIndex = + ActionObsoleteConfig.V200070ObsoleteIndex; + internal BigInteger Amount { get; set; } BigInteger IStakeV1.Amount => Amount; - public Stake(BigInteger amount) + public Stake2(BigInteger amount) { Amount = amount >= 0 ? amount : throw new ArgumentOutOfRangeException(nameof(amount)); } - public Stake() + public Stake2() { } @@ -41,6 +45,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary Date: Fri, 25 Aug 2023 15:09:21 +0900 Subject: [PATCH 026/134] Introduce StakeStateV2 --- Lib9c/Model/Stake/Contract.cs | 77 ++++++++++++++++++++++++++++ Lib9c/Model/Stake/StakeStateV2.cs | 84 +++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 Lib9c/Model/Stake/Contract.cs create mode 100644 Lib9c/Model/Stake/StakeStateV2.cs diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs new file mode 100644 index 000000000..579d37f78 --- /dev/null +++ b/Lib9c/Model/Stake/Contract.cs @@ -0,0 +1,77 @@ +using System; +using Bencodex.Types; + +namespace Lib9c.Model.Stake +{ + public class Contract + { + public const string StateTypeName = "stake_contract"; + public const long StateTypeVersion = 1; + + public const string StakeRegularFixedRewardSheetPrefix + = "StakeRegularFixedRewardSheet_"; + public const string StakeRegularRewardSheetPrefix + = "StakeRegularRewardSheet_"; + + public string StakeRegularFixedRewardSheetTableName { get; init; } + public string StakeRegularRewardSheetTableName { get; init; } + + public Contract( + string stakeRegularFixedRewardSheetTableName, + string stakeRegularRewardSheetTableName) + { + if (!stakeRegularFixedRewardSheetTableName.StartsWith(StakeRegularFixedRewardSheetPrefix)) + { + throw new ArgumentException(nameof(stakeRegularFixedRewardSheetTableName)); + } + + if (!stakeRegularRewardSheetTableName.StartsWith(StakeRegularRewardSheetPrefix)) + { + throw new ArgumentException(nameof(stakeRegularRewardSheetTableName)); + } + + StakeRegularFixedRewardSheetTableName = stakeRegularFixedRewardSheetTableName; + StakeRegularRewardSheetTableName = stakeRegularRewardSheetTableName; + } + + public Contract(IValue serialized) + { + if (serialized is not List list) + { + throw new ArgumentException( + nameof(serialized), + $"{nameof(serialized)} is not List"); + } + + if (list[0] is not Text typeName || + (string)typeName != StateTypeName) + { + throw new ArgumentException( + nameof(serialized), + $"State type name is not {StateTypeName}"); + } + + if (list[1] is not Integer typeVersion || + (long)typeVersion != StateTypeVersion) + { + throw new ArgumentException( + nameof(serialized), + $"State type version is not {StateTypeVersion}"); + } + + const int reservedCount = 2; + StakeRegularFixedRewardSheetTableName = (Text)list[reservedCount]; + StakeRegularRewardSheetTableName = (Text)list[reservedCount + 1]; + } + + public List Serialize() + { + return new List( + (Text)StateTypeName, + (Integer)StateTypeVersion, + (Text)StakeRegularFixedRewardSheetTableName, + (Text)StakeRegularRewardSheetTableName + ); + } + } +} diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs new file mode 100644 index 000000000..443ba6e45 --- /dev/null +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -0,0 +1,84 @@ +using System; +using Bencodex.Types; +using Lib9c.Model.Stake; +using Nekoyume.Model.State; + +namespace Lib9c.Model.State +{ + public readonly struct StakeStateV2 : IState + { + public const string StateTypeName = "stake_state"; + public const int StateTypeVersion = 2; + + public readonly Contract Contract; + public readonly long StartedBlockIndex; + public readonly long ClaimedBlockIndex; + + public long CancellableBlockIndex => + StartedBlockIndex + StakeState.LockupInterval; + public long ClaimableBlockIndex => + ClaimedBlockIndex + StakeState.RewardInterval; + + public StakeStateV2( + Contract contract, + long startedBlockIndex) + : this(contract, startedBlockIndex, startedBlockIndex) + { + } + + public StakeStateV2( + Contract contract, + long startedBlockIndex, + long claimedBlockIndex) + { + Contract = contract; + StartedBlockIndex = startedBlockIndex; + ClaimedBlockIndex = claimedBlockIndex; + } + + public StakeStateV2( + StakeState stakeState, + Contract contract + ) : this( + contract, + stakeState.StartedBlockIndex, + stakeState.GetClaimableBlockIndex(long.MaxValue) - StakeState.RewardInterval + ) + { + } + + public StakeStateV2(IValue serialized) + { + if (serialized is not List list) + { + throw new ArgumentException( + nameof(serialized), + $"{nameof(serialized)} should be List type."); + } + + if (list[0] is not Text stateTypeNameValue || + stateTypeNameValue != StateTypeName || + list[1] is not Integer stateTypeVersionValue || + stateTypeVersionValue.Value != StateTypeVersion) + { + throw new ArgumentException( + nameof(serialized), + $"{nameof(serialized)} doesn't have valid header."); + } + + const int reservedCount = 2; + + Contract = new Contract(list[reservedCount]); + StartedBlockIndex = (Integer)list[reservedCount + 1]; + ClaimedBlockIndex = (Integer)list[reservedCount + 2]; + } + + public IValue Serialize() => new List( + (Text)StateTypeName, + (Integer)StateTypeVersion, + Contract.Serialize(), + (Integer)StartedBlockIndex, + (Integer)ClaimedBlockIndex + ); + } +} From b20dd1c6e73d064f8eb1201ab00f71e139c1a1de Mon Sep 17 00:00:00 2001 From: moreal Date: Mon, 28 Aug 2023 10:38:55 +0900 Subject: [PATCH 027/134] Introduce `stake3` --- Lib9c/Action/AccountStateExtensions.cs | 9 +- Lib9c/Action/Stake.cs | 203 ++++++++++++++++++ Lib9c/Exceptions/InvalidStateTypeException.cs | 13 ++ 3 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 Lib9c/Action/Stake.cs create mode 100644 Lib9c/Exceptions/InvalidStateTypeException.cs diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index 21bf76682..c2ff7c9c2 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -473,7 +473,14 @@ public static IEnumerable GetGoldDistribution( public static T GetSheet(this IAccountState states) where T : ISheet, new() { var address = Addresses.GetSheetAddress(); + return GetSheet(states, address); + } + public static T GetSheet( + this IAccountState states, + Address sheetAddr) + where T : ISheet, new() + { try { var csv = GetSheetCsv(states); @@ -483,7 +490,7 @@ public static IEnumerable GetGoldDistribution( hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(csv)); } - var cacheKey = address.ToHex() + ByteUtil.Hex(hash); + var cacheKey = sheetAddr.ToHex() + ByteUtil.Hex(hash); if (SheetsCache.TryGetValue(cacheKey, out var cached)) { return (T)cached; diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs new file mode 100644 index 000000000..588687ae6 --- /dev/null +++ b/Lib9c/Action/Stake.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Immutable; +using System.Linq; +using System.Numerics; +using Bencodex.Types; +using Lib9c.Abstractions; +using Lib9c.Exceptions; +using Lib9c.Model.Stake; +using Lib9c.Model.State; +using Libplanet.Action; +using Libplanet.Action.State; +using Nekoyume.Exceptions; +using Nekoyume.Model.State; +using Nekoyume.TableData; +using Nekoyume.TableData.Stake; +using Serilog; +using static Lib9c.SerializeKeys; + +namespace Nekoyume.Action +{ + [ActionType("stake3")] + public class Stake : GameAction, IStakeV1 + { + internal BigInteger Amount { get; set; } + + BigInteger IStakeV1.Amount => Amount; + + public Stake(BigInteger amount) + { + Amount = amount >= 0 + ? amount + : throw new ArgumentOutOfRangeException(nameof(amount)); + } + + public Stake() + { + } + + protected override IImmutableDictionary PlainValueInternal => + ImmutableDictionary.Empty.Add(AmountKey, (IValue) (Integer) Amount); + + protected override void LoadPlainValueInternal(IImmutableDictionary plainValue) + { + Amount = plainValue[AmountKey].ToBigInteger(); + } + + public override IAccountStateDelta Execute(IActionContext context) + { + context.UseGas(1); + IAccountStateDelta states = context.PreviousState; + + // Restrict staking if there is a monster collection until now. + if (states.GetAgentState(context.Signer) is { } agentState && + states.TryGetState(MonsterCollectionState.DeriveAddress( + context.Signer, + agentState.MonsterCollectionRound), out Dictionary _)) + { + throw new MonsterCollectionExistingException(); + } + + if (context.Rehearsal) + { + return states.SetState(StakeState.DeriveAddress(context.Signer), MarkChanged) + .MarkBalanceChanged( + context, + GoldCurrencyMock, + context.Signer, + StakeState.DeriveAddress(context.Signer)); + } + + // Validate plain values + if (Amount < 0) + { + throw new ArgumentOutOfRangeException(nameof(Amount)); + } + + var addressesHex = GetSignerAndOtherAddressesHex(context, context.Signer); + var started = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}Stake exec started", addressesHex); + var stakePolicySheet = states.GetSheet(); + var currentStakeRegularRewardSheetAddress = + Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)].TableName); + + var stakeRegularRewardSheet = states.GetSheet( + currentStakeRegularRewardSheetAddress); + var minimumRequiredGold = stakeRegularRewardSheet.OrderedRows.Min(x => x.RequiredGold); + if (Amount != 0 && Amount < minimumRequiredGold) + { + throw new ArgumentOutOfRangeException(nameof(Amount)); + } + + var stakeStateAddress = StakeState.DeriveAddress(context.Signer); + var currency = states.GetGoldCurrency(); + var currentBalance = states.GetBalance(context.Signer, currency); + var stakedBalance = states.GetBalance(stakeStateAddress, currency); + var targetStakeBalance = currency * Amount; + if (currentBalance + stakedBalance < targetStakeBalance) + { + throw new NotEnoughFungibleAssetValueException( + context.Signer.ToHex(), + Amount, + currentBalance); + } + + var latestStakeContract = new Contract( + stakeRegularFixedRewardSheetTableName: stakePolicySheet["StakeRegularFixedRewardSheet"].TableName, + stakeRegularRewardSheetTableName: stakePolicySheet["StakeRegularRewardSheet"].TableName + ); + + var stakeStateValue = states.GetState(stakeStateAddress); + StakeStateV2 stakeState; + if (stakeStateValue is null) + { + if (Amount == 0) + { + throw new StateNullException(stakeStateAddress); + } + + stakeState = new StakeStateV2(latestStakeContract, context.BlockIndex); + return states + .SetState( + stakeStateAddress, + stakeState.Serialize()) + .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance); + } + + if (stakeStateValue is List list) + { + stakeState = new StakeStateV2(list); + } + else if (stakeStateValue is Dictionary dict) + { + var stakeStateV1 = new StakeState(dict); + string stakeRegularFixedRewardSheetTableName; + string stakeRegularRewardSheetTableName; + if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV2Index) + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V1"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; + } + else if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV3Index) + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V2"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; + } + else + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V3"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; + } + + stakeState = new StakeStateV2(stakeStateV1, new Contract( + stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName + )); + } + else + { + throw new InvalidStateTypeException( + $"invalid type of {nameof(stakeStateValue)}: {stakeStateValue.Kind}" + ); + } + + // NOTE: Cannot anything if staking state is claimable. + if (stakeState.ClaimableBlockIndex >= context.BlockIndex) + { + throw new StakeExistingClaimableException(); + } + + // NOTE: Try cancel. + if (Amount == 0) + { + // NOTE: Cannot cancel until lockup ends. + if (stakeState.CancellableBlockIndex > context.BlockIndex) + { + throw new RequiredBlockIndexException(); + } + + return states + .SetState(stakeStateAddress, Null.Value) + .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance); + } + + // NOTE: Cannot re-contract with less balance when the staking is locked up. + if (stakeState.CancellableBlockIndex > context.BlockIndex && + targetStakeBalance <= stakedBalance) + { + throw new RequiredBlockIndexException(); + } + + var ended = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, ended - started); + + // Stake with more or less amount. + return states + .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance) + .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance) + .SetState( + stakeStateAddress, + new StakeStateV2(latestStakeContract, stakeState.StartedBlockIndex).Serialize()); + } + } +} diff --git a/Lib9c/Exceptions/InvalidStateTypeException.cs b/Lib9c/Exceptions/InvalidStateTypeException.cs new file mode 100644 index 000000000..7247079fb --- /dev/null +++ b/Lib9c/Exceptions/InvalidStateTypeException.cs @@ -0,0 +1,13 @@ +using System; + +namespace Lib9c.Exceptions +{ + [Serializable] + public class InvalidStateTypeException : Exception + { + public InvalidStateTypeException(string message) + : base(message) + { + } + } +} From 0c6071bb1dea891035ffa402816fd901a2a9fc4c Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:01:51 +0900 Subject: [PATCH 028/134] Delay obsolete index to v200080 --- Lib9c/Action/Stake2.cs | 3 +-- Lib9c/ActionObsoleteConfig.cs | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib9c/Action/Stake2.cs b/Lib9c/Action/Stake2.cs index 159685ad6..2ee05ded3 100644 --- a/Lib9c/Action/Stake2.cs +++ b/Lib9c/Action/Stake2.cs @@ -17,8 +17,7 @@ namespace Nekoyume.Action [ActionObsolete(ObsoleteBlockIndex)] public class Stake2 : GameAction, IStakeV1 { - public const long ObsoleteBlockIndex = - ActionObsoleteConfig.V200070ObsoleteIndex; + public const long ObsoleteBlockIndex = ActionObsoleteConfig.V200080ObsoleteIndex; internal BigInteger Amount { get; set; } diff --git a/Lib9c/ActionObsoleteConfig.cs b/Lib9c/ActionObsoleteConfig.cs index c53eb88fa..3656a85d0 100644 --- a/Lib9c/ActionObsoleteConfig.cs +++ b/Lib9c/ActionObsoleteConfig.cs @@ -78,6 +78,9 @@ public static class ActionObsoleteConfig public const long V200070ObsoleteIndex = 7_716_400L; + // NOTE: This is temporary value. + public const long V200080ObsoleteIndex = 7_770_000L; + // While v200020, the action obsolete wasn't work well. // So other previous `V*ObsoletedIndex`s lost its meaning and // this block index will replace them. From 8f02aa04f5e3042c105c7006a76ccdd76b06f8e7 Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:04:46 +0900 Subject: [PATCH 029/134] Update `StakeStateV2`'s namespace --- Lib9c/Action/Stake.cs | 4 +--- Lib9c/Model/Stake/Contract.cs | 2 +- Lib9c/Model/Stake/StakeStateV2.cs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 588687ae6..bf334279c 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -4,12 +4,10 @@ using System.Numerics; using Bencodex.Types; using Lib9c.Abstractions; -using Lib9c.Exceptions; -using Lib9c.Model.Stake; -using Lib9c.Model.State; using Libplanet.Action; using Libplanet.Action.State; using Nekoyume.Exceptions; +using Nekoyume.Model.Stake; using Nekoyume.Model.State; using Nekoyume.TableData; using Nekoyume.TableData.Stake; diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 579d37f78..9d2d6a782 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -1,7 +1,7 @@ using System; using Bencodex.Types; -namespace Lib9c.Model.Stake +namespace Nekoyume.Model.Stake { public class Contract { diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs index 443ba6e45..143566df5 100644 --- a/Lib9c/Model/Stake/StakeStateV2.cs +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -1,9 +1,8 @@ using System; using Bencodex.Types; -using Lib9c.Model.Stake; using Nekoyume.Model.State; -namespace Lib9c.Model.State +namespace Nekoyume.Model.Stake { public readonly struct StakeStateV2 : IState { From 1264103e1b54b6bde04726901ac1b10539060d3f Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:11:55 +0900 Subject: [PATCH 030/134] Refactor migrating StakeState --- Lib9c/Action/AccountStateExtensions.cs | 57 ++++++++++++++++++++++++++ Lib9c/Action/Stake.cs | 56 ++++--------------------- 2 files changed, 65 insertions(+), 48 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index c2ff7c9c2..6ac74370a 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -20,6 +20,7 @@ using Nekoyume.Exceptions; using Nekoyume.Model.Coupons; using Nekoyume.Model.Item; +using Nekoyume.Model.Stake; namespace Nekoyume.Action { @@ -925,6 +926,62 @@ public static bool TryGetStakeState( return false; } + public static bool TryGetStakeStateV2( + this IAccountState state, + Address agentAddr, + out StakeStateV2 stakeStateV2) + { + var stakeStateAddr = StakeState.DeriveAddress(agentAddr); + var stakeStateValue = state.GetState(stakeStateAddr); + if (stakeStateValue is null) + { + stakeStateV2 = default; + return false; + } + + if (stakeStateValue is List list) + { + stakeStateV2 = new StakeStateV2(list); + return true; + } + + if (stakeStateValue is Dictionary dict) + { + var stakeStateV1 = new StakeState(dict); + string stakeRegularFixedRewardSheetTableName; + string stakeRegularRewardSheetTableName; + if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV2Index) + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V1"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; + } + else if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV3Index) + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V2"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; + } + // FIXME: consider this case. + // else if (stakeStateV1.StartedBlockIndex < StakeState.CurrencyAsRewardStartIndex) + // { + // } + else + { + stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V3"; + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; + } + + stakeStateV2 = new StakeStateV2( + stakeStateV1, + new Contract( + stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName)); + return true; + } + + stakeStateV2 = default; + return false; + } + public static ArenaParticipants GetArenaParticipants(this IAccountState states, Address arenaParticipantsAddress, int id, int round) { diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index bf334279c..71c2e694f 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -105,62 +105,21 @@ public override IAccountStateDelta Execute(IActionContext context) stakeRegularRewardSheetTableName: stakePolicySheet["StakeRegularRewardSheet"].TableName ); - var stakeStateValue = states.GetState(stakeStateAddress); - StakeStateV2 stakeState; - if (stakeStateValue is null) + if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) { if (Amount == 0) { throw new StateNullException(stakeStateAddress); } - stakeState = new StakeStateV2(latestStakeContract, context.BlockIndex); + stakeStateV2 = new StakeStateV2(latestStakeContract, context.BlockIndex); return states - .SetState( - stakeStateAddress, - stakeState.Serialize()) + .SetState(stakeStateAddress, stakeStateV2.Serialize()) .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance); } - if (stakeStateValue is List list) - { - stakeState = new StakeStateV2(list); - } - else if (stakeStateValue is Dictionary dict) - { - var stakeStateV1 = new StakeState(dict); - string stakeRegularFixedRewardSheetTableName; - string stakeRegularRewardSheetTableName; - if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV2Index) - { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V1"; - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; - } - else if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV3Index) - { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V2"; - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; - } - else - { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V3"; - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; - } - - stakeState = new StakeStateV2(stakeStateV1, new Contract( - stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, - stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName - )); - } - else - { - throw new InvalidStateTypeException( - $"invalid type of {nameof(stakeStateValue)}: {stakeStateValue.Kind}" - ); - } - // NOTE: Cannot anything if staking state is claimable. - if (stakeState.ClaimableBlockIndex >= context.BlockIndex) + if (stakeStateV2.ClaimableBlockIndex >= context.BlockIndex) { throw new StakeExistingClaimableException(); } @@ -169,7 +128,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (Amount == 0) { // NOTE: Cannot cancel until lockup ends. - if (stakeState.CancellableBlockIndex > context.BlockIndex) + if (stakeStateV2.CancellableBlockIndex > context.BlockIndex) { throw new RequiredBlockIndexException(); } @@ -180,7 +139,7 @@ public override IAccountStateDelta Execute(IActionContext context) } // NOTE: Cannot re-contract with less balance when the staking is locked up. - if (stakeState.CancellableBlockIndex > context.BlockIndex && + if (stakeStateV2.CancellableBlockIndex > context.BlockIndex && targetStakeBalance <= stakedBalance) { throw new RequiredBlockIndexException(); @@ -195,7 +154,8 @@ public override IAccountStateDelta Execute(IActionContext context) .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance) .SetState( stakeStateAddress, - new StakeStateV2(latestStakeContract, stakeState.StartedBlockIndex).Serialize()); + new StakeStateV2(latestStakeContract, stakeStateV2.StartedBlockIndex) + .Serialize()); } } } From ca5d2d1dd45062d1a8419f2a45aa2c84f837aa6f Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:15:21 +0900 Subject: [PATCH 031/134] Provide a method to get sheets by type and name pairs --- Lib9c/Action/AccountStateExtensions.cs | 28 +++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index 6ac74370a..ee6b9d99d 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -664,18 +664,32 @@ public static T GetSheet( } public static Dictionary GetSheets( - this IAccountState states, + this IAccountState state, params Type[] sheetTypes) { Dictionary result = sheetTypes.ToDictionary( sheetType => sheetType, sheetType => (Addresses.GetSheetAddress(sheetType.Name), (ISheet)null)); -#pragma warning disable LAA1002 - var addresses = result - .Select(tuple => tuple.Value.address) - .ToArray(); -#pragma warning restore LAA1002 - var csvValues = states.GetStates(addresses); + return state.GetSheetsInternal(result); + } + + public static Dictionary GetSheets( + this IAccountState state, + params (Type sheetType, string sheetName)[] sheetTuples) + { + Dictionary result = sheetTuples.ToDictionary( + tuple => tuple.sheetType, + tuple => (Addresses.GetSheetAddress(tuple.sheetName), (ISheet)null)); + return state.GetSheetsInternal(result); + } + + private static Dictionary GetSheetsInternal( + this IAccountState state, + Dictionary result) + { + var sheetTypes = result.Keys.ToArray(); + var addresses = result.Values.Select(e => e.address).ToArray(); + var csvValues = state.GetStates(addresses); for (var i = 0; i < sheetTypes.Length; i++) { var sheetType = sheetTypes[i]; From 4977c86852a9be9cc1bcb093de03b57bcf5acd9c Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:16:04 +0900 Subject: [PATCH 032/134] Style --- Lib9c/Action/Stake.cs | 19 ++++++++++++------- Lib9c/Extensions/SheetsExtensions.cs | 4 +++- Lib9c/Model/Stake/Contract.cs | 24 +++++++++++++----------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 71c2e694f..8764f3a5c 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -35,9 +35,10 @@ public Stake() } protected override IImmutableDictionary PlainValueInternal => - ImmutableDictionary.Empty.Add(AmountKey, (IValue) (Integer) Amount); + ImmutableDictionary.Empty.Add(AmountKey, (IValue)(Integer)Amount); - protected override void LoadPlainValueInternal(IImmutableDictionary plainValue) + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) { Amount = plainValue[AmountKey].ToBigInteger(); } @@ -77,7 +78,8 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}Stake exec started", addressesHex); var stakePolicySheet = states.GetSheet(); var currentStakeRegularRewardSheetAddress = - Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)].TableName); + Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)] + .TableName); var stakeRegularRewardSheet = states.GetSheet( currentStakeRegularRewardSheetAddress); @@ -101,8 +103,10 @@ public override IAccountStateDelta Execute(IActionContext context) } var latestStakeContract = new Contract( - stakeRegularFixedRewardSheetTableName: stakePolicySheet["StakeRegularFixedRewardSheet"].TableName, - stakeRegularRewardSheetTableName: stakePolicySheet["StakeRegularRewardSheet"].TableName + stakeRegularFixedRewardSheetTableName: + stakePolicySheet["StakeRegularFixedRewardSheet"].TableName, + stakeRegularRewardSheetTableName: + stakePolicySheet["StakeRegularRewardSheet"].TableName ); if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) @@ -132,7 +136,7 @@ public override IAccountStateDelta Execute(IActionContext context) { throw new RequiredBlockIndexException(); } - + return states .SetState(stakeStateAddress, Null.Value) .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance); @@ -146,7 +150,8 @@ public override IAccountStateDelta Execute(IActionContext context) } var ended = DateTimeOffset.UtcNow; - Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, ended - started); + Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, + ended - started); // Stake with more or less amount. return states diff --git a/Lib9c/Extensions/SheetsExtensions.cs b/Lib9c/Extensions/SheetsExtensions.cs index d0cd315f9..27bf6b069 100644 --- a/Lib9c/Extensions/SheetsExtensions.cs +++ b/Lib9c/Extensions/SheetsExtensions.cs @@ -411,7 +411,9 @@ public static RaidSimulatorSheets GetRaidSimulatorSheets( ); } - public static int FindLevelByStakedAmount(this IStakeRewardSheet sheet, Address agentAddress, + public static int FindLevelByStakedAmount( + this IStakeRewardSheet sheet, + Address agentAddress, FungibleAssetValue balance) { List orderedRows = diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 9d2d6a782..45c433404 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -10,17 +10,19 @@ public class Contract public const string StakeRegularFixedRewardSheetPrefix = "StakeRegularFixedRewardSheet_"; + public const string StakeRegularRewardSheetPrefix = "StakeRegularRewardSheet_"; public string StakeRegularFixedRewardSheetTableName { get; init; } - public string StakeRegularRewardSheetTableName { get; init; } + public string StakeRegularRewardSheetTableName { get; init; } - public Contract( + public Contract( string stakeRegularFixedRewardSheetTableName, string stakeRegularRewardSheetTableName) - { - if (!stakeRegularFixedRewardSheetTableName.StartsWith(StakeRegularFixedRewardSheetPrefix)) + { + if (!stakeRegularFixedRewardSheetTableName.StartsWith( + StakeRegularFixedRewardSheetPrefix)) { throw new ArgumentException(nameof(stakeRegularFixedRewardSheetTableName)); } @@ -32,10 +34,10 @@ public Contract( StakeRegularFixedRewardSheetTableName = stakeRegularFixedRewardSheetTableName; StakeRegularRewardSheetTableName = stakeRegularRewardSheetTableName; - } - - public Contract(IValue serialized) - { + } + + public Contract(IValue serialized) + { if (serialized is not List list) { throw new ArgumentException( @@ -64,14 +66,14 @@ public Contract(IValue serialized) StakeRegularRewardSheetTableName = (Text)list[reservedCount + 1]; } - public List Serialize() - { + public List Serialize() + { return new List( (Text)StateTypeName, (Integer)StateTypeVersion, (Text)StakeRegularFixedRewardSheetTableName, (Text)StakeRegularRewardSheetTableName ); - } + } } } From eebffdb6ed7386223a56fdce0ff2f14bb2843a72 Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:26:01 +0900 Subject: [PATCH 033/134] Deprecate `claim_stake_reward8` --- .Lib9c.Tests/Action/ClaimStakeReward1Test.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward2Test.cs | 2 +- ...laimStakeRewardTest.cs => ClaimStakeReward8Test.cs} | 10 +++++----- .../Action/Factory/ClaimStakeRewardFactoryTest.cs | 4 ++-- .../{ClaimStakeReward.cs => ClaimStakeReward8.cs} | 8 +++++--- Lib9c/Action/Factory/ClaimStakeRewardFactory.cs | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) rename .Lib9c.Tests/Action/{ClaimStakeRewardTest.cs => ClaimStakeReward8Test.cs} (98%) rename Lib9c/Action/{ClaimStakeReward.cs => ClaimStakeReward8.cs} (98%) diff --git a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs index f5323c626..1addb0e37 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs @@ -34,7 +34,7 @@ public ClaimStakeReward1Test(ITestOutputHelper outputHelper) var sheets = TableSheetsImporter.ImportSheets(); sheets[nameof(StakeRegularRewardSheet)] = - ClaimStakeReward.V2.StakeRegularRewardSheetCsv; + ClaimStakeReward8.V2.StakeRegularRewardSheetCsv; foreach (var (key, value) in sheets) { _initialState = _initialState diff --git a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs index a7ded3b61..9765181b7 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs @@ -35,7 +35,7 @@ public ClaimStakeReward2Test(ITestOutputHelper outputHelper) var sheets = TableSheetsImporter.ImportSheets(); sheets[nameof(StakeRegularRewardSheet)] = - ClaimStakeReward.V2.StakeRegularRewardSheetCsv; + ClaimStakeReward8.V2.StakeRegularRewardSheetCsv; foreach (var (key, value) in sheets) { _initialState = _initialState diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeReward8Test.cs similarity index 98% rename from .Lib9c.Tests/Action/ClaimStakeRewardTest.cs rename to .Lib9c.Tests/Action/ClaimStakeReward8Test.cs index aeca973de..d50d63331 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward8Test.cs @@ -14,7 +14,7 @@ namespace Lib9c.Tests.Action using Xunit; using Xunit.Abstractions; - public class ClaimStakeRewardTest + public class ClaimStakeReward8Test { private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; @@ -34,7 +34,7 @@ public class ClaimStakeRewardTest private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; private readonly Currency _ncg; - public ClaimStakeRewardTest(ITestOutputHelper outputHelper) + public ClaimStakeReward8Test(ITestOutputHelper outputHelper) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() @@ -53,8 +53,8 @@ public ClaimStakeRewardTest(ITestOutputHelper outputHelper) [Fact] public void Serialization() { - var action = new ClaimStakeReward(_avatarAddr); - var deserialized = new ClaimStakeReward(); + var action = new ClaimStakeReward8(_avatarAddr); + var deserialized = new ClaimStakeReward8(); deserialized.LoadPlainValue(action.PlainValue); Assert.Equal(action.AvatarAddress, deserialized.AvatarAddress); } @@ -442,7 +442,7 @@ private void Execute( .SetState(stakeStateAddr, initialStakeState.Serialize()) .MintAsset(context, stakeStateAddr, _ncg * stakeAmount); - var action = new ClaimStakeReward(avatarAddr); + var action = new ClaimStakeReward8(avatarAddr); var states = action.Execute(new ActionContext { PreviousState = prevState, diff --git a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs index a2a43dc3a..0fdbc5970 100644 --- a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs +++ b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs @@ -52,8 +52,8 @@ public static IEnumerable GetAllClaimStakeRewardV1() [InlineData(ClaimStakeReward6.ObsoleteBlockIndex, typeof(ClaimStakeReward6))] [InlineData(ClaimStakeReward6.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward7))] [InlineData(ClaimStakeReward7.ObsoleteBlockIndex, typeof(ClaimStakeReward7))] - [InlineData(ClaimStakeReward7.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))] - [InlineData(long.MaxValue, typeof(ClaimStakeReward))] + [InlineData(ClaimStakeReward7.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward8))] + [InlineData(long.MaxValue, typeof(ClaimStakeReward8))] public void Create_ByBlockIndex_Success( long blockIndex, Type type) diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward8.cs similarity index 98% rename from Lib9c/Action/ClaimStakeReward.cs rename to Lib9c/Action/ClaimStakeReward8.cs index d2e3330c6..9ce42acad 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward8.cs @@ -22,9 +22,11 @@ namespace Nekoyume.Action /// Hard forked at https://github.com/planetarium/lib9c/pull/2106 /// [ActionType(ActionTypeText)] - public class ClaimStakeReward : GameAction, IClaimStakeReward, IClaimStakeRewardV1 + [ActionObsolete(ObsoleteBlockIndex)] + public class ClaimStakeReward8 : GameAction, IClaimStakeReward, IClaimStakeRewardV1 { private const string ActionTypeText = "claim_stake_reward8"; + private const long ObsoleteBlockIndex = ActionObsoleteConfig.V200080ObsoleteIndex; /// /// This is the version 1 of the stake reward sheet. @@ -178,12 +180,12 @@ public static StakeRegularFixedRewardSheet StakeRegularFixedRewardSheet Address IClaimStakeRewardV1.AvatarAddress => AvatarAddress; - public ClaimStakeReward(Address avatarAddress) : this() + public ClaimStakeReward8(Address avatarAddress) : this() { AvatarAddress = avatarAddress; } - public ClaimStakeReward() + public ClaimStakeReward8() { } diff --git a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs index 87b2b398f..6423cbb0e 100644 --- a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs +++ b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs @@ -13,7 +13,7 @@ public static IClaimStakeReward CreateByBlockIndex( { if (blockIndex > ClaimStakeReward7.ObsoleteBlockIndex) { - return new ClaimStakeReward(avatarAddress); + return new ClaimStakeReward8(avatarAddress); } if (blockIndex > ClaimStakeReward6.ObsoleteBlockIndex) @@ -59,7 +59,7 @@ public static IClaimStakeReward CreateByVersion( 5 => new ClaimStakeReward5(avatarAddress), 6 => new ClaimStakeReward6(avatarAddress), 7 => new ClaimStakeReward7(avatarAddress), - 8 => new ClaimStakeReward(avatarAddress), + 8 => new ClaimStakeReward8(avatarAddress), _ => throw new ArgumentOutOfRangeException( $"Invalid version: {version}"), }; From 397b10327a4afd9a7e88fd3ab2802b63c399cba5 Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:35:14 +0900 Subject: [PATCH 034/134] Correct `StakePolicySheet`'s key column --- Lib9c/TableData/Stake/StakePolicySheet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs index d8450e3a9..3211b03f1 100644 --- a/Lib9c/TableData/Stake/StakePolicySheet.cs +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -8,7 +8,7 @@ public class StakePolicySheet : Sheet [Serializable] public class Row : SheetRow { - public override string Key => TableName; + public override string Key => TableTypeName; public string TableTypeName { get; private set; } From a157f3d400520b4d4c85f742c47ac23abd88649d Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 08:38:09 +0900 Subject: [PATCH 035/134] Introduce `claim_stake_reward9` --- Lib9c/Action/ClaimStakeReward.cs | 242 +++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 Lib9c/Action/ClaimStakeReward.cs diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs new file mode 100644 index 000000000..ddd0d0634 --- /dev/null +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Immutable; +using System.Globalization; +using System.Linq; +using Bencodex.Types; +using Lib9c; +using Lib9c.Abstractions; +using Libplanet.Action; +using Libplanet.Action.State; +using Libplanet.Crypto; +using Libplanet.Types.Assets; +using Nekoyume.Extensions; +using Nekoyume.Helper; +using Nekoyume.Model.Item; +using Nekoyume.Model.Stake; +using Nekoyume.Model.State; +using Nekoyume.TableData; +using static Lib9c.SerializeKeys; + +namespace Nekoyume.Action +{ + /// + /// Hard forked at https://github.com/planetarium/lib9c/pull/2097 + /// + [ActionType(ActionTypeText)] + public class ClaimStakeReward : GameAction, IClaimStakeReward, IClaimStakeRewardV1 + { + private const string ActionTypeText = "claim_stake_reward9"; + + internal Address AvatarAddress { get; private set; } + + Address IClaimStakeRewardV1.AvatarAddress => AvatarAddress; + + public ClaimStakeReward(Address avatarAddress) : this() + { + AvatarAddress = avatarAddress; + } + + public ClaimStakeReward() + { + } + + protected override IImmutableDictionary PlainValueInternal => + ImmutableDictionary.Empty + .Add(AvatarAddressKey, AvatarAddress.Serialize()); + + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) + { + AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); + } + + // StakeState -> StakeStateV2 migration (refactoring?) + // StakeStateV2.Contract 기준으로 시트 가져와서 보상 주기 + // StakeStateV2.ClaimedBlockIndex를 셀프로 액션에서 직접 넣어주니까 잘 넣어줘야... + public override IAccountStateDelta Execute(IActionContext context) + { + context.UseGas(1); + if (context.Rehearsal) + { + return context.PreviousState; + } + + var states = context.PreviousState; + var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); + var stakeStateAddress = StakeState.DeriveAddress(context.Signer); + var ncg = states.GetGoldCurrency(); + var stakedAmount = states.GetBalance(stakeStateAddress, ncg); + if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) + { + throw new FailedLoadStateException( + ActionTypeText, + addressesHex, + typeof(StakeState), + stakeStateAddress); + } + + if (stakeStateV2.ClaimableBlockIndex < context.BlockIndex) + { + throw new RequiredBlockIndexException( + ActionTypeText, + addressesHex, + context.BlockIndex); + } + + if (!states.TryGetAvatarStateV2( + context.Signer, + AvatarAddress, + out var avatarState, + out var migrationRequired)) + { + throw new FailedLoadStateException( + ActionTypeText, + addressesHex, + typeof(AvatarState), + AvatarAddress); + } + + var sheets = states.GetSheets(sheetTuples: new[] + { + ( + typeof(StakeRegularFixedRewardSheet), + stakeStateV2.Contract.StakeRegularFixedRewardSheetTableName + ), + ( + typeof(StakeRegularRewardSheet), + stakeStateV2.Contract.StakeRegularRewardSheetTableName + ), + (typeof(ConsumableItemSheet), nameof(ConsumableItemSheet)), + (typeof(CostumeItemSheet), nameof(CostumeItemSheet)), + (typeof(EquipmentItemSheet), nameof(EquipmentItemSheet)), + (typeof(MaterialItemSheet), nameof(MaterialItemSheet)), + }); + var stakeRegularFixedRewardSheet = sheets.GetSheet(); + var stakeRegularRewardSheet = sheets.GetSheet(); + // NOTE: + var stakingLevel = Math.Min( + stakeRegularRewardSheet.FindLevelByStakedAmount( + context.Signer, + stakedAmount), + stakeRegularRewardSheet.Keys.Max()); + var itemSheet = sheets.GetItemSheet(); + // The first reward is given at the claimable block index. + var rewardSteps = 1 + (int)Math.DivRem( + context.BlockIndex - stakeStateV2.ClaimableBlockIndex, + StakeState.RewardInterval, + out var remained); + + // states = ProcessReward( + // context, + // states, + // ref avatarState, + // itemSheet, + // stakedAmount, + // rewardSteps, + // stakeRegularFixedRewardSheet[stakingLevel].Rewards, + // stakeRegularRewardSheet[stakingLevel].Rewards); + + // Fixed Reward + foreach (var reward in stakeRegularFixedRewardSheet[stakingLevel].Rewards) + { + var itemRow = itemSheet[reward.ItemId]; + var item = itemRow is MaterialItemSheet.Row materialRow + ? ItemFactory.CreateTradableMaterial(materialRow) + : ItemFactory.CreateItem(itemRow, context.Random); + avatarState.inventory.AddItem(item, reward.Count * rewardSteps); + } + + // Regular Reward + foreach (var reward in stakeRegularRewardSheet[stakingLevel].Rewards) + { + var rateFav = FungibleAssetValue.Parse( + stakedAmount.Currency, + reward.DecimalRate.ToString(CultureInfo.InvariantCulture)); + var rewardQuantityForSingleStep = stakedAmount.DivRem(rateFav, out _); + if (rewardQuantityForSingleStep <= 0) + { + continue; + } + + switch (reward.Type) + { + case StakeRegularRewardSheet.StakeRewardType.Item: + { + var majorUnit = (int)rewardQuantityForSingleStep * rewardSteps; + if (majorUnit < 1) + { + continue; + } + + var itemRow = itemSheet[reward.ItemId]; + var item = itemRow is MaterialItemSheet.Row materialRow + ? ItemFactory.CreateTradableMaterial(materialRow) + : ItemFactory.CreateItem(itemRow, context.Random); + + avatarState.inventory.AddItem(item, majorUnit); + break; + } + case StakeRegularRewardSheet.StakeRewardType.Rune: + { + var majorUnit = rewardQuantityForSingleStep * rewardSteps; + if (majorUnit < 1) + { + continue; + } + + var runeReward = RuneHelper.StakeRune * majorUnit; + states = states.MintAsset(context, AvatarAddress, runeReward); + break; + } + case StakeRegularRewardSheet.StakeRewardType.Currency: + { + if (string.IsNullOrEmpty(reward.CurrencyTicker)) + { + throw new NullReferenceException("currency ticker is null or empty"); + } + + var rewardCurrency = reward.CurrencyDecimalPlaces == null + ? Currencies.GetMinterlessCurrency(reward.CurrencyTicker) + : Currency.Uncapped( + reward.CurrencyTicker, + Convert.ToByte(reward.CurrencyDecimalPlaces.Value), + minters: null); + var majorUnit = rewardQuantityForSingleStep * rewardSteps; + var rewardFav = rewardCurrency * majorUnit; + states = states.MintAsset( + context, + context.Signer, + rewardFav); + break; + } + default: + throw new ArgumentException($"Can't handle reward type: {reward.Type}"); + } + } + + // NOTE: update claimed block index. + stakeStateV2 = new StakeStateV2( + stakeStateV2.Contract, + stakeStateV2.StartedBlockIndex, + context.BlockIndex - remained); + + if (migrationRequired) + { + states = states + .SetState(avatarState.address, avatarState.SerializeV2()) + .SetState( + avatarState.address.Derive(LegacyWorldInformationKey), + avatarState.worldInformation.Serialize()) + .SetState( + avatarState.address.Derive(LegacyQuestListKey), + avatarState.questList.Serialize()); + } + + return states + .SetState(stakeStateAddress, stakeStateV2.Serialize()) + .SetState( + avatarState.address.Derive(LegacyInventoryKey), + avatarState.inventory.Serialize()); + } + } +} From 4557d10a576793d63563ff77d6e28a13135a00e9 Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 30 Aug 2023 10:11:00 +0900 Subject: [PATCH 036/134] Treat reward & lockup interval as contract --- Lib9c/Action/AccountStateExtensions.cs | 4 +++- Lib9c/Action/Stake.cs | 12 ++++++---- Lib9c/Model/Stake/Contract.cs | 14 ++++++++++-- Lib9c/Model/Stake/StakeStateV2.cs | 27 +++++++++++++++-------- Lib9c/TableCSV/Stake/StakePolicySheet.csv | 7 ++++-- Lib9c/TableData/Stake/StakePolicySheet.cs | 11 +++++---- 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index ee6b9d99d..9a2ec0f8e 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -988,7 +988,9 @@ public static bool TryGetStakeStateV2( stakeStateV1, new Contract( stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, - stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName)); + stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName, + rewardInterval: StakeState.RewardInterval, + lockupInterval: StakeState.LockupInterval)); return true; } diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 8764f3a5c..4acc9c156 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Immutable; +using System.Globalization; using System.Linq; using System.Numerics; using Bencodex.Types; @@ -78,8 +79,7 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}Stake exec started", addressesHex); var stakePolicySheet = states.GetSheet(); var currentStakeRegularRewardSheetAddress = - Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)] - .TableName); + Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)].Value); var stakeRegularRewardSheet = states.GetSheet( currentStakeRegularRewardSheetAddress); @@ -104,9 +104,13 @@ public override IAccountStateDelta Execute(IActionContext context) var latestStakeContract = new Contract( stakeRegularFixedRewardSheetTableName: - stakePolicySheet["StakeRegularFixedRewardSheet"].TableName, + stakePolicySheet["StakeRegularFixedRewardSheet"].Value, stakeRegularRewardSheetTableName: - stakePolicySheet["StakeRegularRewardSheet"].TableName + stakePolicySheet["StakeRegularRewardSheet"].Value, + rewardInterval: + long.Parse(stakePolicySheet["RewardInterval"].Value, CultureInfo.InvariantCulture), + lockupInterval: + long.Parse(stakePolicySheet["LockupInterval"].Value, CultureInfo.InvariantCulture) ); if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 45c433404..15d45c335 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -16,10 +16,14 @@ public const string StakeRegularRewardSheetPrefix public string StakeRegularFixedRewardSheetTableName { get; init; } public string StakeRegularRewardSheetTableName { get; init; } + public long RewardInterval { get; init; } + public long LockupInterval { get; init; } public Contract( string stakeRegularFixedRewardSheetTableName, - string stakeRegularRewardSheetTableName) + string stakeRegularRewardSheetTableName, + long rewardInterval, + long lockupInterval) { if (!stakeRegularFixedRewardSheetTableName.StartsWith( StakeRegularFixedRewardSheetPrefix)) @@ -34,6 +38,8 @@ public Contract( StakeRegularFixedRewardSheetTableName = stakeRegularFixedRewardSheetTableName; StakeRegularRewardSheetTableName = stakeRegularRewardSheetTableName; + RewardInterval = rewardInterval; + LockupInterval = lockupInterval; } public Contract(IValue serialized) @@ -64,6 +70,8 @@ public Contract(IValue serialized) const int reservedCount = 2; StakeRegularFixedRewardSheetTableName = (Text)list[reservedCount]; StakeRegularRewardSheetTableName = (Text)list[reservedCount + 1]; + RewardInterval = (Integer)list[reservedCount + 2]; + LockupInterval = (Integer)list[reservedCount + 3]; } public List Serialize() @@ -72,7 +80,9 @@ public List Serialize() (Text)StateTypeName, (Integer)StateTypeVersion, (Text)StakeRegularFixedRewardSheetTableName, - (Text)StakeRegularRewardSheetTableName + (Text)StakeRegularRewardSheetTableName, + (Integer)RewardInterval, + (Integer)LockupInterval ); } } diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs index 143566df5..0d88ce9eb 100644 --- a/Lib9c/Model/Stake/StakeStateV2.cs +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -11,28 +11,37 @@ namespace Nekoyume.Model.Stake public readonly Contract Contract; public readonly long StartedBlockIndex; - public readonly long ClaimedBlockIndex; + public readonly long ReceivedBlockIndex; public long CancellableBlockIndex => - StartedBlockIndex + StakeState.LockupInterval; + StartedBlockIndex + Contract.LockupInterval; + + public long ClaimedBlockIndex => ReceivedBlockIndex == 0 + ? StartedBlockIndex + : StartedBlockIndex + Math.DivRem( + ReceivedBlockIndex - StartedBlockIndex, + Contract.RewardInterval, + out _ + ) * Contract.RewardInterval; + public long ClaimableBlockIndex => - ClaimedBlockIndex + StakeState.RewardInterval; + ClaimedBlockIndex + Contract.RewardInterval; public StakeStateV2( Contract contract, long startedBlockIndex) - : this(contract, startedBlockIndex, startedBlockIndex) + : this(contract, startedBlockIndex, 0) { } public StakeStateV2( Contract contract, long startedBlockIndex, - long claimedBlockIndex) + long receivedBlockIndex) { Contract = contract; StartedBlockIndex = startedBlockIndex; - ClaimedBlockIndex = claimedBlockIndex; + ReceivedBlockIndex = receivedBlockIndex; } public StakeStateV2( @@ -41,7 +50,7 @@ Contract contract ) : this( contract, stakeState.StartedBlockIndex, - stakeState.GetClaimableBlockIndex(long.MaxValue) - StakeState.RewardInterval + stakeState.ReceivedBlockIndex ) { } @@ -69,7 +78,7 @@ list[1] is not Integer stateTypeVersionValue || Contract = new Contract(list[reservedCount]); StartedBlockIndex = (Integer)list[reservedCount + 1]; - ClaimedBlockIndex = (Integer)list[reservedCount + 2]; + ReceivedBlockIndex = (Integer)list[reservedCount + 2]; } public IValue Serialize() => new List( @@ -77,7 +86,7 @@ list[1] is not Integer stateTypeVersionValue || (Integer)StateTypeVersion, Contract.Serialize(), (Integer)StartedBlockIndex, - (Integer)ClaimedBlockIndex + (Integer)ReceivedBlockIndex ); } } diff --git a/Lib9c/TableCSV/Stake/StakePolicySheet.csv b/Lib9c/TableCSV/Stake/StakePolicySheet.csv index 0b4295a8d..38088333a 100644 --- a/Lib9c/TableCSV/Stake/StakePolicySheet.csv +++ b/Lib9c/TableCSV/Stake/StakePolicySheet.csv @@ -1,2 +1,5 @@ -table_type_name,table_name -StakeRegularRewardSheet,StakeRegularRewardSheet_V1020100120110 +attr_name,value +StakeRegularRewardSheet,StakeRegularRewardSheet_V5 +StakeRegularFixedRewardSheet,StakeRegularRewardSheet_V5 +RewardInterval,50400 +LockupInterval,201600 diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs index 3211b03f1..c5e345c93 100644 --- a/Lib9c/TableData/Stake/StakePolicySheet.cs +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -8,16 +8,15 @@ public class StakePolicySheet : Sheet [Serializable] public class Row : SheetRow { - public override string Key => TableTypeName; + public override string Key => AttrName; - public string TableTypeName { get; private set; } - - public string TableName { get; private set; } + public string AttrName { get; private set; } + public string Value { get; private set; } public override void Set(IReadOnlyList fields) { - TableTypeName = fields[0]; - TableName = fields[1]; + AttrName = fields[0]; + Value = fields[1]; } } From 3301516e2d8a5ea055fbbbff0285a47e760ec1dd Mon Sep 17 00:00:00 2001 From: jonny Date: Mon, 28 Aug 2023 11:18:42 +0900 Subject: [PATCH 037/134] add EnhancementCostSheetV3.csv.meta file --- Lib9c/TableCSV/Cost/EnhancementCostSheetV3.csv.meta | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Lib9c/TableCSV/Cost/EnhancementCostSheetV3.csv.meta diff --git a/Lib9c/TableCSV/Cost/EnhancementCostSheetV3.csv.meta b/Lib9c/TableCSV/Cost/EnhancementCostSheetV3.csv.meta new file mode 100644 index 000000000..24fc9bf3a --- /dev/null +++ b/Lib9c/TableCSV/Cost/EnhancementCostSheetV3.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 86d2bd2ee3e5821478259fdbdfd7960b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 3840a04f1c142fc92577b62dcd8d2b41bdd2c87c Mon Sep 17 00:00:00 2001 From: hyeon Date: Mon, 28 Aug 2023 15:48:59 +0900 Subject: [PATCH 038/134] Change required block index calculation from adding each step to subtracting accumulated step --- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 49 ++++++++++------------ Lib9c/Action/ItemEnhancement.cs | 8 ++-- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 3a673cfb2..106d000f2 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -14,7 +14,6 @@ namespace Lib9c.Tests.Action using Nekoyume.Model.Item; using Nekoyume.Model.Mail; using Nekoyume.Model.State; - using Nekoyume.TableData; using Xunit; using static SerializeKeys; @@ -90,30 +89,28 @@ public ItemEnhancementTest() [Theory] // from 0 to 1 using one level 0 material - [InlineData(0, 1, 0, 25, 0, 1)] + [InlineData(0, 1, 0, 1)] // from 0 to N using multiple level 0 materials - [InlineData(0, 2, 0, 87, 0, 3)] - [InlineData(0, 4, 20, 837, 0, 15)] + [InlineData(0, 2, 0, 3)] + [InlineData(0, 4, 0, 15)] // from K to K with material(s). Check requiredBlock == 0 - [InlineData(10, 10, 0, 0, 0, 1)] + [InlineData(10, 10, 0, 1)] // from K to N using one level X material - [InlineData(5, 6, 40, 1300, 6, 1)] + [InlineData(5, 6, 6, 1)] // from K to N using multiple materials - [InlineData(5, 7, 120, 3800, 4, 6)] - [InlineData(5, 9, 600, 10275, 7, 5)] + [InlineData(5, 7, 4, 6)] + [InlineData(5, 9, 7, 5)] // from 20 to 21 (just to reach level 21 exp) - [InlineData(20, 21, 1310720, 7500, 20, 1)] + [InlineData(20, 21, 20, 1)] // from 20 to 21 (over level 21) - [InlineData(20, 21, 1310720, 7500, 20, 2)] + [InlineData(20, 21, 20, 2)] // from 21 to 21 (no level up) - [InlineData(21, 21, 0, 0, 1, 1)] - [InlineData(21, 21, 0, 0, 21, 1)] + [InlineData(21, 21, 1, 1)] + [InlineData(21, 21, 21, 1)] // Test: change of exp, change of level, required block, NCG price public void Execute( int startLevel, int expectedLevel, - int expectedCost, - int expectedBlockIndex, int materialLevel, int materialCount) { @@ -133,6 +130,16 @@ public void Execute( var startExp = equipment.Exp; _avatarState.inventory.AddItem(equipment, count: 1); + var expectedTargetRow = _tableSheets.EnhancementCostSheetV3.OrderedList.First(r => + r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && + r.Level == expectedLevel); + var startRow = _tableSheets.EnhancementCostSheetV3.OrderedList.FirstOrDefault(r => + r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && + r.Level == startLevel); + var expectedCost = expectedTargetRow.Cost - (startRow?.Cost ?? 0); + var expectedBlockIndex = + expectedTargetRow.RequiredBlockIndex - (startRow?.RequiredBlockIndex ?? 0); + var expectedExpIncrement = 0L; var materialIds = new List(); for (var i = 0; i < materialCount; i++) @@ -242,20 +249,6 @@ public void Execute( ); Assert.Equal(30, nextAvatarState.mailBox.Count); - EnhancementCostSheetV3.Row startRow; - - if (startLevel != 0) - { - startRow = _tableSheets.EnhancementCostSheetV3.OrderedList - .First(x => x.Grade == 1 && x.Level == startLevel); - } - else - { - startRow = new EnhancementCostSheetV3.Row(); - } - - var targetRow = _tableSheets.EnhancementCostSheetV3.OrderedList - .First(x => x.Grade == 1 && x.Level == expectedLevel); var stateDict = (Dictionary)nextState.GetState(slotAddress); var slot = new CombinationSlotState(stateDict); var slotResult = (ItemEnhancement.ResultModel)slot.Result; diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index 352a0ac21..449a862a5 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -364,10 +364,10 @@ public override IAccountStateDelta Execute(IActionContext context) states.GetGoldCurrency() * requiredNcg); } - // Required block index = Sum of all required blocks from start level to target level - var requiredBlockCount = GetRequiredBlockCount(preItemUsable, enhancementEquipment, - enhancementCostSheet); - var requiredBlockIndex = ctx.BlockIndex + requiredBlockCount; + // Required block index = Total required block to reach target level - total required block to reach start level (already elapsed) + var requiredBlockIndex = + ctx.BlockIndex + + (targetCostRow.RequiredBlockIndex - startCostRow.RequiredBlockIndex); enhancementEquipment.Update(requiredBlockIndex); // Remove materials From f71b2f3657da2c09ecab39a49e42f6af5b8a7016 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 10:46:42 +0900 Subject: [PATCH 039/134] Update Exp logic - Set default Exp for former equipments to 0 - Add GetRealExp function to get real exp of all equipments --- Lib9c/Model/Item/Equipment.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Lib9c/Model/Item/Equipment.cs b/Lib9c/Model/Item/Equipment.cs index dd1a3af1c..d6573b8d4 100644 --- a/Lib9c/Model/Item/Equipment.cs +++ b/Lib9c/Model/Item/Equipment.cs @@ -74,6 +74,10 @@ public Equipment(Dictionary serialized) : base(serialized) Exp = (long)((Integer)value).Value; } } + else + { + Exp = 0L; + } if (serialized.TryGetValue((Text) LegacyStatKey, out value)) { @@ -204,6 +208,19 @@ public void SetLevel(IRandom random, int targetLevel, EnhancementCostSheetV3 she } } } + public long GetRealExp(EquipmentItemSheet itemSheet, EnhancementCostSheetV3 costSheet) + { + if (Exp != 0) return Exp; + if (level == 0) + { + return (long)itemSheet.OrderedList.First(r => + r.ItemSubType == ItemSubType && r.Grade == Grade).Exp!; + } + + return costSheet.OrderedList.First(r => + r.ItemSubType == ItemSubType && r.Grade == Grade && + r.Level == level).Exp; + } public List GetOptions() { From a204de5a28536475d3261e210af89fad815b053b Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 10:48:00 +0900 Subject: [PATCH 040/134] Use GetRealExp function --- Lib9c/Action/ItemEnhancement.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index 449a862a5..0952c7e79 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -220,6 +220,7 @@ public override IAccountStateDelta Execute(IActionContext context) Dictionary sheets = states.GetSheets(sheetTypes: new[] { + typeof(EquipmentItemSheet), typeof(EnhancementCostSheetV3), typeof(MaterialItemSheet), typeof(CrystalEquipmentGrindingSheet), @@ -308,6 +309,7 @@ public override IAccountStateDelta Execute(IActionContext context) sw.Restart(); // Do the action + var equipmentItemSheet = sheets.GetSheet(); // Subtract required action point avatarState.actionPoint -= requiredActionPoint; @@ -322,8 +324,12 @@ public override IAccountStateDelta Execute(IActionContext context) var preItemUsable = new Equipment((Dictionary)enhancementEquipment.Serialize()); // Equipment level up & Update + enhancementEquipment.Exp = enhancementEquipment.GetRealExp(equipmentItemSheet, + enhancementCostSheet); + enhancementEquipment.Exp += - materialEquipments.Aggregate(0L, (total, m) => total + m.Exp); + materialEquipments.Aggregate(0L, + (total, m) => total + m.GetRealExp(equipmentItemSheet, enhancementCostSheet)); var row = enhancementCostSheet .OrderByDescending(r => r.Value.Exp) .First(row => From ae1e69594c50e22b2b28e822fb3f1b886b0b64c5 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 10:48:26 +0900 Subject: [PATCH 041/134] Add test cases to use old/new equipments --- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 75 +++++++++++++++++----- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 106d000f2..02eadf41e 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -89,29 +89,64 @@ public ItemEnhancementTest() [Theory] // from 0 to 1 using one level 0 material - [InlineData(0, 1, 0, 1)] + [InlineData(0, false, 1, 0, false, 1)] + [InlineData(0, false, 1, 0, true, 1)] + [InlineData(0, true, 1, 0, false, 1)] + [InlineData(0, true, 1, 0, true, 1)] // from 0 to N using multiple level 0 materials - [InlineData(0, 2, 0, 3)] - [InlineData(0, 4, 0, 15)] + [InlineData(0, false, 2, 0, false, 3)] + [InlineData(0, false, 4, 0, false, 15)] + [InlineData(0, false, 2, 0, true, 3)] + [InlineData(0, false, 4, 0, true, 15)] + [InlineData(0, true, 2, 0, false, 3)] + [InlineData(0, true, 4, 0, false, 15)] + [InlineData(0, true, 2, 0, true, 3)] + [InlineData(0, true, 4, 0, true, 15)] // from K to K with material(s). Check requiredBlock == 0 - [InlineData(10, 10, 0, 1)] + [InlineData(10, false, 10, 0, false, 1)] + [InlineData(10, false, 10, 0, true, 1)] + [InlineData(10, true, 10, 0, false, 1)] + [InlineData(10, true, 10, 0, true, 1)] // from K to N using one level X material - [InlineData(5, 6, 6, 1)] + [InlineData(5, false, 6, 6, false, 1)] + [InlineData(5, false, 6, 6, true, 1)] + [InlineData(5, true, 6, 6, false, 1)] + [InlineData(5, true, 6, 6, true, 1)] // from K to N using multiple materials - [InlineData(5, 7, 4, 6)] - [InlineData(5, 9, 7, 5)] + [InlineData(5, false, 7, 4, false, 6)] + [InlineData(5, false, 9, 7, false, 5)] + [InlineData(5, false, 7, 4, true, 6)] + [InlineData(5, false, 9, 7, true, 5)] + [InlineData(5, true, 7, 4, false, 6)] + [InlineData(5, true, 9, 7, false, 5)] + [InlineData(5, true, 7, 4, true, 6)] + [InlineData(5, true, 9, 7, true, 5)] // from 20 to 21 (just to reach level 21 exp) - [InlineData(20, 21, 20, 1)] + [InlineData(20, false, 21, 20, false, 1)] + [InlineData(20, false, 21, 20, true, 1)] + [InlineData(20, true, 21, 20, false, 1)] + [InlineData(20, true, 21, 20, true, 1)] // from 20 to 21 (over level 21) - [InlineData(20, 21, 20, 2)] + [InlineData(20, false, 21, 20, false, 2)] + [InlineData(20, false, 21, 20, true, 2)] + [InlineData(20, true, 21, 20, false, 2)] + [InlineData(20, true, 21, 20, true, 2)] // from 21 to 21 (no level up) - [InlineData(21, 21, 1, 1)] - [InlineData(21, 21, 21, 1)] + [InlineData(21, false, 21, 1, false, 1)] + [InlineData(21, false, 21, 21, false, 1)] + [InlineData(21, false, 21, 1, true, 1)] + [InlineData(21, false, 21, 21, true, 1)] + [InlineData(21, true, 21, 1, false, 1)] + [InlineData(21, true, 21, 21, false, 1)] + [InlineData(21, true, 21, 1, true, 1)] + [InlineData(21, true, 21, 21, true, 1)] // Test: change of exp, change of level, required block, NCG price public void Execute( int startLevel, + bool oldStart, int expectedLevel, int materialLevel, + bool oldMaterial, int materialCount) { var row = _tableSheets.EquipmentItemSheet.Values.First(r => r.Grade == 1 && r.Exp > 0); @@ -122,12 +157,17 @@ public void Execute( } else { - equipment.Exp = _tableSheets.EnhancementCostSheetV3.Values.First(r => - r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && + equipment.Exp = _tableSheets.EnhancementCostSheetV3.OrderedList.First(r => + r.ItemSubType == equipment.ItemSubType && r.Grade == equipment.Grade && r.Level == equipment.level).Exp; } var startExp = equipment.Exp; + if (oldStart) + { + equipment.Exp = 0L; + } + _avatarState.inventory.AddItem(equipment, count: 1); var expectedTargetRow = _tableSheets.EnhancementCostSheetV3.OrderedList.First(r => @@ -154,12 +194,17 @@ public void Execute( } else { - material.Exp = _tableSheets.EnhancementCostSheetV3.Values.First(r => - r.Grade == material.Grade && r.ItemSubType == material.ItemSubType && + material.Exp = _tableSheets.EnhancementCostSheetV3.OrderedList.First(r => + r.ItemSubType == material.ItemSubType && r.Grade == material.Grade && r.Level == material.level).Exp; } expectedExpIncrement += material.Exp; + if (oldMaterial) + { + material.Exp = 0L; + } + _avatarState.inventory.AddItem(material, count: 1); } From cd0533b0d69456dc24db4305643c8c1177e2f80d Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 22:34:43 +0900 Subject: [PATCH 042/134] Handle enhancement from level 0 to level 0 case --- Lib9c/Action/ItemEnhancement.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index 0952c7e79..9dd39337f 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -332,13 +332,12 @@ public override IAccountStateDelta Execute(IActionContext context) (total, m) => total + m.GetRealExp(equipmentItemSheet, enhancementCostSheet)); var row = enhancementCostSheet .OrderByDescending(r => r.Value.Exp) - .First(row => + .FirstOrDefault(row => row.Value.ItemSubType == enhancementEquipment.ItemSubType && row.Value.Grade == enhancementEquipment.Grade && row.Value.Exp <= enhancementEquipment.Exp ).Value; - - if (row.Level > enhancementEquipment.level) + if (!(row is null) && row.Level > enhancementEquipment.level) { enhancementEquipment.SetLevel(ctx.Random, row.Level, enhancementCostSheet); } From b1a71aed912374314665c5baa003e242f696570d Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 22:35:15 +0900 Subject: [PATCH 043/134] Conventions --- Lib9c/Action/ItemEnhancement.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index 9dd39337f..9e45cdaa0 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -69,7 +69,8 @@ public ResultModel() public ResultModel(Dictionary serialized) : base(serialized) { id = serialized["id"].ToGuid(); - materialItemIdList = serialized["materialItemIdList"].ToList(StateExtensions.ToGuid); + materialItemIdList = + serialized["materialItemIdList"].ToList(StateExtensions.ToGuid); gold = serialized["gold"].ToBigInteger(); actionPoint = serialized["actionPoint"].ToInteger(); enhancementResult = serialized["enhancementResult"].ToEnum(); @@ -397,7 +398,9 @@ public override IAccountStateDelta Execute(IActionContext context) CRYSTAL = 0 * CrystalCalculator.CRYSTAL, }; - var mail = new ItemEnhanceMail(result, ctx.BlockIndex, ctx.Random.GenerateRandomGuid(), requiredBlockIndex); + var mail = new ItemEnhanceMail( + result, ctx.BlockIndex, ctx.Random.GenerateRandomGuid(), requiredBlockIndex + ); result.id = mail.id; avatarState.inventory.RemoveNonFungibleItem(enhancementEquipment); avatarState.Update(mail); From 31ec5c443d8729470416b1c70e4fc6cc59cf286a Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 22:36:00 +0900 Subject: [PATCH 044/134] Update equipment model - Get EquipmentItemSheet.Row by ID, not Grade and ItemSubType - It also needs ElementalType but ID can cover all conditions. - Returns Exp field unconditionally. It has default value 0 --- Lib9c/Model/Item/Equipment.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib9c/Model/Item/Equipment.cs b/Lib9c/Model/Item/Equipment.cs index d6573b8d4..e70f1eeac 100644 --- a/Lib9c/Model/Item/Equipment.cs +++ b/Lib9c/Model/Item/Equipment.cs @@ -130,10 +130,7 @@ public override IValue Serialize() dict = dict.SetItem(MadeWithMimisbrunnrRecipeKey, MadeWithMimisbrunnrRecipe.Serialize()); } - if (Exp > 0) - { - dict = dict.SetItem(EquipmentExpKey, Exp.Serialize()); - } + dict = dict.SetItem(EquipmentExpKey, Exp.Serialize()); return dict; #pragma warning restore LAA1002 @@ -208,13 +205,13 @@ public void SetLevel(IRandom random, int targetLevel, EnhancementCostSheetV3 she } } } + public long GetRealExp(EquipmentItemSheet itemSheet, EnhancementCostSheetV3 costSheet) { if (Exp != 0) return Exp; if (level == 0) { - return (long)itemSheet.OrderedList.First(r => - r.ItemSubType == ItemSubType && r.Grade == Grade).Exp!; + return (long)itemSheet.OrderedList.First(r => r.Id == Id).Exp!; } return costSheet.OrderedList.First(r => From b3370bcbe9f019be6d93046e1abc0d7238b45c00 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 22:37:30 +0900 Subject: [PATCH 045/134] Update dummy data to make more test cases --- Lib9c/TableCSV/Item/EquipmentItemSheet.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv index e419aafc1..db5f5ff91 100644 --- a/Lib9c/TableCSV/Item/EquipmentItemSheet.csv +++ b/Lib9c/TableCSV/Item/EquipmentItemSheet.csv @@ -1,6 +1,6 @@ id,_name,item_sub_type,grade,elemental_type,set_id,stat_type,stat_value,attack_range,spine_resource_path,exp 10100000,나뭇가지,Weapon,0,Normal,0,ATK,1,2,10100000,0 -10110000,검,Weapon,1,Normal,1,ATK,11,2,10110000,10 +10110000,검,Weapon,1,Normal,1,ATK,11,2,10110000,5 10111000,롱 소드(불),Weapon,1,Fire,2,ATK,14,2,10111000,10 10112000,롱 소드(물),Weapon,1,Water,3,ATK,17,2,10112000,10 10113000,롱 소드(땅),Weapon,1,Land,4,ATK,55,2,10113000,10 From adb922655006710c81809d103e4bb19c48b3e888 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 22:37:52 +0900 Subject: [PATCH 046/134] Add more tests: level 0 to 0 case --- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 02eadf41e..7d82ad169 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -88,20 +88,25 @@ public ItemEnhancementTest() } [Theory] - // from 0 to 1 using one level 0 material - [InlineData(0, false, 1, 0, false, 1)] - [InlineData(0, false, 1, 0, true, 1)] - [InlineData(0, true, 1, 0, false, 1)] - [InlineData(0, true, 1, 0, true, 1)] + // from 0 to 0 using one level 0 material + [InlineData(0, false, 0, 0, false, 1)] + [InlineData(0, false, 0, 0, true, 1)] + [InlineData(0, true, 0, 0, false, 1)] + [InlineData(0, true, 0, 0, true, 1)] + // from 0 to 1 using two level 0 material + [InlineData(0, false, 1, 0, false, 3)] + [InlineData(0, false, 1, 0, true, 3)] + [InlineData(0, true, 1, 0, false, 3)] + [InlineData(0, true, 1, 0, true, 3)] // from 0 to N using multiple level 0 materials - [InlineData(0, false, 2, 0, false, 3)] - [InlineData(0, false, 4, 0, false, 15)] - [InlineData(0, false, 2, 0, true, 3)] - [InlineData(0, false, 4, 0, true, 15)] - [InlineData(0, true, 2, 0, false, 3)] - [InlineData(0, true, 4, 0, false, 15)] - [InlineData(0, true, 2, 0, true, 3)] - [InlineData(0, true, 4, 0, true, 15)] + [InlineData(0, false, 2, 0, false, 7)] + [InlineData(0, false, 4, 0, false, 31)] + [InlineData(0, false, 2, 0, true, 7)] + [InlineData(0, false, 4, 0, true, 31)] + [InlineData(0, true, 2, 0, false, 7)] + [InlineData(0, true, 4, 0, false, 31)] + [InlineData(0, true, 2, 0, true, 7)] + [InlineData(0, true, 4, 0, true, 31)] // from K to K with material(s). Check requiredBlock == 0 [InlineData(10, false, 10, 0, false, 1)] [InlineData(10, false, 10, 0, true, 1)] @@ -149,7 +154,7 @@ public void Execute( bool oldMaterial, int materialCount) { - var row = _tableSheets.EquipmentItemSheet.Values.First(r => r.Grade == 1 && r.Exp > 0); + var row = _tableSheets.EquipmentItemSheet.Values.First(r => r.Id == 10110000); var equipment = (Equipment)ItemFactory.CreateItemUsable(row, default, 0, startLevel); if (startLevel == 0) { @@ -170,15 +175,16 @@ public void Execute( _avatarState.inventory.AddItem(equipment, count: 1); - var expectedTargetRow = _tableSheets.EnhancementCostSheetV3.OrderedList.First(r => - r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && - r.Level == expectedLevel); + var expectedTargetRow = _tableSheets.EnhancementCostSheetV3.OrderedList.FirstOrDefault( + r => + r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && + r.Level == expectedLevel); var startRow = _tableSheets.EnhancementCostSheetV3.OrderedList.FirstOrDefault(r => r.Grade == equipment.Grade && r.ItemSubType == equipment.ItemSubType && r.Level == startLevel); - var expectedCost = expectedTargetRow.Cost - (startRow?.Cost ?? 0); + var expectedCost = (expectedTargetRow?.Cost ?? 0) - (startRow?.Cost ?? 0); var expectedBlockIndex = - expectedTargetRow.RequiredBlockIndex - (startRow?.RequiredBlockIndex ?? 0); + (expectedTargetRow?.RequiredBlockIndex ?? 0) - (startRow?.RequiredBlockIndex ?? 0); var expectedExpIncrement = 0L; var materialIds = new List(); From dccdc964d0ecb3a123f7f4990165098c3f0161cb Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 29 Aug 2023 23:07:59 +0900 Subject: [PATCH 047/134] Fix broken test: equipment always has exp --- .Lib9c.Tests/Model/Item/EquipmentTest.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.Lib9c.Tests/Model/Item/EquipmentTest.cs b/.Lib9c.Tests/Model/Item/EquipmentTest.cs index 77e71b7a6..829e64b62 100644 --- a/.Lib9c.Tests/Model/Item/EquipmentTest.cs +++ b/.Lib9c.Tests/Model/Item/EquipmentTest.cs @@ -2,8 +2,8 @@ namespace Lib9c.Tests.Model.Item { using System; using System.Collections.Generic; - using System.Numerics; using Nekoyume.Model.Item; + using Nekoyume.Model.State; using Nekoyume.TableData; using Xunit; using static SerializeKeys; @@ -43,10 +43,8 @@ public void Serialize(long exp) var deserialized = new Equipment((Bencodex.Types.Dictionary)serialized); var reSerialized = deserialized.Serialize(); - Assert.Equal( - exp != 0, - ((Bencodex.Types.Dictionary)serialized).ContainsKey(EquipmentExpKey) - ); + Assert.True(((Bencodex.Types.Dictionary)serialized).ContainsKey(EquipmentExpKey)); + Assert.True(((Bencodex.Types.Dictionary)serialized)[EquipmentExpKey].ToLong() >= 0); Assert.Equal(costume, deserialized); Assert.Equal(serialized, reSerialized); } From 7e7c45b34db0785a1ad5e2075cbdc59f7a4b6707 Mon Sep 17 00:00:00 2001 From: hyeon Date: Wed, 30 Aug 2023 17:44:20 +0900 Subject: [PATCH 048/134] Fix broken test --- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 7d82ad169..e14b74a89 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -335,7 +335,7 @@ public void Execute( ); Assert.Equal(preItemUsable.ItemId, slotResult.preItemUsable.ItemId); Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId); - Assert.Equal(targetRow.Cost - startRow.Cost, slotResult.gold); + Assert.Equal(expectedCost, slotResult.gold); } } } From 183555a7c5c2f14aa96e8c0b3da2a1df10453bce Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 31 Aug 2023 07:43:54 +0900 Subject: [PATCH 049/134] Handle claim_stake_reward8 in `ClaimStakeRewardFactory` --- .Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs | 4 +++- Lib9c/Action/ClaimStakeReward8.cs | 2 +- Lib9c/Action/Factory/ClaimStakeRewardFactory.cs | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs index 0fdbc5970..4c13b49f4 100644 --- a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs +++ b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs @@ -53,7 +53,9 @@ public static IEnumerable GetAllClaimStakeRewardV1() [InlineData(ClaimStakeReward6.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward7))] [InlineData(ClaimStakeReward7.ObsoleteBlockIndex, typeof(ClaimStakeReward7))] [InlineData(ClaimStakeReward7.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward8))] - [InlineData(long.MaxValue, typeof(ClaimStakeReward8))] + [InlineData(ClaimStakeReward8.ObsoleteBlockIndex, typeof(ClaimStakeReward8))] + [InlineData(ClaimStakeReward8.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))] + [InlineData(long.MaxValue, typeof(ClaimStakeReward))] public void Create_ByBlockIndex_Success( long blockIndex, Type type) diff --git a/Lib9c/Action/ClaimStakeReward8.cs b/Lib9c/Action/ClaimStakeReward8.cs index 9ce42acad..5960a78e3 100644 --- a/Lib9c/Action/ClaimStakeReward8.cs +++ b/Lib9c/Action/ClaimStakeReward8.cs @@ -26,7 +26,7 @@ namespace Nekoyume.Action public class ClaimStakeReward8 : GameAction, IClaimStakeReward, IClaimStakeRewardV1 { private const string ActionTypeText = "claim_stake_reward8"; - private const long ObsoleteBlockIndex = ActionObsoleteConfig.V200080ObsoleteIndex; + public const long ObsoleteBlockIndex = ActionObsoleteConfig.V200080ObsoleteIndex; /// /// This is the version 1 of the stake reward sheet. diff --git a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs index 6423cbb0e..d2b4810fc 100644 --- a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs +++ b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs @@ -11,6 +11,11 @@ public static IClaimStakeReward CreateByBlockIndex( long blockIndex, Address avatarAddress) { + if (blockIndex > ClaimStakeReward8.ObsoleteBlockIndex) + { + return new ClaimStakeReward(avatarAddress); + } + if (blockIndex > ClaimStakeReward7.ObsoleteBlockIndex) { return new ClaimStakeReward8(avatarAddress); @@ -60,6 +65,7 @@ public static IClaimStakeReward CreateByVersion( 6 => new ClaimStakeReward6(avatarAddress), 7 => new ClaimStakeReward7(avatarAddress), 8 => new ClaimStakeReward8(avatarAddress), + 9 => new ClaimStakeReward(avatarAddress), _ => throw new ArgumentOutOfRangeException( $"Invalid version: {version}"), }; From a79135d10c14a209969373abefa63ec9a9168388 Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 31 Aug 2023 07:43:03 +0900 Subject: [PATCH 050/134] Add `StakePolicySheet` property in `StakePolicySheet` for test --- .Lib9c.Tests/TableSheets.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.Lib9c.Tests/TableSheets.cs b/.Lib9c.Tests/TableSheets.cs index f334270d8..c4b1343c3 100644 --- a/.Lib9c.Tests/TableSheets.cs +++ b/.Lib9c.Tests/TableSheets.cs @@ -9,6 +9,7 @@ namespace Lib9c.Tests using Nekoyume.TableData.Garages; using Nekoyume.TableData.GrandFinale; using Nekoyume.TableData.Pet; + using Nekoyume.TableData.Stake; public class TableSheets { @@ -147,6 +148,8 @@ public TableSheets(Dictionary sheets) public StakeAchievementRewardSheet StakeAchievementRewardSheet { get; private set; } + public StakePolicySheet StakePolicySheet { get; private set; } + public SweepRequiredCPSheet SweepRequiredCPSheet { get; private set; } public CrystalEquipmentGrindingSheet CrystalEquipmentGrindingSheet { get; private set; } From d5ca5f8506874ff7ea62e620d72fed70f4e8735c Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 31 Aug 2023 08:32:45 +0900 Subject: [PATCH 051/134] Update .NET SDK version to 6.0.4xx version --- .github/workflows/main.yml | 6 +++--- .github/workflows/publish.yml | 2 +- global.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 904e0a4da..287be87d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.100 + dotnet-version: 6.0.400 - name: Install dependencies run: dotnet restore - name: Build @@ -62,7 +62,7 @@ jobs: submodules: true - uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.100 + dotnet-version: 6.0.400 - name: Enforce netstandard2.1 target with custom patch run: | set -e @@ -103,7 +103,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.100 + dotnet-version: 6.0.400 - name: Collect available action type ids run: | mkdir publish diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 345766be0..c72bd7028 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,7 @@ jobs: submodules: true - uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.100 + dotnet-version: 6.0.400 - name: build run: | dotnet_args="-c Release -p:NoPackageAnalysis=true" diff --git a/global.json b/global.json index d73dacb40..e4a225a52 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "6.0.400", "rollForward": "major" } } From 0488721f6b66f2090ad9bb7e043a1fc32429c800 Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 31 Aug 2023 08:42:28 +0900 Subject: [PATCH 052/134] Freeze `StakeAndClaimStakeReward*ScenarioTest` --- .../StakeAndClaimStakeReward2ScenarioTest.cs | 16 +++++----- .../StakeAndClaimStakeReward3ScenarioTest.cs | 16 +++++----- .../StakeAndClaimStakeRewardScenarioTest.cs | 29 ++++++++++--------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs index 50e73eed0..6f7214c29 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs @@ -633,7 +633,7 @@ public void StakeAndClaimStakeReward(long stakeAmount, (int ItemId, int Amount)[ var context = new ActionContext(); var states = _initialState.MintAsset(context, _signerAddress, _currency * stakeAmount); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -684,7 +684,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta var context = new ActionContext(); var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -709,7 +709,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta BlockIndex = newStakeBlockIndex, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 스테이킹 추가는 가능 // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext @@ -758,7 +758,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta var context = new ActionContext(); var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -783,7 +783,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta BlockIndex = StakeState.LockupInterval - 1, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 락업기간 이전에 deposit을 감소해서 save할때 락업되어 거부되는가 Assert.Throws(() => states = action.Execute(new ActionContext { @@ -816,7 +816,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new var context = new ActionContext(); var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -850,7 +850,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new states.GetBalance(stakeState.address, _currency)); } - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -908,7 +908,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() { var context = new ActionContext(); var states = _initialState.MintAsset(context, _signerAddress, _currency * 500); - IAction action = new Stake(500); + IAction action = new Stake2(500); states = action.Execute(new ActionContext { PreviousState = states, diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs index f7e5ee937..396e26d0d 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs @@ -604,7 +604,7 @@ public void StakeAndClaimStakeReward( var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * stakeAmount); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -657,7 +657,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -682,7 +682,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta BlockIndex = newStakeBlockIndex, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 스테이킹 추가는 가능 // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext @@ -731,7 +731,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -756,7 +756,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 락업기간 이전에 deposit을 감소해서 save할때 락업되어 거부되는가 Assert.Throws(() => states = action.Execute(new ActionContext { @@ -793,7 +793,7 @@ public void StakeLessAfterLockup( var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -827,7 +827,7 @@ public void StakeLessAfterLockup( states.GetBalance(stakeState.address, _ncg)); } - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -885,7 +885,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() { var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * 500); - IAction action = new Stake(500); + IAction action = new Stake2(500); states = action.Execute(new ActionContext { PreviousState = states, diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs index ec8674b2f..9f0f1951a 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs @@ -14,6 +14,7 @@ namespace Lib9c.Tests.Action.Scenario using Xunit; using Xunit.Abstractions; + // Tests for stake2 and claim_stake_reward{..8} actions public class StakeAndClaimStakeRewardScenarioTest { private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; @@ -687,7 +688,7 @@ public void StakeAndClaimStakeReward( var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * stakeAmount); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -701,7 +702,7 @@ public void StakeAndClaimStakeReward( 0 * RuneHelper.StakeRune, _initialStatesWithAvatarStateV2.GetBalance(_avatarAddr, RuneHelper.StakeRune)); - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); states = action.Execute(new ActionContext { PreviousState = states, @@ -755,7 +756,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -772,7 +773,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta _ncg * stakeAmount, states.GetBalance(stakeState.address, _ncg)); - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); states = action.Execute(new ActionContext { PreviousState = states, @@ -780,7 +781,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta BlockIndex = newStakeBlockIndex, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 스테이킹 추가는 가능 // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext @@ -830,7 +831,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -847,7 +848,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta _ncg * stakeAmount, states.GetBalance(stakeState.address, _ncg)); - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); states = action.Execute(new ActionContext { PreviousState = states, @@ -855,7 +856,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, }); - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); // 락업기간 이전에 deposit을 감소해서 save할때 락업되어 거부되는가 Assert.Throws(() => states = action.Execute( new ActionContext @@ -894,7 +895,7 @@ public void StakeLessAfterLockup( var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); - IAction action = new Stake(stakeAmount); + IAction action = new Stake2(stakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -906,7 +907,7 @@ public void StakeLessAfterLockup( // 201,600 블록 도달 이후 → 지정된 캐릭터 앞으로 이하 보상의 수령이 가능해야 한다. foreach ((var claimBlockIndex, (int itemId, int amount)[] expectedItems) in claimEvents) { - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); states = action.Execute(new ActionContext { PreviousState = states, @@ -928,7 +929,7 @@ public void StakeLessAfterLockup( states.GetBalance(stakeState.address, _ncg)); } - action = new Stake(newStakeAmount); + action = new Stake2(newStakeAmount); states = action.Execute(new ActionContext { PreviousState = states, @@ -961,7 +962,7 @@ public void StakeLessAfterLockup( Assert.Throws(() => { // 현재 스테이킹된 NCG를 인출할 수 없다 - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); states = action.Execute(new ActionContext { PreviousState = states, @@ -990,7 +991,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() { var context = new ActionContext(); var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * 500); - IAction action = new Stake(500); + IAction action = new Stake2(500); states = action.Execute(new ActionContext { PreviousState = states, @@ -998,7 +999,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); - action = new ClaimStakeReward(_avatarAddr); + action = new ClaimStakeReward8(_avatarAddr); Assert.Throws(() => states = action.Execute( new ActionContext { From 2453c08616fb7b818bf854fb29e248b629746cce Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 31 Aug 2023 08:47:09 +0900 Subject: [PATCH 053/134] Remove `init` property accessor from Contract's properties --- Lib9c/Model/Stake/Contract.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 15d45c335..8b20d29ae 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -14,10 +14,10 @@ public const string StakeRegularFixedRewardSheetPrefix public const string StakeRegularRewardSheetPrefix = "StakeRegularRewardSheet_"; - public string StakeRegularFixedRewardSheetTableName { get; init; } - public string StakeRegularRewardSheetTableName { get; init; } - public long RewardInterval { get; init; } - public long LockupInterval { get; init; } + public string StakeRegularFixedRewardSheetTableName { get; } + public string StakeRegularRewardSheetTableName { get; } + public long RewardInterval { get; } + public long LockupInterval { get; } public Contract( string stakeRegularFixedRewardSheetTableName, From 9a24c6744b74338a822a6316034ecf1028863641 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 11:00:13 +0900 Subject: [PATCH 054/134] Aura summon does not create mail --- Lib9c/Action/AuraSummon.cs | 8 -------- Lib9c/Model/Mail/IMail.cs | 1 - Lib9c/Model/Mail/SummonMail.cs | 33 --------------------------------- 3 files changed, 42 deletions(-) delete mode 100644 Lib9c/Model/Mail/SummonMail.cs diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 000541e93..f4903f79d 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -175,14 +175,6 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); avatarState.UpdateFromCombination(equipment); avatarState.UpdateQuestRewards(sheets.GetSheet()); - - // Create Mail - var mail = new SummonMail( - context.BlockIndex, - Id, - context.BlockIndex - ); - avatarState.Update(mail); } // Set states diff --git a/Lib9c/Model/Mail/IMail.cs b/Lib9c/Model/Mail/IMail.cs index 5d4b87dfc..4ad564b63 100644 --- a/Lib9c/Model/Mail/IMail.cs +++ b/Lib9c/Model/Mail/IMail.cs @@ -19,6 +19,5 @@ public interface IMail void Read(ProductSellerMail productSellerMail); void Read(ProductCancelMail productCancelMail); void Read(UnloadFromMyGaragesRecipientMail unloadFromMyGaragesRecipientMail); - void Read(SummonMail summonMail); } } diff --git a/Lib9c/Model/Mail/SummonMail.cs b/Lib9c/Model/Mail/SummonMail.cs deleted file mode 100644 index b8400c1ec..000000000 --- a/Lib9c/Model/Mail/SummonMail.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Bencodex.Types; -using Nekoyume.Model.State; - -namespace Nekoyume.Model.Mail -{ - [Serializable] - public class SummonMail : Mail - { - protected override string TypeId => nameof(SummonMail); - public override MailType MailType => MailType.Summon; - - public SummonMail(long blockIndex, Guid id, long requiredBlockIndex) : - base(blockIndex, id, requiredBlockIndex) - { - // TODO: Check what should be included in the summon mail - } - - public SummonMail(Dictionary serialized) : base(serialized) - { - // TODO: Check what should be included in the summon mail - } - - public override void Read(IMail mail) - { - mail.Read(this); - } - - // TODO: Check what should be included in the summon mail - public override IValue Serialize() => ((Dictionary)base.Serialize()) - .Add("key", 0.Serialize()); - } -} From d1c84c6a962f2015120df0f05504151234efb5fe Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 31 Aug 2023 11:42:28 +0900 Subject: [PATCH 055/134] apply some changes of "claim_stake_reward8" to "claim_stake_reward9" --- Lib9c/Action/ClaimStakeReward.cs | 35 +++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index ddd0d0634..f6e524893 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -195,12 +195,41 @@ public override IAccountStateDelta Execute(IActionContext context) throw new NullReferenceException("currency ticker is null or empty"); } - var rewardCurrency = reward.CurrencyDecimalPlaces == null - ? Currencies.GetMinterlessCurrency(reward.CurrencyTicker) - : Currency.Uncapped( + // NOTE: prepare reward currency. + Currency rewardCurrency; + // NOTE: this line covers the reward.CurrencyTicker is following cases: + // - Currencies.Crystal.Ticker + // - Currencies.Garage.Ticker + // - lower case is starting with "rune_" or "runestone_" + // - lower case is starting with "soulstone_" + try + { + rewardCurrency = + Currencies.GetMinterlessCurrency(reward.CurrencyTicker); + } + // NOTE: throw exception if reward.CurrencyTicker is null or empty. + catch (ArgumentNullException) + { + throw; + } + // NOTE: handle the case that reward.CurrencyTicker isn't covered by + // Currencies.GetMinterlessCurrency(). + catch (ArgumentException) + { + // NOTE: throw exception if reward.CurrencyDecimalPlaces is null. + if (reward.CurrencyDecimalPlaces is null) + { + throw new ArgumentException( + $"Decimal places of {reward.CurrencyTicker} is null"); + } + + // NOTE: new currency is created as uncapped currency. + rewardCurrency = Currency.Uncapped( reward.CurrencyTicker, Convert.ToByte(reward.CurrencyDecimalPlaces.Value), minters: null); + } + var majorUnit = rewardQuantityForSingleStep * rewardSteps; var rewardFav = rewardCurrency * majorUnit; states = states.MintAsset( From 40fcb4a221c2e28e8a75b066ad6f10f49f91b153 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 31 Aug 2023 14:34:14 +0900 Subject: [PATCH 056/134] move PatchTableSheet.PrefixRules to StakePolicySheet.SheetPrefixRules --- Lib9c/Action/PatchTableSheet.cs | 11 +++------ Lib9c/TableData/Stake/StakePolicySheet.cs | 28 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Lib9c/Action/PatchTableSheet.cs b/Lib9c/Action/PatchTableSheet.cs index 57a48c6b9..0ef4c2e43 100644 --- a/Lib9c/Action/PatchTableSheet.cs +++ b/Lib9c/Action/PatchTableSheet.cs @@ -8,6 +8,7 @@ using Libplanet.Crypto; using Nekoyume.Model.State; using Nekoyume.TableData; +using Nekoyume.TableData.Stake; using Serilog; namespace Nekoyume.Action @@ -25,13 +26,6 @@ namespace Nekoyume.Action [ActionType("patch_table_sheet")] public class PatchTableSheet : GameAction, IPatchTableSheetV1 { - private static readonly string[] PrefixRules = new string[] { - "StakeRegularRewardSheet_", - "StakeRegularFixedRewardSheet_", - // "CrystalMonsterCollectionMultiplierSheet_", - // "StakeActionPointCoefficientSheet_", - }; - // FIXME: We should eliminate or justify this concept in another way after v100340. // (Until that) please consult Nine Chronicles Dev if you have any questions about this account. private static readonly Address Operator = @@ -74,7 +68,8 @@ public override IAccountStateDelta Execute(IActionContext context) #endif var sheet = states.GetState(sheetAddress); - if (!(sheet is null) && PrefixRules.Any(TableName.StartsWith)) + if (sheet is not null && + StakePolicySheet.SheetPrefixRules.Any(tuple => TableName.StartsWith(tuple.value))) { var msg = $"{TableName} already exists."; throw new ArgumentException(nameof(TableName), msg); diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs index c5e345c93..9424039c0 100644 --- a/Lib9c/TableData/Stake/StakePolicySheet.cs +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -5,6 +5,12 @@ namespace Nekoyume.TableData.Stake { public class StakePolicySheet : Sheet { + public static readonly (string attrName, string value)[] SheetPrefixRules = + { + ("StakeRegularRewardSheet", "StakeRegularRewardSheet_"), + ("StakeRegularFixedRewardSheet", "StakeRegularFixedRewardSheet_"), + }; + [Serializable] public class Row : SheetRow { @@ -17,6 +23,28 @@ public override void Set(IReadOnlyList fields) { AttrName = fields[0]; Value = fields[1]; + Validate(); + } + + public override void Validate() + { + foreach (var (attrName, value) in SheetPrefixRules) + { + if (AttrName != attrName) + { + continue; + } + + if (Value.StartsWith(value)) + { + continue; + } + + throw new SheetRowValidateException( + $"{nameof(Value)}({Value}) must start with" + + $" \"{value}\" when {nameof(AttrName)}({AttrName}) is" + + $" \"{attrName}\""); + } } } From 95b9bbf618b75230e1d6d3ef0965113a358419c6 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 31 Aug 2023 16:11:29 +0900 Subject: [PATCH 057/134] unit test for `StakePolicySheet` --- .../TableData/Stake/StakePolicySheetTest.cs | 62 +++++++++++++++++++ Lib9c/TableCSV/Stake/StakePolicySheet.csv | 2 +- Lib9c/TableData/Sheet.cs | 6 +- Lib9c/TableData/Stake/StakePolicySheet.cs | 50 +++++++++++++-- 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 .Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs diff --git a/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs b/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs new file mode 100644 index 000000000..dd48572fb --- /dev/null +++ b/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs @@ -0,0 +1,62 @@ +namespace Lib9c.Tests.TableData.Stake +{ + using System.Linq; + using System.Text; + using Nekoyume.TableData; + using Nekoyume.TableData.Stake; + using Xunit; + + public class StakePolicySheetTest + { + private const string Csv = @"attr_name,value +StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet_V5 +StakeRegularRewardSheet,StakeRegularRewardSheet_V5 +RewardInterval,50400 +LockupInterval,201600"; + + [Fact] + public void Set_Success() + { + var sheet = new StakePolicySheet(); + sheet.Set(Csv); + Assert.Equal(4, sheet.Count); + var row = sheet["StakeRegularFixedRewardSheet"]; + Assert.Equal("StakeRegularFixedRewardSheet", row.AttrName); + Assert.Equal("StakeRegularFixedRewardSheet_V5", row.Value); + row = sheet["StakeRegularRewardSheet"]; + Assert.Equal("StakeRegularRewardSheet", row.AttrName); + Assert.Equal("StakeRegularRewardSheet_V5", row.Value); + row = sheet["RewardInterval"]; + Assert.Equal("RewardInterval", row.AttrName); + Assert.Equal("50400", row.Value); + row = sheet["LockupInterval"]; + Assert.Equal("LockupInterval", row.AttrName); + Assert.Equal("201600", row.Value); + } + + [Theory] + [InlineData("StakeRegularFixedRewardSheet,")] + [InlineData("StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet")] + [InlineData("StakeRegularFixedRewardSheet,StakeRegularRewardSheet_")] + public void Set_Throw_SheetRowValidateException(string row) + { + var sb = new StringBuilder(); + sb.AppendLine("attr_name,value"); + sb.AppendLine(row); + Assert.Throws(() => + new StakePolicySheet().Set(sb.ToString())); + } + + [Fact] + public void Set_Throw_SheetRowNotFoundException() + { + foreach (var requiredAttrName in StakePolicySheet.RequiredAttrNames) + { + var csv = string.Join( + "\n", + Csv.Split("\n").Where(r => !r.StartsWith(requiredAttrName))); + Assert.Throws(() => new StakePolicySheet().Set(csv)); + } + } + } +} diff --git a/Lib9c/TableCSV/Stake/StakePolicySheet.csv b/Lib9c/TableCSV/Stake/StakePolicySheet.csv index 38088333a..f80402082 100644 --- a/Lib9c/TableCSV/Stake/StakePolicySheet.csv +++ b/Lib9c/TableCSV/Stake/StakePolicySheet.csv @@ -1,5 +1,5 @@ attr_name,value +StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet_V5 StakeRegularRewardSheet,StakeRegularRewardSheet_V5 -StakeRegularFixedRewardSheet,StakeRegularRewardSheet_V5 RewardInterval,50400 LockupInterval,201600 diff --git a/Lib9c/TableData/Sheet.cs b/Lib9c/TableData/Sheet.cs index 080ec12e6..50406e7a2 100644 --- a/Lib9c/TableData/Sheet.cs +++ b/Lib9c/TableData/Sheet.cs @@ -32,10 +32,10 @@ public abstract class Sheet : IDictionary, ISheet public IReadOnlyList? OrderedList => _orderedList; - + public TValue? First { get; private set; } - + public TValue? Last { get; private set; } public ICollection Keys => ((IDictionary)_impl).Keys; @@ -63,7 +63,7 @@ protected Sheet(string name) /// true: csv값의 column과 row가 뒤집혀서 작성되어 있다고 판단합니다. /// /// - public void Set(string csv, bool isReversed = false) + public virtual void Set(string csv, bool isReversed = false) { if (string.IsNullOrEmpty(csv)) { diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs index 9424039c0..f0dc40fce 100644 --- a/Lib9c/TableData/Stake/StakePolicySheet.cs +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -1,16 +1,11 @@ using System; using System.Collections.Generic; +using System.Globalization; namespace Nekoyume.TableData.Stake { public class StakePolicySheet : Sheet { - public static readonly (string attrName, string value)[] SheetPrefixRules = - { - ("StakeRegularRewardSheet", "StakeRegularRewardSheet_"), - ("StakeRegularFixedRewardSheet", "StakeRegularFixedRewardSheet_"), - }; - [Serializable] public class Row : SheetRow { @@ -48,8 +43,51 @@ public override void Validate() } } + public static readonly string[] RequiredAttrNames = + { + "StakeRegularFixedRewardSheet", + "StakeRegularRewardSheet", + "RewardInterval", + "LockupInterval", + }; + + public static readonly (string attrName, string value)[] SheetPrefixRules = + { + ("StakeRegularFixedRewardSheet", "StakeRegularFixedRewardSheet_"), + ("StakeRegularRewardSheet", "StakeRegularRewardSheet_"), + }; + + public string StakeRegularFixedRewardSheetValue => + this["StakeRegularFixedRewardSheet"].Value; + + public string StakeRegularRewardSheetValue => + this["StakeRegularRewardSheet"].Value; + + public long RewardInterval => + long.Parse(this["RewardInterval"].Value, CultureInfo.InvariantCulture); + + public long LockupInterval => + long.Parse(this["LockupInterval"].Value, CultureInfo.InvariantCulture); + public StakePolicySheet() : base(nameof(StakePolicySheet)) { } + + public override void Set(string csv, bool isReversed = false) + { + base.Set(csv, isReversed); + foreach (var requiredAttrName in RequiredAttrNames) + { + if (ContainsKey(requiredAttrName)) + { + continue; + } + + throw new SheetRowNotFoundException( + Name, + nameof(Row.AttrName), + requiredAttrName); + } + } } } From e4bea9e4842d47980ccb0811c483d12c55c81980 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 31 Aug 2023 17:08:15 +0900 Subject: [PATCH 058/134] unit test for stake sheets being read-only --- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 742a15ddf..f78ce2f5b 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -1,5 +1,6 @@ namespace Lib9c.Tests.Action { + using System; using System.Linq; using Bencodex.Types; using Libplanet.Action.State; @@ -8,6 +9,7 @@ namespace Lib9c.Tests.Action using Nekoyume.Action; using Nekoyume.Model.State; using Nekoyume.TableData; + using Nekoyume.TableData.Stake; using Serilog; using Xunit; using Xunit.Abstractions; @@ -86,7 +88,9 @@ public void CheckPermission() const string tableName = "TestTable"; var initStates = MockState.Empty .SetState(AdminState.Address, adminState.Serialize()) - .SetState(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); + .SetState( + Addresses.TableSheet.Derive(tableName), + Dictionary.Empty.Add(tableName, "Initial")); var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { @@ -129,7 +133,9 @@ public void ExecuteNewTable() const string tableName = "TestTable"; var initStates = MockState.Empty .SetState(AdminState.Address, adminState.Serialize()) - .SetState(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); + .SetState( + Addresses.TableSheet.Derive(tableName), + Dictionary.Empty.Add(tableName, "Initial")); var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { @@ -147,5 +153,33 @@ public void ExecuteNewTable() Assert.NotNull(nextState.GetSheet()); } + + [Theory] + [InlineData("StakeRegularFixedRewardSheet_")] + [InlineData("StakeRegularRewardSheet_")] + public void Execute_Throw_ArgumentException(string tableName) + { + var action = new PatchTableSheet + { + TableName = tableName, + TableCsv = string.Empty, + }; + var initialState = new MockStateDelta(); + var nextState = action.Execute(new ActionContext + { + BlockIndex = 0, + PreviousState = initialState, + Rehearsal = false, + }); + Assert.Throws(() => + { + action.Execute(new ActionContext + { + BlockIndex = 0, + PreviousState = nextState, + Rehearsal = false, + }); + }); + } } } From 9fcd417fbbee073e177c38a3b6ac70ec3e3ab175 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 31 Aug 2023 18:50:29 +0900 Subject: [PATCH 059/134] refactor and fix `Stake`: allow stake with same amount --- Lib9c/Action/Stake.cs | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 4acc9c156..66960774c 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -47,7 +47,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + var states = context.PreviousState; // Restrict staking if there is a monster collection until now. if (states.GetAgentState(context.Signer) is { } agentState && @@ -104,13 +104,13 @@ public override IAccountStateDelta Execute(IActionContext context) var latestStakeContract = new Contract( stakeRegularFixedRewardSheetTableName: - stakePolicySheet["StakeRegularFixedRewardSheet"].Value, + stakePolicySheet["StakeRegularFixedRewardSheet"].Value, stakeRegularRewardSheetTableName: - stakePolicySheet["StakeRegularRewardSheet"].Value, + stakePolicySheet["StakeRegularRewardSheet"].Value, rewardInterval: - long.Parse(stakePolicySheet["RewardInterval"].Value, CultureInfo.InvariantCulture), + long.Parse(stakePolicySheet["RewardInterval"].Value, CultureInfo.InvariantCulture), lockupInterval: - long.Parse(stakePolicySheet["LockupInterval"].Value, CultureInfo.InvariantCulture) + long.Parse(stakePolicySheet["LockupInterval"].Value, CultureInfo.InvariantCulture) ); if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) @@ -132,39 +132,38 @@ public override IAccountStateDelta Execute(IActionContext context) throw new StakeExistingClaimableException(); } - // NOTE: Try cancel. - if (Amount == 0) + // NOTE: When the staking state is locked up. + if (stakeStateV2.CancellableBlockIndex > context.BlockIndex) { - // NOTE: Cannot cancel until lockup ends. - if (stakeStateV2.CancellableBlockIndex > context.BlockIndex) + // NOTE: Cannot re-contract with less balance. + if (targetStakeBalance < stakedBalance) { throw new RequiredBlockIndexException(); } + } + // NOTE: Withdraw staking. + if (Amount == 0) + { return states .SetState(stakeStateAddress, Null.Value) .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance); } - // NOTE: Cannot re-contract with less balance when the staking is locked up. - if (stakeStateV2.CancellableBlockIndex > context.BlockIndex && - targetStakeBalance <= stakedBalance) - { - throw new RequiredBlockIndexException(); - } + // NOTE: Contract a new staking. + var newStakeState = new StakeStateV2( + latestStakeContract, + context.BlockIndex); + states = states + .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance) + .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance) + .SetState(stakeStateAddress, newStakeState.Serialize()); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, ended - started); - // Stake with more or less amount. - return states - .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance) - .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance) - .SetState( - stakeStateAddress, - new StakeStateV2(latestStakeContract, stakeStateV2.StartedBlockIndex) - .Serialize()); + return states; } } } From 49def5b5c7091a9be299bbd8ab0045aa3d145ff8 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 20:52:58 +0900 Subject: [PATCH 060/134] Use receipt ID, not result_equipment_id --- Lib9c/TableCSV/Summon/AuraSummonSheet.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv index 727e1164b..2d895b259 100644 --- a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv +++ b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv @@ -1,4 +1,4 @@ groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe2ID,recipe2ratio,recipe3ID,recipe3ratio,recipe4ID,recipe4ratio,recipe5ID,recipe5ratio,recipe6ID,recipe6ratio -10001,600201,2,0,10620000,70,10630000,29,10640000,1,,,,,, -10002,600202,2,0,10620001,50,10630001,30,10640001,17,10650001,3,,,, +10001,600201,2,0,171,70,172,29,173,1,,,,,, +10002,600202,2,0,174,50,175,30,176,17,177,3,,,, ,, From 3d9ec0668e03926b2158ccbd204f317fbc4c97c7 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 20:59:53 +0900 Subject: [PATCH 061/134] Use Recipe ID to find target recipe, not ResultEquipmentId --- Lib9c/Action/AuraSummon.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index f4903f79d..9ede92dfc 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -130,9 +130,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Validate RecipeId var recipeSheet = sheets.GetSheet(); - var recipeRow = recipeSheet.OrderedList.FirstOrDefault( - r => r.ResultEquipmentId == recipeId - ); + var recipeRow = recipeSheet.OrderedList.FirstOrDefault(r => r.Id == recipeId); if (recipeRow is null) { throw new SheetRowNotFoundException( From 91cba07b3fcdbf28cf3c6b6d351992726963328a Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 21:00:19 +0900 Subject: [PATCH 062/134] Optimization - Move out from loop of non-necessary to loop --- Lib9c/Action/AuraSummon.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 9ede92dfc..f8ddb7f08 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -124,12 +124,15 @@ public override IAccountStateDelta Execute(IActionContext context) ); } + var recipeSheet = sheets.GetSheet(); + var materialSheet = sheets.GetSheet(); + var equipmentItemSheet = sheets.GetSheet(); + for (var i = 0; i < SummonCount; i++) { - int recipeId = SummonHelper.PickAuraSummonRecipe(summonRow, context.Random); + var recipeId = SummonHelper.PickAuraSummonRecipe(summonRow, context.Random); // Validate RecipeId - var recipeSheet = sheets.GetSheet(); var recipeRow = recipeSheet.OrderedList.FirstOrDefault(r => r.Id == recipeId); if (recipeRow is null) { @@ -140,7 +143,6 @@ public override IAccountStateDelta Execute(IActionContext context) } // Validate Recipe ResultEquipmentId - var equipmentItemSheet = sheets.GetSheet(); if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, out var equipmentRow)) { @@ -151,7 +153,6 @@ public override IAccountStateDelta Execute(IActionContext context) } // Use materials - var materialSheet = sheets.GetSheet(); var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, summonRow.CostMaterialCount)) @@ -168,13 +169,14 @@ public override IAccountStateDelta Execute(IActionContext context) ); // Add or update equipment - avatarState.blockIndex = context.BlockIndex; - avatarState.updatedAt = context.BlockIndex; avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); avatarState.UpdateFromCombination(equipment); - avatarState.UpdateQuestRewards(sheets.GetSheet()); + avatarState.UpdateQuestRewards(materialSheet); } + avatarState.blockIndex = context.BlockIndex; + avatarState.updatedAt = context.BlockIndex; + // Set states return states .SetState(AvatarAddress, avatarState.SerializeV2()) From 0951c38a29c7aa546a3f73a0e2c6b950794fae34 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 23:29:51 +0900 Subject: [PATCH 063/134] Aura has one subrecipe --- Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv b/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv index 6336c1086..922ce5c66 100644 --- a/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv +++ b/Lib9c/TableCSV/Item/EquipmentItemRecipeSheet.csv @@ -169,10 +169,10 @@ id,result_equipment_id,material_id,material_count,required_action_point,required 168,10452001,303304,360,0,0,3000,320,104520011,104520012,104520013,1000000,Necklace 169,10453001,303304,360,0,0,3000,335,104530011,104530012,,1000000,Necklace 170,10454001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -171,10620000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -172,10630000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -173,10640000,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -174,10620001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -175,10630001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -176,10640001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace -177,10650001,303304,360,0,0,3000,335,104540011,104540012,104540013,1000000,Necklace +171 ,10620000,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +172,10630000,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +173,10640000,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +174,10620001,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +175,10630001,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +176,10640001,303304,360,0,0,3000,335,104540011,,,1000000,Necklace +177,10650001,303304,360,0,0,3000,335,104540011,,,1000000,Necklace From 33bf6f33ddbb4bdc54d4e0f8a957216c3f77a3a7 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 23:30:13 +0900 Subject: [PATCH 064/134] Add options using subrecipe --- Lib9c/Action/AuraSummon.cs | 77 +++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index f8ddb7f08..8f19fc1e1 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -11,7 +11,7 @@ using Nekoyume.Extensions; using Nekoyume.Helper; using Nekoyume.Model.Item; -using Nekoyume.Model.Mail; +using Nekoyume.Model.Stat; using Nekoyume.Model.State; using Nekoyume.TableData; using Nekoyume.TableData.Summon; @@ -127,6 +127,9 @@ public override IAccountStateDelta Execute(IActionContext context) var recipeSheet = sheets.GetSheet(); var materialSheet = sheets.GetSheet(); var equipmentItemSheet = sheets.GetSheet(); + var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); + var optionSheet = sheets.GetSheet(); + var skillSheet = sheets.GetSheet(); for (var i = 0; i < SummonCount; i++) { @@ -152,6 +155,23 @@ public override IAccountStateDelta Execute(IActionContext context) recipeRow.ResultEquipmentId); } + // Validate subRecipeId + if (recipeRow.SubRecipeIds.Count == 0) + { + throw new InvalidRecipeIdException( + $"Recipe {recipeId} does not have any subRecipe."); + } + + var subRecipeId = recipeRow.SubRecipeIds[0]; + if (!equipmentItemSubRecipeSheetV2.TryGetValue(subRecipeId, out var subRecipeRow)) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(EquipmentItemSubRecipeSheetV2), + subRecipeId + ); + } + // Use materials var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, @@ -168,6 +188,15 @@ public override IAccountStateDelta Execute(IActionContext context) context.BlockIndex ); + AddAndUnlockOption( + agentState, + equipment, + context.Random, + subRecipeRow, + optionSheet, + skillSheet + ); + // Add or update equipment avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); avatarState.UpdateFromCombination(equipment); @@ -184,5 +213,51 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(questListAddress, avatarState.questList.Serialize()) .SetState(context.Signer, agentState.Serialize()); } + + public static void AddAndUnlockOption( + AgentState agentState, + Equipment equipment, + IRandom random, + EquipmentItemSubRecipeSheetV2.Row subRecipe, + EquipmentItemOptionSheet optionSheet, + SkillSheet skillSheet + ) + { + foreach (var optionInfo in subRecipe.Options + .OrderByDescending(e => e.Ratio) + .ThenBy(e => e.RequiredBlockIndex) + .ThenBy(e => e.Id)) + { + if (!optionSheet.TryGetValue(optionInfo.Id, out var optionRow)) + { + continue; + } + + var value = random.Next(1, GameConfig.MaximumProbability + 1); + var ratio = optionInfo.Ratio; + + if (value > ratio) + { + continue; + } + + if (optionRow.StatType != StatType.NONE) + { + var stat = CombinationEquipment5.GetStat(optionRow, random); + equipment.StatsMap.AddStatAdditionalValue(stat.StatType, stat.BaseValue); + equipment.optionCountFromCombination++; + agentState.unlockedOptions.Add(optionRow.Id); + } + else + { + var skill = CombinationEquipment.GetSkill(optionRow, skillSheet, random); + if (skill is null) continue; + + equipment.Skills.Add(skill); + equipment.optionCountFromCombination++; + agentState.unlockedOptions.Add(optionRow.Id); + } + } + } } } From cc3c1507a63d7af5c53fbea67382585f86567239 Mon Sep 17 00:00:00 2001 From: hyeon Date: Thu, 31 Aug 2023 23:30:22 +0900 Subject: [PATCH 065/134] Fix tests --- .Lib9c.Tests/Action/AuraSummonTest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs index 92a3666c2..6bf9f2f7d 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -80,10 +80,10 @@ public AuraSummonTest() [Theory] // success first group [InlineData(10001, 1, 600201, 2, 1, new[] { 10620000 }, null)] - [InlineData(10001, 2, 600201, 4, 0, new[] { 10630000, 10640000 }, null)] + [InlineData(10001, 2, 600201, 4, 54, new[] { 10630000, 10640000 }, null)] // success second group [InlineData(10002, 1, 600202, 2, 1, new[] { 10620001 }, null)] - [InlineData(10002, 2, 600202, 4, 6, new[] { 10630001, 10640001 }, null)] + [InlineData(10002, 2, 600202, 4, 4, new[] { 10630001, 10640001 }, null)] // fail by invalid group [InlineData(100003, 1, null, 0, 0, new int[] { }, typeof(RowNotInTableException))] // fail by not enough material @@ -152,6 +152,7 @@ Type expectedExc .Equipments.FirstOrDefault(e => e.Id == equipmentId); Assert.NotNull(resultEquipment); Assert.Equal(1, resultEquipment.RequiredBlockIndex); + Assert.True(resultEquipment.optionCountFromCombination > 0); } } else From 11761a3990fc465276f0ee1730fc6cdbbdce453f Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 12:39:22 +0900 Subject: [PATCH 066/134] expand GameConfigState related to staking policy --- .../Model/State/GameConfigStateTest.cs | 118 ++++++++++++++++++ Lib9c/Model/State/GameConfigState.cs | 100 ++++++++++++++- Lib9c/TableCSV/GameConfigSheet.csv | 5 + 3 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 .Lib9c.Tests/Model/State/GameConfigStateTest.cs diff --git a/.Lib9c.Tests/Model/State/GameConfigStateTest.cs b/.Lib9c.Tests/Model/State/GameConfigStateTest.cs new file mode 100644 index 000000000..8302cf27e --- /dev/null +++ b/.Lib9c.Tests/Model/State/GameConfigStateTest.cs @@ -0,0 +1,118 @@ +namespace Lib9c.Tests.Model.State +{ + using Bencodex.Types; + using Lib9c.Tests.Fixtures.TableCSV; + using Nekoyume; + using Nekoyume.Model.State; + using Nekoyume.TableData; + using Xunit; + + public class GameConfigStateTest + { + [Fact] + public void Constructor_Empty() + { + var state = new GameConfigState(); + Assert.Equal(Addresses.GameConfig, state.address); + } + + [Fact] + public void Constructor_BencodexDictionary() + { + var serialized = GetDefaultGameConfigState().Serialize(); + var state = new GameConfigState((Dictionary)serialized); + AssertDefaultGameConfigState(state); + } + + [Fact] + public void Serde() + { + var state = GetDefaultGameConfigState(); + var ser = state.Serialize(); + var des = new GameConfigState((Dictionary)ser); + Assert.Equal(state.HourglassPerBlock, des.HourglassPerBlock); + Assert.Equal(state.ActionPointMax, des.ActionPointMax); + Assert.Equal(state.DailyRewardInterval, des.DailyRewardInterval); + Assert.Equal(state.DailyArenaInterval, des.DailyArenaInterval); + Assert.Equal(state.WeeklyArenaInterval, des.WeeklyArenaInterval); + Assert.Equal(state.RequiredAppraiseBlock, des.RequiredAppraiseBlock); + Assert.Equal(state.BattleArenaInterval, des.BattleArenaInterval); + Assert.Equal(state.RuneStatSlotUnlockCost, des.RuneStatSlotUnlockCost); + Assert.Equal(state.RuneSkillSlotUnlockCost, des.RuneSkillSlotUnlockCost); + Assert.Equal(state.DailyRuneRewardAmount, des.DailyRuneRewardAmount); + Assert.Equal(state.DailyWorldBossInterval, des.DailyWorldBossInterval); + Assert.Equal(state.WorldBossRequiredInterval, des.WorldBossRequiredInterval); + Assert.Equal( + state.StakeRegularFixedRewardSheet_V2_StartBlockIndex, + des.StakeRegularFixedRewardSheet_V2_StartBlockIndex); + Assert.Equal( + state.StakeRegularRewardSheet_V2_StartBlockIndex, + des.StakeRegularRewardSheet_V2_StartBlockIndex); + Assert.Equal( + state.StakeRegularRewardSheet_V3_StartBlockIndex, + des.StakeRegularRewardSheet_V3_StartBlockIndex); + Assert.Equal( + state.StakeRegularRewardSheet_V4_StartBlockIndex, + des.StakeRegularRewardSheet_V4_StartBlockIndex); + Assert.Equal( + state.StakeRegularRewardSheet_V5_StartBlockIndex, + des.StakeRegularRewardSheet_V5_StartBlockIndex); + var ser2 = des.Serialize(); + Assert.Equal(ser, ser2); + } + + [Fact] + public void Set() + { + var state = new GameConfigState(); + state.Set(GetDefaultGameConfigSheet()); + AssertDefaultGameConfigState(state); + } + + [Fact] + public void Update() + { + var state = GetDefaultGameConfigState(); + Assert.Equal(3, state.HourglassPerBlock); + var row = new GameConfigSheet.Row(); + row.Set(new[] { "hourglass_per_block", "5" }); + state.Update(row); + Assert.Equal(5, state.HourglassPerBlock); + } + + private static void AssertDefaultGameConfigState(GameConfigState state) + { + Assert.Equal(3, state.HourglassPerBlock); + Assert.Equal(120, state.ActionPointMax); + Assert.Equal(1700, state.DailyRewardInterval); + Assert.Equal(5040, state.DailyArenaInterval); + Assert.Equal(56000, state.WeeklyArenaInterval); + Assert.Equal(10, state.RequiredAppraiseBlock); + Assert.Equal(4, state.BattleArenaInterval); + Assert.Equal(100, state.RuneStatSlotUnlockCost); + Assert.Equal(1000, state.RuneSkillSlotUnlockCost); + Assert.Equal(1, state.DailyRuneRewardAmount); + Assert.Equal(7200, state.DailyWorldBossInterval); + Assert.Equal(5, state.WorldBossRequiredInterval); + Assert.Equal(6_700_000L, state.StakeRegularFixedRewardSheet_V2_StartBlockIndex); + Assert.Equal(5_510_416L, state.StakeRegularRewardSheet_V2_StartBlockIndex); + Assert.Equal(6_700_000L, state.StakeRegularRewardSheet_V3_StartBlockIndex); + Assert.Equal(6_910_000L, state.StakeRegularRewardSheet_V4_StartBlockIndex); + Assert.Equal(7_650_000L, state.StakeRegularRewardSheet_V5_StartBlockIndex); + } + + private static GameConfigSheet GetDefaultGameConfigSheet() + { + var sheet = new GameConfigSheet(); + sheet.Set(GameConfigSheetFixtures.Default); + return sheet; + } + + private static GameConfigState GetDefaultGameConfigState() + { + var state = new GameConfigState(); + state.Set(GetDefaultGameConfigSheet()); + return state; + } + } +} diff --git a/Lib9c/Model/State/GameConfigState.cs b/Lib9c/Model/State/GameConfigState.cs index c7cd3b0e1..1c78a52ae 100644 --- a/Lib9c/Model/State/GameConfigState.cs +++ b/Lib9c/Model/State/GameConfigState.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using System.Collections.Generic; using System.Linq; @@ -23,6 +25,11 @@ public class GameConfigState : State public int DailyRuneRewardAmount { get; private set; } public int DailyWorldBossInterval { get; private set; } public int WorldBossRequiredInterval { get; private set; } + public long StakeRegularFixedRewardSheet_V2_StartBlockIndex { get; private set; } + public long StakeRegularRewardSheet_V2_StartBlockIndex { get; private set; } + public long StakeRegularRewardSheet_V3_StartBlockIndex { get; private set; } + public long StakeRegularRewardSheet_V4_StartBlockIndex { get; private set; } + public long StakeRegularRewardSheet_V5_StartBlockIndex { get; private set; } public GameConfigState() : base(Address) { @@ -78,6 +85,41 @@ public GameConfigState(Dictionary serialized) : base(serialized) { WorldBossRequiredInterval = value12.ToInteger(); } + if (serialized.TryGetValue( + (Text)"stake_regular_fixed_reward_sheet_v2_start_block_index", + out var stakeRegularFixedRewardSheetV2StartBlockIndex)) + { + StakeRegularFixedRewardSheet_V2_StartBlockIndex = + stakeRegularFixedRewardSheetV2StartBlockIndex.ToLong(); + } + if (serialized.TryGetValue( + (Text)"stake_regular_reward_sheet_v2_start_block_index", + out var stakeRegularRewardSheetV2StartBlockIndex)) + { + StakeRegularRewardSheet_V2_StartBlockIndex = + stakeRegularRewardSheetV2StartBlockIndex.ToLong(); + } + if (serialized.TryGetValue( + (Text)"stake_regular_reward_sheet_v3_start_block_index", + out var stakeRegularRewardSheetV3StartBlockIndex)) + { + StakeRegularRewardSheet_V3_StartBlockIndex = + stakeRegularRewardSheetV3StartBlockIndex.ToLong(); + } + if (serialized.TryGetValue( + (Text)"stake_regular_reward_sheet_v4_start_block_index", + out var stakeRegularRewardSheetV4StartBlockIndex)) + { + StakeRegularRewardSheet_V4_StartBlockIndex = + stakeRegularRewardSheetV4StartBlockIndex.ToLong(); + } + if (serialized.TryGetValue( + (Text)"stake_regular_reward_sheet_v5_start_block_index", + out var stakeRegularRewardSheetV5StartBlockIndex)) + { + StakeRegularRewardSheet_V5_StartBlockIndex = + stakeRegularRewardSheetV5StartBlockIndex.ToLong(); + } } public GameConfigState(string csv) : base(Address) @@ -130,6 +172,42 @@ public override IValue Serialize() { values.Add((Text)"worldboss_required_interval", WorldBossRequiredInterval.Serialize()); } + + if (StakeRegularFixedRewardSheet_V2_StartBlockIndex > 0) + { + values.Add( + (Text) "stake_regular_fixed_reward_sheet_v2_start_block_index", + StakeRegularFixedRewardSheet_V2_StartBlockIndex.Serialize()); + } + + if (StakeRegularRewardSheet_V2_StartBlockIndex > 0) + { + values.Add( + (Text) "stake_regular_reward_sheet_v2_start_block_index", + StakeRegularRewardSheet_V2_StartBlockIndex.Serialize()); + } + + if (StakeRegularRewardSheet_V3_StartBlockIndex > 0) + { + values.Add( + (Text) "stake_regular_reward_sheet_v3_start_block_index", + StakeRegularRewardSheet_V3_StartBlockIndex.Serialize()); + } + + if (StakeRegularRewardSheet_V4_StartBlockIndex > 0) + { + values.Add( + (Text) "stake_regular_reward_sheet_v4_start_block_index", + StakeRegularRewardSheet_V4_StartBlockIndex.Serialize()); + } + + if (StakeRegularRewardSheet_V5_StartBlockIndex > 0) + { + values.Add( + (Text) "stake_regular_reward_sheet_v5_start_block_index", + StakeRegularRewardSheet_V5_StartBlockIndex.Serialize()); + } + #pragma warning disable LAA1002 return new Dictionary(values.Union((Dictionary) base.Serialize())); #pragma warning restore LAA1002 @@ -137,7 +215,7 @@ public override IValue Serialize() public void Set(GameConfigSheet sheet) { - foreach (var row in sheet.OrderedList) + foreach (var row in sheet.OrderedList!) { Update(row); } @@ -183,6 +261,26 @@ public void Update(GameConfigSheet.Row row) case "worldboss_required_interval": WorldBossRequiredInterval = TableExtensions.ParseInt(row.Value); break; + case "stake_regular_fixed_reward_sheet_v2_start_block_index": + StakeRegularFixedRewardSheet_V2_StartBlockIndex = + TableExtensions.ParseLong(row.Value); + break; + case "stake_regular_reward_sheet_v2_start_block_index": + StakeRegularRewardSheet_V2_StartBlockIndex = + TableExtensions.ParseLong(row.Value); + break; + case "stake_regular_reward_sheet_v3_start_block_index": + StakeRegularRewardSheet_V3_StartBlockIndex = + TableExtensions.ParseLong(row.Value); + break; + case "stake_regular_reward_sheet_v4_start_block_index": + StakeRegularRewardSheet_V4_StartBlockIndex = + TableExtensions.ParseLong(row.Value); + break; + case "stake_regular_reward_sheet_v5_start_block_index": + StakeRegularRewardSheet_V5_StartBlockIndex = + TableExtensions.ParseLong(row.Value); + break; } } } diff --git a/Lib9c/TableCSV/GameConfigSheet.csv b/Lib9c/TableCSV/GameConfigSheet.csv index 50832abad..9917cf44c 100644 --- a/Lib9c/TableCSV/GameConfigSheet.csv +++ b/Lib9c/TableCSV/GameConfigSheet.csv @@ -11,3 +11,8 @@ rune_skill_slot_unlock_cost,1000 daily_rune_reward_amount,1 daily_worldboss_interval,7200 worldboss_required_interval,5 +stake_regular_fixed_reward_sheet_v2_start_block_index,6700000 +stake_regular_reward_sheet_v2_start_block_index,5510416 +stake_regular_reward_sheet_v3_start_block_index,6700000 +stake_regular_reward_sheet_v4_start_block_index,6910000 +stake_regular_reward_sheet_v5_start_block_index,7650000 From a1d92a3a12e4d93606e6a9dac52a4ed1692406fa Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 12:41:13 +0900 Subject: [PATCH 067/134] use GameConfigState to migrate StakeState to StakeStateV2 --- Lib9c/Action/AccountStateExtensions.cs | 32 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index 9a2ec0f8e..563b779ba 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -961,28 +961,38 @@ public static bool TryGetStakeStateV2( if (stakeStateValue is Dictionary dict) { + var gcs = state.GetGameConfigState(); var stakeStateV1 = new StakeState(dict); - string stakeRegularFixedRewardSheetTableName; + var stakeRegularFixedRewardSheetTableName = + stakeStateV1.StartedBlockIndex < + gcs.StakeRegularFixedRewardSheet_V2_StartBlockIndex + ? "StakeRegularFixedRewardSheet_V1" + : "StakeRegularFixedRewardSheet_V2"; string stakeRegularRewardSheetTableName; - if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV2Index) + if (stakeStateV1.StartedBlockIndex < + gcs.StakeRegularRewardSheet_V2_StartBlockIndex) { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V1"; stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; } - else if (stakeStateV1.StartedBlockIndex < StakeState.StakeRewardSheetV3Index) + else if (stakeStateV1.StartedBlockIndex < + gcs.StakeRegularRewardSheet_V3_StartBlockIndex) { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V2"; stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; } - // FIXME: consider this case. - // else if (stakeStateV1.StartedBlockIndex < StakeState.CurrencyAsRewardStartIndex) - // { - // } - else + else if (stakeStateV1.StartedBlockIndex < + gcs.StakeRegularRewardSheet_V4_StartBlockIndex) { - stakeRegularFixedRewardSheetTableName = "StakeRegularFixedRewardSheet_V3"; stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; } + else if (stakeStateV1.StartedBlockIndex < + gcs.StakeRegularRewardSheet_V5_StartBlockIndex) + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V4"; + } + else + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V5"; + } stakeStateV2 = new StakeStateV2( stakeStateV1, From 1a3e1430759e64fd0724b2df8b2afd6a2a4ac04a Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 1 Sep 2023 14:03:44 +0900 Subject: [PATCH 068/134] Fix broken test --- Lib9c/Model/Item/Equipment.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib9c/Model/Item/Equipment.cs b/Lib9c/Model/Item/Equipment.cs index e70f1eeac..3e0493f98 100644 --- a/Lib9c/Model/Item/Equipment.cs +++ b/Lib9c/Model/Item/Equipment.cs @@ -130,7 +130,10 @@ public override IValue Serialize() dict = dict.SetItem(MadeWithMimisbrunnrRecipeKey, MadeWithMimisbrunnrRecipe.Serialize()); } - dict = dict.SetItem(EquipmentExpKey, Exp.Serialize()); + if (Exp > 0) + { + dict = dict.SetItem(EquipmentExpKey, Exp.Serialize()); + } return dict; #pragma warning restore LAA1002 From 7b2e69cf83e8de11d6fa5f760cce012a8c565da1 Mon Sep 17 00:00:00 2001 From: tyrosine1153 Date: Fri, 1 Sep 2023 15:52:40 +0900 Subject: [PATCH 069/134] Add AuraSummonSheet meta file --- Lib9c/TableCSV/Summon.meta | 8 ++++++++ Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 Lib9c/TableCSV/Summon.meta create mode 100644 Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta diff --git a/Lib9c/TableCSV/Summon.meta b/Lib9c/TableCSV/Summon.meta new file mode 100644 index 000000000..dd4b0ba5c --- /dev/null +++ b/Lib9c/TableCSV/Summon.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1832d37acf0fb2a4f8d01cd4fb6c2fdd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta new file mode 100644 index 000000000..0c7de032b --- /dev/null +++ b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1d659cdee0a104444a99ca342a32267c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 1f553ef9431cd32f1031bfe18384a8351b1def39 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 1 Sep 2023 16:07:28 +0900 Subject: [PATCH 070/134] Add AuraSummon constructor with field data --- Lib9c/Action/AuraSummon.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 8f19fc1e1..502e2e0a2 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -37,6 +37,12 @@ public class AuraSummon : GameAction, IAuraSummonV1 int IAuraSummonV1.GroupId => GroupId; int IAuraSummonV1.SummonCount => SummonCount; + public AuraSummon(Address avatarAddress, int groupId, int summonCount) + { + AvatarAddress = avatarAddress; + GroupId = groupId; + SummonCount = summonCount; + } protected override IImmutableDictionary PlainValueInternal => new Dictionary From e7bc53436723124d9fa003ca3412959ad8a861af Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 1 Sep 2023 16:21:15 +0900 Subject: [PATCH 071/134] Change instantiate matching new ctor --- .Lib9c.Tests/Action/AuraSummonTest.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs index 6bf9f2f7d..b2a40c54d 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -128,12 +128,11 @@ Type expectedExc ; } - var action = new AuraSummon - { - AvatarAddress = _avatarAddress, - GroupId = groupId, - SummonCount = summonCount, - }; + var action = new AuraSummon( + _avatarAddress, + groupId, + summonCount + ); if (expectedExc == null) { From d38c045ffcd48841c474ad9ab647f7a913dfb3e8 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 1 Sep 2023 16:37:32 +0900 Subject: [PATCH 072/134] Needs parameterless ctor --- Lib9c/Action/AuraSummon.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 502e2e0a2..14bb57e57 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -37,6 +37,10 @@ public class AuraSummon : GameAction, IAuraSummonV1 int IAuraSummonV1.GroupId => GroupId; int IAuraSummonV1.SummonCount => SummonCount; + public AuraSummon() + { + } + public AuraSummon(Address avatarAddress, int groupId, int summonCount) { AvatarAddress = avatarAddress; From cff87af2f6038fb97d5066cca1ea19ddf60bf072 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:37:09 +0900 Subject: [PATCH 073/134] improve StakePolicySheet --- .../TableCSV/Stake/StakePolicySheetFixtures.cs | 17 +++++++++++++++++ .../TableData/Stake/StakePolicySheetTest.cs | 16 ++++++---------- Lib9c/TableCSV/Stake.meta | 8 ++++++++ Lib9c/TableCSV/Stake/StakePolicySheet.csv.meta | 7 +++++++ Lib9c/TableData/Stake/StakePolicySheet.cs | 9 +++++---- 5 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 .Lib9c.Tests/Fixtures/TableCSV/Stake/StakePolicySheetFixtures.cs create mode 100644 Lib9c/TableCSV/Stake.meta create mode 100644 Lib9c/TableCSV/Stake/StakePolicySheet.csv.meta diff --git a/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakePolicySheetFixtures.cs b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakePolicySheetFixtures.cs new file mode 100644 index 000000000..026daf83b --- /dev/null +++ b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakePolicySheetFixtures.cs @@ -0,0 +1,17 @@ +namespace Lib9c.Tests.Fixtures.TableCSV.Stake +{ + public static class StakePolicySheetFixtures + { + public const string V1 = @"attr_name,value +StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet_V1 +StakeRegularRewardSheet,StakeRegularRewardSheet_V1 +RewardInterval,50400 +LockupInterval,201600"; + + public const string V2 = @"attr_name,value +StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet_V2 +StakeRegularRewardSheet,StakeRegularRewardSheet_V2 +RewardInterval,50400 +LockupInterval,201600"; + } +} diff --git a/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs b/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs index dd48572fb..9b38014b9 100644 --- a/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs +++ b/.Lib9c.Tests/TableData/Stake/StakePolicySheetTest.cs @@ -2,30 +2,25 @@ namespace Lib9c.Tests.TableData.Stake { using System.Linq; using System.Text; + using Lib9c.Tests.Fixtures.TableCSV.Stake; using Nekoyume.TableData; using Nekoyume.TableData.Stake; using Xunit; public class StakePolicySheetTest { - private const string Csv = @"attr_name,value -StakeRegularFixedRewardSheet,StakeRegularFixedRewardSheet_V5 -StakeRegularRewardSheet,StakeRegularRewardSheet_V5 -RewardInterval,50400 -LockupInterval,201600"; - [Fact] public void Set_Success() { var sheet = new StakePolicySheet(); - sheet.Set(Csv); + sheet.Set(StakePolicySheetFixtures.V1); Assert.Equal(4, sheet.Count); var row = sheet["StakeRegularFixedRewardSheet"]; Assert.Equal("StakeRegularFixedRewardSheet", row.AttrName); - Assert.Equal("StakeRegularFixedRewardSheet_V5", row.Value); + Assert.Equal("StakeRegularFixedRewardSheet_V1", row.Value); row = sheet["StakeRegularRewardSheet"]; Assert.Equal("StakeRegularRewardSheet", row.AttrName); - Assert.Equal("StakeRegularRewardSheet_V5", row.Value); + Assert.Equal("StakeRegularRewardSheet_V1", row.Value); row = sheet["RewardInterval"]; Assert.Equal("RewardInterval", row.AttrName); Assert.Equal("50400", row.Value); @@ -54,7 +49,8 @@ public void Set_Throw_SheetRowNotFoundException() { var csv = string.Join( "\n", - Csv.Split("\n").Where(r => !r.StartsWith(requiredAttrName))); + StakePolicySheetFixtures.V1.Split("\n") + .Where(r => !r.StartsWith(requiredAttrName))); Assert.Throws(() => new StakePolicySheet().Set(csv)); } } diff --git a/Lib9c/TableCSV/Stake.meta b/Lib9c/TableCSV/Stake.meta new file mode 100644 index 000000000..02073683c --- /dev/null +++ b/Lib9c/TableCSV/Stake.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dcc1d2494a78e451bb5bf39cbcdab1b9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Lib9c/TableCSV/Stake/StakePolicySheet.csv.meta b/Lib9c/TableCSV/Stake/StakePolicySheet.csv.meta new file mode 100644 index 000000000..e0396ab28 --- /dev/null +++ b/Lib9c/TableCSV/Stake/StakePolicySheet.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3c37fc454282945a29b1043c125b372f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Lib9c/TableData/Stake/StakePolicySheet.cs b/Lib9c/TableData/Stake/StakePolicySheet.cs index f0dc40fce..26262f553 100644 --- a/Lib9c/TableData/Stake/StakePolicySheet.cs +++ b/Lib9c/TableData/Stake/StakePolicySheet.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using Nekoyume.Model.Stake; namespace Nekoyume.TableData.Stake { @@ -53,8 +54,8 @@ public override void Validate() public static readonly (string attrName, string value)[] SheetPrefixRules = { - ("StakeRegularFixedRewardSheet", "StakeRegularFixedRewardSheet_"), - ("StakeRegularRewardSheet", "StakeRegularRewardSheet_"), + ("StakeRegularFixedRewardSheet", Contract.StakeRegularFixedRewardSheetPrefix), + ("StakeRegularRewardSheet", Contract.StakeRegularRewardSheetPrefix), }; public string StakeRegularFixedRewardSheetValue => @@ -63,10 +64,10 @@ public static readonly (string attrName, string value)[] SheetPrefixRules = public string StakeRegularRewardSheetValue => this["StakeRegularRewardSheet"].Value; - public long RewardInterval => + public long RewardIntervalValue => long.Parse(this["RewardInterval"].Value, CultureInfo.InvariantCulture); - public long LockupInterval => + public long LockupIntervalValue => long.Parse(this["LockupInterval"].Value, CultureInfo.InvariantCulture); public StakePolicySheet() : base(nameof(StakePolicySheet)) From 738dd5d6e46cded003383f4cb76fbc36a018811c Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:37:40 +0900 Subject: [PATCH 074/134] improve Contract --- .Lib9c.Tests/Model/Stake/ContractTest.cs | 183 +++++++++++++++++++++++ Lib9c/Model/Stake/Contract.cs | 68 +++++++++ 2 files changed, 251 insertions(+) create mode 100644 .Lib9c.Tests/Model/Stake/ContractTest.cs diff --git a/.Lib9c.Tests/Model/Stake/ContractTest.cs b/.Lib9c.Tests/Model/Stake/ContractTest.cs new file mode 100644 index 000000000..710b7ce21 --- /dev/null +++ b/.Lib9c.Tests/Model/Stake/ContractTest.cs @@ -0,0 +1,183 @@ +namespace Lib9c.Tests.Model.Stake +{ + using System; + using Lib9c.Tests.Fixtures.TableCSV.Stake; + using Nekoyume.Model.Stake; + using Nekoyume.TableData.Stake; + using Xunit; + + public class ContractTest + { + [Theory] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix + "test", + Contract.StakeRegularRewardSheetPrefix + "test", + long.MaxValue, + long.MaxValue)] + public void Constructor_Default( + string stakeRegularFixedRewardSheetTableName, + string stakeRegularRewardSheetTableName, + long rewardInterval, + long lockupInterval) + { + var contract = new Contract( + stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName, + rewardInterval, + lockupInterval); + Assert.Equal( + stakeRegularFixedRewardSheetTableName, + contract.StakeRegularFixedRewardSheetTableName); + Assert.Equal( + stakeRegularRewardSheetTableName, + contract.StakeRegularRewardSheetTableName); + Assert.Equal(rewardInterval, contract.RewardInterval); + Assert.Equal(lockupInterval, contract.LockupInterval); + } + + [Theory] + [InlineData( + null, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1)] + [InlineData( + "", + Contract.StakeRegularRewardSheetPrefix, + 1, + 1)] + [InlineData( + "failed", + Contract.StakeRegularRewardSheetPrefix, + 1, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + null, + 1, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + "", + 1, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + "failed", + 1, + 1)] + public void Constructor_Throws_ArgumentException( + string stakeRegularFixedRewardSheetTableName, + string stakeRegularRewardSheetTableName, + long rewardInterval, + long lockupInterval) + { + Assert.Throws(() => new Contract( + stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName, + rewardInterval, + lockupInterval)); + } + + [Theory] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + -1, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 0, + 1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + -1)] + [InlineData( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 0)] + public void Constructor_Throws_ArgumentOutOfRangeException( + string stakeRegularFixedRewardSheetTableName, + string stakeRegularRewardSheetTableName, + long rewardInterval, + long lockupInterval) + { + Assert.Throws(() => new Contract( + stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName, + rewardInterval, + lockupInterval)); + } + + [Theory] + [InlineData(StakePolicySheetFixtures.V1)] + [InlineData(StakePolicySheetFixtures.V2)] + public void Constructor_StakePolicySheet(string stakePolicySheetCsv) + { + var sheet = new StakePolicySheet(); + sheet.Set(stakePolicySheetCsv); + var contract = new Contract(sheet); + Assert.Equal( + sheet.StakeRegularFixedRewardSheetValue, + contract.StakeRegularFixedRewardSheetTableName); + Assert.Equal( + sheet.StakeRegularRewardSheetValue, + contract.StakeRegularRewardSheetTableName); + Assert.Equal(sheet.RewardIntervalValue, contract.RewardInterval); + Assert.Equal(sheet.LockupIntervalValue, contract.LockupInterval); + } + + [Fact] + public void Serde() + { + var contract = new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 1, + 1); + var ser = contract.Serialize(); + var des = new Contract(ser); + Assert.Equal( + contract.StakeRegularFixedRewardSheetTableName, + des.StakeRegularFixedRewardSheetTableName); + Assert.Equal( + contract.StakeRegularRewardSheetTableName, + des.StakeRegularRewardSheetTableName); + Assert.Equal(contract.RewardInterval, des.RewardInterval); + Assert.Equal(contract.LockupInterval, des.LockupInterval); + var ser2 = des.Serialize(); + Assert.Equal(ser, ser2); + } + + [Fact] + public void Compare() + { + var contractL = new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 1, + 1); + var contractR = new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 1, + 1); + Assert.Equal(contractL, contractR); + contractR = new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 1, + 2); + Assert.NotEqual(contractL, contractR); + } + } +} diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 8b20d29ae..1063aafea 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -1,5 +1,6 @@ using System; using Bencodex.Types; +using Nekoyume.TableData.Stake; namespace Nekoyume.Model.Stake { @@ -19,23 +20,57 @@ public const string StakeRegularRewardSheetPrefix public long RewardInterval { get; } public long LockupInterval { get; } + public Contract(StakePolicySheet stakePolicySheet) : this( + stakePolicySheet.StakeRegularFixedRewardSheetValue, + stakePolicySheet.StakeRegularRewardSheetValue, + stakePolicySheet.RewardIntervalValue, + stakePolicySheet.LockupIntervalValue) + { + } + public Contract( string stakeRegularFixedRewardSheetTableName, string stakeRegularRewardSheetTableName, long rewardInterval, long lockupInterval) { + if (string.IsNullOrEmpty(stakeRegularFixedRewardSheetTableName)) + { + throw new ArgumentException( + $"{nameof(stakeRegularFixedRewardSheetTableName)} is null or empty"); + } + if (!stakeRegularFixedRewardSheetTableName.StartsWith( StakeRegularFixedRewardSheetPrefix)) { throw new ArgumentException(nameof(stakeRegularFixedRewardSheetTableName)); } + if (string.IsNullOrEmpty(stakeRegularRewardSheetTableName)) + { + throw new ArgumentException( + $"{nameof(stakeRegularRewardSheetTableName)} is null or empty"); + } + if (!stakeRegularRewardSheetTableName.StartsWith(StakeRegularRewardSheetPrefix)) { throw new ArgumentException(nameof(stakeRegularRewardSheetTableName)); } + if (rewardInterval <= 0) + { + throw new ArgumentOutOfRangeException( + nameof(rewardInterval), + $"{nameof(rewardInterval)} must be greater than 0"); + } + + if (lockupInterval <= 0) + { + throw new ArgumentOutOfRangeException( + nameof(lockupInterval), + $"{nameof(lockupInterval)} must be greater than 0"); + } + StakeRegularFixedRewardSheetTableName = stakeRegularFixedRewardSheetTableName; StakeRegularRewardSheetTableName = stakeRegularRewardSheetTableName; RewardInterval = rewardInterval; @@ -85,5 +120,38 @@ public List Serialize() (Integer)LockupInterval ); } + + protected bool Equals(Contract other) + { + return StakeRegularFixedRewardSheetTableName == + other.StakeRegularFixedRewardSheetTableName && + StakeRegularRewardSheetTableName == other.StakeRegularRewardSheetTableName && + RewardInterval == other.RewardInterval && + LockupInterval == other.LockupInterval; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Contract)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = StakeRegularFixedRewardSheetTableName != null + ? StakeRegularFixedRewardSheetTableName.GetHashCode() + : 0; + hashCode = (hashCode * 397) ^ (StakeRegularRewardSheetTableName != null + ? StakeRegularRewardSheetTableName.GetHashCode() + : 0); + hashCode = (hashCode * 397) ^ RewardInterval.GetHashCode(); + hashCode = (hashCode * 397) ^ LockupInterval.GetHashCode(); + return hashCode; + } + } } } From 401f340df316bc7e21e7621e91fea6c6e1c46806 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:37:59 +0900 Subject: [PATCH 075/134] improve StakeStateV2 --- .Lib9c.Tests/Model/Stake/StakeStateV2Test.cs | 120 +++++++++++++++++++ Lib9c/Model/Stake/StakeStateV2.cs | 43 ++++++- 2 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 .Lib9c.Tests/Model/Stake/StakeStateV2Test.cs diff --git a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs new file mode 100644 index 000000000..dfd5d925c --- /dev/null +++ b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs @@ -0,0 +1,120 @@ +namespace Lib9c.Tests.Model.Stake +{ + using System; + using Libplanet.Crypto; + using Nekoyume.Model.Stake; + using Nekoyume.Model.State; + using Xunit; + + public class StakeStateV2Test + { + [Theory] + [InlineData(0, 0)] + [InlineData(long.MaxValue, long.MaxValue)] + public void Constructor_Default(long startedBlockIndex, long receivedBlockIndex) + { + var contract = new Contract( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1); + var state = new StakeStateV2(contract, startedBlockIndex, receivedBlockIndex); + Assert.Equal(contract, state.Contract); + Assert.Equal(startedBlockIndex, state.StartedBlockIndex); + Assert.Equal(receivedBlockIndex, state.ReceivedBlockIndex); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(long.MaxValue, long.MaxValue)] + public void Constructor_Throw_ArgumentNullException(long startedBlockIndex, long receivedBlockIndex) + { + Assert.Throws(() => + new StakeStateV2(null, startedBlockIndex, receivedBlockIndex)); + } + + [Theory] + [InlineData(-1, 0)] + [InlineData(0, -1)] + [InlineData(-1, -1)] + public void Constructor_Throw_ArgumentOutOfRangeException(long startedBlockIndex, long receivedBlockIndex) + { + Assert.Throws(() => + new StakeStateV2(null, startedBlockIndex, receivedBlockIndex)); + } + + [Theory] + [InlineData(0, null)] + [InlineData(0, 0)] + [InlineData(long.MaxValue, null)] + [InlineData(long.MaxValue, long.MaxValue)] + public void Constructor_StakeState(long startedBlockIndex, long? receivedBlockIndex) + { + var stakeState = new StakeState( + new PrivateKey().ToAddress(), + startedBlockIndex); + if (receivedBlockIndex.HasValue) + { + stakeState.Claim(receivedBlockIndex.Value); + } + + var contract = new Contract( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1); + var stakeStateV2 = new StakeStateV2(stakeState, contract); + Assert.Equal(contract, stakeStateV2.Contract); + Assert.Equal(stakeState.StartedBlockIndex, stakeStateV2.StartedBlockIndex); + Assert.Equal(stakeState.ReceivedBlockIndex, stakeStateV2.ReceivedBlockIndex); + } + + [Fact] + public void Constructor_StakeState_Throw_ArgumentNullException() + { + var stakeState = new StakeState(new PrivateKey().ToAddress(), 0); + var contract = new Contract( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1); + Assert.Throws(() => new StakeStateV2(null, contract)); + Assert.Throws(() => new StakeStateV2(stakeState, null)); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(long.MaxValue, long.MaxValue)] + public void Serde(long startedBlockIndex, long receivedBlockIndex) + { + var contract = new Contract( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1); + var state = new StakeStateV2(contract, startedBlockIndex, receivedBlockIndex); + var ser = state.Serialize(); + var des = new StakeStateV2(ser); + Assert.Equal(state.Contract, des.Contract); + Assert.Equal(state.StartedBlockIndex, des.StartedBlockIndex); + Assert.Equal(state.ReceivedBlockIndex, des.ReceivedBlockIndex); + var ser2 = des.Serialize(); + Assert.Equal(ser, ser2); + } + + [Fact] + public void Compare() + { + var contract = new Contract( + Contract.StakeRegularFixedRewardSheetPrefix, + Contract.StakeRegularRewardSheetPrefix, + 1, + 1); + var stateL = new StakeStateV2(contract, 0, 0); + var stateR = new StakeStateV2(contract, 0, 0); + Assert.Equal(stateL, stateR); + stateR = new StakeStateV2(contract, 1, 0); + Assert.NotEqual(stateL, stateR); + } + } +} diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs index 0d88ce9eb..efba5d125 100644 --- a/Lib9c/Model/Stake/StakeStateV2.cs +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -39,7 +39,23 @@ public StakeStateV2( long startedBlockIndex, long receivedBlockIndex) { - Contract = contract; + if (startedBlockIndex < 0) + { + throw new ArgumentOutOfRangeException( + nameof(startedBlockIndex), + startedBlockIndex, + "startedBlockIndex should be greater than or equal to 0."); + } + + if (receivedBlockIndex < 0) + { + throw new ArgumentOutOfRangeException( + nameof(receivedBlockIndex), + receivedBlockIndex, + "receivedBlockIndex should be greater than or equal to 0."); + } + + Contract = contract ?? throw new ArgumentNullException(nameof(contract)); StartedBlockIndex = startedBlockIndex; ReceivedBlockIndex = receivedBlockIndex; } @@ -49,7 +65,7 @@ public StakeStateV2( Contract contract ) : this( contract, - stakeState.StartedBlockIndex, + stakeState?.StartedBlockIndex ?? throw new ArgumentNullException(nameof(stakeState)), stakeState.ReceivedBlockIndex ) { @@ -88,5 +104,28 @@ list[1] is not Integer stateTypeVersionValue || (Integer)StartedBlockIndex, (Integer)ReceivedBlockIndex ); + + public bool Equals(StakeStateV2 other) + { + return Equals(Contract, other.Contract) && + StartedBlockIndex == other.StartedBlockIndex && + ReceivedBlockIndex == other.ReceivedBlockIndex; + } + + public override bool Equals(object obj) + { + return obj is StakeStateV2 other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = (Contract != null ? Contract.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ StartedBlockIndex.GetHashCode(); + hashCode = (hashCode * 397) ^ ReceivedBlockIndex.GetHashCode(); + return hashCode; + } + } } } From 4f37b22eb69c2cec2cf25aec140fefd0cf6a5a7e Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:39:49 +0900 Subject: [PATCH 076/134] apply fixture to StakeRegularFixedRewardSheetTest --- .../StakeRegularFixedRewardSheetFixtures.cs | 22 +++++++++++++++++++ .../StakeRegularFixedRewardSheetTest.cs | 10 ++------- 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularFixedRewardSheetFixtures.cs diff --git a/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularFixedRewardSheetFixtures.cs b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularFixedRewardSheetFixtures.cs new file mode 100644 index 000000000..5f21e66c9 --- /dev/null +++ b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularFixedRewardSheetFixtures.cs @@ -0,0 +1,22 @@ +namespace Lib9c.Tests.Fixtures.TableCSV.Stake +{ + public static class StakeRegularFixedRewardSheetFixtures + { + public const string V1 = + @"level,required_gold,item_id,count +1,50,500000,1 +2,500,500000,2 +3,5000,500000,2 +4,50000,500000,2 +5,500000,500000,2"; + + public const string V2 = @"level,required_gold,item_id,count +1,50,500000,1 +2,500,500000,2 +3,5000,500000,2 +4,50000,500000,2 +5,500000,500000,2 +6,5000000,500000,2 +7,10000000,500000,2"; + } +} diff --git a/.Lib9c.Tests/TableData/StakeRegularFixedRewardSheetTest.cs b/.Lib9c.Tests/TableData/StakeRegularFixedRewardSheetTest.cs index d08fc5273..576abcb6b 100644 --- a/.Lib9c.Tests/TableData/StakeRegularFixedRewardSheetTest.cs +++ b/.Lib9c.Tests/TableData/StakeRegularFixedRewardSheetTest.cs @@ -1,5 +1,6 @@ namespace Lib9c.Tests.TableData { + using Lib9c.Tests.Fixtures.TableCSV.Stake; using Libplanet.Action.State; using Libplanet.Types.Assets; using Nekoyume.Extensions; @@ -13,15 +14,8 @@ public class StakeRegularFixedRewardSheetTest public StakeRegularFixedRewardSheetTest() { - const string TableContent = @"level,required_gold,item_id,count -1,50,500000,1 -2,500,500000,2 -3,5000,500000,2 -4,50000,500000,2 -5,500000,500000,2"; - _sheet = new StakeRegularFixedRewardSheet(); - _sheet.Set(TableContent); + _sheet.Set(StakeRegularFixedRewardSheetFixtures.V1); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 _currency = Currency.Legacy("NCG", 2, null); From d59af62776f00213b6d33424142087a7370420db Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:54:32 +0900 Subject: [PATCH 077/134] apply fixture to StakeRegularRewardSheetTest --- .../Stake/StakeRegularRewardSheetFixtures.cs | 51 ++++++ .../TableData/StakeRegularRewardSheetTest.cs | 160 ++++++------------ 2 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 .Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs diff --git a/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs new file mode 100644 index 000000000..6440b66c5 --- /dev/null +++ b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs @@ -0,0 +1,51 @@ +namespace Lib9c.Tests.Fixtures.TableCSV.Stake +{ + public static class StakeRegularRewardSheetFixtures + { + public const string V1 = + @"level,required_gold,item_id,rate,type,currency_ticker,currency_decimal_places,decimal_rate +1,50,400000,,Item,,,10 +1,50,500000,,Item,,,800 +1,50,20001,,Rune,,,6000 +2,500,400000,,Item,,,8 +2,500,500000,,Item,,,800 +2,500,20001,,Rune,,,6000 +3,5000,400000,,Item,,,5 +3,5000,500000,,Item,,,800 +3,5000,20001,,Rune,,,6000 +4,50000,400000,,Item,,,5 +4,50000,500000,,Item,,,800 +4,50000,20001,,Rune,,,6000 +5,500000,400000,,Item,,,5 +5,500000,500000,,Item,,,800 +5,500000,20001,,Rune,,,6000"; + + public const string V2 = + @"level,required_gold,item_id,rate,type,currency_ticker +1,50,400000,10,Item, +1,50,500000,800,Item, +1,50,20001,6000,Rune, +2,500,400000,4,Item, +2,500,500000,600,Item, +2,500,20001,6000,Rune, +3,5000,400000,2,Item, +3,5000,500000,400,Item, +3,5000,20001,6000,Rune, +4,50000,400000,2,Item, +4,50000,500000,400,Item, +4,50000,20001,6000,Rune, +5,500000,400000,2,Item, +5,500000,500000,400,Item, +5,500000,20001,6000,Rune, +6,5000000,400000,2,Item, +6,5000000,500000,400,Item, +6,5000000,20001,6000,Rune, +6,5000000,800201,50,Item, +7,10000000,400000,2,Item, +7,10000000,500000,400,Item, +7,10000000,20001,6000,Rune, +7,10000000,600201,50,Item, +7,10000000,800201,50,Item, +7,10000000,,100,Currency,GARAGE"; + } +} diff --git a/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs b/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs index ba26d1a16..4981499b9 100644 --- a/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs +++ b/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs @@ -1,6 +1,6 @@ namespace Lib9c.Tests.TableData { - using System; + using Lib9c.Tests.Fixtures.TableCSV.Stake; using Libplanet.Action.State; using Libplanet.Types.Assets; using Nekoyume.Extensions; @@ -14,13 +14,8 @@ public class StakeRegularRewardSheetTest public StakeRegularRewardSheetTest() { - const string tableContent = @"level,required_gold,item_id,rate -0,0,0,0 -1,10,400000,50 -1,10,500000,50"; - _sheet = new StakeRegularRewardSheet(); - _sheet.Set(tableContent); + _sheet.Set(StakeRegularRewardSheetFixtures.V1); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 _currency = Currency.Legacy("NCG", 2, null); @@ -30,115 +25,64 @@ public StakeRegularRewardSheetTest() [Fact] public void SetToSheet() { - Assert.Equal(2, _sheet.Count); - var row = _sheet[0]; - Assert.Equal(0, row.Level); - Assert.Equal(0, row.RequiredGold); - Assert.Single(row.Rewards); + Assert.Equal(5, _sheet.Count); + var row = _sheet[1]; + Assert.Equal(50, row.RequiredGold); + Assert.Equal(3, row.Rewards.Count); var reward = row.Rewards[0]; - Assert.Equal(0, reward.ItemId); + Assert.Equal(400000, reward.ItemId); + Assert.Equal(0, reward.Rate); + Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(10m, reward.DecimalRate); + reward = row.Rewards[1]; + Assert.Equal(500000, reward.ItemId); Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); - Assert.Null(reward.CurrencyTicker); + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(800m, reward.DecimalRate); + reward = row.Rewards[2]; + Assert.Equal(20001, reward.ItemId); + Assert.Equal(0, reward.Rate); + Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Rune, reward.Type); + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(6000m, reward.DecimalRate); - row = _sheet[1]; - Assert.Equal(10, row.RequiredGold); - Assert.Equal(2, row.Rewards.Count); + row = _sheet[5]; + Assert.Equal(500000, row.RequiredGold); + Assert.Equal(3, row.Rewards.Count); reward = row.Rewards[0]; Assert.Equal(400000, reward.ItemId); - Assert.Equal(50, reward.Rate); + Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); - Assert.Null(reward.CurrencyTicker); + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(5m, reward.DecimalRate); reward = row.Rewards[1]; Assert.Equal(500000, reward.ItemId); - Assert.Equal(50, reward.Rate); + Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); - Assert.Null(reward.CurrencyTicker); - - var patchedSheet = new StakeRegularRewardSheet(); - const string tableContentWithRune = - @"level,required_gold,item_id,rate,type,currency_ticker,currency_decimal_places,decimal_rate -1,50,400000,10,Item -1,50,500000,800,Item -1,50,20001,6000,Rune -1,50,,,Currency,CRYSTAL,18,0.1 -1,50,,100,Currency,GARAGE,18, -"; - patchedSheet.Set(tableContentWithRune); - Assert.Single(patchedSheet); - row = patchedSheet[1]; - Assert.Equal(50, row.RequiredGold); - Assert.Equal(5, row.Rewards.Count); - for (var i = 0; i < 5; i++) - { - reward = row.Rewards[i]; - var itemId = i switch - { - 0 => 400000, - 1 => 500000, - 2 => 20001, - 3 => 0, - 4 => 0, - _ => throw new ArgumentOutOfRangeException() - }; - var rate = i switch - { - 0 => 10, - 1 => 800, - 2 => 6000, - 3 => 0, - 4 => 100, - _ => throw new ArgumentOutOfRangeException() - }; - var rewardType = i switch - { - 0 => StakeRegularRewardSheet.StakeRewardType.Item, - 1 => StakeRegularRewardSheet.StakeRewardType.Item, - 2 => StakeRegularRewardSheet.StakeRewardType.Rune, - 3 => StakeRegularRewardSheet.StakeRewardType.Currency, - 4 => StakeRegularRewardSheet.StakeRewardType.Currency, - _ => throw new ArgumentOutOfRangeException() - }; - var currencyTicker = i switch - { - 0 => null, - 1 => null, - 2 => null, - 3 => "CRYSTAL", - 4 => "GARAGE", - _ => throw new ArgumentOutOfRangeException() - }; - var currencyDecimalPlaces = i switch - { - 0 => (int?)null, - 1 => null, - 2 => null, - 3 => 18, - 4 => 18, - _ => throw new ArgumentOutOfRangeException() - }; - var decimalRate = i switch - { - 0 => 10m, - 1 => 800m, - 2 => 6000m, - 3 => 0.1m, - 4 => 0m, - _ => throw new ArgumentOutOfRangeException() - }; - Assert.Equal(itemId, reward.ItemId); - Assert.Equal(rate, reward.Rate); - Assert.Equal(rewardType, reward.Type); - Assert.Equal(currencyTicker, reward.CurrencyTicker); - Assert.Equal(currencyDecimalPlaces, reward.CurrencyDecimalPlaces); - Assert.Equal(decimalRate, reward.DecimalRate); - } + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(800m, reward.DecimalRate); + reward = row.Rewards[2]; + Assert.Equal(20001, reward.ItemId); + Assert.Equal(0, reward.Rate); + Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Rune, reward.Type); + Assert.Equal(string.Empty, reward.CurrencyTicker); + Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Equal(6000m, reward.DecimalRate); } [Theory] - [InlineData(0, 0)] - [InlineData(1, 0)] - [InlineData(100, 1)] + [InlineData(50, 1)] + [InlineData(500, 2)] + [InlineData(5000, 3)] + [InlineData(50000, 4)] + [InlineData(500000, 5)] public void FindLevelByStakedAmount(int balance, int expectedLevel) { Assert.Equal( @@ -147,11 +91,15 @@ public void FindLevelByStakedAmount(int balance, int expectedLevel) ); } - [Fact] - public void FindLevelByStakedAmount_Throw_InsufficientBalanceException() + [Theory] + [InlineData(49)] + [InlineData(0)] + [InlineData(-1)] + [InlineData(int.MinValue)] + public void FindLevelByStakedAmount_Throws_InsufficientBalanceException(int balance) { Assert.Throws( - () => _sheet.FindLevelByStakedAmount(default, -1 * _currency)); + () => _sheet.FindLevelByStakedAmount(default, balance * _currency)); } } } From 6ef0b72e472311932410b0edf7bc293663372090 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:55:17 +0900 Subject: [PATCH 078/134] add a option to TableSheets constructor --- .Lib9c.Tests/TableSheets.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.Lib9c.Tests/TableSheets.cs b/.Lib9c.Tests/TableSheets.cs index c4b1343c3..ff00be963 100644 --- a/.Lib9c.Tests/TableSheets.cs +++ b/.Lib9c.Tests/TableSheets.cs @@ -13,13 +13,18 @@ namespace Lib9c.Tests public class TableSheets { - public TableSheets(Dictionary sheets) + public TableSheets(Dictionary sheets, bool ignoreFailedGetProperty = false) { foreach (var (key, value) in sheets) { var sheetPropertyInfo = GetType().GetProperty(key); if (sheetPropertyInfo is null) { + if (ignoreFailedGetProperty) + { + continue; + } + var sb = new StringBuilder($"[{nameof(TableSheets)}]"); sb.Append($" / ({key}, csv)"); sb.Append(" / failed to get property"); From a8c215798c47d4f6aff4b65e410607ec2bd1e6d8 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 17:55:30 +0900 Subject: [PATCH 079/134] apply to InitializeUtil --- .Lib9c.Tests/Util/InitializeUtil.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index 734fcfacb..8ff00d369 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -44,7 +44,7 @@ IAccountStateDelta initialStatesWithAvatarStateV2 var tuple = InitializeTableSheets(states, isDevEx, sheetsOverride); states = tuple.states; - var tableSheets = new TableSheets(tuple.sheets); + var tableSheets = new TableSheets(tuple.sheets, ignoreFailedGetProperty: true); var gameConfigState = new GameConfigState(tuple.sheets[nameof(GameConfigSheet)]); states = states.SetState(gameConfigState.address, gameConfigState.Serialize()); From fdd96f951428bda87432d1fdd8ed8f8ba411546e Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 20:56:15 +0900 Subject: [PATCH 080/134] improve StakeStateV2 --- .Lib9c.Tests/Model/Stake/StakeStateV2Test.cs | 22 +++++++++++++++----- Lib9c/Model/Stake/StakeStateV2.cs | 13 +++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs index dfd5d925c..d56a1b2a7 100644 --- a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs +++ b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs @@ -8,6 +8,14 @@ namespace Lib9c.Tests.Model.Stake public class StakeStateV2Test { + [Fact] + public void DeriveAddress() + { + var agentAddr = new PrivateKey().ToAddress(); + var expectedStakeStateAddr = StakeState.DeriveAddress(agentAddr); + Assert.Equal(expectedStakeStateAddr, StakeStateV2.DeriveAddress(agentAddr)); + } + [Theory] [InlineData(0, 0)] [InlineData(long.MaxValue, long.MaxValue)] @@ -27,7 +35,9 @@ public void Constructor_Default(long startedBlockIndex, long receivedBlockIndex) [Theory] [InlineData(0, 0)] [InlineData(long.MaxValue, long.MaxValue)] - public void Constructor_Throw_ArgumentNullException(long startedBlockIndex, long receivedBlockIndex) + public void Constructor_Throw_ArgumentNullException( + long startedBlockIndex, + long receivedBlockIndex) { Assert.Throws(() => new StakeStateV2(null, startedBlockIndex, receivedBlockIndex)); @@ -37,7 +47,9 @@ public void Constructor_Throw_ArgumentNullException(long startedBlockIndex, long [InlineData(-1, 0)] [InlineData(0, -1)] [InlineData(-1, -1)] - public void Constructor_Throw_ArgumentOutOfRangeException(long startedBlockIndex, long receivedBlockIndex) + public void Constructor_Throw_ArgumentOutOfRangeException( + long startedBlockIndex, + long receivedBlockIndex) { Assert.Throws(() => new StakeStateV2(null, startedBlockIndex, receivedBlockIndex)); @@ -110,10 +122,10 @@ public void Compare() Contract.StakeRegularRewardSheetPrefix, 1, 1); - var stateL = new StakeStateV2(contract, 0, 0); - var stateR = new StakeStateV2(contract, 0, 0); + var stateL = new StakeStateV2(contract, 0); + var stateR = new StakeStateV2(contract, 0); Assert.Equal(stateL, stateR); - stateR = new StakeStateV2(contract, 1, 0); + stateR = new StakeStateV2(contract, 1); Assert.NotEqual(stateL, stateR); } } diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs index efba5d125..a5ee20a22 100644 --- a/Lib9c/Model/Stake/StakeStateV2.cs +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -1,5 +1,6 @@ using System; using Bencodex.Types; +using Libplanet.Crypto; using Nekoyume.Model.State; namespace Nekoyume.Model.Stake @@ -9,6 +10,9 @@ namespace Nekoyume.Model.Stake public const string StateTypeName = "stake_state"; public const int StateTypeVersion = 2; + public static Address DeriveAddress(Address address) => + StakeState.DeriveAddress(address); + public readonly Contract Contract; public readonly long StartedBlockIndex; public readonly long ReceivedBlockIndex; @@ -27,17 +31,10 @@ out _ public long ClaimableBlockIndex => ClaimedBlockIndex + Contract.RewardInterval; - public StakeStateV2( - Contract contract, - long startedBlockIndex) - : this(contract, startedBlockIndex, 0) - { - } - public StakeStateV2( Contract contract, long startedBlockIndex, - long receivedBlockIndex) + long receivedBlockIndex = 0) { if (startedBlockIndex < 0) { From 3a099452f2aa850da846c440b3ab38d256e54f99 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 20:56:32 +0900 Subject: [PATCH 081/134] add GameConfigSheetFixtures --- .../TableCSV/GameConfigSheetFixtures.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .Lib9c.Tests/Fixtures/TableCSV/GameConfigSheetFixtures.cs diff --git a/.Lib9c.Tests/Fixtures/TableCSV/GameConfigSheetFixtures.cs b/.Lib9c.Tests/Fixtures/TableCSV/GameConfigSheetFixtures.cs new file mode 100644 index 000000000..49ac47109 --- /dev/null +++ b/.Lib9c.Tests/Fixtures/TableCSV/GameConfigSheetFixtures.cs @@ -0,0 +1,25 @@ +namespace Lib9c.Tests.Fixtures.TableCSV +{ + public static class GameConfigSheetFixtures + { + public const string Default = @"key,value +hourglass_per_block,3 +action_point_max,120 +daily_reward_interval,1700 +daily_arena_interval,5040 +weekly_arena_interval,56000 +required_appraise_block,10 +battle_arena_interval,4 +rune_stat_slot_unlock_cost,100 +rune_skill_slot_unlock_cost,1000 +daily_rune_reward_amount,1 +daily_worldboss_interval,7200 +worldboss_required_interval,5 +stake_regular_fixed_reward_sheet_v2_start_block_index,6700000 +stake_regular_reward_sheet_v2_start_block_index,5510416 +stake_regular_reward_sheet_v3_start_block_index,6700000 +stake_regular_reward_sheet_v4_start_block_index,6910000 +stake_regular_reward_sheet_v5_start_block_index,7650000 +"; + } +} From 84d22a6730f5edba142b32c2e6ab652c37167f16 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 20:57:15 +0900 Subject: [PATCH 082/134] add IAccountStateExtensions.TryGetSheet(this states, address, out T sheet) --- Lib9c/Action/AccountStateExtensions.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index 563b779ba..dd677d530 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -471,7 +471,8 @@ public static IEnumerable GetGoldDistribution( } } - public static T GetSheet(this IAccountState states) where T : ISheet, new() + public static T GetSheet( + this IAccountState states) where T : ISheet, new() { var address = Addresses.GetSheetAddress(); return GetSheet(states, address); @@ -509,7 +510,8 @@ public static T GetSheet( } } - public static bool TryGetSheet(this IAccountState states, out T sheet) where T : ISheet, new() + public static bool TryGetSheet(this IAccountState states, out T sheet) + where T : ISheet, new() { try { @@ -523,6 +525,21 @@ public static T GetSheet( } } + public static bool TryGetSheet(this IAccountState states, Address address, out T sheet) + where T : ISheet, new() + { + try + { + sheet = states.GetSheet(address); + return true; + } + catch (Exception) + { + sheet = default; + return false; + } + } + public static Dictionary GetSheets( this IAccountState states, bool containAvatarSheets = false, From dc12d93b15b3685c07ad9fbb620f1b5d15b91367 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 1 Sep 2023 20:57:55 +0900 Subject: [PATCH 083/134] fix Stake action with StakeTest --- .Lib9c.Tests/Action/StakeTest.cs | 541 +++++++++++++++++++++++++++++++ Lib9c/Action/Stake.cs | 116 ++++--- 2 files changed, 618 insertions(+), 39 deletions(-) create mode 100644 .Lib9c.Tests/Action/StakeTest.cs diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs new file mode 100644 index 000000000..edd8c1968 --- /dev/null +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -0,0 +1,541 @@ +namespace Lib9c.Tests.Action +{ + using System; + using System.Collections.Generic; + using Bencodex.Types; + using Lib9c.Tests.Fixtures.TableCSV.Stake; + using Lib9c.Tests.Util; + using Libplanet.Action; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Libplanet.Types.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Exceptions; + using Nekoyume.Model.Stake; + using Nekoyume.Model.State; + using Nekoyume.TableData.Stake; + using Serilog; + using Xunit; + using Xunit.Abstractions; + + public class StakeTest + { + private readonly IAccountStateDelta _initialState; + private readonly Currency _ncg; + private readonly Address _agentAddr; + private readonly StakePolicySheet _stakePolicySheet; + + public StakeTest(ITestOutputHelper outputHelper) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.TestOutput(outputHelper) + .CreateLogger(); + + var sheetsOverride = new Dictionary + { + { + "StakeRegularFixedRewardSheet_V1", + StakeRegularFixedRewardSheetFixtures.V1 + }, + { + "StakeRegularFixedRewardSheet_V2", + StakeRegularFixedRewardSheetFixtures.V2 + }, + { + "StakeRegularRewardSheet_V1", + StakeRegularRewardSheetFixtures.V1 + }, + { + "StakeRegularRewardSheet_V2", + StakeRegularRewardSheetFixtures.V2 + }, + { + nameof(StakePolicySheet), + StakePolicySheetFixtures.V2 + }, + }; + ( + _, + _agentAddr, + _, + _, + _initialState + ) = InitializeUtil.InitializeStates(sheetsOverride: sheetsOverride); + _ncg = _initialState.GetGoldCurrency(); + _stakePolicySheet = _initialState.GetSheet(); + } + + [Theory] + [InlineData(long.MinValue, false)] + [InlineData(0, true)] + [InlineData(long.MaxValue, true)] + public void Constructor(long amount, bool success) + { + if (success) + { + var stake = new Stake(amount); + } + else + { + Assert.Throws(() => new Stake(amount)); + } + } + + [Theory] + [InlineData(0)] + [InlineData(long.MaxValue)] + public void Serialization(long amount) + { + var action = new Stake(amount); + var ser = action.PlainValue; + var de = new Stake(); + de.LoadPlainValue(ser); + Assert.Equal(action.Amount, de.Amount); + Assert.Equal(ser, de.PlainValue); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(50)] + [InlineData(long.MaxValue)] + public void Execute_Success_When_Staking_State_Null(long amount) + { + var previousState = _initialState.MintAsset( + new ActionContext { Signer = Addresses.Admin }, + _agentAddr, + _ncg * amount); + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + amount); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(0, 50, 50)] + [InlineData(0, long.MaxValue, long.MaxValue)] + public void Execute_Success_When_Exist_StakeState( + long previousStartedBlockIndex, + long previousAmount, + long amount) + { + var stakeStateAddr = StakeState.DeriveAddress(_agentAddr); + var stakeState = new StakeState( + address: stakeStateAddr, + startedBlockIndex: previousStartedBlockIndex); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + _agentAddr, + _ncg * Math.Max(previousAmount, amount)) + .TransferAsset( + new ActionContext { Signer = _agentAddr }, + _agentAddr, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeState.Serialize()); + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + amount); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(50, 50)] + [InlineData(long.MaxValue, long.MaxValue)] + public void Execute_Success_When_Exist_StakeStateV2(long previousAmount, long nextAmount) + { + var stakeStateAddr = StakeStateV2.DeriveAddress(_agentAddr); + var contract = new Contract( + _stakePolicySheet.StakeRegularFixedRewardSheetValue, + _stakePolicySheet.StakeRegularRewardSheetValue, + _stakePolicySheet.RewardIntervalValue, + _stakePolicySheet.LockupIntervalValue); + var stakeStateV2 = new StakeStateV2( + contract: contract, + startedBlockIndex: 0); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + _agentAddr, + _ncg * Math.Max(previousAmount, nextAmount)) + .TransferAsset( + new ActionContext { Signer = _agentAddr }, + _agentAddr, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeStateV2.Serialize()); + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + nextAmount); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(0, 50, StakeState.LockupInterval)] + [InlineData(0, 50, StakeState.LockupInterval + 1)] + public void Execute_Success_When_Withdraw_With_StakeState( + long previousStartedBlockIndex, + long previousAmount, + long blockIndex) + { + var stakeStateAddr = StakeState.DeriveAddress(_agentAddr); + var stakeState = new StakeState( + address: stakeStateAddr, + startedBlockIndex: previousStartedBlockIndex); + Assert.True(stakeState.IsCancellable(blockIndex)); + stakeState.Claim(blockIndex); + Assert.False(stakeState.IsClaimable(blockIndex)); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeState.Serialize()); + ExecuteInternal( + blockIndex, + previousState, + new TestRandom(), + _agentAddr, + 0); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + // NOTE: LockupInterval of StakePolicySheetFixtures.V2 is 201,600. + [InlineData(0, 50, 201_600)] + [InlineData(0, 50, 201_601)] + public void Execute_Success_When_Withdraw_With_StakeStateV2( + long previousStartedBlockIndex, + long previousAmount, + long blockIndex) + { + var stakeStateAddr = StakeStateV2.DeriveAddress(_agentAddr); + var contract = new Contract( + _stakePolicySheet.StakeRegularFixedRewardSheetValue, + _stakePolicySheet.StakeRegularRewardSheetValue, + _stakePolicySheet.RewardIntervalValue, + _stakePolicySheet.LockupIntervalValue); + var stakeStateV2 = new StakeStateV2( + contract: contract, + startedBlockIndex: previousStartedBlockIndex, + receivedBlockIndex: blockIndex); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeStateV2.Serialize()); + ExecuteInternal( + blockIndex, + previousState, + new TestRandom(), + _agentAddr, + 0); + } + + [Theory] + [InlineData(0)] + [InlineData(9)] // NOTE: 9 is just a random number. + public void Execute_Throw_MonsterCollectionExistingException( + int monsterCollectionRound) + { + var previousState = _initialState; + var agentState = previousState.GetAgentState(_agentAddr); + if (monsterCollectionRound > 0) + { + for (var i = 0; i < monsterCollectionRound; i++) + { + agentState.IncreaseCollectionRound(); + } + + previousState = previousState + .SetState(_agentAddr, agentState.Serialize()); + } + + var monsterCollectionAddr = + MonsterCollectionState.DeriveAddress(_agentAddr, monsterCollectionRound); + var monsterCollectionState = new MonsterCollectionState( + monsterCollectionAddr, + 1, + 0); + previousState = previousState + .SetState(monsterCollectionAddr, monsterCollectionState.SerializeV2()); + Assert.Throws(() => + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + 0)); + } + + [Theory] + [InlineData(-1)] + [InlineData(long.MinValue)] + public void Execute_Throw_ArgumentOutOfRangeException_Via_Negative_Amount(long amount) + { + Assert.Throws(() => + ExecuteInternal( + 0, + _initialState, + new TestRandom(), + _agentAddr, + amount)); + } + + [Theory] + [InlineData(nameof(StakePolicySheet))] + // NOTE: StakePolicySheet in _initialState has V2. + [InlineData("StakeRegularFixedRewardSheet_V2")] + // NOTE: StakePolicySheet in _initialState has V2. + [InlineData("StakeRegularRewardSheet_V2")] + public void Execute_Throw_StateNullException_Via_Sheet(string sheetName) + { + var previousState = _initialState.SetState( + Addresses.GetSheetAddress(sheetName), + Null.Value); + Assert.Throws(() => + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + 0)); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(49)] + [InlineData(1)] + public void Execute_Throw_ArgumentOutOfRangeException_Via_Minimum_Amount(long amount) + { + Assert.Throws(() => + ExecuteInternal( + 0, + _initialState, + new TestRandom(), + _agentAddr, + amount)); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(0, 50)] + [InlineData(49, 50)] + [InlineData(long.MaxValue - 1, long.MaxValue)] + public void Execute_Throws_NotEnoughFungibleAssetValueException( + long balance, + long amount) + { + var previousState = _initialState; + if (balance > 0) + { + previousState = _initialState.MintAsset( + new ActionContext { Signer = Addresses.Admin }, + _agentAddr, + _ncg * balance); + } + + Assert.Throws(() => + ExecuteInternal( + 0, + previousState, + new TestRandom(), + _agentAddr, + amount)); + } + + [Fact] + public void Execute_Throw_StateNullException_Via_0_Amount() + { + Assert.Throws(() => + ExecuteInternal( + 0, + _initialState, + new TestRandom(), + _agentAddr, + 0)); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(0, 50, StakeState.RewardInterval)] + [InlineData( + long.MaxValue - StakeState.RewardInterval, + long.MaxValue, + long.MaxValue)] + public void Execute_Throw_StakeExistingClaimableException_With_StakeState( + long previousStartedBlockIndex, + long previousAmount, + long blockIndex) + { + var stakeStateAddr = StakeState.DeriveAddress(_agentAddr); + var stakeState = new StakeState( + address: stakeStateAddr, + startedBlockIndex: previousStartedBlockIndex); + Assert.True(stakeState.IsClaimable(blockIndex)); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeState.Serialize()); + Assert.Throws(() => + ExecuteInternal( + blockIndex, + previousState, + new TestRandom(), + _agentAddr, + previousAmount)); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + // NOTE: RewardInterval of StakePolicySheetFixtures.V2 is 50,400. + [InlineData(0, 50, 50400)] + [InlineData( + long.MaxValue - 50400, + long.MaxValue, + long.MaxValue)] + public void Execute_Throw_StakeExistingClaimableException_With_StakeStateV2( + long previousStartedBlockIndex, + long previousAmount, + long blockIndex) + { + var stakeStateAddr = StakeStateV2.DeriveAddress(_agentAddr); + var contract = new Contract( + _stakePolicySheet.StakeRegularFixedRewardSheetValue, + _stakePolicySheet.StakeRegularRewardSheetValue, + _stakePolicySheet.RewardIntervalValue, + _stakePolicySheet.LockupIntervalValue); + var stakeStateV2 = new StakeStateV2( + contract: contract, + startedBlockIndex: previousStartedBlockIndex); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeStateV2.Serialize()); + Assert.Throws(() => + ExecuteInternal( + blockIndex, + previousState, + new TestRandom(), + _agentAddr, + previousAmount)); + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + // NOTE: LockupInterval of StakePolicySheetFixtures.V2 is 201,600. + [InlineData(0, 50 + 1, 201_600 - 1, 50)] + [InlineData( + long.MaxValue - 201_600, + 50 + 1, + long.MaxValue - 1, + 50)] + public void + Execute_Throw_RequiredBlockIndexException_Via_Reduced_Amount_When_Lucked_Up_With_StakeState( + long previousStartedBlockIndex, + long previousAmount, + long blockIndex, + long reducedAmount) + { + var stakeStateAddr = StakeState.DeriveAddress(_agentAddr); + var stakeState = new StakeState( + address: stakeStateAddr, + startedBlockIndex: previousStartedBlockIndex); + Assert.False(stakeState.IsCancellable(blockIndex)); + stakeState.Claim(blockIndex); + Assert.False(stakeState.IsClaimable(blockIndex)); + var previousState = _initialState + .MintAsset( + new ActionContext { Signer = Addresses.Admin }, + stakeStateAddr, + _ncg * previousAmount) + .SetState(stakeStateAddr, stakeState.Serialize()); + Assert.Throws(() => + ExecuteInternal( + blockIndex, + previousState, + new TestRandom(), + _agentAddr, + reducedAmount)); + } + + private IAccountStateDelta ExecuteInternal( + long blockIndex, + IAccountStateDelta previousState, + IRandom random, + Address signer, + long amount) + { + var previousBalance = previousState.GetBalance(signer, _ncg); + var previousStakeBalance = previousState.GetBalance( + StakeState.DeriveAddress(signer), + _ncg); + var previousTotalBalance = previousBalance + previousStakeBalance; + var action = new Stake(amount); + var nextState = action.Execute(new ActionContext + { + BlockIndex = blockIndex, + PreviousState = previousState, + Random = random, + Rehearsal = false, + Signer = signer, + }); + + var amountNCG = _ncg * amount; + var nextBalance = nextState.GetBalance(signer, _ncg); + var nextStakeBalance = nextState.GetBalance( + StakeState.DeriveAddress(signer), + _ncg); + Assert.Equal(previousTotalBalance - amountNCG, nextBalance); + Assert.Equal(amountNCG, nextStakeBalance); + + if (amount == 0) + { + Assert.False(nextState.TryGetStakeStateV2(_agentAddr, out _)); + } + else if (amount > 0) + { + Assert.True(nextState.TryGetStakeStateV2(_agentAddr, out var stakeStateV2)); + Assert.Equal( + _stakePolicySheet.StakeRegularFixedRewardSheetValue, + stakeStateV2.Contract.StakeRegularFixedRewardSheetTableName); + Assert.Equal( + _stakePolicySheet.StakeRegularRewardSheetValue, + stakeStateV2.Contract.StakeRegularRewardSheetTableName); + Assert.Equal( + _stakePolicySheet.RewardIntervalValue, + stakeStateV2.Contract.RewardInterval); + Assert.Equal( + _stakePolicySheet.LockupIntervalValue, + stakeStateV2.Contract.LockupInterval); + Assert.Equal(blockIndex, stakeStateV2.StartedBlockIndex); + Assert.Equal(0, stakeStateV2.ReceivedBlockIndex); + Assert.Equal( + blockIndex + stakeStateV2.Contract.LockupInterval, + stakeStateV2.CancellableBlockIndex); + Assert.Equal(blockIndex, stakeStateV2.ClaimedBlockIndex); + Assert.Equal( + blockIndex + stakeStateV2.Contract.RewardInterval, + stakeStateV2.ClaimableBlockIndex); + } + + return nextState; + } + } +} diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 66960774c..b5decd738 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Immutable; -using System.Globalization; using System.Linq; using System.Numerics; using Bencodex.Types; using Lib9c.Abstractions; using Libplanet.Action; using Libplanet.Action.State; +using Libplanet.Crypto; +using Libplanet.Types.Assets; using Nekoyume.Exceptions; using Nekoyume.Model.Stake; using Nekoyume.Model.State; @@ -46,10 +47,11 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { + var started = DateTimeOffset.UtcNow; context.UseGas(1); var states = context.PreviousState; - // Restrict staking if there is a monster collection until now. + // NOTE: Restrict staking if there is a monster collection until now. if (states.GetAgentState(context.Signer) is { } agentState && states.TryGetState(MonsterCollectionState.DeriveAddress( context.Signer, @@ -68,25 +70,37 @@ public override IAccountStateDelta Execute(IActionContext context) StakeState.DeriveAddress(context.Signer)); } - // Validate plain values + // NOTE: When the amount is less than 0. if (Amount < 0) { - throw new ArgumentOutOfRangeException(nameof(Amount)); + throw new ArgumentOutOfRangeException( + nameof(Amount), + "The amount must be greater than or equal to 0."); } var addressesHex = GetSignerAndOtherAddressesHex(context, context.Signer); - var started = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}Stake exec started", addressesHex); - var stakePolicySheet = states.GetSheet(); - var currentStakeRegularRewardSheetAddress = - Addresses.GetSheetAddress(stakePolicySheet[nameof(StakeRegularRewardSheet)].Value); + if (!states.TryGetSheet(out var stakePolicySheet)) + { + throw new StateNullException(Addresses.GetSheetAddress()); + } + + var currentStakeRegularRewardSheetAddr = Addresses.GetSheetAddress( + stakePolicySheet.StakeRegularRewardSheetValue); + if (!states.TryGetSheet( + currentStakeRegularRewardSheetAddr, + out var stakeRegularRewardSheet)) + { + throw new StateNullException(currentStakeRegularRewardSheetAddr); + } - var stakeRegularRewardSheet = states.GetSheet( - currentStakeRegularRewardSheetAddress); var minimumRequiredGold = stakeRegularRewardSheet.OrderedRows.Min(x => x.RequiredGold); + // NOTE: When the amount is less than the minimum required gold. if (Amount != 0 && Amount < minimumRequiredGold) { - throw new ArgumentOutOfRangeException(nameof(Amount)); + throw new ArgumentOutOfRangeException( + nameof(Amount), + $"The amount must be greater than or equal to {minimumRequiredGold}."); } var stakeStateAddress = StakeState.DeriveAddress(context.Signer); @@ -94,6 +108,7 @@ public override IAccountStateDelta Execute(IActionContext context) var currentBalance = states.GetBalance(context.Signer, currency); var stakedBalance = states.GetBalance(stakeStateAddress, currency); var targetStakeBalance = currency * Amount; + // NOTE: When the total balance is less than the target balance. if (currentBalance + stakedBalance < targetStakeBalance) { throw new NotEnoughFungibleAssetValueException( @@ -102,32 +117,33 @@ public override IAccountStateDelta Execute(IActionContext context) currentBalance); } - var latestStakeContract = new Contract( - stakeRegularFixedRewardSheetTableName: - stakePolicySheet["StakeRegularFixedRewardSheet"].Value, - stakeRegularRewardSheetTableName: - stakePolicySheet["StakeRegularRewardSheet"].Value, - rewardInterval: - long.Parse(stakePolicySheet["RewardInterval"].Value, CultureInfo.InvariantCulture), - lockupInterval: - long.Parse(stakePolicySheet["LockupInterval"].Value, CultureInfo.InvariantCulture) - ); - + var latestStakeContract = new Contract(stakePolicySheet); + // NOTE: When the staking state is not exist. if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) { + // NOTE: Cannot withdraw staking. if (Amount == 0) { throw new StateNullException(stakeStateAddress); } - stakeStateV2 = new StakeStateV2(latestStakeContract, context.BlockIndex); - return states - .SetState(stakeStateAddress, stakeStateV2.Serialize()) - .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance); + // NOTE: Contract a new staking. + states = ContractNewStake( + context, + states, + stakeStateAddress, + stakedBalance: null, + targetStakeBalance, + latestStakeContract); + Log.Debug( + "{AddressesHex}Stake Total Executed Time: {Elapsed}", + addressesHex, + DateTimeOffset.UtcNow - started); + return states; } // NOTE: Cannot anything if staking state is claimable. - if (stakeStateV2.ClaimableBlockIndex >= context.BlockIndex) + if (stakeStateV2.ClaimableBlockIndex <= context.BlockIndex) { throw new StakeExistingClaimableException(); } @@ -151,19 +167,41 @@ public override IAccountStateDelta Execute(IActionContext context) } // NOTE: Contract a new staking. - var newStakeState = new StakeStateV2( - latestStakeContract, - context.BlockIndex); - states = states - .TransferAsset(context, stakeStateAddress, context.Signer, stakedBalance) - .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance) - .SetState(stakeStateAddress, newStakeState.Serialize()); - - var ended = DateTimeOffset.UtcNow; - Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, - ended - started); - + states = ContractNewStake( + context, + states, + stakeStateAddress, + stakedBalance, + targetStakeBalance, + latestStakeContract); + Log.Debug( + "{AddressesHex}Stake Total Executed Time: {Elapsed}", + addressesHex, + DateTimeOffset.UtcNow - started); return states; } + + private static IAccountStateDelta ContractNewStake( + IActionContext context, + IAccountStateDelta state, + Address stakeStateAddr, + FungibleAssetValue? stakedBalance, + FungibleAssetValue targetStakeBalance, + Contract latestStakeContract) + { + var newStakeState = new StakeStateV2(latestStakeContract, context.BlockIndex); + if (stakedBalance.HasValue) + { + state = state.TransferAsset( + context, + stakeStateAddr, + context.Signer, + stakedBalance.Value); + } + + return state + .TransferAsset(context, context.Signer, stakeStateAddr, targetStakeBalance) + .SetState(stakeStateAddr, newStakeState.Serialize()); + } } } From 5b0d75482b8f025ea91ed294e70cd20bcd74b968 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 12:03:57 +0900 Subject: [PATCH 084/134] set dotnet language version from 8 to 9 --- .Lib9c.Tests/Lib9c.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Lib9c.Tests.csproj b/.Lib9c.Tests/Lib9c.Tests.csproj index eddb6f59a..fb877391a 100644 --- a/.Lib9c.Tests/Lib9c.Tests.csproj +++ b/.Lib9c.Tests/Lib9c.Tests.csproj @@ -2,7 +2,7 @@ net6.0 - 8.0 + 9.0 false false true From 77e185caaba155b42a532e8325768c9a30076c95 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 12:09:42 +0900 Subject: [PATCH 085/134] fix bugs of claim_stake_reward9 --- Lib9c/Action/ClaimStakeReward.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index f6e524893..a85bc0b4b 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -75,7 +75,7 @@ public override IAccountStateDelta Execute(IActionContext context) stakeStateAddress); } - if (stakeStateV2.ClaimableBlockIndex < context.BlockIndex) + if (stakeStateV2.ClaimableBlockIndex > context.BlockIndex) { throw new RequiredBlockIndexException( ActionTypeText, @@ -124,17 +124,7 @@ public override IAccountStateDelta Execute(IActionContext context) var rewardSteps = 1 + (int)Math.DivRem( context.BlockIndex - stakeStateV2.ClaimableBlockIndex, StakeState.RewardInterval, - out var remained); - - // states = ProcessReward( - // context, - // states, - // ref avatarState, - // itemSheet, - // stakedAmount, - // rewardSteps, - // stakeRegularFixedRewardSheet[stakingLevel].Rewards, - // stakeRegularRewardSheet[stakingLevel].Rewards); + out _); // Fixed Reward foreach (var reward in stakeRegularFixedRewardSheet[stakingLevel].Rewards) @@ -247,7 +237,7 @@ public override IAccountStateDelta Execute(IActionContext context) stakeStateV2 = new StakeStateV2( stakeStateV2.Contract, stakeStateV2.StartedBlockIndex, - context.BlockIndex - remained); + context.BlockIndex); if (migrationRequired) { From b4fbea61c9adbe9d70640075e01ab37503e92197 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 13:01:26 +0900 Subject: [PATCH 086/134] introduce StakeStateUtils --- Lib9c/Action/AccountStateExtensions.cs | 66 ++------------------ Lib9c/Model/Stake/StakeStateUtils.cs | 85 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 61 deletions(-) create mode 100644 Lib9c/Model/Stake/StakeStateUtils.cs diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index dd677d530..c3f498273 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -962,67 +962,11 @@ public static bool TryGetStakeStateV2( Address agentAddr, out StakeStateV2 stakeStateV2) { - var stakeStateAddr = StakeState.DeriveAddress(agentAddr); - var stakeStateValue = state.GetState(stakeStateAddr); - if (stakeStateValue is null) - { - stakeStateV2 = default; - return false; - } - - if (stakeStateValue is List list) - { - stakeStateV2 = new StakeStateV2(list); - return true; - } - - if (stakeStateValue is Dictionary dict) - { - var gcs = state.GetGameConfigState(); - var stakeStateV1 = new StakeState(dict); - var stakeRegularFixedRewardSheetTableName = - stakeStateV1.StartedBlockIndex < - gcs.StakeRegularFixedRewardSheet_V2_StartBlockIndex - ? "StakeRegularFixedRewardSheet_V1" - : "StakeRegularFixedRewardSheet_V2"; - string stakeRegularRewardSheetTableName; - if (stakeStateV1.StartedBlockIndex < - gcs.StakeRegularRewardSheet_V2_StartBlockIndex) - { - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; - } - else if (stakeStateV1.StartedBlockIndex < - gcs.StakeRegularRewardSheet_V3_StartBlockIndex) - { - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; - } - else if (stakeStateV1.StartedBlockIndex < - gcs.StakeRegularRewardSheet_V4_StartBlockIndex) - { - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; - } - else if (stakeStateV1.StartedBlockIndex < - gcs.StakeRegularRewardSheet_V5_StartBlockIndex) - { - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V4"; - } - else - { - stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V5"; - } - - stakeStateV2 = new StakeStateV2( - stakeStateV1, - new Contract( - stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, - stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName, - rewardInterval: StakeState.RewardInterval, - lockupInterval: StakeState.LockupInterval)); - return true; - } - - stakeStateV2 = default; - return false; + var stakeStateAddr = StakeStateV2.DeriveAddress(agentAddr); + return StakeStateUtils.TryMigrate( + state, + stakeStateAddr, + out stakeStateV2); } public static ArenaParticipants GetArenaParticipants(this IAccountState states, diff --git a/Lib9c/Model/Stake/StakeStateUtils.cs b/Lib9c/Model/Stake/StakeStateUtils.cs new file mode 100644 index 000000000..5d2ab6a88 --- /dev/null +++ b/Lib9c/Model/Stake/StakeStateUtils.cs @@ -0,0 +1,85 @@ +using Bencodex.Types; +using Libplanet.Action.State; +using Libplanet.Crypto; +using Nekoyume.Action; +using Nekoyume.Model.State; + +namespace Nekoyume.Model.Stake +{ + public static class StakeStateUtils + { + // FIXME: Use StakePolicySheet instead of hard-coding. + public static bool TryMigrate( + IAccountState state, + Address stakeStateAddr, + out StakeStateV2 stakeStateV2) + { + var serialized = state.GetState(stakeStateAddr); + if (serialized is null or Null) + { + stakeStateV2 = default; + return false; + } + + if (serialized is List list) + { + stakeStateV2 = new StakeStateV2(list); + return true; + } + + if (serialized is not Dictionary dict) + { + stakeStateV2 = default; + return false; + } + + var gameConfigState = state.GetGameConfigState(); + if (gameConfigState is null) + { + stakeStateV2 = default; + return false; + } + + var stakeStateV1 = new StakeState(dict); + var stakeRegularFixedRewardSheetTableName = + stakeStateV1.StartedBlockIndex < + gameConfigState.StakeRegularFixedRewardSheet_V2_StartBlockIndex + ? "StakeRegularFixedRewardSheet_V1" + : "StakeRegularFixedRewardSheet_V2"; + string stakeRegularRewardSheetTableName; + if (stakeStateV1.StartedBlockIndex < + gameConfigState.StakeRegularRewardSheet_V2_StartBlockIndex) + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V1"; + } + else if (stakeStateV1.StartedBlockIndex < + gameConfigState.StakeRegularRewardSheet_V3_StartBlockIndex) + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V2"; + } + else if (stakeStateV1.StartedBlockIndex < + gameConfigState.StakeRegularRewardSheet_V4_StartBlockIndex) + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V3"; + } + else if (stakeStateV1.StartedBlockIndex < + gameConfigState.StakeRegularRewardSheet_V5_StartBlockIndex) + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V4"; + } + else + { + stakeRegularRewardSheetTableName = "StakeRegularRewardSheet_V5"; + } + + stakeStateV2 = new StakeStateV2( + stakeStateV1, + new Contract( + stakeRegularFixedRewardSheetTableName: stakeRegularFixedRewardSheetTableName, + stakeRegularRewardSheetTableName: stakeRegularRewardSheetTableName, + rewardInterval: StakeState.RewardInterval, + lockupInterval: StakeState.LockupInterval)); + return true; + } + } +} From e4677b0db01d9f17040b2f290b8dbea5066adb1a Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 14:37:19 +0900 Subject: [PATCH 087/134] remove useless comment --- Lib9c/Model/Stake/StakeStateUtils.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib9c/Model/Stake/StakeStateUtils.cs b/Lib9c/Model/Stake/StakeStateUtils.cs index 5d2ab6a88..d6b08dfd3 100644 --- a/Lib9c/Model/Stake/StakeStateUtils.cs +++ b/Lib9c/Model/Stake/StakeStateUtils.cs @@ -8,7 +8,6 @@ namespace Nekoyume.Model.Stake { public static class StakeStateUtils { - // FIXME: Use StakePolicySheet instead of hard-coding. public static bool TryMigrate( IAccountState state, Address stakeStateAddr, From b518d14afe91cd56b948d1cfb9f680823eaf2b02 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 14:37:41 +0900 Subject: [PATCH 088/134] rename minor --- .Lib9c.Tests/Action/StakeTest.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index edd8c1968..a34572e45 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -106,7 +106,7 @@ public void Execute_Success_When_Staking_State_Null(long amount) new ActionContext { Signer = Addresses.Admin }, _agentAddr, _ncg * amount); - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -138,7 +138,7 @@ public void Execute_Success_When_Exist_StakeState( stakeStateAddr, _ncg * previousAmount) .SetState(stakeStateAddr, stakeState.Serialize()); - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -172,7 +172,7 @@ public void Execute_Success_When_Exist_StakeStateV2(long previousAmount, long ne stakeStateAddr, _ncg * previousAmount) .SetState(stakeStateAddr, stakeStateV2.Serialize()); - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -202,7 +202,7 @@ public void Execute_Success_When_Withdraw_With_StakeState( stakeStateAddr, _ncg * previousAmount) .SetState(stakeStateAddr, stakeState.Serialize()); - ExecuteInternal( + Execute( blockIndex, previousState, new TestRandom(), @@ -236,7 +236,7 @@ public void Execute_Success_When_Withdraw_With_StakeStateV2( stakeStateAddr, _ncg * previousAmount) .SetState(stakeStateAddr, stakeStateV2.Serialize()); - ExecuteInternal( + Execute( blockIndex, previousState, new TestRandom(), @@ -272,7 +272,7 @@ public void Execute_Throw_MonsterCollectionExistingException( previousState = previousState .SetState(monsterCollectionAddr, monsterCollectionState.SerializeV2()); Assert.Throws(() => - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -286,7 +286,7 @@ public void Execute_Throw_MonsterCollectionExistingException( public void Execute_Throw_ArgumentOutOfRangeException_Via_Negative_Amount(long amount) { Assert.Throws(() => - ExecuteInternal( + Execute( 0, _initialState, new TestRandom(), @@ -306,7 +306,7 @@ public void Execute_Throw_StateNullException_Via_Sheet(string sheetName) Addresses.GetSheetAddress(sheetName), Null.Value); Assert.Throws(() => - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -321,7 +321,7 @@ public void Execute_Throw_StateNullException_Via_Sheet(string sheetName) public void Execute_Throw_ArgumentOutOfRangeException_Via_Minimum_Amount(long amount) { Assert.Throws(() => - ExecuteInternal( + Execute( 0, _initialState, new TestRandom(), @@ -348,7 +348,7 @@ public void Execute_Throws_NotEnoughFungibleAssetValueException( } Assert.Throws(() => - ExecuteInternal( + Execute( 0, previousState, new TestRandom(), @@ -360,7 +360,7 @@ public void Execute_Throws_NotEnoughFungibleAssetValueException( public void Execute_Throw_StateNullException_Via_0_Amount() { Assert.Throws(() => - ExecuteInternal( + Execute( 0, _initialState, new TestRandom(), @@ -392,7 +392,7 @@ public void Execute_Throw_StakeExistingClaimableException_With_StakeState( _ncg * previousAmount) .SetState(stakeStateAddr, stakeState.Serialize()); Assert.Throws(() => - ExecuteInternal( + Execute( blockIndex, previousState, new TestRandom(), @@ -429,7 +429,7 @@ public void Execute_Throw_StakeExistingClaimableException_With_StakeStateV2( _ncg * previousAmount) .SetState(stakeStateAddr, stakeStateV2.Serialize()); Assert.Throws(() => - ExecuteInternal( + Execute( blockIndex, previousState, new TestRandom(), @@ -467,7 +467,7 @@ public void _ncg * previousAmount) .SetState(stakeStateAddr, stakeState.Serialize()); Assert.Throws(() => - ExecuteInternal( + Execute( blockIndex, previousState, new TestRandom(), @@ -475,7 +475,7 @@ public void reducedAmount)); } - private IAccountStateDelta ExecuteInternal( + private IAccountStateDelta Execute( long blockIndex, IAccountStateDelta previousState, IRandom random, From 9c89a4ca6aa1efdaf9c950d754c4b5bb3dbe01d8 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:41:40 +0900 Subject: [PATCH 089/134] add exception message --- Lib9c/Currencies.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib9c/Currencies.cs b/Lib9c/Currencies.cs index 084316bfa..88358f806 100644 --- a/Lib9c/Currencies.cs +++ b/Lib9c/Currencies.cs @@ -59,7 +59,9 @@ public static Currency GetMinterlessCurrency(string? ticker) { if (string.IsNullOrEmpty(ticker)) { - throw new ArgumentNullException(nameof(ticker)); + throw new ArgumentNullException( + nameof(ticker), + "ticker should not be null or empty."); } switch (ticker) From 3e11954924d7760771b703f9b3eee1fd1e6af6c8 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:42:22 +0900 Subject: [PATCH 090/134] set to null when parse failed in StakeRegularRewardSheet.CurrencyDecimalPlaces --- Lib9c/TableData/StakeRegularRewardSheet.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib9c/TableData/StakeRegularRewardSheet.cs b/Lib9c/TableData/StakeRegularRewardSheet.cs index 2d3d80295..664796957 100644 --- a/Lib9c/TableData/StakeRegularRewardSheet.cs +++ b/Lib9c/TableData/StakeRegularRewardSheet.cs @@ -82,7 +82,9 @@ public RewardInfo(params string[] fields) return; } - CurrencyDecimalPlaces = ParseInt(fields[4], 0); + CurrencyDecimalPlaces = TryParseInt(fields[4], out var currencyDecimalPlaces) + ? currencyDecimalPlaces + : null; if (fields.Length == 5) { From 4ddc21f8a03b8a791358c53c42c407833a4966f9 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:43:37 +0900 Subject: [PATCH 091/134] generalize GetSheetCsv() method --- Lib9c/Action/AccountStateExtensions.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index c3f498273..139d74ccf 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -485,7 +485,7 @@ public static T GetSheet( { try { - var csv = GetSheetCsv(states); + var csv = GetSheetCsv(states, sheetAddr); byte[] hash; using (var sha256 = SHA256.Create()) { @@ -712,7 +712,7 @@ public static bool TryGetSheet(this IAccountState states, Address address, ou var sheetType = sheetTypes[i]; var address = addresses[i]; var csvValue = csvValues[i]; - if (csvValue is null) + if (csvValue is null or Null) { throw new FailedLoadStateException(address, sheetType); } @@ -732,7 +732,7 @@ public static bool TryGetSheet(this IAccountState states, Address address, ou } var sheetConstructorInfo = sheetType.GetConstructor(Type.EmptyTypes); - if (!(sheetConstructorInfo?.Invoke(Array.Empty()) is ISheet sheet)) + if (sheetConstructorInfo?.Invoke(Array.Empty()) is not ISheet sheet) { throw new FailedLoadSheetException(sheetType); } @@ -748,11 +748,15 @@ public static bool TryGetSheet(this IAccountState states, Address address, ou public static string GetSheetCsv(this IAccountState states) where T : ISheet, new() { var address = Addresses.GetSheetAddress(); + return states.GetSheetCsv(address); + } + + public static string GetSheetCsv(this IAccountState states, Address address) + { var value = states.GetState(address); - if (value is null) + if (value is null or Null) { - Log.Warning("{TypeName} is null ({Address})", typeof(T).FullName, address.ToHex()); - throw new FailedLoadStateException(typeof(T).FullName); + throw new FailedLoadStateException(address, typeof(ISheet)); } try @@ -761,7 +765,7 @@ public static bool TryGetSheet(this IAccountState states, Address address, ou } catch (Exception e) { - Log.Error(e, "Unexpected error occurred during GetSheetCsv<{TypeName}>()", typeof(T).FullName); + Log.Error(e, "Unexpected error occurred during GetSheetCsv({Address})", address); throw; } } From 18e51ceaba6d44068260190b19b36de7aca7c837 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:44:57 +0900 Subject: [PATCH 092/134] add note to sheet fixture --- .../TableCSV/Stake/StakeRegularRewardSheetFixtures.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs index 6440b66c5..1ad2b95c6 100644 --- a/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs +++ b/.Lib9c.Tests/Fixtures/TableCSV/Stake/StakeRegularRewardSheetFixtures.cs @@ -47,5 +47,11 @@ public static class StakeRegularRewardSheetFixtures 7,10000000,600201,50,Item, 7,10000000,800201,50,Item, 7,10000000,,100,Currency,GARAGE"; + // NOTE: belows are same. + // since "claim_stake_reward8". + // 7,10000000,20001,6000,Rune, + // 7,10000000,,6000,Rune, + // since "claim_stake_reward9". + // 7,10000000,,6000,Currency,RUNE_GOLDENLEAF } } From c89622aea05fe9a1beb9d11c8fd3e95c09eef97d Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:46:08 +0900 Subject: [PATCH 093/134] add ==, != operators to StakeStateV2 --- .Lib9c.Tests/Model/Stake/StakeStateV2Test.cs | 2 ++ Lib9c/Model/Stake/StakeStateV2.cs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs index d56a1b2a7..f637384f1 100644 --- a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs +++ b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs @@ -125,8 +125,10 @@ public void Compare() var stateL = new StakeStateV2(contract, 0); var stateR = new StakeStateV2(contract, 0); Assert.Equal(stateL, stateR); + Assert.True(stateL == stateR); stateR = new StakeStateV2(contract, 1); Assert.NotEqual(stateL, stateR); + Assert.True(stateL != stateR); } } } diff --git a/Lib9c/Model/Stake/StakeStateV2.cs b/Lib9c/Model/Stake/StakeStateV2.cs index a5ee20a22..7b72cbe23 100644 --- a/Lib9c/Model/Stake/StakeStateV2.cs +++ b/Lib9c/Model/Stake/StakeStateV2.cs @@ -124,5 +124,15 @@ public override int GetHashCode() return hashCode; } } + + public static bool operator ==(StakeStateV2 left, StakeStateV2 right) + { + return left.Equals(right); + } + + public static bool operator !=(StakeStateV2 left, StakeStateV2 right) + { + return !(left == right); + } } } From 919c61134531fd43aa2de899eb5ffa65e3a9ed08 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:46:23 +0900 Subject: [PATCH 094/134] fix StakeTest value minor --- .Lib9c.Tests/Action/StakeTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index a34572e45..c5e124fd4 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -214,7 +214,7 @@ public void Execute_Success_When_Withdraw_With_StakeState( // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. // NOTE: LockupInterval of StakePolicySheetFixtures.V2 is 201,600. [InlineData(0, 50, 201_600)] - [InlineData(0, 50, 201_601)] + [InlineData(0, 50, 201_600 + 1)] public void Execute_Success_When_Withdraw_With_StakeStateV2( long previousStartedBlockIndex, long previousAmount, From 35974b2bec155bf36150634e14f2fdece315a35d Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 18:46:45 +0900 Subject: [PATCH 095/134] add unit tests for claim_stake_reward9 --- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 580 ++++++++++++++++++++ Lib9c/Action/ClaimStakeReward.cs | 57 +- 2 files changed, 611 insertions(+), 26 deletions(-) create mode 100644 .Lib9c.Tests/Action/ClaimStakeRewardTest.cs diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs new file mode 100644 index 000000000..56294b741 --- /dev/null +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -0,0 +1,580 @@ +namespace Lib9c.Tests.Action +{ + using System; + using System.Collections.Generic; + using System.Linq; + using Bencodex.Types; + using Lib9c.Tests.Fixtures.TableCSV.Stake; + using Lib9c.Tests.Util; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Libplanet.Types.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Model.Stake; + using Nekoyume.Model.State; + using Nekoyume.TableData.Stake; + using Serilog; + using Xunit; + using Xunit.Abstractions; + + public class ClaimStakeRewardTest + { + private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; + private const int AvatarIndex = 0; + private static readonly Address AgentAddr = new Address(AgentAddressHex); + + private static readonly Address AvatarAddr = + Addresses.GetAvatarAddress(AgentAddr, AvatarIndex); + + private readonly IAccountStateDelta[] _initialStates; + private readonly Currency _ncg; + private readonly StakePolicySheet _stakePolicySheet; + + public ClaimStakeRewardTest(ITestOutputHelper outputHelper) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Verbose() + .WriteTo.TestOutput(outputHelper) + .CreateLogger(); + var sheetsOverride = new Dictionary + { + { + "StakeRegularFixedRewardSheet_V1", + StakeRegularFixedRewardSheetFixtures.V1 + }, + { + "StakeRegularFixedRewardSheet_V2", + StakeRegularFixedRewardSheetFixtures.V2 + }, + { + "StakeRegularRewardSheet_V1", + StakeRegularRewardSheetFixtures.V1 + }, + { + "StakeRegularRewardSheet_V2", + StakeRegularRewardSheetFixtures.V2 + }, + { + nameof(StakePolicySheet), + StakePolicySheetFixtures.V2 + }, + }; + IAccountStateDelta initialStatesWithAvatarStateV1; + IAccountStateDelta initialStatesWithAvatarStateV2; + ( + _, + _, + _, + initialStatesWithAvatarStateV1, + initialStatesWithAvatarStateV2) = InitializeUtil.InitializeStates( + agentAddr: AgentAddr, + avatarIndex: AvatarIndex, + sheetsOverride: sheetsOverride); + _initialStates = new[] + { + initialStatesWithAvatarStateV1, + initialStatesWithAvatarStateV2, + }; + _ncg = initialStatesWithAvatarStateV2.GetGoldCurrency(); + _stakePolicySheet = initialStatesWithAvatarStateV2.GetSheet(); + } + + public static IEnumerable + GetMemberData_Execute_Success_With_StakePolicySheetFixtureV2() + { + // NOTE: + // - minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + // - RewardInterval of StakePolicySheetFixtures.V2 is 50,400. + + // NOTE: staking level 1 + yield return new object[] + { + 0, null, 50, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 5), + (500_000, 1), + }, + }; + + // NOTE: staking level 2 + yield return new object[] + { + 0, null, 500, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 125), + (500_000, 2), + }, + }; + + // NOTE: staking level 3 + yield return new object[] + { + 0, null, 5000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 2500), + (500_000, 2 + 12), + }, + }; + + // NOTE: staking level 4 + yield return new object[] + { + 0, null, 50_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 8), + }, + new (int itemSheetId, int count)[] + { + (400_000, 25_000), + (500_000, 2 + 125), + }, + }; + + // NOTE: staking level 5 + yield return new object[] + { + 0, null, 500_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 83), + }, + new (int itemSheetId, int count)[] + { + (400_000, 250_000), + (500_000, 2 + 1_250), + }, + }; + + // NOTE: staking level 6 + yield return new object[] + { + 0, null, 5_000_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 833), + }, + new (int itemSheetId, int count)[] + { + (400_000, 2_500_000), + (500_000, 2 + 12_500), + }, + }; + + // NOTE: staking level 7 + yield return new object[] + { + 0, null, 10_000_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 100_000), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 1_666), + }, + new (int itemSheetId, int count)[] + { + (400_000, 5_000_000), + (500_000, 2 + 250_00), + (600_201, 200_000), + (800_201, 200_000), + }, + }; + } + + [Fact] + public void Constructor() + { + var action = new ClaimStakeReward(AvatarAddr); + Assert.Equal(AvatarAddr, action.AvatarAddress); + } + + [Fact] + public void Serde() + { + var action = new ClaimStakeReward(AvatarAddr); + var ser = action.PlainValue; + var des = new ClaimStakeReward(); + des.LoadPlainValue(action.PlainValue); + Assert.Equal(action.AvatarAddress, des.AvatarAddress); + Assert.Equal(ser, des.PlainValue); + } + + [Fact] + public void Execute_Throw_FailedLoadStateException_When_Staking_State_Null() + { + foreach (var initialState in _initialStates) + { + Assert.Throws(() => + Execute( + initialState, + AgentAddr, + AvatarAddr, + 0)); + + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var previousState = initialState.SetState(stakeAddr, Null.Value); + Assert.Throws(() => + Execute( + previousState, + AgentAddr, + AvatarAddr, + 0)); + } + } + + [Theory] + [InlineData(0, null, 0)] + [InlineData(0, null, StakeState.RewardInterval - 1)] + [InlineData(0, StakeState.RewardInterval - 2, StakeState.RewardInterval - 1)] + [InlineData(0, StakeState.RewardInterval, StakeState.RewardInterval + 1)] + [InlineData(0, StakeState.RewardInterval, StakeState.RewardInterval * 2 - 1)] + [InlineData(0, StakeState.RewardInterval * 2 - 2, StakeState.RewardInterval * 2 - 1)] + [InlineData(0, StakeState.RewardInterval * 2, StakeState.RewardInterval * 2 + 1)] + public void Execute_Throw_RequiredBlockIndexException_With_StakeState( + long startedBlockIndex, + long? receivedBlockIndex, + long blockIndex) + { + var stakeAddr = StakeState.DeriveAddress(AgentAddr); + var stakeState = new StakeState(stakeAddr, startedBlockIndex); + if (receivedBlockIndex is not null) + { + stakeState.Claim((long)receivedBlockIndex); + } + + foreach (var initialState in _initialStates) + { + var prevState = initialState + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 50) + .SetState(stakeAddr, stakeState.Serialize()); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Theory] + // NOTE: RewardInterval of StakePolicySheetFixtures.V2 is 50,400. + [InlineData(0, null, 0)] + [InlineData(0, null, 50_400 - 1)] + [InlineData(0, 50_400 - 1, 50_400 - 1)] + [InlineData(0, 50_400, 50_400 + 1)] + [InlineData(0, 50_400, 50_400 * 2 - 1)] + [InlineData(0, 50_400 * 2 - 2, 50_400 * 2 - 1)] + [InlineData(0, 50_400 * 2, 50_400 * 2 + 1)] + public void Execute_Throw_RequiredBlockIndexException_With_StakeStateV2( + long startedBlockIndex, + long? receivedBlockIndex, + long blockIndex) + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2( + _stakePolicySheet, + startedBlockIndex, + receivedBlockIndex); + foreach (var initialState in _initialStates) + { + var prevState = initialState + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 50) + .SetState(stakeAddr, stakeStateV2.Serialize()); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Fact] + public void Execute_Throw_FailedLoadStateException_When_Sheet_Null() + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2(_stakePolicySheet, 0, null); + var blockIndex = stakeStateV2.StartedBlockIndex + stakeStateV2.Contract.RewardInterval; + foreach (var initialState in _initialStates) + { + var prevState = initialState + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 50) + .SetState(stakeAddr, stakeStateV2.Serialize()); + // NOTE: Set StakeRegularFixedRewardSheetTable to Null + var sheetAddr = Addresses.GetSheetAddress( + stakeStateV2.Contract.StakeRegularFixedRewardSheetTableName); + prevState = prevState.SetState(sheetAddr, Null.Value); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + + prevState = initialState + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 50) + .SetState(stakeAddr, stakeStateV2.Serialize()); + // NOTE: Set StakeRegularRewardSheetTableName to Null + sheetAddr = Addresses.GetSheetAddress( + stakeStateV2.Contract.StakeRegularRewardSheetTableName); + prevState = prevState.SetState(sheetAddr, Null.Value); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Theory] + // NOTE: minimum required_gold of StakeRegularRewardSheetFixtures.V2 is 50. + [InlineData(49)] + [InlineData(0)] + public void Execute_Throw_InsufficientBalanceException(long stakedBalance) + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2(_stakePolicySheet, 0, null); + var blockIndex = stakeStateV2.StartedBlockIndex + stakeStateV2.Contract.RewardInterval; + foreach (var initialState in _initialStates) + { + var previousState = initialState.SetState(stakeAddr, stakeStateV2.Serialize()); + previousState = stakedBalance > 0 + ? previousState.MintAsset( + new ActionContext(), + stakeAddr, + _ncg * stakedBalance) + : previousState; + Assert.Throws(() => + Execute( + previousState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Fact] + public void Execute_Throw_ArgumentNullException_When_Reward_CurrencyTicker_Null() + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2(_stakePolicySheet, 0, null); + var blockIndex = stakeStateV2.StartedBlockIndex + stakeStateV2.Contract.RewardInterval; + foreach (var initialState in _initialStates) + { + var prevState = initialState + // NOTE: required_gold to receive Currency + // of StakeRegularRewardSheetFixtures.V2 is 10,000,000. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 10_000_000) + .SetState(stakeAddr, stakeStateV2.Serialize()); + // NOTE: Set CurrencyTicker to string.Empty. + var sheetAddr = Addresses.GetSheetAddress( + stakeStateV2.Contract.StakeRegularRewardSheetTableName); + var sheetValue = prevState.GetSheetCsv(sheetAddr); + sheetValue = string.Join('\n', sheetValue.Split('\n') + .Select(line => string.Join(',', line.Split(',') + .Select((column, index) => index == 5 + ? string.Empty + : column)))); + prevState = prevState.SetState(sheetAddr, sheetValue.Serialize()); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Fact] + public void + Execute_Throw_ArgumentNullException_When_Reward_CurrencyTicker_New_CurrencyDecimalPlaces_Null() + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2(_stakePolicySheet, 0, null); + var blockIndex = stakeStateV2.StartedBlockIndex + stakeStateV2.Contract.RewardInterval; + foreach (var initialState in _initialStates) + { + var prevState = initialState + // NOTE: required_gold to receive Currency + // of StakeRegularRewardSheetFixtures.V2 is 10,000,000. + .MintAsset(new ActionContext(), stakeAddr, _ncg * 10_000_000) + .SetState(stakeAddr, stakeStateV2.Serialize()); + // NOTE: Set CurrencyTicker to string.Empty. + var sheetAddr = Addresses.GetSheetAddress( + stakeStateV2.Contract.StakeRegularRewardSheetTableName); + var sheetValue = prevState.GetSheetCsv(sheetAddr); + sheetValue = string.Join('\n', sheetValue.Split('\n') + .Select(line => string.Join(',', line.Split(',') + .Select((column, index) => + { + return index switch + { + 5 => "NEW_TICKER", + 6 => string.Empty, + _ => column, + }; + })))); + prevState = prevState.SetState(sheetAddr, sheetValue.Serialize()); + Assert.Throws(() => + Execute( + prevState, + AgentAddr, + AvatarAddr, + blockIndex)); + } + } + + [Theory] + [MemberData(nameof(GetMemberData_Execute_Success_With_StakePolicySheetFixtureV2))] + public void Execute_Success( + long startedBlockIndex, + long? receivedBlockIndex, + long stakedBalance, + long blockIndex, + (Address balanceAddr, FungibleAssetValue fav)[] expectedBalances, + (int itemSheetId, int count)[] expectedItems) + { + var stakeAddr = StakeStateV2.DeriveAddress(AgentAddr); + var stakeStateV2 = PrepareStakeStateV2( + _stakePolicySheet, + startedBlockIndex, + receivedBlockIndex); + foreach (var initialState in _initialStates) + { + var previousState = stakedBalance > 0 + ? initialState.MintAsset( + new ActionContext(), + stakeAddr, + _ncg * stakedBalance) + : initialState; + previousState = previousState.SetState(stakeAddr, stakeStateV2.Serialize()); + var nextState = Execute( + previousState, + AgentAddr, + AvatarAddr, + blockIndex); + Expect( + nextState, + expectedBalances, + AvatarAddr.Derive("inventory"), + expectedItems); + } + } + + private static StakeStateV2 PrepareStakeStateV2( + StakePolicySheet stakePolicySheet, + long startedBlockIndex, + long? receivedBlockIndex) + { + var contract = new Contract( + stakePolicySheet.StakeRegularFixedRewardSheetValue, + stakePolicySheet.StakeRegularRewardSheetValue, + stakePolicySheet.RewardIntervalValue, + stakePolicySheet.LockupIntervalValue); + return receivedBlockIndex is null + ? new StakeStateV2(contract, startedBlockIndex) + : new StakeStateV2(contract, startedBlockIndex, receivedBlockIndex.Value); + } + + private static IAccountStateDelta Execute( + IAccountStateDelta prevState, + Address agentAddr, + Address avatarAddr, + long blockIndex) + { + var stakeAddr = StakeStateV2.DeriveAddress(agentAddr); + var ncg = prevState.GetGoldCurrency(); + var prevBalance = prevState.GetBalance(agentAddr, ncg); + var prevStakedBalance = prevState.GetBalance(stakeAddr, ncg); + var action = new ClaimStakeReward(avatarAddr); + var nextState = action.Execute(new ActionContext + { + PreviousState = prevState, + Signer = agentAddr, + BlockIndex = blockIndex, + }); + var nextBalance = nextState.GetBalance(agentAddr, ncg); + Assert.Equal(prevBalance, nextBalance); + var nextStakedBalance = nextState.GetBalance(stakeAddr, ncg); + Assert.Equal(prevStakedBalance, nextStakedBalance); + Assert.True(nextState.TryGetStakeStateV2(agentAddr, out var stakeStateV2)); + Assert.Equal(blockIndex, stakeStateV2.ReceivedBlockIndex); + Assert.True(stakeStateV2.ClaimedBlockIndex <= blockIndex); + Assert.True(stakeStateV2.ClaimableBlockIndex > blockIndex); + + return nextState; + } + + private static void Expect( + IAccountState state, + (Address balanceAddr, FungibleAssetValue fav)[] expectedBalances, + Address inventoryAddr, + (int itemSheetId, int count)[] expectedItems) + { + if (expectedBalances is not null) + { + foreach (var (balanceAddr, fav) in expectedBalances) + { + Assert.Equal(fav, state.GetBalance(balanceAddr, fav.Currency)); + } + } + + if (expectedItems is not null) + { + var inventory = state.GetInventory(inventoryAddr); + foreach (var (itemSheetId, count) in expectedItems) + { + Assert.Equal(count, inventory.Items.First(e => e.item.Id == itemSheetId).count); + } + } + + // if (expectedRune > 0) + // { + // Assert.Equal( + // expectedRune * RuneHelper.StakeRune, + // state.GetBalance(avatarAddr, RuneHelper.StakeRune)); + // } + // else + // { + // Assert.Equal( + // 0 * RuneHelper.StakeRune, + // state.GetBalance(avatarAddr, RuneHelper.StakeRune)); + // } + // + // if (!string.IsNullOrEmpty(expectedCurrencyAddrHex)) + // { + // var addr = new Address(expectedCurrencyAddrHex); + // var currency = Currencies.GetMinterlessCurrency(expectedCurrencyTicker); + // Assert.Equal( + // expectedCurrencyAmount * currency, + // state.GetBalance(addr, currency)); + // } + } + } +} diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index a85bc0b4b..0c3610828 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -50,9 +50,6 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - // StakeState -> StakeStateV2 migration (refactoring?) - // StakeStateV2.Contract 기준으로 시트 가져와서 보상 주기 - // StakeStateV2.ClaimedBlockIndex를 셀프로 액션에서 직접 넣어주니까 잘 넣어줘야... public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); @@ -63,16 +60,14 @@ public override IAccountStateDelta Execute(IActionContext context) var states = context.PreviousState; var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); - var stakeStateAddress = StakeState.DeriveAddress(context.Signer); - var ncg = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeStateAddress, ncg); + var stakeStateAddr = StakeState.DeriveAddress(context.Signer); if (!states.TryGetStakeStateV2(context.Signer, out var stakeStateV2)) { throw new FailedLoadStateException( ActionTypeText, addressesHex, typeof(StakeState), - stakeStateAddress); + stakeStateAddr); } if (stakeStateV2.ClaimableBlockIndex > context.BlockIndex) @@ -114,17 +109,21 @@ public override IAccountStateDelta Execute(IActionContext context) var stakeRegularFixedRewardSheet = sheets.GetSheet(); var stakeRegularRewardSheet = sheets.GetSheet(); // NOTE: + var ncg = states.GetGoldCurrency(); + var stakedNcg = states.GetBalance(stakeStateAddr, ncg); var stakingLevel = Math.Min( stakeRegularRewardSheet.FindLevelByStakedAmount( context.Signer, - stakedAmount), + stakedNcg), stakeRegularRewardSheet.Keys.Max()); var itemSheet = sheets.GetItemSheet(); // The first reward is given at the claimable block index. - var rewardSteps = 1 + (int)Math.DivRem( - context.BlockIndex - stakeStateV2.ClaimableBlockIndex, - StakeState.RewardInterval, - out _); + var rewardSteps = stakeStateV2.ClaimableBlockIndex == context.BlockIndex + ? 1 + : 1 + (int)Math.DivRem( + context.BlockIndex - stakeStateV2.ClaimableBlockIndex, + stakeStateV2.Contract.RewardInterval, + out _); // Fixed Reward foreach (var reward in stakeRegularFixedRewardSheet[stakingLevel].Rewards) @@ -140,9 +139,9 @@ public override IAccountStateDelta Execute(IActionContext context) foreach (var reward in stakeRegularRewardSheet[stakingLevel].Rewards) { var rateFav = FungibleAssetValue.Parse( - stakedAmount.Currency, + stakedNcg.Currency, reward.DecimalRate.ToString(CultureInfo.InvariantCulture)); - var rewardQuantityForSingleStep = stakedAmount.DivRem(rateFav, out _); + var rewardQuantityForSingleStep = stakedNcg.DivRem(rateFav, out _); if (rewardQuantityForSingleStep <= 0) { continue; @@ -162,7 +161,6 @@ public override IAccountStateDelta Execute(IActionContext context) var item = itemRow is MaterialItemSheet.Row materialRow ? ItemFactory.CreateTradableMaterial(materialRow) : ItemFactory.CreateItem(itemRow, context.Random); - avatarState.inventory.AddItem(item, majorUnit); break; } @@ -180,11 +178,6 @@ public override IAccountStateDelta Execute(IActionContext context) } case StakeRegularRewardSheet.StakeRewardType.Currency: { - if (string.IsNullOrEmpty(reward.CurrencyTicker)) - { - throw new NullReferenceException("currency ticker is null or empty"); - } - // NOTE: prepare reward currency. Currency rewardCurrency; // NOTE: this line covers the reward.CurrencyTicker is following cases: @@ -209,7 +202,7 @@ public override IAccountStateDelta Execute(IActionContext context) // NOTE: throw exception if reward.CurrencyDecimalPlaces is null. if (reward.CurrencyDecimalPlaces is null) { - throw new ArgumentException( + throw new ArgumentNullException( $"Decimal places of {reward.CurrencyTicker} is null"); } @@ -222,10 +215,22 @@ public override IAccountStateDelta Execute(IActionContext context) var majorUnit = rewardQuantityForSingleStep * rewardSteps; var rewardFav = rewardCurrency * majorUnit; - states = states.MintAsset( - context, - context.Signer, - rewardFav); + if (Currencies.IsRuneTicker(rewardCurrency.Ticker) || + Currencies.IsSoulstoneTicker(rewardCurrency.Ticker)) + { + states = states.MintAsset( + context, + AvatarAddress, + rewardFav); + } + else + { + states = states.MintAsset( + context, + context.Signer, + rewardFav); + } + break; } default: @@ -252,7 +257,7 @@ public override IAccountStateDelta Execute(IActionContext context) } return states - .SetState(stakeStateAddress, stakeStateV2.Serialize()) + .SetState(stakeStateAddr, stakeStateV2.Serialize()) .SetState( avatarState.address.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()); From 0217026afe5be056a73c6414c4f6ba950bf2321a Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 4 Sep 2023 19:10:59 +0900 Subject: [PATCH 096/134] add StakeStateUtilsTest --- .../Model/Stake/StakeStateUtilsTest.cs | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 .Lib9c.Tests/Model/Stake/StakeStateUtilsTest.cs diff --git a/.Lib9c.Tests/Model/Stake/StakeStateUtilsTest.cs b/.Lib9c.Tests/Model/Stake/StakeStateUtilsTest.cs new file mode 100644 index 000000000..876b9d469 --- /dev/null +++ b/.Lib9c.Tests/Model/Stake/StakeStateUtilsTest.cs @@ -0,0 +1,154 @@ +namespace Lib9c.Tests.Model.Stake +{ + using System; + using Lib9c.Tests.Action; + using Lib9c.Tests.Fixtures.TableCSV; + using Lib9c.Tests.Fixtures.TableCSV.Stake; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Nekoyume; + using Nekoyume.Model.Stake; + using Nekoyume.Model.State; + using Nekoyume.TableData.Stake; + using Xunit; + + public class StakeStateUtilsTest + { + [Fact] + public void TryMigrate_Throw_NullReferenceException_When_IAccountDelta_Null() + { + Assert.Throws(() => + StakeStateUtils.TryMigrate(null, default, out _)); + } + + [Fact] + public void TryMigrate_Return_False_When_Staking_State_Null() + { + var state = new MockStateDelta(); + Assert.False(StakeStateUtils.TryMigrate(state, new PrivateKey().ToAddress(), out _)); + } + + [Theory] + [InlineData( + 0, + null, + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1")] + [InlineData( + 0, + long.MaxValue, + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1")] + // NOTE: "stake_regular_reward_sheet_v2_start_block_index" in + // GameConfigSheetFixtures.Default is 5,510,416. + [InlineData( + 5_510_416 - 1, + null, + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1")] + [InlineData( + 5_510_416, + null, + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V2")] + // NOTE: "stake_regular_fixed_reward_sheet_v2_start_block_index" and + // "stake_regular_reward_sheet_v3_start_block_index" in + // GameConfigSheetFixtures.Default is 6,700,000. + [InlineData( + 6_700_000 - 1, + null, + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V2")] + [InlineData( + 6_700_000, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V3")] + // NOTE: "stake_regular_reward_sheet_v4_start_block_index" in + // GameConfigSheetFixtures.Default is 6,910,000. + [InlineData( + 6_910_000 - 1, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V3")] + [InlineData( + 6_910_000, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V4")] + // NOTE: "stake_regular_reward_sheet_v5_start_block_index" in + // GameConfigSheetFixtures.Default is 7,650,000. + [InlineData( + 7_650_000 - 1, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V4")] + [InlineData( + 7_650_000, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V5")] + // NOTE: latest. + [InlineData( + long.MaxValue, + null, + "StakeRegularFixedRewardSheet_V2", + "StakeRegularRewardSheet_V5")] + public void TryMigrate_Return_True_With_StakeState( + long startedBlockIndex, + long? receivedBlockIndex, + string stakeRegularFixedRewardSheetTableName, + string stakeRegularRewardSheetTableName) + { + IAccountStateDelta state = new MockStateDelta(); + state = state.SetState( + Addresses.GameConfig, + new GameConfigState(GameConfigSheetFixtures.Default).Serialize()); + var stakeAddr = new PrivateKey().ToAddress(); + var stakeState = new StakeState(stakeAddr, startedBlockIndex); + if (receivedBlockIndex is not null) + { + stakeState.Claim(receivedBlockIndex.Value); + } + + state = state.SetState(stakeAddr, stakeState.Serialize()); + Assert.True(StakeStateUtils.TryMigrate(state, stakeAddr, out var stakeStateV2)); + Assert.Equal( + stakeRegularFixedRewardSheetTableName, + stakeStateV2.Contract.StakeRegularFixedRewardSheetTableName); + Assert.Equal( + stakeRegularRewardSheetTableName, + stakeStateV2.Contract.StakeRegularRewardSheetTableName); + Assert.Equal(stakeState.StartedBlockIndex, stakeStateV2.StartedBlockIndex); + Assert.Equal(stakeState.ReceivedBlockIndex, stakeStateV2.ReceivedBlockIndex); + } + + [Theory] + [InlineData(0, null)] + [InlineData(0, long.MaxValue)] + [InlineData(long.MaxValue, null)] + [InlineData(long.MaxValue, long.MaxValue)] + public void TryMigrate_Return_True_With_StakeStateV2( + long startedBlockIndex, + long? receivedBlockIndex) + { + IAccountStateDelta state = new MockStateDelta(); + state = state.SetState( + Addresses.GameConfig, + new GameConfigState(GameConfigSheetFixtures.Default).Serialize()); + var stakeAddr = new PrivateKey().ToAddress(); + var stakePolicySheet = new StakePolicySheet(); + stakePolicySheet.Set(StakePolicySheetFixtures.V2); + var contract = new Contract(stakePolicySheet); + var stakeStateV2 = receivedBlockIndex is null + ? new StakeStateV2(contract, startedBlockIndex) + : new StakeStateV2(contract, receivedBlockIndex.Value); + + state = state.SetState(stakeAddr, stakeStateV2.Serialize()); + Assert.True(StakeStateUtils.TryMigrate(state, stakeAddr, out var result)); + Assert.Equal(stakeStateV2.Contract, result.Contract); + Assert.Equal(stakeStateV2.StartedBlockIndex, result.StartedBlockIndex); + Assert.Equal(stakeStateV2.ReceivedBlockIndex, result.ReceivedBlockIndex); + } + } +} From 644c6a6c47a52fd29aaf28cd83aa0b3d561b3117 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 5 Sep 2023 11:04:28 +0900 Subject: [PATCH 097/134] fix unit test --- .../TableData/StakeRegularRewardSheetTest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs b/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs index 4981499b9..7e4f610a3 100644 --- a/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs +++ b/.Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs @@ -34,21 +34,21 @@ public void SetToSheet() Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(10m, reward.DecimalRate); reward = row.Rewards[1]; Assert.Equal(500000, reward.ItemId); Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(800m, reward.DecimalRate); reward = row.Rewards[2]; Assert.Equal(20001, reward.ItemId); Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Rune, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(6000m, reward.DecimalRate); row = _sheet[5]; @@ -59,21 +59,21 @@ public void SetToSheet() Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(5m, reward.DecimalRate); reward = row.Rewards[1]; Assert.Equal(500000, reward.ItemId); Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Item, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(800m, reward.DecimalRate); reward = row.Rewards[2]; Assert.Equal(20001, reward.ItemId); Assert.Equal(0, reward.Rate); Assert.Equal(StakeRegularRewardSheet.StakeRewardType.Rune, reward.Type); Assert.Equal(string.Empty, reward.CurrencyTicker); - Assert.Equal(0, reward.CurrencyDecimalPlaces); + Assert.Null(reward.CurrencyDecimalPlaces); Assert.Equal(6000m, reward.DecimalRate); } From dc2493ca0b3ab62e8a6a367c68b58afdd8ea42d4 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 5 Sep 2023 12:18:34 +0900 Subject: [PATCH 098/134] improve unit test for claim_stake_reward9 with StakeState --- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 185 +++++++++++++++++--- 1 file changed, 162 insertions(+), 23 deletions(-) diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index 56294b741..4209ee10c 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -80,6 +80,128 @@ public ClaimStakeRewardTest(ITestOutputHelper outputHelper) _stakePolicySheet = initialStatesWithAvatarStateV2.GetSheet(); } + public static IEnumerable + GetMemberData_Execute_Success_With_StakePolicySheetFixtureV1() + { + // NOTE: + // - minimum required_gold of StakeRegularRewardSheetFixtures.V1 is 50. + // - RewardInterval of StakePolicySheetFixtures.V1 is 50,400. + + // NOTE: staking level 1 + yield return new object[] + { + 0, null, 50, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 5), + (500_000, 1), + }, + }; + + // NOTE: staking level 2 + yield return new object[] + { + 0, null, 500, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 62), + (500_000, 2), + }, + }; + + // NOTE: staking level 3 + yield return new object[] + { + 0, null, 5000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 0), + }, + new (int itemSheetId, int count)[] + { + (400_000, 1000), + (500_000, 2 + 6), + }, + }; + + // NOTE: staking level 4 + yield return new object[] + { + 0, null, 50_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 8), + }, + new (int itemSheetId, int count)[] + { + (400_000, 10_000), + (500_000, 2 + 62), + }, + }; + + // NOTE: staking level 5 + yield return new object[] + { + 0, null, 500_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 83), + }, + new (int itemSheetId, int count)[] + { + (400_000, 100_000), + (500_000, 2 + 625), + }, + }; + + // NOTE: staking level 6 + yield return new object[] + { + 0, null, 5_000_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 833), + }, + new (int itemSheetId, int count)[] + { + (400_000, 1_000_000), + (500_000, 2 + 6_250), + }, + }; + + // NOTE: staking level 7 + yield return new object[] + { + 0, null, 10_000_000, 50_400, + new (Address balanceAddr, FungibleAssetValue fav)[] + { + (AgentAddr, Currencies.Garage * 0), + (AvatarAddr, Currencies.GetRune("RUNE_GOLDENLEAF") * 1_666), + }, + new (int itemSheetId, int count)[] + { + (400_000, 2_000_000), + (500_000, 2 + 12_500), + (600_201, 200_000), + (800_201, 200_000), + }, + }; + } + public static IEnumerable GetMemberData_Execute_Success_With_StakePolicySheetFixtureV2() { @@ -450,9 +572,48 @@ public void } } + [Theory] + [MemberData(nameof(GetMemberData_Execute_Success_With_StakePolicySheetFixtureV1))] + public void Execute_Success_With_StakeState( + long startedBlockIndex, + long? receivedBlockIndex, + long stakedBalance, + long blockIndex, + (Address balanceAddr, FungibleAssetValue fav)[] expectedBalances, + (int itemSheetId, int count)[] expectedItems) + { + var stakeAddr = StakeState.DeriveAddress(AgentAddr); + var stakeState = new StakeState(stakeAddr, startedBlockIndex); + if (receivedBlockIndex is not null) + { + stakeState.Claim((long)receivedBlockIndex); + } + + foreach (var initialState in _initialStates) + { + var previousState = stakedBalance > 0 + ? initialState.MintAsset( + new ActionContext(), + stakeAddr, + _ncg * stakedBalance) + : initialState; + previousState = previousState.SetState(stakeAddr, stakeState.Serialize()); + var nextState = Execute( + previousState, + AgentAddr, + AvatarAddr, + blockIndex); + Expect( + nextState, + expectedBalances, + AvatarAddr.Derive("inventory"), + expectedItems); + } + } + [Theory] [MemberData(nameof(GetMemberData_Execute_Success_With_StakePolicySheetFixtureV2))] - public void Execute_Success( + public void Execute_Success_With_StakeStateV2( long startedBlockIndex, long? receivedBlockIndex, long stakedBalance, @@ -553,28 +714,6 @@ private static void Expect( Assert.Equal(count, inventory.Items.First(e => e.item.Id == itemSheetId).count); } } - - // if (expectedRune > 0) - // { - // Assert.Equal( - // expectedRune * RuneHelper.StakeRune, - // state.GetBalance(avatarAddr, RuneHelper.StakeRune)); - // } - // else - // { - // Assert.Equal( - // 0 * RuneHelper.StakeRune, - // state.GetBalance(avatarAddr, RuneHelper.StakeRune)); - // } - // - // if (!string.IsNullOrEmpty(expectedCurrencyAddrHex)) - // { - // var addr = new Address(expectedCurrencyAddrHex); - // var currency = Currencies.GetMinterlessCurrency(expectedCurrencyTicker); - // Assert.Equal( - // expectedCurrencyAmount * currency, - // state.GetBalance(addr, currency)); - // } } } } From 66976d4336547592e3374dd44ed7dfa2d1a278c8 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 5 Sep 2023 14:03:28 +0900 Subject: [PATCH 099/134] fix unit test --- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index 4209ee10c..92a56e663 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -196,8 +196,6 @@ public static IEnumerable { (400_000, 2_000_000), (500_000, 2 + 12_500), - (600_201, 200_000), - (800_201, 200_000), }, }; } From 9995adb3b38bdefb688a8e5cebd1b43acf0a77f6 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 5 Sep 2023 14:04:53 +0900 Subject: [PATCH 100/134] Bump libplanet to 3.2.0 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index 419d7a510..97b3d2e59 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit 419d7a510c09c90cfede35fc7973c0af5c10015d +Subproject commit 97b3d2e597c067f06b4f45c8a7b8ccb2ac4ae3f3 From 23ae5cf14041b66d5d323a7ebd2e402a0bbe0b8c Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 5 Sep 2023 14:19:49 +0900 Subject: [PATCH 101/134] Accommodate API changes --- .Lib9c.Benchmarks/Program.cs | 2 +- .../Action/Craft/UnlocakCraftActionTest.cs | 2 +- .../Action/Craft/UnlockRecipeTest.cs | 2 +- .../Action/CreateOrReplaceAvatarTest.cs | 4 ++-- .../Action/FaucetCurrencyTest.cs | 2 +- .../Action/FaucetRuneTest.cs | 2 +- .../Action/ManipulateStateTest.cs | 14 +++++++------- .../Action/Stage/ClearStageTest.cs | 2 +- .../CustomActionsDeserializableValidatorTest.cs | 2 +- .../Action/AccountStateDeltaExtensionsTest.cs | 6 +++--- .../Action/AccountStateViewExtensionsTest.cs | 10 +++++----- .Lib9c.Tests/Action/ActionContext.cs | 2 +- .Lib9c.Tests/Action/ActionEvaluationTest.cs | 2 +- .Lib9c.Tests/Action/ActivateAccount0Test.cs | 6 +++--- .Lib9c.Tests/Action/ActivateAccountTest.cs | 4 ++-- .Lib9c.Tests/Action/AddActivatedAccount0Test.cs | 4 ++-- .Lib9c.Tests/Action/AddActivatedAccountTest.cs | 4 ++-- .Lib9c.Tests/Action/ApprovePledgeTest.cs | 4 ++-- .Lib9c.Tests/Action/ArenahelperTest.cs | 2 +- .Lib9c.Tests/Action/AuraSummonTest.cs | 2 +- .Lib9c.Tests/Action/BattleArena10Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena11Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena12Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena13Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena1Test.cs | 4 ++-- .Lib9c.Tests/Action/BattleArena2Test.cs | 4 ++-- .Lib9c.Tests/Action/BattleArena3Test.cs | 4 ++-- .Lib9c.Tests/Action/BattleArena4Test.cs | 4 ++-- .Lib9c.Tests/Action/BattleArena5Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena6Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena7Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena8Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleArena9Test.cs | 6 +++--- .Lib9c.Tests/Action/BattleGrandFinale1Test.cs | 2 +- .Lib9c.Tests/Action/BattleGrandFinale2Test.cs | 2 +- .Lib9c.Tests/Action/BattleGrandFinale3Test.cs | 2 +- .Lib9c.Tests/Action/Buy10Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy11Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy2Test.cs | 2 +- .Lib9c.Tests/Action/Buy3Test.cs | 2 +- .Lib9c.Tests/Action/Buy4Test.cs | 2 +- .Lib9c.Tests/Action/Buy5Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy6Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy7Test.cs | 6 +++--- .Lib9c.Tests/Action/Buy8Test.cs | 4 ++-- .Lib9c.Tests/Action/Buy9Test.cs | 4 ++-- .Lib9c.Tests/Action/BuyMultipleTest.cs | 6 +++--- .Lib9c.Tests/Action/BuyProduct0Test.cs | 2 +- .Lib9c.Tests/Action/BuyProductTest.cs | 2 +- .Lib9c.Tests/Action/BuyTest.cs | 4 ++-- .Lib9c.Tests/Action/CancelMonsterCollectTest.cs | 4 ++-- .../Action/CancelProductRegistrationTest.cs | 2 +- .Lib9c.Tests/Action/ChargeActionPoint2Test.cs | 2 +- .Lib9c.Tests/Action/ChargeActionPointTest.cs | 4 ++-- .../Action/ClaimMonsterCollectionReward0Test.cs | 4 ++-- .../Action/ClaimMonsterCollectionReward2Test.cs | 6 +++--- .../Action/ClaimMonsterCollectionRewardTest.cs | 6 +++--- .Lib9c.Tests/Action/ClaimRaidRewardTest.cs | 4 ++-- .Lib9c.Tests/Action/ClaimStakeReward1Test.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward2Test.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward3Test.cs | 6 +++--- .Lib9c.Tests/Action/ClaimStakeReward4Test.cs | 6 +++--- .Lib9c.Tests/Action/ClaimStakeReward5Test.cs | 6 +++--- .Lib9c.Tests/Action/ClaimStakeReward6Test.cs | 6 +++--- .Lib9c.Tests/Action/ClaimStakeReward7Test.cs | 6 +++--- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 6 +++--- .../Action/ClaimWorldBossKillRewardTest.cs | 2 +- .../Action/CombinationConsumable0Test.cs | 2 +- .../Action/CombinationConsumable2Test.cs | 2 +- .../Action/CombinationConsumable3Test.cs | 2 +- .../Action/CombinationConsumable4Test.cs | 2 +- .../Action/CombinationConsumable5Test.cs | 2 +- .../Action/CombinationConsumable6Test.cs | 2 +- .../Action/CombinationConsumable7Test.cs | 2 +- .Lib9c.Tests/Action/CombinationConsumableTest.cs | 4 ++-- .Lib9c.Tests/Action/CombinationEquipment0Test.cs | 2 +- .../Action/CombinationEquipment10Test.cs | 4 ++-- .../Action/CombinationEquipment11Test.cs | 4 ++-- .../Action/CombinationEquipment12Test.cs | 4 ++-- .../Action/CombinationEquipment13Test.cs | 6 +++--- .../Action/CombinationEquipment14Test.cs | 6 +++--- .../Action/CombinationEquipment15Test.cs | 6 +++--- .Lib9c.Tests/Action/CombinationEquipment2Test.cs | 2 +- .Lib9c.Tests/Action/CombinationEquipment3Test.cs | 2 +- .Lib9c.Tests/Action/CombinationEquipment4Test.cs | 2 +- .Lib9c.Tests/Action/CombinationEquipment5Test.cs | 2 +- .Lib9c.Tests/Action/CombinationEquipment6Test.cs | 2 +- .Lib9c.Tests/Action/CombinationEquipment7Test.cs | 4 ++-- .Lib9c.Tests/Action/CombinationEquipment8Test.cs | 4 ++-- .Lib9c.Tests/Action/CombinationEquipment9Test.cs | 4 ++-- .Lib9c.Tests/Action/CombinationEquipmentTest.cs | 6 +++--- .Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs | 2 +- .Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs | 2 +- .../Action/Coupons/TransferCouponsTest.cs | 2 +- .../Action/CreatePendingActivationTest.cs | 2 +- .Lib9c.Tests/Action/CreatePledgeTest.cs | 2 +- .Lib9c.Tests/Action/DailyReward0Test.cs | 2 +- .Lib9c.Tests/Action/DailyReward2Test.cs | 2 +- .Lib9c.Tests/Action/DailyReward3Test.cs | 2 +- .Lib9c.Tests/Action/DailyReward4Test.cs | 2 +- .Lib9c.Tests/Action/DailyReward5Test.cs | 8 ++++---- .Lib9c.Tests/Action/DailyReward6Test.cs | 8 ++++---- .Lib9c.Tests/Action/DailyRewardTest.cs | 8 ++++---- .Lib9c.Tests/Action/EndPledgeTest.cs | 4 ++-- .../Action/EventConsumableItemCraftsTest.cs | 4 ++-- .Lib9c.Tests/Action/EventDungeonBattleV1Test.cs | 6 +++--- .Lib9c.Tests/Action/EventDungeonBattleV2Test.cs | 6 +++--- .Lib9c.Tests/Action/EventDungeonBattleV3Test.cs | 6 +++--- .Lib9c.Tests/Action/EventDungeonBattleV4Test.cs | 6 +++--- .Lib9c.Tests/Action/EventDungeonBattleV5Test.cs | 6 +++--- .../Action/EventMaterialItemCraftsTest.cs | 4 ++-- .../Action/Garages/DeliverToOthersGaragesTest.cs | 10 +++++----- .../Action/Garages/LoadIntoMyGaragesTest.cs | 10 +++++----- .../Action/Garages/UnloadFromMyGaragesTest.cs | 10 +++++----- .Lib9c.Tests/Action/Grinding0Test.cs | 2 +- .Lib9c.Tests/Action/GrindingTest.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash0Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash10Test.cs | 10 +++++----- .Lib9c.Tests/Action/HackAndSlash11Test.cs | 10 +++++----- .Lib9c.Tests/Action/HackAndSlash12Test.cs | 10 +++++----- .Lib9c.Tests/Action/HackAndSlash13Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash15Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash16Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash17Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash18Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash19Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash20Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash21Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlash2Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash3Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash4Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash5Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash6Test.cs | 6 +++--- .Lib9c.Tests/Action/HackAndSlash7Test.cs | 6 +++--- .Lib9c.Tests/Action/HackAndSlash8Test.cs | 6 +++--- .Lib9c.Tests/Action/HackAndSlash9Test.cs | 10 +++++----- .../Action/HackAndSlashRandomBuffTest.cs | 2 +- .Lib9c.Tests/Action/HackAndSlashSweep1Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlashSweep2Test.cs | 12 ++++++------ .Lib9c.Tests/Action/HackAndSlashSweep3Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep4Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep5Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep6Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep7Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep8Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashSweep9Test.cs | 16 ++++++++-------- .Lib9c.Tests/Action/HackAndSlashTest14.cs | 12 ++++++------ .Lib9c.Tests/Action/ItemEnhancement0Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement11Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement12Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement2Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement3Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement4Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement5Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement6Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement7Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement8Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 2 +- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 2 +- .Lib9c.Tests/Action/JoinArena1Test.cs | 2 +- .Lib9c.Tests/Action/JoinArena2Test.cs | 2 +- .Lib9c.Tests/Action/JoinArena3Test.cs | 2 +- .Lib9c.Tests/Action/MarketValidationTest.cs | 2 +- .../Action/MigrateMonsterCollectionTest.cs | 2 +- .../MigrationActivatedAccountsStateTest.cs | 2 +- .Lib9c.Tests/Action/MigrationAvatarStateTest.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs | 4 ++-- .Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs | 4 ++-- .Lib9c.Tests/Action/MockStateDelta.cs | 16 ++++++++-------- .Lib9c.Tests/Action/MonsterCollect0Test.cs | 6 +++--- .Lib9c.Tests/Action/MonsterCollect2Test.cs | 6 +++--- .Lib9c.Tests/Action/MonsterCollectTest.cs | 6 +++--- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 2 +- .Lib9c.Tests/Action/PetEnhancement0Test.cs | 8 ++++---- .Lib9c.Tests/Action/PrepareRewardAssetsTest.cs | 2 +- .Lib9c.Tests/Action/Raid1Test.cs | 6 +++--- .Lib9c.Tests/Action/Raid2Test.cs | 4 ++-- .Lib9c.Tests/Action/Raid3Test.cs | 4 ++-- .Lib9c.Tests/Action/Raid4Test.cs | 8 ++++---- .Lib9c.Tests/Action/Raid5Test.cs | 8 ++++---- .Lib9c.Tests/Action/Raid6Test.cs | 8 ++++---- .Lib9c.Tests/Action/RankingBattle0Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle10Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle11Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle2Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle3Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle4Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle5Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle6Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle7Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle8Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle9Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattleTest.cs | 2 +- .Lib9c.Tests/Action/RapidCombination0Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination2Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination3Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination4Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination5Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination6Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination7Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombination8Test.cs | 2 +- .Lib9c.Tests/Action/RapidCombinationTest.cs | 2 +- .Lib9c.Tests/Action/ReRegisterProduct0Test.cs | 2 +- .Lib9c.Tests/Action/ReRegisterProductTest.cs | 2 +- .Lib9c.Tests/Action/RedeemCode0Test.cs | 4 ++-- .Lib9c.Tests/Action/RedeemCodeTest.cs | 4 ++-- .Lib9c.Tests/Action/RegisterProduct0Test.cs | 2 +- .Lib9c.Tests/Action/RegisterProductTest.cs | 2 +- .Lib9c.Tests/Action/RenewAdminStateTest.cs | 2 +- .Lib9c.Tests/Action/RequestPledgeTest.cs | 4 ++-- .Lib9c.Tests/Action/RewardGoldTest.cs | 6 +++--- .../Action/Scenario/ArenaScenarioTest.cs | 6 +++--- .Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs | 6 +++--- .../CombinationAndRapidCombinationTest.cs | 2 +- .Lib9c.Tests/Action/Scenario/ItemCraftTest.cs | 4 ++-- .../Action/Scenario/MarketScenarioTest.cs | 2 +- .Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs | 4 ++-- .../Pet/AdditionalOptionRateByFixedValueTest.cs | 4 ++-- .Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs | 4 ++-- .../Pet/DiscountMaterialCostCrystalTest.cs | 2 +- .../Pet/IncreaseBlockPerHourglassTest.cs | 4 ++-- .../Scenario/Pet/ReduceRequiredBlockTest.cs | 4 ++-- .../Action/Scenario/RapidCombinationTest.cs | 4 ++-- .Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs | 2 +- .../Scenario/SellAndCancellationAndSellTest.cs | 2 +- .../StakeAndClaimStakeReward2ScenarioTest.cs | 2 +- .../StakeAndClaimStakeReward3ScenarioTest.cs | 2 +- .../StakeAndClaimStakeRewardScenarioTest.cs | 2 +- .../Action/Scenario/WorldUnlockScenarioTest.cs | 2 +- .Lib9c.Tests/Action/SecureMiningRewardTest.cs | 2 +- .Lib9c.Tests/Action/Sell0Test.cs | 2 +- .Lib9c.Tests/Action/Sell10Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell11Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell2Test.cs | 2 +- .Lib9c.Tests/Action/Sell3Test.cs | 2 +- .Lib9c.Tests/Action/Sell4Test.cs | 2 +- .Lib9c.Tests/Action/Sell5Test.cs | 2 +- .Lib9c.Tests/Action/Sell6Test.cs | 2 +- .Lib9c.Tests/Action/Sell7Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell8Test.cs | 4 ++-- .Lib9c.Tests/Action/Sell9Test.cs | 4 ++-- .Lib9c.Tests/Action/SellCancellation0Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation2Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation3Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation4Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation5Test.cs | 12 ++++++------ .Lib9c.Tests/Action/SellCancellation6Test.cs | 12 ++++++------ .Lib9c.Tests/Action/SellCancellation7Test.cs | 10 +++++----- .Lib9c.Tests/Action/SellCancellation8Test.cs | 12 ++++++------ .Lib9c.Tests/Action/SellCancellationTest.cs | 12 ++++++------ .Lib9c.Tests/Action/SellTest.cs | 4 ++-- .../Snapshot/TransferAsset0SnapshotTest.cs | 2 +- .Lib9c.Tests/Action/Stake0Test.cs | 2 +- .Lib9c.Tests/Action/StakeTest.cs | 2 +- .Lib9c.Tests/Action/TransferAsset2Test.cs | 4 ++-- .Lib9c.Tests/Action/TransferAsset3Test.cs | 4 ++-- .Lib9c.Tests/Action/TransferAssetTest.cs | 4 ++-- .Lib9c.Tests/Action/TransferAssetTest0.cs | 4 ++-- .Lib9c.Tests/Action/TransferAssets0Test.cs | 4 ++-- .Lib9c.Tests/Action/TransferAssetsTest.cs | 4 ++-- .../Action/UnlockEquipmentRecipe1Test.cs | 4 ++-- .Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs | 4 ++-- .Lib9c.Tests/Action/UnlockRuneSlotTest.cs | 2 +- .Lib9c.Tests/Action/UnlockWorld1Test.cs | 4 ++-- .Lib9c.Tests/Action/UnlockWorldTest.cs | 4 ++-- .Lib9c.Tests/Action/UpdateSell0Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell2Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell3Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSell4Test.cs | 2 +- .Lib9c.Tests/Action/UpdateSellTest.cs | 2 +- .Lib9c.Tests/Action/ValidatorSetOperateTest.cs | 2 +- .Lib9c.Tests/Extensions/SheetsExtensionsTest.cs | 4 ++-- .../TestHelper/MakeInitialStateResult.cs | 6 +++--- .Lib9c.Tests/Util/CraftUtil.cs | 12 ++++++------ .Lib9c.Tests/Util/CurrencyUtil.cs | 4 ++-- .Lib9c.Tests/Util/InitializeUtil.cs | 8 ++++---- .Lib9c.Tests/Util/QuestUtil.cs | 6 +++--- .Lib9c.Tools/SubCommand/State.cs | 2 +- .../AccountStateDelta.cs | 12 ++++++------ .../AccountStateDeltaMarshaller.cs | 6 +++--- .../ActionContext.cs | 2 +- .../ActionEvaluation.cs | 2 +- .../Action/Craft/UnlockCraftAction.cs | 2 +- Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs | 2 +- Lib9c.DevExtensions/Action/CreateArenaDummy.cs | 2 +- .../Action/CreateOrReplaceAvatar.cs | 6 +++--- Lib9c.DevExtensions/Action/CreateTestbed.cs | 2 +- Lib9c.DevExtensions/Action/FaucetCurrency.cs | 2 +- Lib9c.DevExtensions/Action/FaucetRune.cs | 2 +- Lib9c.DevExtensions/Action/ManipulateState.cs | 6 +++--- Lib9c.DevExtensions/Action/Stage/ClearStage.cs | 2 +- Lib9c.MessagePack/AccountStateDelta.cs | 12 ++++++------ Lib9c.MessagePack/Action/NCActionEvaluation.cs | 8 ++++---- .../Formatters/AccountStateDeltaFormatter.cs | 8 ++++---- .../NineChroniclesResolverGetFormatterHelper.cs | 2 +- Lib9c.Renderers/ActionEvaluation.cs | 4 ++-- Lib9c.Renderers/Renderers/ActionRenderer.cs | 2 +- Lib9c/Action/AccountStateDeltaExtensions.cs | 16 ++++++++-------- Lib9c/Action/ActionBase.cs | 4 ++-- Lib9c/Action/ActionBaseExtensions.cs | 16 ++++++++-------- Lib9c/Action/ActivateAccount.cs | 4 ++-- Lib9c/Action/ActivateAccount0.cs | 4 ++-- Lib9c/Action/AddActivatedAccount.cs | 4 ++-- Lib9c/Action/AddActivatedAccount0.cs | 4 ++-- Lib9c/Action/AddRedeemCode.cs | 2 +- Lib9c/Action/ApprovePledge.cs | 2 +- Lib9c/Action/AuraSummon.cs | 2 +- Lib9c/Action/BattleArena.cs | 2 +- Lib9c/Action/BattleArena1.cs | 2 +- Lib9c/Action/BattleArena10.cs | 2 +- Lib9c/Action/BattleArena11.cs | 2 +- Lib9c/Action/BattleArena12.cs | 2 +- Lib9c/Action/BattleArena2.cs | 2 +- Lib9c/Action/BattleArena3.cs | 2 +- Lib9c/Action/BattleArena4.cs | 2 +- Lib9c/Action/BattleArena5.cs | 2 +- Lib9c/Action/BattleArena6.cs | 2 +- Lib9c/Action/BattleArena7.cs | 2 +- Lib9c/Action/BattleArena8.cs | 2 +- Lib9c/Action/BattleArena9.cs | 2 +- Lib9c/Action/BattleGrandFinale.cs | 2 +- Lib9c/Action/BattleGrandFinale1.cs | 2 +- Lib9c/Action/BattleGrandFinale2.cs | 2 +- Lib9c/Action/Buy.cs | 2 +- Lib9c/Action/Buy0.cs | 2 +- Lib9c/Action/Buy10.cs | 2 +- Lib9c/Action/Buy11.cs | 2 +- Lib9c/Action/Buy2.cs | 2 +- Lib9c/Action/Buy3.cs | 2 +- Lib9c/Action/Buy4.cs | 2 +- Lib9c/Action/Buy5.cs | 2 +- Lib9c/Action/Buy6.cs | 2 +- Lib9c/Action/Buy7.cs | 2 +- Lib9c/Action/Buy8.cs | 2 +- Lib9c/Action/Buy9.cs | 2 +- Lib9c/Action/BuyMultiple.cs | 2 +- Lib9c/Action/BuyProduct.cs | 10 +++++----- Lib9c/Action/BuyProduct0.cs | 10 +++++----- Lib9c/Action/CancelMonsterCollect.cs | 4 ++-- Lib9c/Action/CancelProductRegistration.cs | 6 +++--- Lib9c/Action/ChargeActionPoint.cs | 2 +- Lib9c/Action/ChargeActionPoint0.cs | 2 +- Lib9c/Action/ChargeActionPoint2.cs | 2 +- Lib9c/Action/ClaimMonsterCollectionReward.cs | 6 +++--- Lib9c/Action/ClaimMonsterCollectionReward0.cs | 4 ++-- Lib9c/Action/ClaimMonsterCollectionReward2.cs | 4 ++-- Lib9c/Action/ClaimRaidReward.cs | 4 ++-- Lib9c/Action/ClaimStakeReward.cs | 6 +++--- Lib9c/Action/ClaimStakeReward1.cs | 2 +- Lib9c/Action/ClaimStakeReward2.cs | 2 +- Lib9c/Action/ClaimStakeReward3.cs | 6 +++--- Lib9c/Action/ClaimStakeReward4.cs | 6 +++--- Lib9c/Action/ClaimStakeReward5.cs | 6 +++--- Lib9c/Action/ClaimStakeReward6.cs | 6 +++--- Lib9c/Action/ClaimStakeReward7.cs | 6 +++--- Lib9c/Action/ClaimWordBossKillReward.cs | 4 ++-- Lib9c/Action/CombinationConsumable.cs | 2 +- Lib9c/Action/CombinationConsumable0.cs | 2 +- Lib9c/Action/CombinationConsumable2.cs | 2 +- Lib9c/Action/CombinationConsumable3.cs | 2 +- Lib9c/Action/CombinationConsumable4.cs | 2 +- Lib9c/Action/CombinationConsumable5.cs | 2 +- Lib9c/Action/CombinationConsumable6.cs | 2 +- Lib9c/Action/CombinationConsumable7.cs | 2 +- Lib9c/Action/CombinationEquipment.cs | 10 +++++----- Lib9c/Action/CombinationEquipment0.cs | 2 +- Lib9c/Action/CombinationEquipment10.cs | 2 +- Lib9c/Action/CombinationEquipment11.cs | 2 +- Lib9c/Action/CombinationEquipment12.cs | 2 +- Lib9c/Action/CombinationEquipment13.cs | 10 +++++----- Lib9c/Action/CombinationEquipment14.cs | 10 +++++----- Lib9c/Action/CombinationEquipment15.cs | 10 +++++----- Lib9c/Action/CombinationEquipment2.cs | 2 +- Lib9c/Action/CombinationEquipment3.cs | 2 +- Lib9c/Action/CombinationEquipment4.cs | 2 +- Lib9c/Action/CombinationEquipment5.cs | 2 +- Lib9c/Action/CombinationEquipment6.cs | 2 +- Lib9c/Action/CombinationEquipment7.cs | 2 +- Lib9c/Action/CombinationEquipment8.cs | 2 +- Lib9c/Action/CombinationEquipment9.cs | 2 +- Lib9c/Action/Coupons/IssueCoupons.cs | 2 +- Lib9c/Action/Coupons/RedeemCoupon.cs | 2 +- Lib9c/Action/Coupons/TransferCoupons.cs | 2 +- Lib9c/Action/CreateAvatar.cs | 2 +- Lib9c/Action/CreateAvatar0.cs | 6 +++--- Lib9c/Action/CreateAvatar2.cs | 2 +- Lib9c/Action/CreateAvatar3.cs | 2 +- Lib9c/Action/CreateAvatar4.cs | 2 +- Lib9c/Action/CreateAvatar5.cs | 2 +- Lib9c/Action/CreateAvatar6.cs | 2 +- Lib9c/Action/CreateAvatar7.cs | 2 +- Lib9c/Action/CreateAvatar8.cs | 2 +- Lib9c/Action/CreatePendingActivation.cs | 2 +- Lib9c/Action/CreatePendingActivations.cs | 2 +- Lib9c/Action/CreatePledge.cs | 2 +- Lib9c/Action/DailyReward.cs | 2 +- Lib9c/Action/DailyReward0.cs | 2 +- Lib9c/Action/DailyReward2.cs | 2 +- Lib9c/Action/DailyReward3.cs | 2 +- Lib9c/Action/DailyReward4.cs | 2 +- Lib9c/Action/DailyReward5.cs | 2 +- Lib9c/Action/DailyReward6.cs | 2 +- Lib9c/Action/EndPledge.cs | 2 +- Lib9c/Action/EventConsumableItemCrafts.cs | 2 +- Lib9c/Action/EventDungeonBattle.cs | 2 +- Lib9c/Action/EventDungeonBattleV1.cs | 2 +- Lib9c/Action/EventDungeonBattleV2.cs | 2 +- Lib9c/Action/EventDungeonBattleV3.cs | 2 +- Lib9c/Action/EventDungeonBattleV4.cs | 2 +- Lib9c/Action/EventMaterialItemCrafts.cs | 2 +- Lib9c/Action/Garages/DeliverToOthersGarages.cs | 10 +++++----- Lib9c/Action/Garages/LoadIntoMyGarages.cs | 10 +++++----- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 14 +++++++------- Lib9c/Action/Grinding.cs | 4 ++-- Lib9c/Action/Grinding0.cs | 4 ++-- Lib9c/Action/HackAndSlash.cs | 6 +++--- Lib9c/Action/HackAndSlash0.cs | 2 +- Lib9c/Action/HackAndSlash10.cs | 2 +- Lib9c/Action/HackAndSlash11.cs | 2 +- Lib9c/Action/HackAndSlash12.cs | 2 +- Lib9c/Action/HackAndSlash13.cs | 2 +- Lib9c/Action/HackAndSlash14.cs | 2 +- Lib9c/Action/HackAndSlash15.cs | 4 ++-- Lib9c/Action/HackAndSlash16.cs | 6 +++--- Lib9c/Action/HackAndSlash17.cs | 6 +++--- Lib9c/Action/HackAndSlash18.cs | 6 +++--- Lib9c/Action/HackAndSlash19.cs | 6 +++--- Lib9c/Action/HackAndSlash2.cs | 2 +- Lib9c/Action/HackAndSlash20.cs | 6 +++--- Lib9c/Action/HackAndSlash3.cs | 2 +- Lib9c/Action/HackAndSlash4.cs | 2 +- Lib9c/Action/HackAndSlash5.cs | 2 +- Lib9c/Action/HackAndSlash6.cs | 2 +- Lib9c/Action/HackAndSlash7.cs | 2 +- Lib9c/Action/HackAndSlash8.cs | 2 +- Lib9c/Action/HackAndSlash9.cs | 2 +- Lib9c/Action/HackAndSlashRandomBuff.cs | 2 +- Lib9c/Action/HackAndSlashSweep.cs | 2 +- Lib9c/Action/HackAndSlashSweep1.cs | 2 +- Lib9c/Action/HackAndSlashSweep2.cs | 2 +- Lib9c/Action/HackAndSlashSweep3.cs | 2 +- Lib9c/Action/HackAndSlashSweep4.cs | 2 +- Lib9c/Action/HackAndSlashSweep5.cs | 2 +- Lib9c/Action/HackAndSlashSweep6.cs | 2 +- Lib9c/Action/HackAndSlashSweep7.cs | 2 +- Lib9c/Action/HackAndSlashSweep8.cs | 2 +- Lib9c/Action/InitializeStates.cs | 2 +- Lib9c/Action/ItemEnhancement.cs | 2 +- Lib9c/Action/ItemEnhancement0.cs | 2 +- Lib9c/Action/ItemEnhancement10.cs | 2 +- Lib9c/Action/ItemEnhancement11.cs | 2 +- Lib9c/Action/ItemEnhancement12.cs | 2 +- Lib9c/Action/ItemEnhancement2.cs | 2 +- Lib9c/Action/ItemEnhancement3.cs | 2 +- Lib9c/Action/ItemEnhancement4.cs | 2 +- Lib9c/Action/ItemEnhancement5.cs | 2 +- Lib9c/Action/ItemEnhancement6.cs | 2 +- Lib9c/Action/ItemEnhancement7.cs | 2 +- Lib9c/Action/ItemEnhancement8.cs | 2 +- Lib9c/Action/ItemEnhancement9.cs | 2 +- Lib9c/Action/JoinArena.cs | 2 +- Lib9c/Action/JoinArena1.cs | 2 +- Lib9c/Action/JoinArena2.cs | 2 +- Lib9c/Action/MigrateMonsterCollection.cs | 2 +- Lib9c/Action/MigrationActivatedAccountsState.cs | 2 +- Lib9c/Action/MigrationAvatarState.cs | 2 +- Lib9c/Action/MigrationLegacyShop.cs | 2 +- Lib9c/Action/MigrationLegacyShop0.cs | 2 +- Lib9c/Action/MimisbrunnrBattle.cs | 2 +- Lib9c/Action/MimisbrunnrBattle0.cs | 2 +- Lib9c/Action/MimisbrunnrBattle10.cs | 2 +- Lib9c/Action/MimisbrunnrBattle11.cs | 2 +- Lib9c/Action/MimisbrunnrBattle12.cs | 2 +- Lib9c/Action/MimisbrunnrBattle2.cs | 2 +- Lib9c/Action/MimisbrunnrBattle3.cs | 2 +- Lib9c/Action/MimisbrunnrBattle4.cs | 2 +- Lib9c/Action/MimisbrunnrBattle5.cs | 2 +- Lib9c/Action/MimisbrunnrBattle6.cs | 2 +- Lib9c/Action/MimisbrunnrBattle7.cs | 2 +- Lib9c/Action/MimisbrunnrBattle8.cs | 2 +- Lib9c/Action/MimisbrunnrBattle9.cs | 2 +- Lib9c/Action/MonsterCollect.cs | 4 ++-- Lib9c/Action/MonsterCollect0.cs | 4 ++-- Lib9c/Action/MonsterCollect2.cs | 4 ++-- Lib9c/Action/PatchTableSheet.cs | 2 +- Lib9c/Action/PetEnhancement.cs | 2 +- Lib9c/Action/PrepareRewardAssets.cs | 4 ++-- Lib9c/Action/Raid.cs | 4 ++-- Lib9c/Action/Raid1.cs | 4 ++-- Lib9c/Action/Raid2.cs | 4 ++-- Lib9c/Action/Raid3.cs | 4 ++-- Lib9c/Action/Raid4.cs | 4 ++-- Lib9c/Action/Raid5.cs | 4 ++-- Lib9c/Action/RankingBattle.cs | 2 +- Lib9c/Action/RankingBattle0.cs | 2 +- Lib9c/Action/RankingBattle10.cs | 2 +- Lib9c/Action/RankingBattle11.cs | 6 +++--- Lib9c/Action/RankingBattle2.cs | 2 +- Lib9c/Action/RankingBattle3.cs | 2 +- Lib9c/Action/RankingBattle4.cs | 2 +- Lib9c/Action/RankingBattle5.cs | 2 +- Lib9c/Action/RankingBattle6.cs | 2 +- Lib9c/Action/RankingBattle7.cs | 2 +- Lib9c/Action/RankingBattle8.cs | 2 +- Lib9c/Action/RankingBattle9.cs | 2 +- Lib9c/Action/RapidCombination.cs | 2 +- Lib9c/Action/RapidCombination0.cs | 2 +- Lib9c/Action/RapidCombination2.cs | 2 +- Lib9c/Action/RapidCombination3.cs | 2 +- Lib9c/Action/RapidCombination4.cs | 2 +- Lib9c/Action/RapidCombination5.cs | 2 +- Lib9c/Action/RapidCombination6.cs | 2 +- Lib9c/Action/RapidCombination7.cs | 2 +- Lib9c/Action/RapidCombination8.cs | 2 +- Lib9c/Action/ReRegisterProduct.cs | 4 ++-- Lib9c/Action/ReRegisterProduct0.cs | 4 ++-- Lib9c/Action/RedeemCode.cs | 2 +- Lib9c/Action/RedeemCode0.cs | 2 +- Lib9c/Action/RedeemCode2.cs | 2 +- Lib9c/Action/RegisterProduct.cs | 6 +++--- Lib9c/Action/RegisterProduct0.cs | 6 +++--- Lib9c/Action/RenewAdminState.cs | 2 +- Lib9c/Action/RequestPledge.cs | 2 +- Lib9c/Action/RewardGold.cs | 16 ++++++++-------- Lib9c/Action/RuneEnhancement.cs | 2 +- Lib9c/Action/RuneEnhancement0.cs | 2 +- Lib9c/Action/SecureMiningReward.cs | 4 ++-- Lib9c/Action/Sell.cs | 2 +- Lib9c/Action/Sell0.cs | 2 +- Lib9c/Action/Sell10.cs | 2 +- Lib9c/Action/Sell11.cs | 2 +- Lib9c/Action/Sell2.cs | 2 +- Lib9c/Action/Sell3.cs | 2 +- Lib9c/Action/Sell4.cs | 2 +- Lib9c/Action/Sell5.cs | 2 +- Lib9c/Action/Sell6.cs | 2 +- Lib9c/Action/Sell7.cs | 2 +- Lib9c/Action/Sell8.cs | 2 +- Lib9c/Action/Sell9.cs | 2 +- Lib9c/Action/SellCancellation.cs | 6 +++--- Lib9c/Action/SellCancellation0.cs | 2 +- Lib9c/Action/SellCancellation2.cs | 2 +- Lib9c/Action/SellCancellation3.cs | 2 +- Lib9c/Action/SellCancellation4.cs | 2 +- Lib9c/Action/SellCancellation5.cs | 2 +- Lib9c/Action/SellCancellation6.cs | 2 +- Lib9c/Action/SellCancellation7.cs | 2 +- Lib9c/Action/SellCancellation8.cs | 2 +- Lib9c/Action/Stake.cs | 4 ++-- Lib9c/Action/Stake0.cs | 4 ++-- Lib9c/Action/TransferAsset.cs | 2 +- Lib9c/Action/TransferAsset0.cs | 2 +- Lib9c/Action/TransferAsset2.cs | 2 +- Lib9c/Action/TransferAsset3.cs | 2 +- Lib9c/Action/TransferAssets.cs | 6 +++--- Lib9c/Action/TransferAssets0.cs | 6 +++--- Lib9c/Action/UnlockEquipmentRecipe.cs | 4 ++-- Lib9c/Action/UnlockEquipmentRecipe1.cs | 4 ++-- Lib9c/Action/UnlockRuneSlot.cs | 2 +- Lib9c/Action/UnlockWorld.cs | 2 +- Lib9c/Action/UnlockWorld1.cs | 2 +- Lib9c/Action/UpdateSell.cs | 4 ++-- Lib9c/Action/UpdateSell0.cs | 2 +- Lib9c/Action/UpdateSell2.cs | 2 +- Lib9c/Action/UpdateSell3.cs | 2 +- Lib9c/Action/UpdateSell4.cs | 2 +- Lib9c/Action/ValidatorSetOperate.cs | 4 ++-- 579 files changed, 1089 insertions(+), 1089 deletions(-) diff --git a/.Lib9c.Benchmarks/Program.cs b/.Lib9c.Benchmarks/Program.cs index 596a89b98..25921d2a2 100644 --- a/.Lib9c.Benchmarks/Program.cs +++ b/.Lib9c.Benchmarks/Program.cs @@ -184,7 +184,7 @@ private static ImmutableDictionary GetTotalDelta( .SelectMany(a => a.OutputState.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); - IAccountStateDelta lastStates = actionEvaluations.Count > 0 + IAccount lastStates = actionEvaluations.Count > 0 ? actionEvaluations[actionEvaluations.Count - 1].OutputState : null; ImmutableDictionary totalDelta = diff --git a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs index fbf2ce11a..7fe19127f 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs @@ -20,7 +20,7 @@ public class UnlockCraftActionTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV2; private readonly Address _worldInformationAddress; public UnlockCraftActionTest() diff --git a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs index 164577427..f9a70708c 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs @@ -19,7 +19,7 @@ public class UnlockRecipeTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV2; private readonly Address _recipeAddress; public UnlockRecipeTest() diff --git a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs index c29ae8f77..aa04d238e 100644 --- a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs @@ -23,7 +23,7 @@ namespace Lib9c.DevExtensions.Tests.Action { public class CreateOrReplaceAvatarTest { - private readonly IAccountStateDelta _initialStates; + private readonly IAccount _initialStates; public CreateOrReplaceAvatarTest() { @@ -410,7 +410,7 @@ public void Execute_Failure( } private static void Execute( - IAccountStateDelta previousStates, + IAccount previousStates, long blockIndex, Address agentAddr, int avatarIndex, diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs index 5218acce4..e830cb1d3 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs @@ -14,7 +14,7 @@ namespace Lib9c.DevExtensions.Tests.Action { public class FaucetCurrencyTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Currency _ncg; private readonly Currency _crystal; diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs index f3891e871..4bdb17d38 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs @@ -21,7 +21,7 @@ namespace Lib9c.DevExtensions.Tests.Action { public class FaucetRuneTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _avatarAddress; private readonly RuneSheet _runeSheet; diff --git a/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs b/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs index c7c41859f..0500cc3ac 100644 --- a/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs @@ -39,7 +39,7 @@ public class ManipulateStateTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV2; private readonly Address _inventoryAddress; private readonly Address _worldInformationAddress; private readonly Address _questListAddress; @@ -345,8 +345,8 @@ public static IEnumerable FetchBalance() // ~MemberData // Logics - private IAccountStateDelta Manipulate( - IAccountStateDelta state, + private IAccount Manipulate( + IAccount state, List<(Address addr, IValue value)> targetStateList, List<(Address addr, FungibleAssetValue fav)> targetBalanceList ) @@ -366,7 +366,7 @@ private IAccountStateDelta Manipulate( } private void TestAvatarState( - IAccountStateDelta state, + IAccount state, string? name, int? level, long? exp, int? actionPoint, long? blockIndex, long? dailyRewardReceivedIndex, int? hair, int? lens, int? ear, int? tail @@ -425,7 +425,7 @@ private void TestAvatarState( } } - private void TestInventoryState(IAccountStateDelta state, Inventory targetInventory) + private void TestInventoryState(IAccount state, Inventory targetInventory) { var avatarState = state.GetAvatarStateV2(_avatarAddress); var inventoryState = avatarState.inventory; @@ -475,7 +475,7 @@ public void SetAvatarState( ); } - private void TestQuestState(IAccountStateDelta state, List targetQuestIdList) + private void TestQuestState(IAccount state, List targetQuestIdList) { var avatarState = state.GetAvatarStateV2(_avatarAddress); var questState = avatarState.questList; @@ -485,7 +485,7 @@ private void TestQuestState(IAccountStateDelta state, List targetQuestIdLis } } - private void TestWorldInformation(IAccountStateDelta state, int lastClearedStage) + private void TestWorldInformation(IAccount state, int lastClearedStage) { var avatarState = state.GetAvatarStateV2(_avatarAddress); var worldInformation = avatarState.worldInformation; diff --git a/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs b/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs index e880ec166..16ea2f363 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs @@ -15,7 +15,7 @@ public class ClearStageTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV2; private readonly Address _worldInfoAddress; public ClearStageTest() diff --git a/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs b/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs index b3332b71d..0b3d82745 100644 --- a/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs +++ b/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs @@ -47,7 +47,7 @@ public void LoadPlainValue(IValue plainValue) AvatarAddress = new Address(((Binary)((Dictionary)plainValue)["a"]).ByteArray); } - public IAccountStateDelta Execute(IActionContext context) + public IAccount Execute(IActionContext context) { context.UseGas(1); return context.PreviousState; diff --git a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs index 47290b398..81ce6f334 100644 --- a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs @@ -45,7 +45,7 @@ public AccountStateDeltaExtensionsTest() public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrystal, Type exc) { var context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta(); + IAccount states = new MockStateDelta(); var rewardInfoAddress = new PrivateKey().ToAddress(); var rewardRecord = new WorldBossKillRewardRecord(); for (int i = 0; i < level; i++) @@ -105,7 +105,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys [Fact] public void SetCouponWallet() { - IAccountStateDelta states = new MockStateDelta(); + IAccount states = new MockStateDelta(); var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA"); var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135"); var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B"); @@ -168,7 +168,7 @@ public void Mead(int agentBalance) var mead = Currencies.Mead; var price = RequestPledge.DefaultRefillMead * mead; ActionContext context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta() + IAccount states = new MockStateDelta() .SetState( agentContractAddress, List.Empty.Add(patron.Serialize()).Add(true.Serialize())) diff --git a/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs index ba1bc3505..289d39373 100644 --- a/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs @@ -186,7 +186,7 @@ public void TryGetAgentAvatarStatesV2(bool backward) [Fact] public void GetStatesAsDict() { - IAccountStateDelta states = new MockStateDelta(); + IAccount states = new MockStateDelta(); var dict = new Dictionary { { new PrivateKey().ToAddress(), Null.Value }, @@ -213,7 +213,7 @@ public void GetStatesAsDict() [Fact] public void GetSheets() { - IAccountStateDelta states = new MockStateDelta(); + IAccount states = new MockStateDelta(); SheetsExtensionsTest.InitSheets( states, out _, @@ -240,7 +240,7 @@ public void GetSheets() [InlineData(true)] public void GetCrystalCostState(bool exist) { - IAccountStateDelta state = new MockStateDelta(); + IAccount state = new MockStateDelta(); int expectedCount = exist ? 1 : 0; FungibleAssetValue expectedCrystal = exist ? 100 * CrystalCalculator.CRYSTAL @@ -273,7 +273,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist) Address previousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 1); Address beforePreviousCostAddress = Addresses.GetWeeklyCrystalCostAddress(weeklyIndex - 2); var crystalCostState = new CrystalCostState(default, 100 * CrystalCalculator.CRYSTAL); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(dailyCostAddress, crystalCostState.Serialize()) .SetState(weeklyCostAddress, crystalCostState.Serialize()) .SetState(previousCostAddress, crystalCostState.Serialize()) @@ -303,7 +303,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist) [Fact] public void GetCouponWallet() { - IAccountStateDelta states = new MockStateDelta(); + IAccount states = new MockStateDelta(); var guid1 = new Guid("6856AE42-A820-4041-92B0-5D7BAA52F2AA"); var guid2 = new Guid("701BA698-CCB9-4FC7-B88F-7CB8C707D135"); var guid3 = new Guid("910296E7-34E4-45D7-9B4E-778ED61F278B"); diff --git a/.Lib9c.Tests/Action/ActionContext.cs b/.Lib9c.Tests/Action/ActionContext.cs index c1f823297..123b78223 100644 --- a/.Lib9c.Tests/Action/ActionContext.cs +++ b/.Lib9c.Tests/Action/ActionContext.cs @@ -29,7 +29,7 @@ public class ActionContext : IActionContext public bool Rehearsal { get; set; } - public IAccountStateDelta PreviousState { get; set; } + public IAccount PreviousState { get; set; } public IRandom Random { get; set; } diff --git a/.Lib9c.Tests/Action/ActionEvaluationTest.cs b/.Lib9c.Tests/Action/ActionEvaluationTest.cs index 6bed9f1a1..ad35adae9 100644 --- a/.Lib9c.Tests/Action/ActionEvaluationTest.cs +++ b/.Lib9c.Tests/Action/ActionEvaluationTest.cs @@ -21,7 +21,7 @@ public class ActionEvaluationTest private readonly Currency _currency; private readonly Address _signer; private readonly Address _sender; - private readonly IAccountStateDelta _states; + private readonly IAccount _states; public ActionEvaluationTest() { diff --git a/.Lib9c.Tests/Action/ActivateAccount0Test.cs b/.Lib9c.Tests/Action/ActivateAccount0Test.cs index 244199825..fbc092f5e 100644 --- a/.Lib9c.Tests/Action/ActivateAccount0Test.cs +++ b/.Lib9c.Tests/Action/ActivateAccount0Test.cs @@ -24,7 +24,7 @@ public void Execute() .SetState(pendingActivation.address, pendingActivation.Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = state, Signer = default, @@ -48,7 +48,7 @@ public void Rehearsal() ActivationKey.Create(privateKey, nonce); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, @@ -151,7 +151,7 @@ public void ForbidReusingActivationKey() .SetState(pendingActivation.address, pendingActivation.Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = state, Signer = default, diff --git a/.Lib9c.Tests/Action/ActivateAccountTest.cs b/.Lib9c.Tests/Action/ActivateAccountTest.cs index 7b9695ddf..1feb545f7 100644 --- a/.Lib9c.Tests/Action/ActivateAccountTest.cs +++ b/.Lib9c.Tests/Action/ActivateAccountTest.cs @@ -41,7 +41,7 @@ public void Execute(bool invalid, bool pendingExist, bool alreadyActivated, Type if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = state, Signer = default, @@ -72,7 +72,7 @@ public void Rehearsal() ActivateAccount action = activationKey.CreateActivateAccount(nonce); Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index 5d994f961..44b8502e1 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -21,7 +21,7 @@ public void Execute() var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = 1, Miner = default, @@ -50,7 +50,7 @@ public void Rehearsal() var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = 1, Miner = default, diff --git a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs index 06ea2ec31..8e4b74d04 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs @@ -34,7 +34,7 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, Miner = default, @@ -65,7 +65,7 @@ public void Rehearsal() var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount(newComer); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = 1, Miner = default, diff --git a/.Lib9c.Tests/Action/ApprovePledgeTest.cs b/.Lib9c.Tests/Action/ApprovePledgeTest.cs index ab7755649..20059d6f5 100644 --- a/.Lib9c.Tests/Action/ApprovePledgeTest.cs +++ b/.Lib9c.Tests/Action/ApprovePledgeTest.cs @@ -19,7 +19,7 @@ public void Execute(int mead) var address = new PrivateKey().ToAddress(); var patron = new PrivateKey().ToAddress(); var contractAddress = address.Derive(nameof(RequestPledge)); - IAccountStateDelta states = new MockStateDelta() + IAccount states = new MockStateDelta() .SetState( contractAddress, List.Empty.Add(patron.Serialize()).Add(false.Serialize()).Add(mead.Serialize()) @@ -61,7 +61,7 @@ public void Execute_Throw_Exception(bool invalidPatron, bool alreadyContract, Ty contract = List.Empty.Add(patron.Serialize()).Add(true.Serialize()); } - IAccountStateDelta states = new MockStateDelta().SetState(contractAddress, contract); + IAccount states = new MockStateDelta().SetState(contractAddress, contract); var action = new ApprovePledge { diff --git a/.Lib9c.Tests/Action/ArenahelperTest.cs b/.Lib9c.Tests/Action/ArenahelperTest.cs index 72db196c7..665f88db5 100644 --- a/.Lib9c.Tests/Action/ArenahelperTest.cs +++ b/.Lib9c.Tests/Action/ArenahelperTest.cs @@ -21,7 +21,7 @@ namespace Lib9c.Tests.Action public class ArenaHelperTest { - private IAccountStateDelta _state; + private IAccount _state; private Currency _crystal; private Address _agent1Address; private Address _avatar1Address; diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/AuraSummonTest.cs index b2a40c54d..319e152de 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/AuraSummonTest.cs @@ -20,7 +20,7 @@ public class AuraSummonTest private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public AuraSummonTest() { diff --git a/.Lib9c.Tests/Action/BattleArena10Test.cs b/.Lib9c.Tests/Action/BattleArena10Test.cs index 59b9f8864..c90b860b8 100644 --- a/.Lib9c.Tests/Action/BattleArena10Test.cs +++ b/.Lib9c.Tests/Action/BattleArena10Test.cs @@ -37,7 +37,7 @@ public class BattleArena10Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena10Test(ITestOutputHelper outputHelper) { @@ -1283,9 +1283,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena11Test.cs b/.Lib9c.Tests/Action/BattleArena11Test.cs index c494ff6a9..943da3768 100644 --- a/.Lib9c.Tests/Action/BattleArena11Test.cs +++ b/.Lib9c.Tests/Action/BattleArena11Test.cs @@ -37,7 +37,7 @@ public class BattleArena11Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena11Test(ITestOutputHelper outputHelper) { @@ -1283,9 +1283,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena12Test.cs b/.Lib9c.Tests/Action/BattleArena12Test.cs index 97bfab0cf..db5bb9a2c 100644 --- a/.Lib9c.Tests/Action/BattleArena12Test.cs +++ b/.Lib9c.Tests/Action/BattleArena12Test.cs @@ -37,7 +37,7 @@ public class BattleArena12Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena12Test(ITestOutputHelper outputHelper) { @@ -1322,9 +1322,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena13Test.cs b/.Lib9c.Tests/Action/BattleArena13Test.cs index 20bbd67e5..cca3f8f7f 100644 --- a/.Lib9c.Tests/Action/BattleArena13Test.cs +++ b/.Lib9c.Tests/Action/BattleArena13Test.cs @@ -37,7 +37,7 @@ public class BattleArena13Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena13Test(ITestOutputHelper outputHelper) { @@ -1283,9 +1283,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena1Test.cs b/.Lib9c.Tests/Action/BattleArena1Test.cs index 251719db1..7be1240fe 100644 --- a/.Lib9c.Tests/Action/BattleArena1Test.cs +++ b/.Lib9c.Tests/Action/BattleArena1Test.cs @@ -38,7 +38,7 @@ public class BattleArena1Test private readonly AvatarState _avatar4; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _state; + private IAccount _state; public BattleArena1Test(ITestOutputHelper outputHelper) { @@ -190,7 +190,7 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccount JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; _state = _state.MintAsset(context, signer, preCurrency); diff --git a/.Lib9c.Tests/Action/BattleArena2Test.cs b/.Lib9c.Tests/Action/BattleArena2Test.cs index 8f4901d81..7c23815fd 100644 --- a/.Lib9c.Tests/Action/BattleArena2Test.cs +++ b/.Lib9c.Tests/Action/BattleArena2Test.cs @@ -40,7 +40,7 @@ public class BattleArena2Test private readonly AvatarState _avatar4; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _state; + private IAccount _state; public BattleArena2Test(ITestOutputHelper outputHelper) { @@ -194,7 +194,7 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccount JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; _state = _state.MintAsset(context, signer, preCurrency); diff --git a/.Lib9c.Tests/Action/BattleArena3Test.cs b/.Lib9c.Tests/Action/BattleArena3Test.cs index c0cef8bf6..f63391050 100644 --- a/.Lib9c.Tests/Action/BattleArena3Test.cs +++ b/.Lib9c.Tests/Action/BattleArena3Test.cs @@ -40,7 +40,7 @@ public class BattleArena3Test private readonly AvatarState _avatar4; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _state; + private IAccount _state; public BattleArena3Test(ITestOutputHelper outputHelper) { @@ -194,7 +194,7 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccount JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; _state = _state.MintAsset(context, signer, preCurrency); diff --git a/.Lib9c.Tests/Action/BattleArena4Test.cs b/.Lib9c.Tests/Action/BattleArena4Test.cs index 547107f6b..e42baf9ee 100644 --- a/.Lib9c.Tests/Action/BattleArena4Test.cs +++ b/.Lib9c.Tests/Action/BattleArena4Test.cs @@ -40,7 +40,7 @@ public class BattleArena4Test private readonly AvatarState _avatar4; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _state; + private IAccount _state; public BattleArena4Test(ITestOutputHelper outputHelper) { @@ -194,7 +194,7 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccount JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; _state = _state.MintAsset(context, signer, preCurrency); diff --git a/.Lib9c.Tests/Action/BattleArena5Test.cs b/.Lib9c.Tests/Action/BattleArena5Test.cs index e7b64be69..73198dcd2 100644 --- a/.Lib9c.Tests/Action/BattleArena5Test.cs +++ b/.Lib9c.Tests/Action/BattleArena5Test.cs @@ -35,7 +35,7 @@ public class BattleArena5Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena5Test(ITestOutputHelper outputHelper) { @@ -974,9 +974,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena6Test.cs b/.Lib9c.Tests/Action/BattleArena6Test.cs index 144bcd534..0d2b429e1 100644 --- a/.Lib9c.Tests/Action/BattleArena6Test.cs +++ b/.Lib9c.Tests/Action/BattleArena6Test.cs @@ -36,7 +36,7 @@ public class BattleArena6Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena6Test(ITestOutputHelper outputHelper) { @@ -1060,9 +1060,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena7Test.cs b/.Lib9c.Tests/Action/BattleArena7Test.cs index 6cbcf3b74..d44acad98 100644 --- a/.Lib9c.Tests/Action/BattleArena7Test.cs +++ b/.Lib9c.Tests/Action/BattleArena7Test.cs @@ -36,7 +36,7 @@ public class BattleArena7Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena7Test(ITestOutputHelper outputHelper) { @@ -1073,9 +1073,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena8Test.cs b/.Lib9c.Tests/Action/BattleArena8Test.cs index ef0afc550..32f79760b 100644 --- a/.Lib9c.Tests/Action/BattleArena8Test.cs +++ b/.Lib9c.Tests/Action/BattleArena8Test.cs @@ -37,7 +37,7 @@ public class BattleArena8Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena8Test(ITestOutputHelper outputHelper) { @@ -1283,9 +1283,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleArena9Test.cs b/.Lib9c.Tests/Action/BattleArena9Test.cs index b5e6e7bf5..d46c6b344 100644 --- a/.Lib9c.Tests/Action/BattleArena9Test.cs +++ b/.Lib9c.Tests/Action/BattleArena9Test.cs @@ -37,7 +37,7 @@ public class BattleArena9Test private readonly Address _avatar4Address; private readonly Currency _crystal; private readonly Currency _ncg; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleArena9Test(ITestOutputHelper outputHelper) { @@ -1283,9 +1283,9 @@ private void Execute( Assert.InRange(materialCount, 0, high); } - private IAccountStateDelta JoinArena( + private IAccount JoinArena( IActionContext context, - IAccountStateDelta states, + IAccount states, Address signer, Address avatarAddress, long blockIndex, diff --git a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs index bf6fb473d..64525c07d 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs @@ -36,7 +36,7 @@ public class BattleGrandFinale1Test private readonly Address _avatar2Address; private readonly Address _avatar3Address; private readonly Address _avatar4Address; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleGrandFinale1Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs index e4fa7d288..2573b5fc1 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs @@ -36,7 +36,7 @@ public class BattleGrandFinale2Test private readonly Address _avatar2Address; private readonly Address _avatar3Address; private readonly Address _avatar4Address; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleGrandFinale2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs index 12b879bc2..04407b1cc 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs @@ -36,7 +36,7 @@ public class BattleGrandFinale3Test private readonly Address _avatar2Address; private readonly Address _avatar3Address; private readonly Address _avatar4Address; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public BattleGrandFinale3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 7ca2769f7..8e9795410 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -34,7 +34,7 @@ public class Buy10Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy10Test(ITestOutputHelper outputHelper) { @@ -571,7 +571,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) purchaseInfos = new[] { purchaseInfo }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, PreviousState = _initialState, diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index 8eec859fc..6f062182e 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -35,7 +35,7 @@ public class Buy11Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; private IValue _arenaSheetState; public Buy11Test(ITestOutputHelper outputHelper) @@ -577,7 +577,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) purchaseInfos = new[] { purchaseInfo }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, PreviousState = _initialState, diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index efe20dbe1..08a921f55 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -25,7 +25,7 @@ public class Buy2Test private readonly AvatarState _buyerAvatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index 0aa7c0188..580ba26ce 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -25,7 +25,7 @@ public class Buy3Test private readonly AvatarState _buyerAvatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index a1f6a85cd..ece6ae947 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -27,7 +27,7 @@ public class Buy4Test private readonly AvatarState _buyerAvatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index 130cc6d93..e93801690 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -28,7 +28,7 @@ public class Buy5Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _productId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy5Test(ITestOutputHelper outputHelper) { @@ -546,7 +546,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar() [Fact] public void Execute_ErrorCode_ShopItemExpired() { - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; Address shardedShopStateAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); ShardedShopState shopState = new ShardedShopState(shardedShopStateAddress); Weapon itemUsable = (Weapon)ItemFactory.CreateItemUsable( diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index f4c6bdb9e..4c42b2cb0 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -29,7 +29,7 @@ public class Buy6Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _productId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy6Test(ITestOutputHelper outputHelper) { @@ -702,7 +702,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar(ItemType itemType [Fact] public void Execute_ErrorCode_ShopItemExpired() { - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; Address shardedShopStateAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); ShardedShopState shopState = new ShardedShopState(shardedShopStateAddress); Weapon itemUsable = (Weapon)ItemFactory.CreateItemUsable( diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index b49c5e658..b7134607b 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -29,7 +29,7 @@ public class Buy7Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _productId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy7Test(ITestOutputHelper outputHelper) { @@ -782,7 +782,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar(ItemType itemType [Fact] public void Execute_ErrorCode_ShopItemExpired() { - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; Address shardedShopStateAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); ShardedShopState shopState = new ShardedShopState(shardedShopStateAddress); Weapon itemUsable = (Weapon)ItemFactory.CreateItemUsable( @@ -834,7 +834,7 @@ public void Execute_ErrorCode_ShopItemExpired() [InlineData(10, 20)] public void Execute_ErrorCode_InvalidPrice(int shopPrice, int price) { - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; Address shardedShopStateAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); ShardedShopState shopState = new ShardedShopState(shardedShopStateAddress); Weapon itemUsable = (Weapon)ItemFactory.CreateItemUsable( diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index 1d772d1f5..06b1b1414 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -31,7 +31,7 @@ public class Buy8Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy8Test(ITestOutputHelper outputHelper) { @@ -528,7 +528,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) purchaseInfos = new[] { purchaseInfo }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, PreviousState = _initialState, diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index 91067cff5..a93592b9a 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -31,7 +31,7 @@ public class Buy9Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Buy9Test(ITestOutputHelper outputHelper) { @@ -627,7 +627,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) purchaseInfos = new[] { purchaseInfo }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, PreviousState = _initialState, diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index 889e0e269..15f04477f 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -24,7 +24,7 @@ public class BuyMultipleTest private readonly AvatarState _buyerAvatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public BuyMultipleTest(ITestOutputHelper outputHelper) { @@ -307,7 +307,7 @@ public void Execute(params ShopItemData[] productDatas) .SetState(avatarState.address, avatarState.Serialize()); } - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; var buyerGold = previousStates.GetBalance(_buyerAgentAddress, goldCurrency); var priceSumData = productDatas @@ -560,7 +560,7 @@ public void ExecuteThrowShopItemExpiredError() var sellerAgentAddress = new PrivateKey().ToAddress(); var (avatarState, agentState) = CreateAvatarState(sellerAgentAddress, sellerAvatarAddress); - IAccountStateDelta previousStates = _initialState; + IAccount previousStates = _initialState; var shopState = previousStates.GetShopState(); var productId = Guid.NewGuid(); diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index b690173d0..a579bdb22 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -35,7 +35,7 @@ public class BuyProduct0Test private readonly AvatarState _buyerAvatarState; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public BuyProduct0Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index 5c1b9a89f..4753df2d9 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -35,7 +35,7 @@ public class BuyProductTest private readonly AvatarState _buyerAvatarState; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public BuyProductTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index 883ac45b1..b26a6cf18 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -34,7 +34,7 @@ public class BuyTest private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly Guid _orderId; - private IAccountStateDelta _initialState; + private IAccount _initialState; public BuyTest(ITestOutputHelper outputHelper) { @@ -617,7 +617,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) purchaseInfos = new[] { purchaseInfo }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, PreviousState = _initialState, diff --git a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs index 9d43a6212..87a7209b1 100644 --- a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs @@ -16,7 +16,7 @@ public class CancelMonsterCollectTest { private readonly Address _signer; private readonly TableSheets _tableSheets; - private IAccountStateDelta _state; + private IAccount _state; public CancelMonsterCollectTest() { @@ -75,7 +75,7 @@ public void Execute(int prevLevel, int collectionLevel, long blockIndex) level = collectionLevel, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _state, Signer = _signer, diff --git a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs index da8dc08d0..58bfa70e0 100644 --- a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs +++ b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs @@ -19,7 +19,7 @@ namespace Lib9c.Tests.Action public class CancelProductRegistrationTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; diff --git a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs index 79b0ee3ee..cee93cf04 100644 --- a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs +++ b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs @@ -17,7 +17,7 @@ public class ChargeActionPoint2Test private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public ChargeActionPoint2Test() { diff --git a/.Lib9c.Tests/Action/ChargeActionPointTest.cs b/.Lib9c.Tests/Action/ChargeActionPointTest.cs index 545ab3cd4..0733ee893 100644 --- a/.Lib9c.Tests/Action/ChargeActionPointTest.cs +++ b/.Lib9c.Tests/Action/ChargeActionPointTest.cs @@ -20,7 +20,7 @@ public class ChargeActionPointTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public ChargeActionPointTest() { @@ -79,7 +79,7 @@ public void Execute(bool useTradable, bool backward) Assert.Equal(0, avatarState.actionPoint); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs index d66875bad..b03c32650 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs @@ -18,7 +18,7 @@ public class ClaimMonsterCollectionReward0Test private readonly Address _signer; private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; - private IAccountStateDelta _state; + private IAccount _state; public ClaimMonsterCollectionReward0Test() { @@ -142,7 +142,7 @@ public void Execute(int rewardLevel, int prevRewardLevel, int collectionLevel) collectionRound = 0, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _state, Signer = _signer, diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs index 8271b4072..a81f5e7b3 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs @@ -24,7 +24,7 @@ public class ClaimMonsterCollectionReward2Test private readonly Address _signer; private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; - private IAccountStateDelta _state; + private IAccount _state; public ClaimMonsterCollectionReward2Test(ITestOutputHelper outputHelper) { @@ -112,7 +112,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo } else { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _state, Signer = _signer, @@ -208,7 +208,7 @@ public void Rehearsal() avatarAddress = _avatarAddress, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = new MockStateDelta(), Signer = _signer, diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs index 42afc3861..4d501eb49 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs @@ -24,7 +24,7 @@ public class ClaimMonsterCollectionRewardTest private readonly Address _signer; private readonly Address _avatarAddress; private readonly ClaimMonsterCollectionReward _action; - private IAccountStateDelta _state; + private IAccount _state; public ClaimMonsterCollectionRewardTest(ITestOutputHelper outputHelper) { @@ -109,7 +109,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo } else { - IAccountStateDelta nextState = _action.Execute(new ActionContext + IAccount nextState = _action.Execute(new ActionContext { PreviousState = _state, Signer = _signer, @@ -185,7 +185,7 @@ public void Execute_Throw_RequiredBlockIndexException() [Fact] public void Rehearsal() { - IAccountStateDelta nextState = _action.Execute(new ActionContext + IAccount nextState = _action.Execute(new ActionContext { PreviousState = new MockStateDelta(), Signer = _signer, diff --git a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs index bce191ff4..9607da49b 100644 --- a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs @@ -13,7 +13,7 @@ namespace Lib9c.Tests.Action public class ClaimRaidRewardTest { private readonly TableSheets _tableSheets; - private readonly IAccountStateDelta _state; + private readonly IAccount _state; public ClaimRaidRewardTest() { @@ -62,7 +62,7 @@ public void Execute(Type exc, int rank, int latestRank) HighScore = highScore, LatestRewardRank = latestRank, }; - IAccountStateDelta state = _state.SetState(raiderAddress, raiderState.Serialize()); + IAccount state = _state.SetState(raiderAddress, raiderState.Serialize()); var randomSeed = 0; var rows = _tableSheets.WorldBossRankRewardSheet.Values diff --git a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs index f5323c626..a945bdade 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs @@ -15,7 +15,7 @@ namespace Lib9c.Tests.Action public class ClaimStakeReward1Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Currency _currency; private readonly GoldCurrencyState _goldCurrencyState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs index a7ded3b61..f7b18d6cb 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs @@ -15,7 +15,7 @@ namespace Lib9c.Tests.Action public class ClaimStakeReward2Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Currency _currency; private readonly GoldCurrencyState _goldCurrencyState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs index 95d9c6a32..180b452a7 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs @@ -21,8 +21,8 @@ public class ClaimStakeReward3Test private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeReward3Test(ITestOutputHelper outputHelper) @@ -196,7 +196,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs index 7fe3a598b..0a6d58430 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs @@ -21,8 +21,8 @@ public class ClaimStakeReward4Test private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeReward4Test(ITestOutputHelper outputHelper) @@ -230,7 +230,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimStakeReward5Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward5Test.cs index d3020df66..ad2843b2f 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward5Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward5Test.cs @@ -21,8 +21,8 @@ public class ClaimStakeReward5Test private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeReward5Test(ITestOutputHelper outputHelper) @@ -230,7 +230,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimStakeReward6Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward6Test.cs index fd1776a63..51d8c3c5e 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward6Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward6Test.cs @@ -19,8 +19,8 @@ public class ClaimStakeReward6Test private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeReward6Test(ITestOutputHelper outputHelper) @@ -233,7 +233,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimStakeReward7Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward7Test.cs index 686de0f06..533b1275a 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward7Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward7Test.cs @@ -19,8 +19,8 @@ public class ClaimStakeReward7Test private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeReward7Test(ITestOutputHelper outputHelper) @@ -209,7 +209,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index aeca973de..5a40306f9 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -30,8 +30,8 @@ public class ClaimStakeRewardTest private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public ClaimStakeRewardTest(ITestOutputHelper outputHelper) @@ -416,7 +416,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta prevState, + IAccount prevState, Address agentAddr, Address avatarAddr, long startedBlockIndex, diff --git a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs index 71af64a6e..2a675ab09 100644 --- a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs @@ -26,7 +26,7 @@ public void Execute(long blockIndex, Type exc) var tableSheets = new TableSheets(sheets); Address agentAddress = new PrivateKey().ToAddress(); Address avatarAddress = new PrivateKey().ToAddress(); - IAccountStateDelta state = new MockStateDelta(); + IAccount state = new MockStateDelta(); var runeWeightSheet = new RuneWeightSheet(); runeWeightSheet.Set(@"id,boss_id,rank,rune_id,weight diff --git a/.Lib9c.Tests/Action/CombinationConsumable0Test.cs b/.Lib9c.Tests/Action/CombinationConsumable0Test.cs index cbad109f8..650c8c95c 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable0Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable0Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable0Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable0Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs index b66de46b6..1b710aee8 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable2Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable2Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs index 29ebf29b8..ecbff3009 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable3Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable3Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs index 57beb321e..4299445de 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable4Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable4Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs index 46c99f08e..79aa4bd3c 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable5Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable5Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs index ab50812d7..ff98ea856 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs @@ -23,7 +23,7 @@ public class CombinationConsumable6Test private readonly IRandom _random; private readonly TableSheets _tableSheets; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumable6Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs index cc17b1b4b..b77b4a845 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs @@ -22,7 +22,7 @@ public class CombinationConsumable7Test private readonly Dictionary _sheets; private readonly IRandom _random; private readonly TableSheets _tableSheets; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public CombinationConsumable7Test() { diff --git a/.Lib9c.Tests/Action/CombinationConsumableTest.cs b/.Lib9c.Tests/Action/CombinationConsumableTest.cs index d9d7a6ed1..9164c1f93 100644 --- a/.Lib9c.Tests/Action/CombinationConsumableTest.cs +++ b/.Lib9c.Tests/Action/CombinationConsumableTest.cs @@ -21,7 +21,7 @@ public class CombinationConsumableTest private readonly Address _avatarAddress; private readonly IRandom _random; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationConsumableTest() { @@ -99,7 +99,7 @@ public void Execute(bool backward) _tableSheets.WorldSheet, GameConfig.RequireClearedStageLevel.CombinationConsumableAction); - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs index aa526d8cf..30cd3c0de 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs @@ -23,7 +23,7 @@ public class CombinationEquipment0Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment0Test() { diff --git a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs index 66f8f22c0..1a6f74915 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs @@ -27,7 +27,7 @@ public class CombinationEquipment10Test private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public CombinationEquipment10Test(ITestOutputHelper outputHelper) { @@ -305,7 +305,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } var context = new ActionContext(); - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs index 282575ee1..180671bc7 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs @@ -29,7 +29,7 @@ public class CombinationEquipment11Test private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private IValue _arenaSheetState; public CombinationEquipment11Test(ITestOutputHelper outputHelper) @@ -312,7 +312,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } var context = new ActionContext(); - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs index 2f4f0bc44..a9b1f3bc9 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs @@ -34,7 +34,7 @@ public class CombinationEquipment12Test private readonly Address _slotAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -151,7 +151,7 @@ bool previousCostStateExist ) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockIdsExist) { var unlockIds = List.Empty.Add(1.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs index f8204bd31..43783d29b 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs @@ -30,7 +30,7 @@ public class CombinationEquipment13Test private readonly Address _slotAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -146,7 +146,7 @@ bool previousCostStateExist ) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockIdsExist) { var unlockIds = List.Empty.Add(1.Serialize()); @@ -383,7 +383,7 @@ public void ExecuteBySuperCraft( int recipeId) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs index 624e935d0..a6c62c1ab 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs @@ -30,7 +30,7 @@ public class CombinationEquipment14Test private readonly Address _slotAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -147,7 +147,7 @@ bool previousCostStateExist ) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockIdsExist) { var unlockIds = List.Empty.Add(1.Serialize()); @@ -385,7 +385,7 @@ public void ExecuteBySuperCraft( int recipeId) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs index c935d0e7c..9616dbc55 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs @@ -30,7 +30,7 @@ public class CombinationEquipment15Test private readonly Address _slotAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -147,7 +147,7 @@ bool previousCostStateExist ) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockIdsExist) { var unlockIds = List.Empty.Add(1.Serialize()); @@ -385,7 +385,7 @@ public void ExecuteBySuperCraft( int recipeId) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs index e5639c619..13f59f62d 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs @@ -23,7 +23,7 @@ public class CombinationEquipment2Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment2Test() { diff --git a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs index f2f48c4ce..dd70f8339 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs @@ -23,7 +23,7 @@ public class CombinationEquipment3Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs index b5a4b37f0..250f8faf7 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs @@ -23,7 +23,7 @@ public class CombinationEquipment4Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs index 347e8caac..0d8574eaa 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs @@ -23,7 +23,7 @@ public class CombinationEquipment5Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment5Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs index b05ee0e4f..199fbc62a 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs @@ -25,7 +25,7 @@ public class CombinationEquipment6Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment6Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs index e16bc3acd..801f31062 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs @@ -25,7 +25,7 @@ public class CombinationEquipment7Test private readonly TableSheets _tableSheets; private readonly IRandom _random; private readonly AvatarState _avatarState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public CombinationEquipment7Test(ITestOutputHelper outputHelper) { @@ -131,7 +131,7 @@ public void Execute(bool backward) _avatarState.Update(mail); } - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs index c72ec39ff..41e9c1644 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs @@ -26,7 +26,7 @@ public class CombinationEquipment8Test private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public CombinationEquipment8Test(ITestOutputHelper outputHelper) { @@ -214,7 +214,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } var context = new ActionContext(); - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs index 019555514..b38126779 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs @@ -26,7 +26,7 @@ public class CombinationEquipment9Test private readonly Address _avatarAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public CombinationEquipment9Test(ITestOutputHelper outputHelper) { @@ -214,7 +214,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } var context = new ActionContext(); - IAccountStateDelta previousState; + IAccount previousState; if (backward) { previousState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs index bd52403ff..0f80092a1 100644 --- a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs +++ b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs @@ -30,7 +30,7 @@ public class CombinationEquipmentTest private readonly Address _slotAddress; private readonly TableSheets _tableSheets; private readonly IRandom _random; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -149,7 +149,7 @@ bool previousCostStateExist ) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockIdsExist) { var unlockIds = List.Empty.Add(1.Serialize()); @@ -387,7 +387,7 @@ public void ExecuteWithCheckingHammerPointState( int recipeId) { var context = new ActionContext(); - IAccountStateDelta state = _initialState; + IAccount state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) { diff --git a/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs b/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs index 66dd356d0..457168fde 100644 --- a/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs +++ b/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs @@ -18,7 +18,7 @@ public class IssueCouponsTest [Fact] public void Execute() { - IAccountStateDelta state = new Lib9c.Tests.Action.MockStateDelta() + IAccount state = new Lib9c.Tests.Action.MockStateDelta() .SetState( AdminState.Address, new AdminState(CouponsFixture.AgentAddress1, 1) diff --git a/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs b/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs index 5171f18d5..0b24fd3fc 100644 --- a/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs +++ b/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs @@ -20,7 +20,7 @@ public void Execute() { IRandom random = new TestRandom(); var sheets = TableSheetsImporter.ImportSheets(); - IAccountStateDelta state = new Lib9c.Tests.Action.MockStateDelta() + IAccount state = new Lib9c.Tests.Action.MockStateDelta() .SetState( Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() diff --git a/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs b/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs index fc2d21cd9..3aae3bf4b 100644 --- a/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs +++ b/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs @@ -17,7 +17,7 @@ public class TransferCouponsTest [Fact] public void Execute() { - IAccountStateDelta state = new Lib9c.Tests.Action.MockStateDelta(); + IAccount state = new Lib9c.Tests.Action.MockStateDelta(); IRandom random = new TestRandom(); var coupon1 = new Coupon(CouponsFixture.Guid1, CouponsFixture.RewardSet1); diff --git a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs index e3d24d288..2a09ec848 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs @@ -81,7 +81,7 @@ public void Rehearsal() ); var pendingActivation = new PendingActivationState(nonce, pubKey); var action = new CreatePendingActivation(pendingActivation); - IAccountStateDelta nextState = action.Execute( + IAccount nextState = action.Execute( new ActionContext() { BlockIndex = 101, diff --git a/.Lib9c.Tests/Action/CreatePledgeTest.cs b/.Lib9c.Tests/Action/CreatePledgeTest.cs index 02f0e7068..245ad8622 100644 --- a/.Lib9c.Tests/Action/CreatePledgeTest.cs +++ b/.Lib9c.Tests/Action/CreatePledgeTest.cs @@ -34,7 +34,7 @@ public void Execute(bool admin, Type exc) var agentAddress = new PrivateKey().ToAddress(); var pledgeAddress = agentAddress.GetPledgeAddress(); var context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta() + IAccount states = new MockStateDelta() .SetState(Addresses.Admin, adminState.Serialize()) .MintAsset(context, patronAddress, 4 * 500 * mead); diff --git a/.Lib9c.Tests/Action/DailyReward0Test.cs b/.Lib9c.Tests/Action/DailyReward0Test.cs index 1008aab76..18cff1ba8 100644 --- a/.Lib9c.Tests/Action/DailyReward0Test.cs +++ b/.Lib9c.Tests/Action/DailyReward0Test.cs @@ -11,7 +11,7 @@ public class DailyReward0Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/DailyReward2Test.cs b/.Lib9c.Tests/Action/DailyReward2Test.cs index 2a31215a0..ead161381 100644 --- a/.Lib9c.Tests/Action/DailyReward2Test.cs +++ b/.Lib9c.Tests/Action/DailyReward2Test.cs @@ -13,7 +13,7 @@ namespace Lib9c.Tests.Action public class DailyReward2Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/DailyReward3Test.cs b/.Lib9c.Tests/Action/DailyReward3Test.cs index 55e3f1e82..5b01cbad1 100644 --- a/.Lib9c.Tests/Action/DailyReward3Test.cs +++ b/.Lib9c.Tests/Action/DailyReward3Test.cs @@ -13,7 +13,7 @@ namespace Lib9c.Tests.Action public class DailyReward3Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/DailyReward4Test.cs b/.Lib9c.Tests/Action/DailyReward4Test.cs index 7775f782b..cb157d876 100644 --- a/.Lib9c.Tests/Action/DailyReward4Test.cs +++ b/.Lib9c.Tests/Action/DailyReward4Test.cs @@ -18,7 +18,7 @@ public class DailyReward4Test { private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialState; + private IAccount _initialState; public DailyReward4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/DailyReward5Test.cs b/.Lib9c.Tests/Action/DailyReward5Test.cs index 3d467c558..6c4312a2e 100644 --- a/.Lib9c.Tests/Action/DailyReward5Test.cs +++ b/.Lib9c.Tests/Action/DailyReward5Test.cs @@ -16,7 +16,7 @@ public class DailyReward5Test { private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public DailyReward5Test(ITestOutputHelper outputHelper) { @@ -88,7 +88,7 @@ public void Rehearsal() [InlineData(2)] public void Execute(int avatarStateSerializedVersion) { - IAccountStateDelta previousStates = null; + IAccount previousStates = null; switch (avatarStateSerializedVersion) { case 1: @@ -145,14 +145,14 @@ public void Execute_Throw_RequiredBlockIndexException( } } - private IAccountStateDelta SetAvatarStateAsV2To(IAccountStateDelta state, AvatarState avatarState) => + private IAccount SetAvatarStateAsV2To(IAccount state, AvatarState avatarState) => state .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize()) .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize()) .SetState(_avatarAddress, avatarState.SerializeV2()); - private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, long blockIndex = 0) + private IAccount ExecuteInternal(IAccount previousStates, long blockIndex = 0) { var dailyRewardAction = new DailyReward5 { diff --git a/.Lib9c.Tests/Action/DailyReward6Test.cs b/.Lib9c.Tests/Action/DailyReward6Test.cs index d79de8f5f..2ce4d81fc 100644 --- a/.Lib9c.Tests/Action/DailyReward6Test.cs +++ b/.Lib9c.Tests/Action/DailyReward6Test.cs @@ -18,7 +18,7 @@ public class DailyReward6Test { private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public DailyReward6Test(ITestOutputHelper outputHelper) { @@ -93,7 +93,7 @@ public void Rehearsal() [InlineData(2)] public void Execute(int avatarStateSerializedVersion) { - IAccountStateDelta previousStates = null; + IAccount previousStates = null; switch (avatarStateSerializedVersion) { case 1: @@ -173,14 +173,14 @@ private void Execute_Without_Runereward() Assert.Equal(0, (int)avatarRuneAmount.MajorUnit); } - private IAccountStateDelta SetAvatarStateAsV2To(IAccountStateDelta state, AvatarState avatarState) => + private IAccount SetAvatarStateAsV2To(IAccount state, AvatarState avatarState) => state .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize()) .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize()) .SetState(_avatarAddress, avatarState.SerializeV2()); - private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, long blockIndex = 0) + private IAccount ExecuteInternal(IAccount previousStates, long blockIndex = 0) { var dailyRewardAction = new DailyReward6 { diff --git a/.Lib9c.Tests/Action/DailyRewardTest.cs b/.Lib9c.Tests/Action/DailyRewardTest.cs index 9ad513573..8546b5306 100644 --- a/.Lib9c.Tests/Action/DailyRewardTest.cs +++ b/.Lib9c.Tests/Action/DailyRewardTest.cs @@ -16,7 +16,7 @@ public class DailyRewardTest { private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public DailyRewardTest(ITestOutputHelper outputHelper) { @@ -84,7 +84,7 @@ public void Rehearsal() [InlineData(false)] public void Execute(bool legacy) { - IAccountStateDelta previousStates = null; + IAccount previousStates = null; switch (legacy) { case true: @@ -165,14 +165,14 @@ private void Execute_Without_Runereward() Assert.Equal(0, (int)avatarRuneAmount.MajorUnit); } - private IAccountStateDelta SetAvatarStateAsV2To(IAccountStateDelta state, AvatarState avatarState) => + private IAccount SetAvatarStateAsV2To(IAccount state, AvatarState avatarState) => state .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), avatarState.worldInformation.Serialize()) .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize()) .SetState(_avatarAddress, avatarState.SerializeV2()); - private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, long blockIndex = 0) + private IAccount ExecuteInternal(IAccount previousStates, long blockIndex = 0) { var dailyRewardAction = new DailyReward { diff --git a/.Lib9c.Tests/Action/EndPledgeTest.cs b/.Lib9c.Tests/Action/EndPledgeTest.cs index e678b8690..88c37da11 100644 --- a/.Lib9c.Tests/Action/EndPledgeTest.cs +++ b/.Lib9c.Tests/Action/EndPledgeTest.cs @@ -19,7 +19,7 @@ public void Execute(int balance) var patron = new PrivateKey().ToAddress(); var agent = new PrivateKey().ToAddress(); var context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta() + IAccount states = new MockStateDelta() .SetState(agent.GetPledgeAddress(), List.Empty.Add(patron.Serialize()).Add(true.Serialize())); var mead = Currencies.Mead; if (balance > 0) @@ -52,7 +52,7 @@ public void Execute_Throw_Exception(bool invalidSigner, bool invalidAgent, Type Address patron = new PrivateKey().ToAddress(); Address agent = new PrivateKey().ToAddress(); List contract = List.Empty.Add(patron.Serialize()).Add(true.Serialize()); - IAccountStateDelta states = new MockStateDelta().SetState(agent.GetPledgeAddress(), contract); + IAccount states = new MockStateDelta().SetState(agent.GetPledgeAddress(), contract); var action = new EndPledge { diff --git a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs index 0b188b4ba..c9f12960f 100644 --- a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Action public class EventConsumableItemCraftsTest { - private readonly IAccountStateDelta _initialStates; + private readonly IAccount _initialStates; private readonly TableSheets _tableSheets; private readonly Address _agentAddress; @@ -100,7 +100,7 @@ public void Execute_Success( } private void Execute( - IAccountStateDelta previousStates, + IAccount previousStates, int eventScheduleId, int eventConsumableItemRecipeId, int slotIndex, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs index 94afaa176..bcadbac61 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs @@ -25,7 +25,7 @@ public class EventDungeonBattleV1Test private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public EventDungeonBattleV1Test() { @@ -383,8 +383,8 @@ public void Execute_V100301() eventDungeonInfo.RemainingTickets); } - private IAccountStateDelta Execute( - IAccountStateDelta previousStates, + private IAccount Execute( + IAccount previousStates, int eventScheduleId, int eventDungeonId, int eventDungeonStageId, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs index 04a2dad3b..b1929e735 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs @@ -25,7 +25,7 @@ public class EventDungeonBattleV2Test private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public EventDungeonBattleV2Test() { @@ -397,8 +397,8 @@ public void Execute_V100301() eventDungeonInfo.RemainingTickets); } - private IAccountStateDelta Execute( - IAccountStateDelta previousStates, + private IAccount Execute( + IAccount previousStates, int eventScheduleId, int eventDungeonId, int eventDungeonStageId, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs index a5fb074d8..122a6a7e0 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs @@ -25,7 +25,7 @@ public class EventDungeonBattleV3Test private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public EventDungeonBattleV3Test() { @@ -395,8 +395,8 @@ public void Execute_V100301() eventDungeonInfo.RemainingTickets); } - private IAccountStateDelta Execute( - IAccountStateDelta previousStates, + private IAccount Execute( + IAccount previousStates, int eventScheduleId, int eventDungeonId, int eventDungeonStageId, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs index 39c4ca231..498534a8a 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs @@ -26,7 +26,7 @@ public class EventDungeonBattleV4Test private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public EventDungeonBattleV4Test() { @@ -435,8 +435,8 @@ public void Execute_V100301() eventDungeonInfo.RemainingTickets); } - private IAccountStateDelta Execute( - IAccountStateDelta previousStates, + private IAccount Execute( + IAccount previousStates, int eventScheduleId, int eventDungeonId, int eventDungeonStageId, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs index a5a283e7f..bd0aa106a 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs @@ -27,7 +27,7 @@ public class EventDungeonBattleV5Test private readonly Address _agentAddress; private readonly Address _avatarAddress; - private IAccountStateDelta _initialStates; + private IAccount _initialStates; public EventDungeonBattleV5Test() { @@ -436,8 +436,8 @@ public void Execute_V100301() eventDungeonInfo.RemainingTickets); } - private IAccountStateDelta Execute( - IAccountStateDelta previousStates, + private IAccount Execute( + IAccount previousStates, int eventScheduleId, int eventDungeonId, int eventDungeonStageId, diff --git a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs index c02a80e7f..5f8f6709b 100644 --- a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class EventMaterialItemCraftsTest { - private readonly IAccountStateDelta _initialStates; + private readonly IAccount _initialStates; private readonly TableSheets _tableSheets; private readonly Address _agentAddress; @@ -213,7 +213,7 @@ public void Execute_InvalidMaterialCountException( } private void Execute( - IAccountStateDelta previousStates, + IAccount previousStates, int eventScheduleId, int eventMaterialItemRecipeId, Dictionary materialsToUse, diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs index e0e451819..fb3035230 100644 --- a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -27,13 +27,13 @@ public class DeliverToOthersGaragesTest private static readonly Address SenderAgentAddr = Addresses.Admin; private readonly TableSheets _tableSheets; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; private readonly Address _recipientAgentAddr; private readonly FungibleAssetValue[] _fungibleAssetValues; private readonly (HashDigest fungibleId, int count)[] _fungibleIdAndCounts; private readonly ITradableFungibleItem[] _tradableFungibleItems; - private readonly IAccountStateDelta _previousStates; + private readonly IAccount _previousStates; public DeliverToOthersGaragesTest() { @@ -315,10 +315,10 @@ public void Execute_Throws_Exception() } } - private static (DeliverToOthersGarages action, IAccountStateDelta nextStates) Execute( + private static (DeliverToOthersGarages action, IAccount nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousState, + IAccount previousState, IRandom random, Address recipientAgentAddr, IEnumerable? fungibleAssetValues, @@ -355,7 +355,7 @@ private static FungibleAssetValue[] GetFungibleAssetValues() FungibleAssetValue[] fungibleAssetValues, (HashDigest fungibleId, int count)[] fungibleIdAndCounts, ITradableFungibleItem[] _tradableFungibleItems, - IAccountStateDelta previousStates) + IAccount previousStates) GetSuccessfulPreviousStatesWithPlainValue() { var previousStates = _initialStatesWithAvatarStateV2; diff --git a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs index 4c7a2b8d5..016d675fb 100644 --- a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs @@ -28,14 +28,14 @@ public class LoadIntoMyGaragesTest private readonly TableSheets _tableSheets; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; private readonly (Address balanceAddr, FungibleAssetValue value)[] _fungibleAssetValues; private readonly Address? _inventoryAddr; private readonly (HashDigest fungibleId, int count)[] _fungibleIdAndCounts; private readonly FungibleAssetValue _cost; private readonly ITradableFungibleItem[] _tradableFungibleItems; - private readonly IAccountStateDelta _previousStates; + private readonly IAccount _previousStates; public LoadIntoMyGaragesTest() { @@ -395,10 +395,10 @@ public void Execute_Throws_Exception() } } - private static (LoadIntoMyGarages action, IAccountStateDelta nextStates) Execute( + private static (LoadIntoMyGarages action, IAccount nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousState, + IAccount previousState, IRandom random, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, Address? inventoryAddr, @@ -452,7 +452,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] (HashDigest fungibleId, int count)[] fungibleIdAndCounts, FungibleAssetValue cost, ITradableFungibleItem[] _tradableFungibleItems, - IAccountStateDelta previousStates) + IAccount previousStates) GetSuccessfulPreviousStatesWithPlainValue() { var previousStates = _initialStatesWithAvatarStateV2; diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index 92b10355e..5aec4395a 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -31,13 +31,13 @@ public class UnloadFromMyGaragesTest Addresses.GetAvatarAddress(AgentAddr, AvatarIndex); private readonly TableSheets _tableSheets; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; private readonly Address _recipientAvatarAddr; private readonly (Address balanceAddr, FungibleAssetValue value)[] _fungibleAssetValues; private readonly (HashDigest fungibleId, int count)[] _fungibleIdAndCounts; private readonly IFungibleItem[] _fungibleItems; - private readonly IAccountStateDelta _previousStates; + private readonly IAccount _previousStates; public UnloadFromMyGaragesTest() { @@ -323,10 +323,10 @@ public void Execute_Throws_Exception() } } - private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execute( + private static (UnloadFromMyGarages action, IAccount nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousState, + IAccount previousState, IRandom random, Address recipientAvatarAddr, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, @@ -376,7 +376,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, (HashDigest fungibleId, int count)[] fungibleIdAndCounts, IFungibleItem[] _fungibleItems, - IAccountStateDelta previousStates) + IAccount previousStates) GetSuccessfulPreviousStatesWithPlainValue() { var previousStates = _initialStatesWithAvatarStateV2; diff --git a/.Lib9c.Tests/Action/Grinding0Test.cs b/.Lib9c.Tests/Action/Grinding0Test.cs index 2446bc6c2..c6ea61b8b 100644 --- a/.Lib9c.Tests/Action/Grinding0Test.cs +++ b/.Lib9c.Tests/Action/Grinding0Test.cs @@ -27,7 +27,7 @@ public class Grinding0Test private readonly AvatarState _avatarState; private readonly Currency _crystalCurrency; private readonly Currency _ncgCurrency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public Grinding0Test() { diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index 1e5615bad..2fd9f199a 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -27,7 +27,7 @@ public class GrindingTest private readonly AvatarState _avatarState; private readonly Currency _crystalCurrency; private readonly Currency _ncgCurrency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public GrindingTest() { diff --git a/.Lib9c.Tests/Action/HackAndSlash0Test.cs b/.Lib9c.Tests/Action/HackAndSlash0Test.cs index d8f494a95..f06925f41 100644 --- a/.Lib9c.Tests/Action/HackAndSlash0Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash0Test.cs @@ -30,7 +30,7 @@ public class HackAndSlash0Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash0Test() { diff --git a/.Lib9c.Tests/Action/HackAndSlash10Test.cs b/.Lib9c.Tests/Action/HackAndSlash10Test.cs index c86c04179..7a3afabdc 100644 --- a/.Lib9c.Tests/Action/HackAndSlash10Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash10Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash10Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash10Test() { @@ -201,7 +201,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -486,7 +486,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -870,7 +870,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -1019,7 +1019,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash11Test.cs b/.Lib9c.Tests/Action/HackAndSlash11Test.cs index 8fa667412..e1ce4753d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash11Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash11Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash11Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash11Test() { @@ -200,7 +200,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -444,7 +444,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -818,7 +818,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -966,7 +966,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash12Test.cs b/.Lib9c.Tests/Action/HackAndSlash12Test.cs index 83f87d00d..8488c5edc 100644 --- a/.Lib9c.Tests/Action/HackAndSlash12Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash12Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash12Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash12Test() { @@ -174,7 +174,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -428,7 +428,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -802,7 +802,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -962,7 +962,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash13Test.cs b/.Lib9c.Tests/Action/HackAndSlash13Test.cs index b9942fc3c..fea991187 100644 --- a/.Lib9c.Tests/Action/HackAndSlash13Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash13Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash13Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash13Test() { @@ -176,7 +176,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -434,7 +434,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { @@ -581,7 +581,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u avatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -811,7 +811,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -999,7 +999,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash15Test.cs b/.Lib9c.Tests/Action/HackAndSlash15Test.cs index 2c762d82c..1e3cb5f6d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash15Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash15Test.cs @@ -38,7 +38,7 @@ public class HackAndSlash15Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash15Test() { @@ -172,7 +172,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -430,7 +430,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -553,7 +553,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u avatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -783,7 +783,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -940,7 +940,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash16Test.cs b/.Lib9c.Tests/Action/HackAndSlash16Test.cs index e9d1f46d4..c691b8b6d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash16Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash16Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash16Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash16Test() { @@ -173,7 +173,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -431,7 +431,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -554,7 +554,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -788,7 +788,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -985,7 +985,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash17Test.cs b/.Lib9c.Tests/Action/HackAndSlash17Test.cs index be49499dc..aa44192b5 100644 --- a/.Lib9c.Tests/Action/HackAndSlash17Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash17Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash17Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash17Test() { @@ -173,7 +173,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -431,7 +431,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -554,7 +554,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -788,7 +788,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -985,7 +985,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash18Test.cs b/.Lib9c.Tests/Action/HackAndSlash18Test.cs index 688a2d3bb..3e7b2f184 100644 --- a/.Lib9c.Tests/Action/HackAndSlash18Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash18Test.cs @@ -41,7 +41,7 @@ public class HackAndSlash18Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash18Test() { @@ -171,7 +171,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -429,7 +429,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -552,7 +552,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -786,7 +786,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -1079,7 +1079,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash19Test.cs b/.Lib9c.Tests/Action/HackAndSlash19Test.cs index d174fd9a5..09da13a62 100644 --- a/.Lib9c.Tests/Action/HackAndSlash19Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash19Test.cs @@ -41,7 +41,7 @@ public class HackAndSlash19Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash19Test() { @@ -170,7 +170,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -433,7 +433,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -560,7 +560,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -799,7 +799,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -999,7 +999,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash20Test.cs b/.Lib9c.Tests/Action/HackAndSlash20Test.cs index 7b1ec3aa7..4972ebb9f 100644 --- a/.Lib9c.Tests/Action/HackAndSlash20Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash20Test.cs @@ -42,7 +42,7 @@ public class HackAndSlash20Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash20Test() { @@ -171,7 +171,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -434,7 +434,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -561,7 +561,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -800,7 +800,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -1089,7 +1089,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash21Test.cs b/.Lib9c.Tests/Action/HackAndSlash21Test.cs index bdb648c3c..8ca1a206f 100644 --- a/.Lib9c.Tests/Action/HackAndSlash21Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash21Test.cs @@ -43,7 +43,7 @@ public class HackAndSlash21Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash21Test() { @@ -172,7 +172,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -435,7 +435,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -562,7 +562,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -801,7 +801,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( _avatarAddress.Derive(LegacyInventoryKey), @@ -1090,7 +1090,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlash2Test.cs b/.Lib9c.Tests/Action/HackAndSlash2Test.cs index 82eafcb09..76403b828 100644 --- a/.Lib9c.Tests/Action/HackAndSlash2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash2Test.cs @@ -32,7 +32,7 @@ public class HackAndSlash2Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash2Test() { diff --git a/.Lib9c.Tests/Action/HackAndSlash3Test.cs b/.Lib9c.Tests/Action/HackAndSlash3Test.cs index b837b06e7..7764b4aca 100644 --- a/.Lib9c.Tests/Action/HackAndSlash3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash3Test.cs @@ -29,7 +29,7 @@ public class HackAndSlash3Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash3Test() { diff --git a/.Lib9c.Tests/Action/HackAndSlash4Test.cs b/.Lib9c.Tests/Action/HackAndSlash4Test.cs index 8b4b83abc..b8f6c0d26 100644 --- a/.Lib9c.Tests/Action/HackAndSlash4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash4Test.cs @@ -32,7 +32,7 @@ public class HackAndSlash4Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash4Test() { diff --git a/.Lib9c.Tests/Action/HackAndSlash5Test.cs b/.Lib9c.Tests/Action/HackAndSlash5Test.cs index f26102429..908c7d83f 100644 --- a/.Lib9c.Tests/Action/HackAndSlash5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash5Test.cs @@ -32,7 +32,7 @@ public class HackAndSlash5Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash5Test() { diff --git a/.Lib9c.Tests/Action/HackAndSlash6Test.cs b/.Lib9c.Tests/Action/HackAndSlash6Test.cs index 92a16d146..3cfa90411 100644 --- a/.Lib9c.Tests/Action/HackAndSlash6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash6Test.cs @@ -34,7 +34,7 @@ public class HackAndSlash6Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash6Test() { @@ -165,7 +165,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains, bo previousAvatarState.Update2(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -395,7 +395,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) Assert.Null(action.Result); - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash7Test.cs b/.Lib9c.Tests/Action/HackAndSlash7Test.cs index a474ea71e..d47f0786e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash7Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash7Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash7Test() { @@ -193,7 +193,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains, bo previousAvatarState.Update2(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -496,7 +496,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) WeeklyArenaAddress = _weeklyArenaState.address, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash8Test.cs b/.Lib9c.Tests/Action/HackAndSlash8Test.cs index fa54c828d..fb640da05 100644 --- a/.Lib9c.Tests/Action/HackAndSlash8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash8Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash8Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash8Test() { @@ -200,7 +200,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -489,7 +489,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash9Test.cs b/.Lib9c.Tests/Action/HackAndSlash9Test.cs index 8c0894e53..63b7e3459 100644 --- a/.Lib9c.Tests/Action/HackAndSlash9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash9Test.cs @@ -39,7 +39,7 @@ public class HackAndSlash9Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlash9Test() { @@ -201,7 +201,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -509,7 +509,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -893,7 +893,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -1042,7 +1042,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs index ac67a70f8..fa7e04894 100644 --- a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs @@ -35,7 +35,7 @@ public class HackAndSlashRandomBuffTest private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; private readonly Currency _currency; diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs index 2bb30efbc..0f3fab46f 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs @@ -32,7 +32,7 @@ public class HackAndSlashSweep1Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep1Test() @@ -119,7 +119,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -291,7 +291,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -345,7 +345,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -404,7 +404,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -473,7 +473,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs index ad32f64a7..96a5e32a7 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs @@ -32,7 +32,7 @@ public class HackAndSlashSweep2Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep2Test() @@ -119,7 +119,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -329,7 +329,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -383,7 +383,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -442,7 +442,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -511,7 +511,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs index 7cd7918cc..da9fd395f 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs @@ -33,7 +33,7 @@ public class HackAndSlashSweep3Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep3Test() @@ -143,7 +143,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -359,7 +359,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -413,7 +413,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -473,7 +473,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -548,7 +548,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -623,7 +623,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -698,7 +698,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs index 1dd9884f5..eda619825 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs @@ -33,7 +33,7 @@ public class HackAndSlashSweep4Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep4Test() @@ -163,7 +163,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -363,7 +363,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -417,7 +417,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -477,7 +477,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -552,7 +552,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -627,7 +627,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -702,7 +702,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs index 6327db82e..f9245c678 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs @@ -34,7 +34,7 @@ public class HackAndSlashSweep5Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep5Test() @@ -161,7 +161,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -383,7 +383,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -445,7 +445,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -505,7 +505,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -580,7 +580,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -655,7 +655,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -730,7 +730,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs index e51e412a9..407049834 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs @@ -36,7 +36,7 @@ public class HackAndSlashSweep6Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep6Test() @@ -168,7 +168,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -390,7 +390,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -452,7 +452,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -512,7 +512,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -587,7 +587,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -662,7 +662,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -737,7 +737,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs index beaccdd98..dc04acbfa 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs @@ -36,7 +36,7 @@ public class HackAndSlashSweep7Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep7Test() @@ -168,7 +168,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -393,7 +393,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -455,7 +455,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -515,7 +515,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -590,7 +590,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -665,7 +665,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -740,7 +740,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs index 77abf5a2d..337a3cfba 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs @@ -36,7 +36,7 @@ public class HackAndSlashSweep8Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep8Test() @@ -168,7 +168,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -398,7 +398,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -461,7 +461,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -522,7 +522,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -598,7 +598,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -674,7 +674,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -750,7 +750,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs index 283a0bcac..94e83ef5e 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs @@ -37,7 +37,7 @@ public class HackAndSlashSweep9Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly IRandom _random; public HackAndSlashSweep9Test() @@ -169,7 +169,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, apStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -399,7 +399,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI new WorldInformation(0, _initialState.GetSheet(), 10000001), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -462,7 +462,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) new WorldInformation(0, _initialState.GetSheet(), 25), }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -523,7 +523,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA var apStone = ItemFactory.CreateTradableMaterial(row); avatarState.inventory.AddItem(apStone, holdingApStoneCount); - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -599,7 +599,7 @@ public void Execute_NotEnoughActionPointException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -675,7 +675,7 @@ public void Execute_PlayCountIsZeroException(bool backward) actionPoint = 0, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); @@ -751,7 +751,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool level = 1, }; - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/HackAndSlashTest14.cs b/.Lib9c.Tests/Action/HackAndSlashTest14.cs index c3ad3e466..b3b63fb91 100644 --- a/.Lib9c.Tests/Action/HackAndSlashTest14.cs +++ b/.Lib9c.Tests/Action/HackAndSlashTest14.cs @@ -38,7 +38,7 @@ public class HackAndSlashTest14 private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public HackAndSlashTest14() { @@ -163,7 +163,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); @@ -421,7 +421,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; + IAccount state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -544,7 +544,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u avatarAddress = _avatarAddress, }; - IAccountStateDelta state = _initialState; + IAccount state = _initialState; if (unlockedIdsExist) { state = state.SetState( @@ -774,7 +774,7 @@ public void ExecuteWithoutPlayCount() previousAvatarState.Update(mail); } - IAccountStateDelta state = _initialState + IAccount state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), previousAvatarState.worldInformation.Serialize()) @@ -931,7 +931,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs index 1a8e94a57..4eaa5fe8c 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs @@ -25,7 +25,7 @@ public class ItemEnhancement0Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement0Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 742bbf99c..d5b0744ee 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -29,7 +29,7 @@ public class ItemEnhancement10Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; private IValue _arenaSheetState; public ItemEnhancement10Test() diff --git a/.Lib9c.Tests/Action/ItemEnhancement11Test.cs b/.Lib9c.Tests/Action/ItemEnhancement11Test.cs index d7f2d78f8..031defc69 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement11Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement11Test.cs @@ -27,7 +27,7 @@ public class ItemEnhancement11Test private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement11Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement12Test.cs b/.Lib9c.Tests/Action/ItemEnhancement12Test.cs index aa3dddb78..fd22ba663 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement12Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement12Test.cs @@ -24,7 +24,7 @@ public class ItemEnhancement12Test private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement12Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs index e1c0d66f7..955117608 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs @@ -24,7 +24,7 @@ public class ItemEnhancement2Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement2Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs index 72ccd55a7..2733f83da 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs @@ -24,7 +24,7 @@ public class ItemEnhancement3Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement3Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs index 2033c10e8..5bfe74eda 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs @@ -25,7 +25,7 @@ public class ItemEnhancement4Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement4Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs index af896dc57..e00a9ccf7 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs @@ -25,7 +25,7 @@ public class ItemEnhancement5Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement5Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs index fd1832490..7869aa7c0 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs @@ -25,7 +25,7 @@ public class ItemEnhancement6Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement6Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs index 87eb16328..f234b5f68 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs @@ -27,7 +27,7 @@ public class ItemEnhancement7Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement7Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs index bb874bfda..60f677c70 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs @@ -27,7 +27,7 @@ public class ItemEnhancement8Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement8Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index 25ebf15f6..f177c5603 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -28,7 +28,7 @@ public class ItemEnhancement9Test private readonly Address _slotAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancement9Test() { diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 3c270b27b..63a16fc2b 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -24,7 +24,7 @@ public class ItemEnhancementTest private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ItemEnhancementTest() { diff --git a/.Lib9c.Tests/Action/JoinArena1Test.cs b/.Lib9c.Tests/Action/JoinArena1Test.cs index 5a92415bc..bcad3265b 100644 --- a/.Lib9c.Tests/Action/JoinArena1Test.cs +++ b/.Lib9c.Tests/Action/JoinArena1Test.cs @@ -32,7 +32,7 @@ public class JoinArena1Test private readonly Address _avatar2Address; private readonly IRandom _random; private readonly Currency _currency; - private IAccountStateDelta _state; + private IAccount _state; public JoinArena1Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/JoinArena2Test.cs b/.Lib9c.Tests/Action/JoinArena2Test.cs index 4a329df5a..3bed1c136 100644 --- a/.Lib9c.Tests/Action/JoinArena2Test.cs +++ b/.Lib9c.Tests/Action/JoinArena2Test.cs @@ -32,7 +32,7 @@ public class JoinArena2Test private readonly Address _avatar2Address; private readonly IRandom _random; private readonly Currency _currency; - private IAccountStateDelta _state; + private IAccount _state; public JoinArena2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/JoinArena3Test.cs b/.Lib9c.Tests/Action/JoinArena3Test.cs index 87f4c6e29..6828e0f51 100644 --- a/.Lib9c.Tests/Action/JoinArena3Test.cs +++ b/.Lib9c.Tests/Action/JoinArena3Test.cs @@ -33,7 +33,7 @@ public class JoinArena3Test private readonly Address _avatar2Address; private readonly IRandom _random; private readonly Currency _currency; - private IAccountStateDelta _state; + private IAccount _state; public JoinArena3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/MarketValidationTest.cs b/.Lib9c.Tests/Action/MarketValidationTest.cs index 96a6faa23..77f7eadc1 100644 --- a/.Lib9c.Tests/Action/MarketValidationTest.cs +++ b/.Lib9c.Tests/Action/MarketValidationTest.cs @@ -19,7 +19,7 @@ public class MarketValidationTest private static readonly Address AvatarAddress = new Address("47d082a115c63e7b58b1532d20e631538eafadde"); private static readonly Currency Gold = Currency.Legacy("NCG", 2, minters: null); - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MarketValidationTest() { diff --git a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs index 82673d8c7..5eab7065e 100644 --- a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs +++ b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs @@ -20,7 +20,7 @@ public class MigrateMonsterCollectionTest { private readonly Address _signer; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _state; + private readonly IAccount _state; public MigrateMonsterCollectionTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs index 7a4e33f17..ebbe28a73 100644 --- a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs @@ -23,7 +23,7 @@ public void Execute() var action = new MigrationActivatedAccountsState(); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = state, Signer = admin, diff --git a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs index 628a36dde..c8ed5973b 100644 --- a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs @@ -46,7 +46,7 @@ public void Execute() }, }; - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = state, Signer = admin, diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs index 5fa849e28..e982d4771 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle0Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle0Test() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs index fb3b7bdc5..ab7b9d263 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs @@ -25,7 +25,7 @@ public class MimisbrunnrBattle10Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Dictionary _sheets; public MimisbrunnrBattle10Test() @@ -791,7 +791,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs index abff420cd..ede38096e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs @@ -24,7 +24,7 @@ public class MimisbrunnrBattle11Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Dictionary _sheets; public MimisbrunnrBattle11Test() @@ -686,7 +686,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs index 50603b0aa..37b34145b 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs @@ -26,7 +26,7 @@ public class MimisbrunnrBattle12Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Dictionary _sheets; public MimisbrunnrBattle12Test() @@ -693,7 +693,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs index 3f12ea00c..2f1c5fdad 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs @@ -27,7 +27,7 @@ public class MimisbrunnrBattle13Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Dictionary _sheets; public MimisbrunnrBattle13Test() @@ -694,7 +694,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs index ff472a5a9..eb0608c4d 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle2Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle2Test() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs index ef81ceeb5..375473818 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle3Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle3Test() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs index ab17d20be..67f20b67c 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs @@ -29,7 +29,7 @@ public class MimisbrunnrBattle4Test private readonly Address _rankingMapAddress; private readonly WeeklyArenaState _weeklyArenaState; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle4Test() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs index f9727b58d..1eec79bf9 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle5Test private readonly Address _rankingMapAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle5Test() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs index 2f9b7c3e9..072eb080e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle6Test private readonly Address _rankingMapAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle6Test() { @@ -675,7 +675,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs index 35ff553a7..236a357bf 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs @@ -28,7 +28,7 @@ public class MimisbrunnrBattle7Test private readonly Address _rankingMapAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle7Test() { @@ -675,7 +675,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs index 3497b86e8..ce324a055 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs @@ -25,7 +25,7 @@ public class MimisbrunnrBattle8Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle8Test() { @@ -627,7 +627,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs index 995732b6c..c60cd203e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs @@ -26,7 +26,7 @@ public class MimisbrunnrBattle9Test private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public MimisbrunnrBattle9Test() { @@ -677,7 +677,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) previousAvatarState.Update(mail); } - IAccountStateDelta state; + IAccount state; if (backward) { state = _initialState.SetState(_avatarAddress, previousAvatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/MockStateDelta.cs b/.Lib9c.Tests/Action/MockStateDelta.cs index 08e382a17..dfad94be1 100644 --- a/.Lib9c.Tests/Action/MockStateDelta.cs +++ b/.Lib9c.Tests/Action/MockStateDelta.cs @@ -20,7 +20,7 @@ namespace Lib9c.Tests.Action /// except this has its constructors exposed as public for testing. /// [Pure] - public class MockStateDelta : IAccountStateDelta + public class MockStateDelta : IAccount { private readonly IAccountState _baseState; @@ -94,7 +94,7 @@ private MockStateDelta(IAccountState baseState, IAccountDelta delta) /// [Pure] - public IAccountStateDelta SetState(Address address, IValue state) => + public IAccount SetState(Address address, IValue state) => UpdateStates(Delta.States.SetItem(address, state)); /// @@ -131,7 +131,7 @@ public ValidatorSet GetValidatorSet() => /// [Pure] - public IAccountStateDelta MintAsset( + public IAccount MintAsset( IActionContext context, Address recipient, FungibleAssetValue value) { if (value.Sign <= 0) @@ -182,7 +182,7 @@ public IAccountStateDelta MintAsset( /// [Pure] - public IAccountStateDelta TransferAsset( + public IAccount TransferAsset( IActionContext context, Address sender, Address recipient, @@ -193,7 +193,7 @@ public IAccountStateDelta TransferAsset( /// [Pure] - public IAccountStateDelta BurnAsset( + public IAccount BurnAsset( IActionContext context, Address owner, FungibleAssetValue value) { string msg; @@ -244,7 +244,7 @@ public IAccountStateDelta BurnAsset( /// [Pure] - public IAccountStateDelta SetValidator(Validator validator) + public IAccount SetValidator(Validator validator) { return UpdateValidatorSet(GetValidatorSet().Update(validator)); } @@ -314,7 +314,7 @@ private MockStateDelta UpdateValidatorSet( }; [Pure] - private IAccountStateDelta TransferAssetV0( + private IAccount TransferAssetV0( Address sender, Address recipient, FungibleAssetValue value, @@ -350,7 +350,7 @@ private IAccountStateDelta TransferAssetV0( } [Pure] - private IAccountStateDelta TransferAssetV1( + private IAccount TransferAssetV1( Address sender, Address recipient, FungibleAssetValue value, diff --git a/.Lib9c.Tests/Action/MonsterCollect0Test.cs b/.Lib9c.Tests/Action/MonsterCollect0Test.cs index e5656fcb3..8685284da 100644 --- a/.Lib9c.Tests/Action/MonsterCollect0Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect0Test.cs @@ -16,7 +16,7 @@ public class MonsterCollect0Test { private readonly TableSheets _tableSheets; private readonly Address _signer; - private IAccountStateDelta _initialState; + private IAccount _initialState; public MonsterCollect0Test() { @@ -80,7 +80,7 @@ public void Execute(bool exist, int level, int monsterCollectionRound, int prevL collectionRound = monsterCollectionRound, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _initialState, Signer = _signer, @@ -236,7 +236,7 @@ public void Rehearsal() level = 1, collectionRound = 1, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = new MockStateDelta(), Signer = _signer, diff --git a/.Lib9c.Tests/Action/MonsterCollect2Test.cs b/.Lib9c.Tests/Action/MonsterCollect2Test.cs index 94c9f6d5b..ecc6e1a89 100644 --- a/.Lib9c.Tests/Action/MonsterCollect2Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect2Test.cs @@ -17,7 +17,7 @@ public class MonsterCollect2Test { private readonly TableSheets _tableSheets; private readonly Address _signer; - private IAccountStateDelta _initialState; + private IAccount _initialState; public MonsterCollect2Test() { @@ -98,7 +98,7 @@ public void Execute(int? prevLevel, int level, long blockIndex, Type exc, int? e } else { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _initialState, Signer = _signer, @@ -162,7 +162,7 @@ public void Rehearsal() { level = 1, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = new MockStateDelta(), Signer = _signer, diff --git a/.Lib9c.Tests/Action/MonsterCollectTest.cs b/.Lib9c.Tests/Action/MonsterCollectTest.cs index ba6b82e58..01dd5efa0 100644 --- a/.Lib9c.Tests/Action/MonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/MonsterCollectTest.cs @@ -17,7 +17,7 @@ public class MonsterCollectTest { private readonly TableSheets _tableSheets; private readonly Address _signer; - private IAccountStateDelta _initialState; + private IAccount _initialState; public MonsterCollectTest() { @@ -99,7 +99,7 @@ public void Execute(int balance, int? prevLevel, int level, long blockIndex, Typ } else { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = _initialState, Signer = _signer, @@ -183,7 +183,7 @@ public void Rehearsal() { level = 1, }; - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = new MockStateDelta(), Signer = _signer, diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 742a15ddf..2db8e39ec 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -14,7 +14,7 @@ namespace Lib9c.Tests.Action public class PatchTableSheetTest { - private IAccountStateDelta _initialState; + private IAccount _initialState; public PatchTableSheetTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/PetEnhancement0Test.cs b/.Lib9c.Tests/Action/PetEnhancement0Test.cs index 5e245e879..9908f5dea 100644 --- a/.Lib9c.Tests/Action/PetEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/PetEnhancement0Test.cs @@ -20,8 +20,8 @@ public class PetEnhancement0Test { private readonly Address _agentAddr; private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly int _targetPetId; private readonly long _firstRoundStartBlockIndex; @@ -272,8 +272,8 @@ public void Execute_Throw_NotEnoughFungibleAssetValueException( mintAssets: false)); } - private static IAccountStateDelta Execute( - IAccountStateDelta prevStates, + private static IAccount Execute( + IAccount prevStates, long blockIndex, Address agentAddr, Address avatarAddr, diff --git a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs index 302d1d21d..d4233cc12 100644 --- a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs +++ b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs @@ -36,7 +36,7 @@ public void Execute(bool admin, bool includeNcg, Type exc) #pragma warning restore CS0618 } - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(Addresses.Admin, adminState.Serialize()); var action = new PrepareRewardAssets(poolAddress, assets); diff --git a/.Lib9c.Tests/Action/Raid1Test.cs b/.Lib9c.Tests/Action/Raid1Test.cs index e4036f326..21e50a7ee 100644 --- a/.Lib9c.Tests/Action/Raid1Test.cs +++ b/.Lib9c.Tests/Action/Raid1Test.cs @@ -113,7 +113,7 @@ long executeOffset var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -375,7 +375,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -527,7 +527,7 @@ public void Execute_Throw_ActionObsoletedException() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Raid2Test.cs b/.Lib9c.Tests/Action/Raid2Test.cs index 99f5ba8f8..f12f3dc35 100644 --- a/.Lib9c.Tests/Action/Raid2Test.cs +++ b/.Lib9c.Tests/Action/Raid2Test.cs @@ -116,7 +116,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -393,7 +393,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Raid3Test.cs b/.Lib9c.Tests/Action/Raid3Test.cs index eece78e4e..400705b17 100644 --- a/.Lib9c.Tests/Action/Raid3Test.cs +++ b/.Lib9c.Tests/Action/Raid3Test.cs @@ -117,7 +117,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -395,7 +395,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Raid4Test.cs b/.Lib9c.Tests/Action/Raid4Test.cs index 6fe6bc3c9..bac4860dd 100644 --- a/.Lib9c.Tests/Action/Raid4Test.cs +++ b/.Lib9c.Tests/Action/Raid4Test.cs @@ -136,7 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -436,7 +436,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -588,7 +588,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -630,7 +630,7 @@ public void Execute_With_Free_Crystal_Fee() Signer = _agentAddress, }; - IAccountStateDelta nextState; + IAccount nextState; var exception = Record.Exception(() => nextState = action.Execute(ctx)); Assert.Null(exception); } diff --git a/.Lib9c.Tests/Action/Raid5Test.cs b/.Lib9c.Tests/Action/Raid5Test.cs index ed9269b23..1d1b2b590 100644 --- a/.Lib9c.Tests/Action/Raid5Test.cs +++ b/.Lib9c.Tests/Action/Raid5Test.cs @@ -136,7 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -436,7 +436,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -590,7 +590,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -632,7 +632,7 @@ public void Execute_With_Free_Crystal_Fee() Signer = _agentAddress, }; - IAccountStateDelta nextState; + IAccount nextState; var exception = Record.Exception(() => nextState = action.Execute(ctx)); Assert.Null(exception); } diff --git a/.Lib9c.Tests/Action/Raid6Test.cs b/.Lib9c.Tests/Action/Raid6Test.cs index bc817441a..c26630b61 100644 --- a/.Lib9c.Tests/Action/Raid6Test.cs +++ b/.Lib9c.Tests/Action/Raid6Test.cs @@ -136,7 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -436,7 +436,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -590,7 +590,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new MockStateDelta() + IAccount state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -632,7 +632,7 @@ public void Execute_With_Free_Crystal_Fee() Signer = _agentAddress, }; - IAccountStateDelta nextState; + IAccount nextState; var exception = Record.Exception(() => nextState = action.Execute(ctx)); Assert.Null(exception); } diff --git a/.Lib9c.Tests/Action/RankingBattle0Test.cs b/.Lib9c.Tests/Action/RankingBattle0Test.cs index 12ca1b075..4c3cc9f13 100644 --- a/.Lib9c.Tests/Action/RankingBattle0Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle0Test.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Action public class RankingBattle0Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RankingBattle10Test.cs b/.Lib9c.Tests/Action/RankingBattle10Test.cs index 2d5fc8cf3..ba8d32c97 100644 --- a/.Lib9c.Tests/Action/RankingBattle10Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle10Test.cs @@ -27,7 +27,7 @@ public class RankingBattle10Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle10Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle11Test.cs b/.Lib9c.Tests/Action/RankingBattle11Test.cs index 1f8e556a1..c640d8ef0 100644 --- a/.Lib9c.Tests/Action/RankingBattle11Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle11Test.cs @@ -29,7 +29,7 @@ public class RankingBattle11Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private IValue _arenaSheetState; public RankingBattle11Test(ITestOutputHelper outputHelper) diff --git a/.Lib9c.Tests/Action/RankingBattle2Test.cs b/.Lib9c.Tests/Action/RankingBattle2Test.cs index ff0c3f2cf..f2359dd09 100644 --- a/.Lib9c.Tests/Action/RankingBattle2Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle2Test.cs @@ -25,7 +25,7 @@ public class RankingBattle2Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private IAccountStateDelta _initialState; + private IAccount _initialState; public RankingBattle2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle3Test.cs b/.Lib9c.Tests/Action/RankingBattle3Test.cs index 0fa4577de..ef102d761 100644 --- a/.Lib9c.Tests/Action/RankingBattle3Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle3Test.cs @@ -25,7 +25,7 @@ public class RankingBattle3Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private IAccountStateDelta _initialState; + private IAccount _initialState; public RankingBattle3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle4Test.cs b/.Lib9c.Tests/Action/RankingBattle4Test.cs index e8c14deed..d3c8f556b 100644 --- a/.Lib9c.Tests/Action/RankingBattle4Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle4Test.cs @@ -26,7 +26,7 @@ public class RankingBattle4Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle5Test.cs b/.Lib9c.Tests/Action/RankingBattle5Test.cs index 45835afc6..c835c3ab1 100644 --- a/.Lib9c.Tests/Action/RankingBattle5Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle5Test.cs @@ -28,7 +28,7 @@ public class RankingBattle5Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle5Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle6Test.cs b/.Lib9c.Tests/Action/RankingBattle6Test.cs index f272cb2ef..ceaf70fae 100644 --- a/.Lib9c.Tests/Action/RankingBattle6Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle6Test.cs @@ -28,7 +28,7 @@ public class RankingBattle6Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle6Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle7Test.cs b/.Lib9c.Tests/Action/RankingBattle7Test.cs index 561f1d1c6..bb40f38cd 100644 --- a/.Lib9c.Tests/Action/RankingBattle7Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle7Test.cs @@ -28,7 +28,7 @@ public class RankingBattle7Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle7Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle8Test.cs b/.Lib9c.Tests/Action/RankingBattle8Test.cs index 42e039490..f788da8d4 100644 --- a/.Lib9c.Tests/Action/RankingBattle8Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle8Test.cs @@ -29,7 +29,7 @@ public class RankingBattle8Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle8Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattle9Test.cs b/.Lib9c.Tests/Action/RankingBattle9Test.cs index 0508acc62..111f9629e 100644 --- a/.Lib9c.Tests/Action/RankingBattle9Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle9Test.cs @@ -29,7 +29,7 @@ public class RankingBattle9Test private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattle9Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RankingBattleTest.cs b/.Lib9c.Tests/Action/RankingBattleTest.cs index f17badd6a..e52953158 100644 --- a/.Lib9c.Tests/Action/RankingBattleTest.cs +++ b/.Lib9c.Tests/Action/RankingBattleTest.cs @@ -25,7 +25,7 @@ public class RankingBattleTest private readonly Address _avatar1Address; private readonly Address _avatar2Address; private readonly Address _weeklyArenaAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public RankingBattleTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RapidCombination0Test.cs b/.Lib9c.Tests/Action/RapidCombination0Test.cs index 6803a989b..18ea74c1e 100644 --- a/.Lib9c.Tests/Action/RapidCombination0Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination0Test.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class RapidCombination0Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination2Test.cs b/.Lib9c.Tests/Action/RapidCombination2Test.cs index f90b9adbf..d0af9767c 100644 --- a/.Lib9c.Tests/Action/RapidCombination2Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination2Test.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class RapidCombination2Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination3Test.cs b/.Lib9c.Tests/Action/RapidCombination3Test.cs index c6d46c539..f0cadf4c7 100644 --- a/.Lib9c.Tests/Action/RapidCombination3Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination3Test.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class RapidCombination3Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination4Test.cs b/.Lib9c.Tests/Action/RapidCombination4Test.cs index 27ef87e61..6549a3b90 100644 --- a/.Lib9c.Tests/Action/RapidCombination4Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination4Test.cs @@ -20,7 +20,7 @@ public class RapidCombination4Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination5Test.cs b/.Lib9c.Tests/Action/RapidCombination5Test.cs index f60d9bdc3..8f6504c3c 100644 --- a/.Lib9c.Tests/Action/RapidCombination5Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination5Test.cs @@ -20,7 +20,7 @@ namespace Lib9c.Tests.Action public class RapidCombination5Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination6Test.cs b/.Lib9c.Tests/Action/RapidCombination6Test.cs index a1172cb4b..ce6c7365a 100644 --- a/.Lib9c.Tests/Action/RapidCombination6Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination6Test.cs @@ -22,7 +22,7 @@ namespace Lib9c.Tests.Action public class RapidCombination6Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination7Test.cs b/.Lib9c.Tests/Action/RapidCombination7Test.cs index d61a794d2..2ce549267 100644 --- a/.Lib9c.Tests/Action/RapidCombination7Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination7Test.cs @@ -22,7 +22,7 @@ namespace Lib9c.Tests.Action public class RapidCombination7Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombination8Test.cs b/.Lib9c.Tests/Action/RapidCombination8Test.cs index a0fdb3cc4..1a5acf2ac 100644 --- a/.Lib9c.Tests/Action/RapidCombination8Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination8Test.cs @@ -22,7 +22,7 @@ namespace Lib9c.Tests.Action public class RapidCombination8Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/RapidCombinationTest.cs b/.Lib9c.Tests/Action/RapidCombinationTest.cs index 6182af6ed..c973ff132 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest.cs @@ -22,7 +22,7 @@ namespace Lib9c.Tests.Action public class RapidCombinationTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs index 95eed5bbb..7a1131dd6 100644 --- a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs @@ -30,7 +30,7 @@ public class ReRegisterProduct0Test private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly GameConfigState _gameConfigState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ReRegisterProduct0Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index e9c58dee1..446bf0779 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -30,7 +30,7 @@ public class ReRegisterProductTest private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; private readonly GameConfigState _gameConfigState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public ReRegisterProductTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/RedeemCode0Test.cs b/.Lib9c.Tests/Action/RedeemCode0Test.cs index aa2cf206c..a957b5ca2 100644 --- a/.Lib9c.Tests/Action/RedeemCode0Test.cs +++ b/.Lib9c.Tests/Action/RedeemCode0Test.cs @@ -88,7 +88,7 @@ public void Execute() _avatarAddress ); - IAccountStateDelta nextState = redeemCode.Execute(new ActionContext() + IAccount nextState = redeemCode.Execute(new ActionContext() { BlockIndex = 1, Miner = default, @@ -121,7 +121,7 @@ public void Rehearsal() _avatarAddress ); - IAccountStateDelta nextState = redeemCode.Execute(new ActionContext() + IAccount nextState = redeemCode.Execute(new ActionContext() { BlockIndex = 1, Miner = default, diff --git a/.Lib9c.Tests/Action/RedeemCodeTest.cs b/.Lib9c.Tests/Action/RedeemCodeTest.cs index 0820e7be5..9aa536a3c 100644 --- a/.Lib9c.Tests/Action/RedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/RedeemCodeTest.cs @@ -103,7 +103,7 @@ public void Execute(bool backward) _avatarAddress ); - IAccountStateDelta nextState = redeemCode.Execute(new ActionContext() + IAccount nextState = redeemCode.Execute(new ActionContext() { BlockIndex = 1, Miner = default, @@ -136,7 +136,7 @@ public void Rehearsal() _avatarAddress ); - IAccountStateDelta nextState = redeemCode.Execute(new ActionContext() + IAccount nextState = redeemCode.Execute(new ActionContext() { BlockIndex = 1, Miner = default, diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index affe9346f..22810d021 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -30,7 +30,7 @@ public class RegisterProduct0Test private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GameConfigState _gameConfigState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public RegisterProduct0Test() { diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 90be45ec6..0b327f8d0 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -30,7 +30,7 @@ public class RegisterProductTest private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GameConfigState _gameConfigState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public RegisterProductTest() { diff --git a/.Lib9c.Tests/Action/RenewAdminStateTest.cs b/.Lib9c.Tests/Action/RenewAdminStateTest.cs index 42e27c8ba..7113ec4dc 100644 --- a/.Lib9c.Tests/Action/RenewAdminStateTest.cs +++ b/.Lib9c.Tests/Action/RenewAdminStateTest.cs @@ -12,7 +12,7 @@ namespace Lib9c.Tests.Action public class RenewAdminStateTest { - private IAccountStateDelta _stateDelta; + private IAccount _stateDelta; private long _validUntil; private AdminState _adminState; private PrivateKey _adminPrivateKey; diff --git a/.Lib9c.Tests/Action/RequestPledgeTest.cs b/.Lib9c.Tests/Action/RequestPledgeTest.cs index 0b55a5c50..17ded3b8c 100644 --- a/.Lib9c.Tests/Action/RequestPledgeTest.cs +++ b/.Lib9c.Tests/Action/RequestPledgeTest.cs @@ -20,7 +20,7 @@ public void Execute(int contractedMead) Currency mead = Currencies.Mead; Address patron = new PrivateKey().ToAddress(); var context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta().MintAsset(context, patron, 2 * mead); + IAccount states = new MockStateDelta().MintAsset(context, patron, 2 * mead); var address = new PrivateKey().ToAddress(); var action = new RequestPledge { @@ -51,7 +51,7 @@ public void Execute_Throw_AlreadyContractedException() Address patron = new PrivateKey().ToAddress(); var address = new PrivateKey().ToAddress(); Address contractAddress = address.GetPledgeAddress(); - IAccountStateDelta states = new MockStateDelta().SetState(contractAddress, List.Empty); + IAccount states = new MockStateDelta().SetState(contractAddress, List.Empty); var action = new RequestPledge { AgentAddress = address, diff --git a/.Lib9c.Tests/Action/RewardGoldTest.cs b/.Lib9c.Tests/Action/RewardGoldTest.cs index 1144a8440..5eb6b1616 100644 --- a/.Lib9c.Tests/Action/RewardGoldTest.cs +++ b/.Lib9c.Tests/Action/RewardGoldTest.cs @@ -377,7 +377,7 @@ public void GoldDistributedEachAccount() PreviousState = _baseState, }; - IAccountStateDelta delta; + IAccount delta; // 제너시스에 받아야 할 돈들 검사 delta = action.GenesisGoldDistribution(ctx, _baseState); @@ -449,7 +449,7 @@ public void MiningReward() void AssertMinerReward(int blockIndex, string expected) { ctx.BlockIndex = blockIndex; - IAccountStateDelta delta = action.MinerReward(ctx, _baseState); + IAccount delta = action.MinerReward(ctx, _baseState); Assert.Equal(FungibleAssetValue.Parse(currency, expected), delta.GetBalance(miner, currency)); } @@ -569,7 +569,7 @@ public void TransferMead(int patronMead, int balance) var patronAddress = new PrivateKey().ToAddress(); var contractAddress = agentAddress.GetPledgeAddress(); IActionContext context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta() + IAccount states = new MockStateDelta() .MintAsset(context, patronAddress, patronMead * Currencies.Mead) .TransferAsset(context, patronAddress, agentAddress, 1 * Currencies.Mead) .SetState(contractAddress, List.Empty.Add(patronAddress.Serialize()).Add(true.Serialize()).Add(balance.Serialize())) diff --git a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs index 484ab70d4..d3a9c06ae 100644 --- a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs @@ -28,7 +28,7 @@ public class ArenaScenarioTest private readonly Currency _ncg; private TableSheets _tableSheets; private Dictionary _sheets; - private IAccountStateDelta _state; + private IAccount _state; public ArenaScenarioTest(ITestOutputHelper outputHelper) { @@ -92,7 +92,7 @@ public ArenaScenarioTest(ITestOutputHelper outputHelper) return (equipments, costumes); } - public IAccountStateDelta JoinArena( + public IAccount JoinArena( IActionContext context, IRandom random, Address signer, @@ -122,7 +122,7 @@ public IAccountStateDelta JoinArena( return _state; } - public IAccountStateDelta BattleArena( + public IAccount BattleArena( IRandom random, Address signer, Address myAvatarAddress, diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index f8864e1cc..a104777eb 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -27,7 +27,7 @@ public class AuraScenarioTest private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly Address _enemyAvatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Aura _aura; private readonly TableSheets _tableSheets; private readonly Currency _currency; @@ -338,7 +338,7 @@ public void Market() })); } - private void Assert_Player(AvatarState avatarState, IAccountStateDelta state, Address avatarAddress, Address itemSlotStateAddress) + private void Assert_Player(AvatarState avatarState, IAccount state, Address avatarAddress, Address itemSlotStateAddress) { var nextAvatarState = state.GetAvatarStateV2(avatarAddress); var equippedItem = Assert.IsType(nextAvatarState.inventory.Equipments.First()); @@ -358,7 +358,7 @@ private void Assert_Equipments(IEnumerable equipments) Assert.Equal(_aura.ItemId, equipmentId); } - private ItemSlotState Assert_ItemSlot(IAccountStateDelta state, Address itemSlotStateAddress) + private ItemSlotState Assert_ItemSlot(IAccount state, Address itemSlotStateAddress) { var rawItemSlot = Assert.IsType(state.GetState(itemSlotStateAddress)); var itemSlotState = new ItemSlotState(rawItemSlot); diff --git a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs index 10b46a079..1de62f489 100644 --- a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs @@ -19,7 +19,7 @@ public class CombinationAndRapidCombinationTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly TableSheets _tableSheets; private Address _agentAddress; private Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs b/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs index 704e0c4ac..6e3d994bb 100644 --- a/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs @@ -26,8 +26,8 @@ public class ItemCraftTest private readonly Address _avatarAddr; private readonly Address _inventoryAddr; private readonly Address _worldInformationAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly TableSheets _tableSheets; public ItemCraftTest() diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index 57f7d3213..c0013b6e4 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -35,7 +35,7 @@ public class MarketScenarioTest private readonly TableSheets _tableSheets; private readonly Currency _currency; private readonly GameConfigState _gameConfigState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public MarketScenarioTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs index 9b14fd448..ee91aca9e 100644 --- a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs @@ -19,7 +19,7 @@ public void Contract() Currency mead = Currencies.Mead; var patron = new PrivateKey().ToAddress(); IActionContext context = new ActionContext(); - IAccountStateDelta states = new MockStateDelta().MintAsset(context, patron, 10 * mead); + IAccount states = new MockStateDelta().MintAsset(context, patron, 10 * mead); var agentAddress = new PrivateKey().ToAddress(); var requestPledge = new RequestPledge @@ -103,7 +103,7 @@ bool IsTarget(Type type) } } - private IAccountStateDelta Execute(IActionContext context, IAccountStateDelta state, IAction action, Address signer) + private IAccount Execute(IActionContext context, IAccount state, IAction action, Address signer) { Assert.True(state.GetBalance(signer, Currencies.Mead) > 0 * Currencies.Mead); var nextState = state.BurnAsset(context, signer, 1 * Currencies.Mead); diff --git a/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs index 3335e5e42..43531f9b2 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs @@ -25,8 +25,8 @@ private const PetOptionType PetOptionType private readonly TableSheets _tableSheets; private readonly Address _agentAddr; private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStateV1; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV1; + private readonly IAccount _initialStateV2; private readonly Address _inventoryAddr; private readonly Address _worldInfoAddr; private readonly Address _recipeAddr; diff --git a/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs index f84e3c406..38cfe804b 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs @@ -21,8 +21,8 @@ public class CommonTest private readonly Address _avatarAddr; private readonly Address _recipeAddr; private readonly Address _worldInfoAddr; - private readonly IAccountStateDelta _initialStateV1; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV1; + private readonly IAccount _initialStateV2; public CommonTest() { diff --git a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs index 8a2af5a8a..8aa4d0e82 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs @@ -26,7 +26,7 @@ public class DiscountMaterialCostCrystalTest private readonly Address _avatarAddr; private readonly Address _inventoryAddr; private readonly Address _worldInformationAddr; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV2; private readonly TableSheets _tableSheets; private int? _petId; diff --git a/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs index 9a51864a5..b65b4776c 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs @@ -28,8 +28,8 @@ public class IncreaseBlockPerHourglassTest private readonly Address _inventoryAddr; private readonly Address _worldInfoAddr; private readonly Address _recipeIdsAddr; - private readonly IAccountStateDelta _initialStateV1; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV1; + private readonly IAccount _initialStateV2; private readonly TableSheets _tableSheets; private readonly int _hourglassItemId; private int? _petId; diff --git a/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs index cd1b0ee19..a4913fade 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs @@ -26,8 +26,8 @@ public class ReduceRequiredBlockTest private readonly TableSheets _tableSheets; private readonly Address _agentAddr; private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStateV1; - private readonly IAccountStateDelta _initialStateV2; + private readonly IAccount _initialStateV1; + private readonly IAccount _initialStateV2; private readonly Address _inventoryAddr; private readonly Address _worldInfoAddr; private readonly Address _recipeAddr; diff --git a/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs b/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs index 7015f39ad..b1799613b 100644 --- a/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs @@ -21,8 +21,8 @@ public class RapidCombinationTest private readonly Address _avatarAddr; private readonly Address _inventoryAddr; private readonly Address _worldInformationAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV1; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly TableSheets _tableSheets; private readonly int _hourGlassItemId; diff --git a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs index e86aeed06..358b25859 100644 --- a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs @@ -39,7 +39,7 @@ public void Craft_And_Equip() ); var context = new ActionContext(); - IAccountStateDelta initialState = new Tests.Action.MockStateDelta() + IAccount initialState = new Tests.Action.MockStateDelta() .SetState(agentAddress, agentState.Serialize()) .SetState(avatarAddress, avatarState.SerializeV2()) .SetState( diff --git a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs index d76c806ed..ab301ef9a 100644 --- a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs +++ b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs @@ -22,7 +22,7 @@ public class SellAndCancellationAndSellTest private readonly TableSheets _tableSheets; private readonly Address _agentAddress; private readonly Address _avatarAddress; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public SellAndCancellationAndSellTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs index 50e73eed0..afdcabf9c 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action.Scenario public class StakeAndClaimStakeReward2ScenarioTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Currency _currency; private readonly GoldCurrencyState _goldCurrencyState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs index f7e5ee937..deb89eb38 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs @@ -18,7 +18,7 @@ public class StakeAndClaimStakeReward3ScenarioTest { private readonly Address _agentAddr; private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public StakeAndClaimStakeReward3ScenarioTest(ITestOutputHelper outputHelper) diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs index ec8674b2f..dcd12637b 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs @@ -19,7 +19,7 @@ public class StakeAndClaimStakeRewardScenarioTest private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; - private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; + private readonly IAccount _initialStatesWithAvatarStateV2; private readonly Currency _ncg; public StakeAndClaimStakeRewardScenarioTest(ITestOutputHelper outputHelper) diff --git a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs index 31d7c0a99..0da7610c1 100644 --- a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs @@ -17,7 +17,7 @@ namespace Lib9c.Tests.Action.Scenario public class WorldUnlockScenarioTest { private TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; private Address _agentAddress; private Address _avatarAddress; private Address _rankingMapAddress; diff --git a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs index 606a05950..215b7e8ed 100644 --- a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs +++ b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs @@ -46,7 +46,7 @@ public class SecureMiningRewardTest public void Execute() { var action = new SecureMiningReward(recipient: _recipient); - IAccountStateDelta nextState = action.Execute( + IAccount nextState = action.Execute( new ActionContext { PreviousState = _previousState, diff --git a/.Lib9c.Tests/Action/Sell0Test.cs b/.Lib9c.Tests/Action/Sell0Test.cs index 0ddab8694..6ee65a8c7 100644 --- a/.Lib9c.Tests/Action/Sell0Test.cs +++ b/.Lib9c.Tests/Action/Sell0Test.cs @@ -21,7 +21,7 @@ public class Sell0Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell0Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell10Test.cs b/.Lib9c.Tests/Action/Sell10Test.cs index 5360a8d10..162392eb9 100644 --- a/.Lib9c.Tests/Action/Sell10Test.cs +++ b/.Lib9c.Tests/Action/Sell10Test.cs @@ -29,7 +29,7 @@ public class Sell10Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell10Test(ITestOutputHelper outputHelper) { @@ -391,7 +391,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/Sell11Test.cs b/.Lib9c.Tests/Action/Sell11Test.cs index 9049597dd..74d6458ae 100644 --- a/.Lib9c.Tests/Action/Sell11Test.cs +++ b/.Lib9c.Tests/Action/Sell11Test.cs @@ -29,7 +29,7 @@ public class Sell11Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell11Test(ITestOutputHelper outputHelper) { @@ -439,7 +439,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/Sell2Test.cs b/.Lib9c.Tests/Action/Sell2Test.cs index 777e5b8d8..cf48423f2 100644 --- a/.Lib9c.Tests/Action/Sell2Test.cs +++ b/.Lib9c.Tests/Action/Sell2Test.cs @@ -21,7 +21,7 @@ public class Sell2Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell3Test.cs b/.Lib9c.Tests/Action/Sell3Test.cs index 783c28936..a18adc4ad 100644 --- a/.Lib9c.Tests/Action/Sell3Test.cs +++ b/.Lib9c.Tests/Action/Sell3Test.cs @@ -23,7 +23,7 @@ public class Sell3Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell4Test.cs b/.Lib9c.Tests/Action/Sell4Test.cs index 60ad5026a..30eca9597 100644 --- a/.Lib9c.Tests/Action/Sell4Test.cs +++ b/.Lib9c.Tests/Action/Sell4Test.cs @@ -26,7 +26,7 @@ public class Sell4Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell5Test.cs b/.Lib9c.Tests/Action/Sell5Test.cs index 4302a6271..960d46cdc 100644 --- a/.Lib9c.Tests/Action/Sell5Test.cs +++ b/.Lib9c.Tests/Action/Sell5Test.cs @@ -25,7 +25,7 @@ public class Sell5Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell5Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell6Test.cs b/.Lib9c.Tests/Action/Sell6Test.cs index b3392ca0d..6a6a18bd7 100644 --- a/.Lib9c.Tests/Action/Sell6Test.cs +++ b/.Lib9c.Tests/Action/Sell6Test.cs @@ -25,7 +25,7 @@ public class Sell6Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell6Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/Sell7Test.cs b/.Lib9c.Tests/Action/Sell7Test.cs index f68ea63e8..29f00c37f 100644 --- a/.Lib9c.Tests/Action/Sell7Test.cs +++ b/.Lib9c.Tests/Action/Sell7Test.cs @@ -29,7 +29,7 @@ public class Sell7Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell7Test(ITestOutputHelper outputHelper) { @@ -414,7 +414,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/Sell8Test.cs b/.Lib9c.Tests/Action/Sell8Test.cs index ab8669a9e..5d057aee4 100644 --- a/.Lib9c.Tests/Action/Sell8Test.cs +++ b/.Lib9c.Tests/Action/Sell8Test.cs @@ -29,7 +29,7 @@ public class Sell8Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell8Test(ITestOutputHelper outputHelper) { @@ -407,7 +407,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/Sell9Test.cs b/.Lib9c.Tests/Action/Sell9Test.cs index 681fbdb7f..6f076247f 100644 --- a/.Lib9c.Tests/Action/Sell9Test.cs +++ b/.Lib9c.Tests/Action/Sell9Test.cs @@ -29,7 +29,7 @@ public class Sell9Test private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public Sell9Test(ITestOutputHelper outputHelper) { @@ -391,7 +391,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/SellCancellation0Test.cs b/.Lib9c.Tests/Action/SellCancellation0Test.cs index 9c8a4ba1b..e30612876 100644 --- a/.Lib9c.Tests/Action/SellCancellation0Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation0Test.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Action public class SellCancellation0Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/SellCancellation2Test.cs b/.Lib9c.Tests/Action/SellCancellation2Test.cs index c84b29449..491fced58 100644 --- a/.Lib9c.Tests/Action/SellCancellation2Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation2Test.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class SellCancellation2Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/SellCancellation3Test.cs b/.Lib9c.Tests/Action/SellCancellation3Test.cs index c6eab1a28..1e016ab0f 100644 --- a/.Lib9c.Tests/Action/SellCancellation3Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation3Test.cs @@ -16,7 +16,7 @@ public class SellCancellation3Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/SellCancellation4Test.cs b/.Lib9c.Tests/Action/SellCancellation4Test.cs index 547f01426..ecc78d0f5 100644 --- a/.Lib9c.Tests/Action/SellCancellation4Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation4Test.cs @@ -16,7 +16,7 @@ public class SellCancellation4Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; diff --git a/.Lib9c.Tests/Action/SellCancellation5Test.cs b/.Lib9c.Tests/Action/SellCancellation5Test.cs index 08ab84ac7..8ffd94b88 100644 --- a/.Lib9c.Tests/Action/SellCancellation5Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation5Test.cs @@ -18,7 +18,7 @@ namespace Lib9c.Tests.Action public class SellCancellation5Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; @@ -143,7 +143,7 @@ public void Execute(ItemType itemType, string guid, bool contain) Assert.Equal(requiredBlockIndex, nonFungibleItem.RequiredBlockIndex); Assert.Equal(contain, avatarState.inventory.TryGetNonFungibleItem(itemId, out _)); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(Addresses.Shop, legacyShopState.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -206,7 +206,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() ), }; - IAccountStateDelta prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); + IAccount prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); var action = new SellCancellation5 { @@ -242,7 +242,7 @@ public void Execute_Throw_ItemDoesNotExistException() Sell6.ExpiredBlockIndex, (ITradableItem)itemUsable); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation5 @@ -282,7 +282,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() (ITradableItem)itemUsable); shopState.Register(shopItem); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation5 @@ -322,7 +322,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() (ITradableItem)itemUsable); shopState.Register(shopItem); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation5 diff --git a/.Lib9c.Tests/Action/SellCancellation6Test.cs b/.Lib9c.Tests/Action/SellCancellation6Test.cs index ce6bd97ae..f19cdc378 100644 --- a/.Lib9c.Tests/Action/SellCancellation6Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation6Test.cs @@ -20,7 +20,7 @@ namespace Lib9c.Tests.Action public class SellCancellation6Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; @@ -178,7 +178,7 @@ public void Execute(ItemType itemType, string guid, bool contain, int itemCount, avatarState.inventory.TryGetTradableItems(itemId, requiredBlockIndex, itemCount, out _) ); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(Addresses.Shop, legacyShopState.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -259,7 +259,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() ), }; - IAccountStateDelta prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); + IAccount prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); var action = new SellCancellation6 { @@ -327,7 +327,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) Sell6.ExpiredBlockIndex, tradableItem); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation6 @@ -368,7 +368,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() (ITradableItem)itemUsable); shopState.Register(shopItem); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation6 @@ -408,7 +408,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() (ITradableItem)itemUsable); shopState.Register(shopItem); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(shardedShopAddress, shopState.Serialize()); var action = new SellCancellation6 diff --git a/.Lib9c.Tests/Action/SellCancellation7Test.cs b/.Lib9c.Tests/Action/SellCancellation7Test.cs index e0cb57252..31e96ef70 100644 --- a/.Lib9c.Tests/Action/SellCancellation7Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation7Test.cs @@ -23,7 +23,7 @@ public class SellCancellation7Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; @@ -163,7 +163,7 @@ bool backward avatarState.mailBox.Add(expirationMail); var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); - IAccountStateDelta prevState = _initialState; + IAccount prevState = _initialState; if (inventoryCount > 1) { @@ -298,7 +298,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() ), }; - IAccountStateDelta prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); + IAccount prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); var action = new SellCancellation7 { @@ -369,7 +369,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) 1 ); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -430,7 +430,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use ); shopState.Add(orderDigest, 0); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); diff --git a/.Lib9c.Tests/Action/SellCancellation8Test.cs b/.Lib9c.Tests/Action/SellCancellation8Test.cs index 5411e0706..f4d1e12c0 100644 --- a/.Lib9c.Tests/Action/SellCancellation8Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation8Test.cs @@ -23,7 +23,7 @@ public class SellCancellation8Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; @@ -163,7 +163,7 @@ bool fromPreviousAction avatarState.mailBox.Add(expirationMail); var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); - IAccountStateDelta prevState = _initialState; + IAccount prevState = _initialState; if (inventoryCount > 1) { @@ -301,7 +301,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() ), }; - IAccountStateDelta prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); + IAccount prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); var action = new SellCancellation8 { @@ -386,7 +386,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); orderDigestList.Add(orderDigest); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(orderDigestList.Address, orderDigestList.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -450,7 +450,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); orderDigestList.Add(orderDigest); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(orderDigestList.Address, orderDigestList.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -608,7 +608,7 @@ bool fromPreviousAction avatarState.mailBox.Add(expirationMail); var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); - IAccountStateDelta prevState = _initialState; + IAccount prevState = _initialState; if (inventoryCount > 1) { diff --git a/.Lib9c.Tests/Action/SellCancellationTest.cs b/.Lib9c.Tests/Action/SellCancellationTest.cs index 4f62d0c25..f3d5fbdc1 100644 --- a/.Lib9c.Tests/Action/SellCancellationTest.cs +++ b/.Lib9c.Tests/Action/SellCancellationTest.cs @@ -24,7 +24,7 @@ namespace Lib9c.Tests.Action public class SellCancellationTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Address _agentAddress; private readonly Address _avatarAddress; private readonly GoldCurrencyState _goldCurrencyState; @@ -167,7 +167,7 @@ bool fromPreviousAction avatarState.mailBox.Add(expirationMail); var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); - IAccountStateDelta prevState = _initialState; + IAccount prevState = _initialState; if (inventoryCount > 1) { @@ -336,7 +336,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() ), }; - IAccountStateDelta prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); + IAccount prevState = _initialState.SetState(_avatarAddress, avatarState.Serialize()); var action = new SellCancellation { @@ -421,7 +421,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); orderDigestList.Add(orderDigest); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(orderDigestList.Address, orderDigestList.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -485,7 +485,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); orderDigestList.Add(orderDigest); - IAccountStateDelta prevState = _initialState + IAccount prevState = _initialState .SetState(Order.DeriveAddress(orderId), order.Serialize()) .SetState(orderDigestList.Address, orderDigestList.Serialize()) .SetState(shardedShopAddress, shopState.Serialize()); @@ -643,7 +643,7 @@ bool fromPreviousAction avatarState.mailBox.Add(expirationMail); var orderDigestList = new OrderDigestListState(OrderDigestListState.DeriveAddress(_avatarAddress)); - IAccountStateDelta prevState = _initialState; + IAccount prevState = _initialState; if (inventoryCount > 1) { diff --git a/.Lib9c.Tests/Action/SellTest.cs b/.Lib9c.Tests/Action/SellTest.cs index 5285c766a..c21c94249 100644 --- a/.Lib9c.Tests/Action/SellTest.cs +++ b/.Lib9c.Tests/Action/SellTest.cs @@ -28,7 +28,7 @@ public class SellTest private readonly Currency _currency; private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; - private IAccountStateDelta _initialState; + private IAccount _initialState; public SellTest(ITestOutputHelper outputHelper) { @@ -438,7 +438,7 @@ public void Execute_Throw_DuplicateOrderIdException() shardedShopState.Add(order.Digest2(avatarState, _tableSheets.CostumeStatSheet), 1); Assert.Single(shardedShopState.OrderDigestList); - IAccountStateDelta previousStates = _initialState + IAccount previousStates = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(shardedShopAddress, shardedShopState.Serialize()); diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index 81d7a606f..2c99e2cc3 100644 --- a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs +++ b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs @@ -49,7 +49,7 @@ public Task TransferCrystal() var recipientAddress = recipientPrivateKey.ToAddress(); var crystal = CrystalCalculator.CRYSTAL; var context = new ActionContext(); - IAccountStateDelta state = new MockStateDelta().MintAsset(context, senderAddress, crystal * 100); + IAccount state = new MockStateDelta().MintAsset(context, senderAddress, crystal * 100); var actionContext = new ActionContext { Signer = senderAddress, diff --git a/.Lib9c.Tests/Action/Stake0Test.cs b/.Lib9c.Tests/Action/Stake0Test.cs index 23efedd5d..1ed4077cf 100644 --- a/.Lib9c.Tests/Action/Stake0Test.cs +++ b/.Lib9c.Tests/Action/Stake0Test.cs @@ -14,7 +14,7 @@ namespace Lib9c.Tests.Action public class Stake0Test { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Currency _currency; private readonly GoldCurrencyState _goldCurrencyState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index a195d9c41..64b1fe102 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -14,7 +14,7 @@ namespace Lib9c.Tests.Action public class StakeTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Currency _currency; private readonly GoldCurrencyState _goldCurrencyState; private readonly TableSheets _tableSheets; diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index 0887201a5..febbf7e29 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -57,7 +57,7 @@ public void Execute() recipient: _recipient, amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -263,7 +263,7 @@ public void Rehearsal() amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index bb8eecc58..03d0f550a 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -83,7 +83,7 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) recipient: _recipient, amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -286,7 +286,7 @@ public void Rehearsal() amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index 08499d420..c9547e6ba 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -59,7 +59,7 @@ public void Execute() recipient: _recipient, amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -207,7 +207,7 @@ public void Rehearsal() ); var context = new ActionContext(); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta().MintAsset(context, _sender, Currencies.Mead * 1), Signer = default, diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 050aea169..23c3bb935 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -55,7 +55,7 @@ public void Execute() recipient: _recipient, amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -232,7 +232,7 @@ public void Rehearsal() amount: _currency * 100 ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index 8057fce51..9e84cb2e4 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -107,7 +107,7 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) (_recipient2, _currency * 100), } ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -322,7 +322,7 @@ public void Rehearsal() } ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 8db9787ff..0fdfc8bf4 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -78,7 +78,7 @@ public void Execute() (_recipient2, _currency * 100), } ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = prevState, Signer = _sender, @@ -232,7 +232,7 @@ public void Rehearsal() } ); - IAccountStateDelta nextState = action.Execute(new ActionContext() + IAccount nextState = action.Execute(new ActionContext() { PreviousState = new MockStateDelta(), Signer = default, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs index 9580b950a..fb7dacfef 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs @@ -24,7 +24,7 @@ public class UnlockEquipmentRecipe1Test private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public UnlockEquipmentRecipe1Test() { @@ -140,7 +140,7 @@ Type exc if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = state, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs index 20faf57b1..1c3310a00 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs @@ -24,7 +24,7 @@ public class UnlockEquipmentRecipeTest private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public UnlockEquipmentRecipeTest() { @@ -140,7 +140,7 @@ Type exc if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = state, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs index 806b66bf5..b3bf1ec93 100644 --- a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs +++ b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs @@ -22,7 +22,7 @@ public UnlockRuneSlotTest() _goldCurrency = Currency.Legacy("NCG", 2, null); } - public IAccountStateDelta Init(out Address agentAddress, out Address avatarAddress, out long blockIndex) + public IAccount Init(out Address agentAddress, out Address avatarAddress, out long blockIndex) { agentAddress = new PrivateKey().ToAddress(); avatarAddress = new PrivateKey().ToAddress(); diff --git a/.Lib9c.Tests/Action/UnlockWorld1Test.cs b/.Lib9c.Tests/Action/UnlockWorld1Test.cs index a7c0855e7..e87bba249 100644 --- a/.Lib9c.Tests/Action/UnlockWorld1Test.cs +++ b/.Lib9c.Tests/Action/UnlockWorld1Test.cs @@ -25,7 +25,7 @@ public class UnlockWorld1Test private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public UnlockWorld1Test() { @@ -155,7 +155,7 @@ Type exc if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = state, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/UnlockWorldTest.cs b/.Lib9c.Tests/Action/UnlockWorldTest.cs index 49b6aae61..f50292dc1 100644 --- a/.Lib9c.Tests/Action/UnlockWorldTest.cs +++ b/.Lib9c.Tests/Action/UnlockWorldTest.cs @@ -25,7 +25,7 @@ public class UnlockWorldTest private readonly Address _avatarAddress; private readonly AvatarState _avatarState; private readonly Currency _currency; - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; public UnlockWorldTest() { @@ -157,7 +157,7 @@ Type exc if (exc is null) { - IAccountStateDelta nextState = action.Execute(new ActionContext + IAccount nextState = action.Execute(new ActionContext { PreviousState = state, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/UpdateSell0Test.cs b/.Lib9c.Tests/Action/UpdateSell0Test.cs index 0e1e29f7b..fcee931fb 100644 --- a/.Lib9c.Tests/Action/UpdateSell0Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell0Test.cs @@ -28,7 +28,7 @@ public class UpdateSell0Test private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public UpdateSell0Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/UpdateSell2Test.cs b/.Lib9c.Tests/Action/UpdateSell2Test.cs index 366121f52..7b8a8f526 100644 --- a/.Lib9c.Tests/Action/UpdateSell2Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell2Test.cs @@ -28,7 +28,7 @@ public class UpdateSell2Test private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public UpdateSell2Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/UpdateSell3Test.cs b/.Lib9c.Tests/Action/UpdateSell3Test.cs index 659e289f3..bcbdff219 100644 --- a/.Lib9c.Tests/Action/UpdateSell3Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell3Test.cs @@ -28,7 +28,7 @@ public class UpdateSell3Test private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public UpdateSell3Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/UpdateSell4Test.cs b/.Lib9c.Tests/Action/UpdateSell4Test.cs index d41643560..fdc919c6d 100644 --- a/.Lib9c.Tests/Action/UpdateSell4Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell4Test.cs @@ -28,7 +28,7 @@ public class UpdateSell4Test private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public UpdateSell4Test(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/UpdateSellTest.cs b/.Lib9c.Tests/Action/UpdateSellTest.cs index 276a1a8da..02ad6e5f0 100644 --- a/.Lib9c.Tests/Action/UpdateSellTest.cs +++ b/.Lib9c.Tests/Action/UpdateSellTest.cs @@ -28,7 +28,7 @@ public class UpdateSellTest private readonly AvatarState _avatarState; private readonly TableSheets _tableSheets; private readonly GoldCurrencyState _goldCurrencyState; - private IAccountStateDelta _initialState; + private IAccount _initialState; public UpdateSellTest(ITestOutputHelper outputHelper) { diff --git a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs index a7244fad9..c05bf87dc 100644 --- a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs +++ b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Action public class ValidatorSetOperateTest { - private readonly IAccountStateDelta _initialState; + private readonly IAccount _initialState; private readonly Validator _validator; public ValidatorSetOperateTest(ITestOutputHelper outputHelper) diff --git a/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs b/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs index c8858d98b..37296e539 100644 --- a/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs +++ b/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Extensions public class SheetsExtensionsTest { - private IAccountStateDelta _states; + private IAccount _states; private Dictionary _sheetNameAndFiles; private Dictionary _sheetsAddressAndValues; private Type[] _sheetTypes; @@ -55,7 +55,7 @@ public void GetSheet() } internal static void InitSheets( - IAccountStateDelta states, + IAccount states, out Dictionary sheetNameAndFiles, out Dictionary sheetsAddressAndValues, out Type[] sheetTypes, diff --git a/.Lib9c.Tests/TestHelper/MakeInitialStateResult.cs b/.Lib9c.Tests/TestHelper/MakeInitialStateResult.cs index 2d8e674fd..a95c768c0 100644 --- a/.Lib9c.Tests/TestHelper/MakeInitialStateResult.cs +++ b/.Lib9c.Tests/TestHelper/MakeInitialStateResult.cs @@ -8,7 +8,7 @@ namespace Lib9c.Tests.TestHelper public class MakeInitialStateResult { - private readonly IAccountStateDelta _state; + private readonly IAccount _state; private readonly CreateTestbed _testbed; private readonly AgentState _agentState; private readonly AvatarState _avatarState; @@ -19,7 +19,7 @@ public class MakeInitialStateResult private readonly FungibleAssetValue _currencyGold; public MakeInitialStateResult( - IAccountStateDelta state, + IAccount state, CreateTestbed testbed, AgentState agentState, AvatarState avatarState, @@ -40,7 +40,7 @@ public MakeInitialStateResult( _agentCurrencyGold = agentCurrencyGold; } - public IAccountStateDelta GetState() + public IAccount GetState() { return _state; } diff --git a/.Lib9c.Tests/Util/CraftUtil.cs b/.Lib9c.Tests/Util/CraftUtil.cs index 67147821c..dfe97b627 100644 --- a/.Lib9c.Tests/Util/CraftUtil.cs +++ b/.Lib9c.Tests/Util/CraftUtil.cs @@ -16,8 +16,8 @@ namespace Lib9c.Tests.Util public static class CraftUtil { - public static IAccountStateDelta PrepareCombinationSlot( - IAccountStateDelta state, + public static IAccount PrepareCombinationSlot( + IAccount state, Address avatarAddress, int slotIndex ) @@ -36,8 +36,8 @@ int slotIndex return state.SetState(slotAddress, slotState.Serialize()); } - public static IAccountStateDelta AddMaterialsToInventory( - IAccountStateDelta state, + public static IAccount AddMaterialsToInventory( + IAccount state, TableSheets tableSheets, Address avatarAddress, IEnumerable materialList, @@ -58,8 +58,8 @@ IRandom random ); } - public static IAccountStateDelta UnlockStage( - IAccountStateDelta state, + public static IAccount UnlockStage( + IAccount state, TableSheets tableSheets, Address worldInformationAddress, int stage diff --git a/.Lib9c.Tests/Util/CurrencyUtil.cs b/.Lib9c.Tests/Util/CurrencyUtil.cs index e17092418..6027142b1 100644 --- a/.Lib9c.Tests/Util/CurrencyUtil.cs +++ b/.Lib9c.Tests/Util/CurrencyUtil.cs @@ -7,9 +7,9 @@ namespace Lib9c.Tests.Util public static class CurrencyUtil { - public static IAccountStateDelta AddCurrency( + public static IAccount AddCurrency( IActionContext context, - IAccountStateDelta state, + IAccount state, Address agentAddress, Currency currency, FungibleAssetValue amount diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index 734fcfacb..b20bc0f96 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -17,8 +17,8 @@ public static ( TableSheets tableSheets, Address agentAddr, Address avatarAddr, - IAccountStateDelta initialStatesWithAvatarStateV1, - IAccountStateDelta initialStatesWithAvatarStateV2 + IAccount initialStatesWithAvatarStateV1, + IAccount initialStatesWithAvatarStateV2 ) InitializeStates( Address? adminAddr = null, Address? agentAddr = null, @@ -84,9 +84,9 @@ IAccountStateDelta initialStatesWithAvatarStateV2 initialStatesWithAvatarStateV2); } - private static (IAccountStateDelta states, Dictionary sheets) + private static (IAccount states, Dictionary sheets) InitializeTableSheets( - IAccountStateDelta states, + IAccount states, bool isDevEx = false, Dictionary sheetsOverride = null) { diff --git a/.Lib9c.Tests/Util/QuestUtil.cs b/.Lib9c.Tests/Util/QuestUtil.cs index 3062f25b2..e11c56293 100644 --- a/.Lib9c.Tests/Util/QuestUtil.cs +++ b/.Lib9c.Tests/Util/QuestUtil.cs @@ -8,9 +8,9 @@ namespace Lib9c.Tests.Util public static class QuestUtil { - public static (IAccountStateDelta, IAccountStateDelta) DisableQuestList( - IAccountStateDelta stateV1, - IAccountStateDelta stateV2, + public static (IAccount, IAccount) DisableQuestList( + IAccount stateV1, + IAccount stateV2, Address avatarAddress ) { diff --git a/.Lib9c.Tools/SubCommand/State.cs b/.Lib9c.Tools/SubCommand/State.cs index 25ae63536..fa09f90e3 100644 --- a/.Lib9c.Tools/SubCommand/State.cs +++ b/.Lib9c.Tools/SubCommand/State.cs @@ -450,7 +450,7 @@ private static ImmutableDictionary GetTotalDelta( .SelectMany(a => a.OutputState.Delta.UpdatedTotalSupplyCurrencies) .ToImmutableHashSet(); - IAccountStateDelta lastStates = actionEvaluations.Count > 0 + IAccount lastStates = actionEvaluations.Count > 0 ? actionEvaluations[actionEvaluations.Count - 1].OutputState : null; ImmutableDictionary totalDelta = diff --git a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs index 931e5f02a..b7485ceef 100644 --- a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs +++ b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs @@ -10,7 +10,7 @@ namespace Libplanet.Extensions.ActionEvaluatorCommonComponents; -public class AccountStateDelta : IAccountStateDelta +public class AccountStateDelta : IAccount { private IImmutableDictionary _states; private IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; @@ -128,7 +128,7 @@ public AccountStateDelta(byte[] bytes) public IReadOnlyList GetStates(IReadOnlyList
addresses) => addresses.Select(GetState).ToArray(); - public IAccountStateDelta SetState(Address address, IValue state) => + public IAccount SetState(Address address, IValue state) => new AccountStateDelta(_states.SetItem(address, state), _fungibles, _totalSupplies, _validatorSet); public FungibleAssetValue GetBalance(Address address, Currency currency) { @@ -160,7 +160,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) return BaseState.GetTotalSupply(currency); } - public IAccountStateDelta MintAsset( + public IAccount MintAsset( IActionContext context, Address recipient, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException @@ -214,7 +214,7 @@ public IAccountStateDelta MintAsset( }; } - public IAccountStateDelta TransferAsset( + public IAccount TransferAsset( IActionContext context, Address sender, Address recipient, @@ -248,7 +248,7 @@ public IAccountStateDelta TransferAsset( }; } - public IAccountStateDelta BurnAsset( + public IAccount BurnAsset( IActionContext context, Address owner, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException @@ -295,7 +295,7 @@ public ValidatorSet GetValidatorSet() return _validatorSet ?? BaseState.GetValidatorSet(); } - public IAccountStateDelta SetValidator(Validator validator) + public IAccount SetValidator(Validator validator) { return new AccountStateDelta( _states, diff --git a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDeltaMarshaller.cs b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDeltaMarshaller.cs index 20375ca89..ac9a354ca 100644 --- a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDeltaMarshaller.cs +++ b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDeltaMarshaller.cs @@ -8,12 +8,12 @@ public static class AccountStateDeltaMarshaller { private static readonly Codec Codec = new Codec(); - public static byte[] Serialize(this IAccountStateDelta value) + public static byte[] Serialize(this IAccount value) { return Codec.Encode(Marshal(value)); } - public static IEnumerable Marshal(IEnumerable stateDeltas) + public static IEnumerable Marshal(IEnumerable stateDeltas) { foreach (var stateDelta in stateDeltas) { @@ -22,7 +22,7 @@ public static IEnumerable Marshal(IEnumerable st } } - public static Dictionary Marshal(IAccountStateDelta stateDelta) + public static Dictionary Marshal(IAccount stateDelta) { var state = new Dictionary(stateDelta.Delta.States.Select( kv => new KeyValuePair( diff --git a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionContext.cs b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionContext.cs index 20c5ce953..9f87fc0d8 100644 --- a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionContext.cs +++ b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionContext.cs @@ -44,7 +44,7 @@ public ActionContext( public int BlockProtocolVersion { get; init; } public bool Rehearsal { get; init; } public AccountStateDelta PreviousState { get; init; } - IAccountStateDelta IActionContext.PreviousState => PreviousState; + IAccount IActionContext.PreviousState => PreviousState; public IRandom Random { get; init; } public HashDigest? PreviousStateRootHash { get; init; } public bool BlockAction { get; init; } diff --git a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionEvaluation.cs b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionEvaluation.cs index 0daefb29f..fe040f552 100644 --- a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionEvaluation.cs +++ b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/ActionEvaluation.cs @@ -22,6 +22,6 @@ public ActionEvaluation( public ActionContext InputContext { get; } IActionContext IActionEvaluation.InputContext => InputContext; public AccountStateDelta OutputState { get; } - IAccountStateDelta IActionEvaluation.OutputState => OutputState; + IAccount IActionEvaluation.OutputState => OutputState; public Exception? Exception { get; } } diff --git a/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs b/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs index 34fc2c26d..8adf7f651 100644 --- a/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs +++ b/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs @@ -23,7 +23,7 @@ public class UnlockCraftAction : GameAction public Address AvatarAddress { get; set; } public ActionTypeAttribute ActionType { get; set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs b/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs index 0595898e0..e02549225 100644 --- a/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs +++ b/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs @@ -18,7 +18,7 @@ public class UnlockRecipe : GameAction public Address AvatarAddress { get; set; } public int TargetStage { get; set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c.DevExtensions/Action/CreateArenaDummy.cs b/Lib9c.DevExtensions/Action/CreateArenaDummy.cs index 4ce182099..ea46bccca 100644 --- a/Lib9c.DevExtensions/Action/CreateArenaDummy.cs +++ b/Lib9c.DevExtensions/Action/CreateArenaDummy.cs @@ -53,7 +53,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue["equipments"]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs index 12448377a..cef36cc60 100644 --- a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs +++ b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs @@ -364,7 +364,7 @@ public CreateOrReplaceAvatar( CrystalRandomBuff = crystalRandomBuff; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -379,8 +379,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Signer); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, IRandom random, long blockIndex, Address signer) diff --git a/Lib9c.DevExtensions/Action/CreateTestbed.cs b/Lib9c.DevExtensions/Action/CreateTestbed.cs index c64c4918e..5978131dc 100644 --- a/Lib9c.DevExtensions/Action/CreateTestbed.cs +++ b/Lib9c.DevExtensions/Action/CreateTestbed.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( weeklyArenaAddress = plainValue["w"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var sellData = TestbedHelper.LoadData("TestbedSell"); diff --git a/Lib9c.DevExtensions/Action/FaucetCurrency.cs b/Lib9c.DevExtensions/Action/FaucetCurrency.cs index 4282854da..f3fe300fa 100644 --- a/Lib9c.DevExtensions/Action/FaucetCurrency.cs +++ b/Lib9c.DevExtensions/Action/FaucetCurrency.cs @@ -20,7 +20,7 @@ public class FaucetCurrency : GameAction, IFaucetCurrency public int FaucetNcg { get; set; } public int FaucetCrystal { get; set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c.DevExtensions/Action/FaucetRune.cs b/Lib9c.DevExtensions/Action/FaucetRune.cs index 3c62c6109..c913d0d38 100644 --- a/Lib9c.DevExtensions/Action/FaucetRune.cs +++ b/Lib9c.DevExtensions/Action/FaucetRune.cs @@ -22,7 +22,7 @@ public class FaucetRune : GameAction, IFaucetRune public Address AvatarAddress { get; set; } public List FaucetRuneInfos { get; set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c.DevExtensions/Action/ManipulateState.cs b/Lib9c.DevExtensions/Action/ManipulateState.cs index f56578c11..b746bf4cc 100644 --- a/Lib9c.DevExtensions/Action/ManipulateState.cs +++ b/Lib9c.DevExtensions/Action/ManipulateState.cs @@ -44,7 +44,7 @@ protected override void LoadPlainValueInternal( .ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -55,9 +55,9 @@ public override IAccountStateDelta Execute(IActionContext context) return Execute(context, context.PreviousState, StateList, BalanceList); } - public static IAccountStateDelta Execute( + public static IAccount Execute( IActionContext context, - IAccountStateDelta prevStates, + IAccount prevStates, List<(Address addr, IValue value)> stateList, List<(Address addr, FungibleAssetValue fav)> balanceList) { diff --git a/Lib9c.DevExtensions/Action/Stage/ClearStage.cs b/Lib9c.DevExtensions/Action/Stage/ClearStage.cs index 431b5efd7..62d68b236 100644 --- a/Lib9c.DevExtensions/Action/Stage/ClearStage.cs +++ b/Lib9c.DevExtensions/Action/Stage/ClearStage.cs @@ -20,7 +20,7 @@ public class ClearStage : GameAction public Address AvatarAddress { get; set; } public int TargetStage { get; set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c.MessagePack/AccountStateDelta.cs b/Lib9c.MessagePack/AccountStateDelta.cs index 0f716a71c..60fc978b4 100644 --- a/Lib9c.MessagePack/AccountStateDelta.cs +++ b/Lib9c.MessagePack/AccountStateDelta.cs @@ -13,7 +13,7 @@ namespace Lib9c.Formatters { - public struct AccountStateDelta : IAccountStateDelta + public struct AccountStateDelta : IAccount { private IImmutableDictionary _states; private IImmutableDictionary<(Address, Currency), BigInteger> _balances; @@ -73,7 +73,7 @@ public AccountStateDelta(byte[] bytes) public IReadOnlyList GetStates(IReadOnlyList
addresses) => addresses.Select(_states.GetValueOrDefault).ToArray(); - public IAccountStateDelta SetState(Address address, IValue state) => + public IAccount SetState(Address address, IValue state) => new AccountStateDelta(_states.SetItem(address, state), _balances, _totalSupplies); public FungibleAssetValue GetBalance(Address address, Currency currency) @@ -106,7 +106,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) return currency * 0; } - public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) + public IAccount MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException // 던지는 처리를 해야하는데 여기서 트랜잭션 서명자를 무슨 수로 가져올지 잘 모르겠음. @@ -151,7 +151,7 @@ public IAccountStateDelta MintAsset(IActionContext context, Address recipient, F ); } - public IAccountStateDelta TransferAsset( + public IAccount TransferAsset( IActionContext context, Address sender, Address recipient, @@ -182,7 +182,7 @@ public IAccountStateDelta TransferAsset( return new AccountStateDelta(_states, balances, _totalSupplies); } - public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) + public IAccount BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException // 던지는 처리를 해야하는데 여기서 트랜잭션 서명자를 무슨 수로 가져올지 잘 모르겠음. @@ -219,7 +219,7 @@ public IAccountStateDelta BurnAsset(IActionContext context, Address owner, Fungi ); } - public IAccountStateDelta SetValidator(Validator validator) + public IAccount SetValidator(Validator validator) { return new AccountStateDelta(); } diff --git a/Lib9c.MessagePack/Action/NCActionEvaluation.cs b/Lib9c.MessagePack/Action/NCActionEvaluation.cs index 237275f29..7be6f4de7 100644 --- a/Lib9c.MessagePack/Action/NCActionEvaluation.cs +++ b/Lib9c.MessagePack/Action/NCActionEvaluation.cs @@ -28,7 +28,7 @@ public struct NCActionEvaluation [Key(3)] [MessagePackFormatter(typeof(AccountStateDeltaFormatter))] - public IAccountStateDelta OutputState { get; set; } + public IAccount OutputState { get; set; } [Key(4)] [MessagePackFormatter(typeof(ExceptionFormatter))] @@ -36,7 +36,7 @@ public struct NCActionEvaluation [Key(5)] [MessagePackFormatter(typeof(AccountStateDeltaFormatter))] - public IAccountStateDelta PreviousState { get; set; } + public IAccount PreviousState { get; set; } [Key(6)] public int RandomSeed { get; set; } @@ -50,9 +50,9 @@ public NCActionEvaluation( ActionBase? action, Address signer, long blockIndex, - IAccountStateDelta outputStates, + IAccount outputStates, Exception? exception, - IAccountStateDelta previousStates, + IAccount previousStates, int randomSeed, Dictionary extra ) diff --git a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs index cf78a6136..107078807 100644 --- a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs +++ b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs @@ -10,9 +10,9 @@ namespace Lib9c.Formatters { - public class AccountStateDeltaFormatter : IMessagePackFormatter + public class AccountStateDeltaFormatter : IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, IAccountStateDelta value, + public void Serialize(ref MessagePackWriter writer, IAccount value, MessagePackSerializerOptions options) { var state = new Dictionary( @@ -49,14 +49,14 @@ public void Serialize(ref MessagePackWriter writer, IAccountStateDelta value, writer.Write(new Codec().Encode(bdict)); } - public IAccountStateDelta Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public IAccount Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { options.Security.DepthStep(ref reader); var bytes = reader.ReadBytes(); if (bytes is null) { - throw new NullReferenceException($"ReadBytes from serialized {nameof(IAccountStateDelta)} is null."); + throw new NullReferenceException($"ReadBytes from serialized {nameof(IAccount)} is null."); } return new AccountStateDelta(new Codec().Decode(bytes.Value.ToArray())); diff --git a/Lib9c.MessagePack/Formatters/NineChroniclesResolverGetFormatterHelper.cs b/Lib9c.MessagePack/Formatters/NineChroniclesResolverGetFormatterHelper.cs index bff06adcf..0a466d925 100644 --- a/Lib9c.MessagePack/Formatters/NineChroniclesResolverGetFormatterHelper.cs +++ b/Lib9c.MessagePack/Formatters/NineChroniclesResolverGetFormatterHelper.cs @@ -17,7 +17,7 @@ public static class NineChroniclesResolverGetFormatterHelper {typeof(Address), new AddressFormatter()}, {typeof(Exception), new ExceptionFormatter()}, {typeof(FungibleAssetValue), new FungibleAssetValueFormatter()}, - {typeof(IAccountStateDelta), new AccountStateDeltaFormatter()}, + {typeof(IAccount), new AccountStateDeltaFormatter()}, {typeof(PublicKey), new PublicKeyFormatter()}, {typeof(Dictionary), new BencodexFormatter()}, {typeof(IValue), new BencodexFormatter()}, diff --git a/Lib9c.Renderers/ActionEvaluation.cs b/Lib9c.Renderers/ActionEvaluation.cs index 67592b1ba..d081045cc 100644 --- a/Lib9c.Renderers/ActionEvaluation.cs +++ b/Lib9c.Renderers/ActionEvaluation.cs @@ -19,11 +19,11 @@ public struct ActionEvaluation public TxId? TxId { get; set; } - public IAccountStateDelta OutputState { get; set; } + public IAccount OutputState { get; set; } public Exception? Exception { get; set; } - public IAccountStateDelta PreviousState { get; set; } + public IAccount PreviousState { get; set; } public int RandomSeed { get; set; } diff --git a/Lib9c.Renderers/Renderers/ActionRenderer.cs b/Lib9c.Renderers/Renderers/ActionRenderer.cs index 93fa914d4..f75e21014 100644 --- a/Lib9c.Renderers/Renderers/ActionRenderer.cs +++ b/Lib9c.Renderers/Renderers/ActionRenderer.cs @@ -33,7 +33,7 @@ public ActionRenderer() _actionLoader = new NCActionLoader(); } - public void RenderAction(IValue action, IActionContext context, IAccountStateDelta nextStates) => + public void RenderAction(IValue action, IActionContext context, IAccount nextStates) => ActionRenderSubject.OnNext(new ActionEvaluation { Action = context.BlockAction diff --git a/Lib9c/Action/AccountStateDeltaExtensions.cs b/Lib9c/Action/AccountStateDeltaExtensions.cs index 32bc30184..3d1b9c7be 100644 --- a/Lib9c/Action/AccountStateDeltaExtensions.cs +++ b/Lib9c/Action/AccountStateDeltaExtensions.cs @@ -19,8 +19,8 @@ namespace Nekoyume.Action { public static class AccountStateDeltaExtensions { - public static IAccountStateDelta MarkBalanceChanged( - this IAccountStateDelta states, + public static IAccount MarkBalanceChanged( + this IAccount states, IActionContext context, Currency currency, params Address[] accounts @@ -44,8 +44,8 @@ params Address[] accounts } - public static IAccountStateDelta SetWorldBossKillReward( - this IAccountStateDelta states, + public static IAccount SetWorldBossKillReward( + this IAccount states, IActionContext context, Address rewardInfoAddress, WorldBossKillRewardRecord rewardRecord, @@ -96,8 +96,8 @@ public static IAccountStateDelta SetWorldBossKillReward( } #nullable enable - public static IAccountStateDelta SetCouponWallet( - this IAccountStateDelta states, + public static IAccount SetCouponWallet( + this IAccount states, Address agentAddress, IImmutableDictionary couponWallet, bool rehearsal = false) @@ -115,8 +115,8 @@ public static IAccountStateDelta SetCouponWallet( } #nullable disable - public static IAccountStateDelta Mead( - this IAccountStateDelta states, IActionContext context, Address signer, BigInteger rawValue) + public static IAccount Mead( + this IAccount states, IActionContext context, Address signer, BigInteger rawValue) { while (true) { diff --git a/Lib9c/Action/ActionBase.cs b/Lib9c/Action/ActionBase.cs index 17fad2adf..2c7a6206e 100644 --- a/Lib9c/Action/ActionBase.cs +++ b/Lib9c/Action/ActionBase.cs @@ -29,7 +29,7 @@ public abstract class ActionBase : IAction public abstract IValue PlainValue { get; } public abstract void LoadPlainValue(IValue plainValue); - public abstract IAccountStateDelta Execute(IActionContext context); + public abstract IAccount Execute(IActionContext context); /// /// returns "[Signer Address, AvatarState Address, ...]" @@ -50,7 +50,7 @@ protected string GetSignerAndOtherAddressesHex(IActionContext ctx, params Addres return sb.ToString(); } - protected IAccountStateDelta LogError(IActionContext context, string message, params object[] values) + protected IAccount LogError(IActionContext context, string message, params object[] values) { string actionType = GetType().Name; object[] prependedValues = new object[values.Length + 2]; diff --git a/Lib9c/Action/ActionBaseExtensions.cs b/Lib9c/Action/ActionBaseExtensions.cs index de3495b9d..240215e53 100644 --- a/Lib9c/Action/ActionBaseExtensions.cs +++ b/Lib9c/Action/ActionBaseExtensions.cs @@ -26,7 +26,7 @@ public static IImmutableSet
CalculateUpdateAddresses(this IEnumerable true; - public IAccountStateDelta PreviousState => new AddressTraceStateDelta(); + public IAccount PreviousState => new AddressTraceStateDelta(); public IRandom Random => default; @@ -74,7 +74,7 @@ public void UseGas(long gas) public long GasLimit() => 0; } - private class AddressTraceStateDelta : IAccountStateDelta + private class AddressTraceStateDelta : IAccount { private AddressTraceDelta _delta; @@ -103,7 +103,7 @@ public AddressTraceStateDelta(AddressTraceDelta delta) public IImmutableSet UpdatedTotalSupplyCurrencies => Delta.UpdatedTotalSupplyCurrencies; - public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) + public IAccount BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { return new AddressTraceStateDelta( new AddressTraceDelta(Delta.UpdatedAddresses.Union(new [] { owner }))); @@ -129,19 +129,19 @@ public FungibleAssetValue GetTotalSupply(Currency currency) throw new NotSupportedException(); } - public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) + public IAccount MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { return new AddressTraceStateDelta( new AddressTraceDelta(Delta.UpdatedAddresses.Union(new[] { recipient }))); } - public IAccountStateDelta SetState(Address address, IValue state) + public IAccount SetState(Address address, IValue state) { return new AddressTraceStateDelta( new AddressTraceDelta(Delta.UpdatedAddresses.Union(new[] { address }))); } - public IAccountStateDelta TransferAsset( + public IAccount TransferAsset( IActionContext context, Address sender, Address recipient, @@ -155,7 +155,7 @@ public IAccountStateDelta TransferAsset( public ValidatorSet GetValidatorSet() => throw new NotSupportedException(); - public IAccountStateDelta SetValidator(Validator validator) + public IAccount SetValidator(Validator validator) { throw new NotSupportedException(); } diff --git a/Lib9c/Action/ActivateAccount.cs b/Lib9c/Action/ActivateAccount.cs index dcd42fcb4..d9e16e98a 100644 --- a/Lib9c/Action/ActivateAccount.cs +++ b/Lib9c/Action/ActivateAccount.cs @@ -43,10 +43,10 @@ public ActivateAccount(Address pendingAddress, byte[] signature) Signature = signature; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousState; + IAccount state = context.PreviousState; Address activatedAddress = context.Signer.Derive(ActivationKey.DeriveKey); if (context.Rehearsal) diff --git a/Lib9c/Action/ActivateAccount0.cs b/Lib9c/Action/ActivateAccount0.cs index 1b88f6313..c43341b82 100644 --- a/Lib9c/Action/ActivateAccount0.cs +++ b/Lib9c/Action/ActivateAccount0.cs @@ -42,10 +42,10 @@ public ActivateAccount0(Address pendingAddress, byte[] signature) Signature = signature; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousState; + IAccount state = context.PreviousState; if (context.Rehearsal) { diff --git a/Lib9c/Action/AddActivatedAccount.cs b/Lib9c/Action/AddActivatedAccount.cs index 063697bea..962866ab9 100644 --- a/Lib9c/Action/AddActivatedAccount.cs +++ b/Lib9c/Action/AddActivatedAccount.cs @@ -37,10 +37,10 @@ public AddActivatedAccount() } )); - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousState; + IAccount state = context.PreviousState; var address = Address.Derive(ActivationKey.DeriveKey); if (context.Rehearsal) diff --git a/Lib9c/Action/AddActivatedAccount0.cs b/Lib9c/Action/AddActivatedAccount0.cs index ece888951..3bb8a12e8 100644 --- a/Lib9c/Action/AddActivatedAccount0.cs +++ b/Lib9c/Action/AddActivatedAccount0.cs @@ -36,10 +36,10 @@ public AddActivatedAccount0() } )); - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousState; + IAccount state = context.PreviousState; if (context.Rehearsal) { diff --git a/Lib9c/Action/AddRedeemCode.cs b/Lib9c/Action/AddRedeemCode.cs index a2ac953a0..6c4a0ae81 100644 --- a/Lib9c/Action/AddRedeemCode.cs +++ b/Lib9c/Action/AddRedeemCode.cs @@ -17,7 +17,7 @@ public class AddRedeemCode : GameAction, IAddRedeemCodeV1 string IAddRedeemCodeV1.RedeemCsv => redeemCsv; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ApprovePledge.cs b/Lib9c/Action/ApprovePledge.cs index f5793933d..7048f6db6 100644 --- a/Lib9c/Action/ApprovePledge.cs +++ b/Lib9c/Action/ApprovePledge.cs @@ -24,7 +24,7 @@ public override void LoadPlainValue(IValue plainValue) PatronAddress = ((Dictionary)plainValue)["values"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); Address signer = context.Signer; diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 14bb57e57..1cdce084f 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -64,7 +64,7 @@ protected override void LoadPlainValueInternal( SummonCount = plainValue[SummonCountKey].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena.cs b/Lib9c/Action/BattleArena.cs index 2ef8316f9..881739756 100644 --- a/Lib9c/Action/BattleArena.cs +++ b/Lib9c/Action/BattleArena.cs @@ -86,7 +86,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena1.cs b/Lib9c/Action/BattleArena1.cs index 3e725de7b..02b2b7be7 100644 --- a/Lib9c/Action/BattleArena1.cs +++ b/Lib9c/Action/BattleArena1.cs @@ -84,7 +84,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena10.cs b/Lib9c/Action/BattleArena10.cs index 6cc31aa7b..61aff896b 100644 --- a/Lib9c/Action/BattleArena10.cs +++ b/Lib9c/Action/BattleArena10.cs @@ -89,7 +89,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena11.cs b/Lib9c/Action/BattleArena11.cs index 229c29679..6de7dba76 100644 --- a/Lib9c/Action/BattleArena11.cs +++ b/Lib9c/Action/BattleArena11.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena12.cs b/Lib9c/Action/BattleArena12.cs index 02f87db31..46c3d11dd 100644 --- a/Lib9c/Action/BattleArena12.cs +++ b/Lib9c/Action/BattleArena12.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena2.cs b/Lib9c/Action/BattleArena2.cs index 3e50f46b8..a696ca218 100644 --- a/Lib9c/Action/BattleArena2.cs +++ b/Lib9c/Action/BattleArena2.cs @@ -83,7 +83,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena3.cs b/Lib9c/Action/BattleArena3.cs index 92bec05c8..7efa6cd09 100644 --- a/Lib9c/Action/BattleArena3.cs +++ b/Lib9c/Action/BattleArena3.cs @@ -83,7 +83,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena4.cs b/Lib9c/Action/BattleArena4.cs index 2fdf87bfd..3004ef924 100644 --- a/Lib9c/Action/BattleArena4.cs +++ b/Lib9c/Action/BattleArena4.cs @@ -83,7 +83,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena5.cs b/Lib9c/Action/BattleArena5.cs index 937a672e2..d31fe8e72 100644 --- a/Lib9c/Action/BattleArena5.cs +++ b/Lib9c/Action/BattleArena5.cs @@ -84,7 +84,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena6.cs b/Lib9c/Action/BattleArena6.cs index 3e60ce4f4..51e99ae67 100644 --- a/Lib9c/Action/BattleArena6.cs +++ b/Lib9c/Action/BattleArena6.cs @@ -85,7 +85,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena7.cs b/Lib9c/Action/BattleArena7.cs index 00340eaca..e88a7d8d5 100644 --- a/Lib9c/Action/BattleArena7.cs +++ b/Lib9c/Action/BattleArena7.cs @@ -91,7 +91,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena8.cs b/Lib9c/Action/BattleArena8.cs index e3f81bc6f..f1cfe7baf 100644 --- a/Lib9c/Action/BattleArena8.cs +++ b/Lib9c/Action/BattleArena8.cs @@ -93,7 +93,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleArena9.cs b/Lib9c/Action/BattleArena9.cs index 3c3138d85..951a2041e 100644 --- a/Lib9c/Action/BattleArena9.cs +++ b/Lib9c/Action/BattleArena9.cs @@ -92,7 +92,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue[RuneInfos].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleGrandFinale.cs b/Lib9c/Action/BattleGrandFinale.cs index c177f2154..d556b10dd 100644 --- a/Lib9c/Action/BattleGrandFinale.cs +++ b/Lib9c/Action/BattleGrandFinale.cs @@ -77,7 +77,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleGrandFinale1.cs b/Lib9c/Action/BattleGrandFinale1.cs index d1fdebfe0..c94637a56 100644 --- a/Lib9c/Action/BattleGrandFinale1.cs +++ b/Lib9c/Action/BattleGrandFinale1.cs @@ -76,7 +76,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/BattleGrandFinale2.cs b/Lib9c/Action/BattleGrandFinale2.cs index 97533c137..faa1d0ba6 100644 --- a/Lib9c/Action/BattleGrandFinale2.cs +++ b/Lib9c/Action/BattleGrandFinale2.cs @@ -77,7 +77,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue[EquipmentsKey]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Buy.cs b/Lib9c/Action/Buy.cs index 8f932298c..4ad0718d8 100644 --- a/Lib9c/Action/Buy.cs +++ b/Lib9c/Action/Buy.cs @@ -63,7 +63,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new PurchaseInfo((Dictionary)value)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/Buy0.cs b/Lib9c/Action/Buy0.cs index 24ff811c6..fd4fe9aba 100644 --- a/Lib9c/Action/Buy0.cs +++ b/Lib9c/Action/Buy0.cs @@ -51,7 +51,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new PurchaseInfo((Dictionary)value)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/Buy11.cs b/Lib9c/Action/Buy11.cs index 4d40f07a6..594d830a7 100644 --- a/Lib9c/Action/Buy11.cs +++ b/Lib9c/Action/Buy11.cs @@ -64,7 +64,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new PurchaseInfo((Dictionary)value)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/Buy2.cs b/Lib9c/Action/Buy2.cs index 84443e357..accd59993 100644 --- a/Lib9c/Action/Buy2.cs +++ b/Lib9c/Action/Buy2.cs @@ -52,7 +52,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new PurchaseInfo((Dictionary)value)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/Buy9.cs b/Lib9c/Action/Buy9.cs index 1c083eb4d..adfde17ca 100644 --- a/Lib9c/Action/Buy9.cs +++ b/Lib9c/Action/Buy9.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new PurchaseInfo((Dictionary)value)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/BuyMultiple.cs b/Lib9c/Action/BuyMultiple.cs index a53777c2f..15e53d52b 100644 --- a/Lib9c/Action/BuyMultiple.cs +++ b/Lib9c/Action/BuyMultiple.cs @@ -216,7 +216,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary ProductInfos; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; @@ -120,8 +120,8 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, Address sellerAvatarAddress, - IAccountStateDelta states, Address sellerAgentAddress, AvatarState buyerAvatarState, AvatarState sellerAvatarState, + private IAccount Buy(IActionContext context, IProductInfo productInfo, Address sellerAvatarAddress, + IAccount states, Address sellerAgentAddress, AvatarState buyerAvatarState, AvatarState sellerAvatarState, MaterialItemSheet materialSheet, bool sellerMigrationRequired) { var productId = productInfo.ProductId; @@ -222,7 +222,7 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, // backward compatibility for order - shared shop state. // TODO DELETE THIS METHOD AFTER PRODUCT MIGRATION END. - private static IAccountStateDelta Buy_Order(PurchaseInfo purchaseInfo, IActionContext context, IAccountStateDelta states, AvatarState buyerAvatarState, MaterialItemSheet materialSheet, AvatarState sellerAvatarState) + private static IAccount Buy_Order(PurchaseInfo purchaseInfo, IActionContext context, IAccount states, AvatarState buyerAvatarState, MaterialItemSheet materialSheet, AvatarState sellerAvatarState) { Address shardedShopAddress = ShardedShopStateV2.DeriveAddress(purchaseInfo.ItemSubType, purchaseInfo.OrderId); diff --git a/Lib9c/Action/BuyProduct0.cs b/Lib9c/Action/BuyProduct0.cs index a25a043cc..cdc6620ab 100644 --- a/Lib9c/Action/BuyProduct0.cs +++ b/Lib9c/Action/BuyProduct0.cs @@ -30,10 +30,10 @@ public class BuyProduct0 : GameAction public Address AvatarAddress; public IEnumerable ProductInfos; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; @@ -120,8 +120,8 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, Address sellerAvatarAddress, - IAccountStateDelta states, Address sellerAgentAddress, AvatarState buyerAvatarState, AvatarState sellerAvatarState, + private IAccount Buy(IActionContext context, IProductInfo productInfo, Address sellerAvatarAddress, + IAccount states, Address sellerAgentAddress, AvatarState buyerAvatarState, AvatarState sellerAvatarState, MaterialItemSheet materialSheet, bool sellerMigrationRequired) { var productId = productInfo.ProductId; @@ -212,7 +212,7 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, // backward compatibility for order - shared shop state. // TODO DELETE THIS METHOD AFTER PRODUCT MIGRATION END. - private static IAccountStateDelta Buy_Order(PurchaseInfo purchaseInfo, IActionContext context, IAccountStateDelta states, AvatarState buyerAvatarState, MaterialItemSheet materialSheet, AvatarState sellerAvatarState) + private static IAccount Buy_Order(PurchaseInfo purchaseInfo, IActionContext context, IAccount states, AvatarState buyerAvatarState, MaterialItemSheet materialSheet, AvatarState sellerAvatarState) { Address shardedShopAddress = ShardedShopStateV2.DeriveAddress(purchaseInfo.ItemSubType, purchaseInfo.OrderId); diff --git a/Lib9c/Action/CancelMonsterCollect.cs b/Lib9c/Action/CancelMonsterCollect.cs index 3b69f1ef6..8f22c04ad 100644 --- a/Lib9c/Action/CancelMonsterCollect.cs +++ b/Lib9c/Action/CancelMonsterCollect.cs @@ -32,10 +32,10 @@ public class CancelMonsterCollect : GameAction, ICancelMonsterCollectV1 int ICancelMonsterCollectV1.CollectRound => collectRound; int ICancelMonsterCollectV1.Level => level; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; Address collectionAddress = MonsterCollectionState0.DeriveAddress(context.Signer, collectRound); if (context.Rehearsal) { diff --git a/Lib9c/Action/CancelProductRegistration.cs b/Lib9c/Action/CancelProductRegistration.cs index 16cf0baec..af66e0363 100644 --- a/Lib9c/Action/CancelProductRegistration.cs +++ b/Lib9c/Action/CancelProductRegistration.cs @@ -25,10 +25,10 @@ public class CancelProductRegistration : GameAction public Address AvatarAddress; public List ProductInfos; public bool ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; @@ -144,7 +144,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - public static IAccountStateDelta Cancel(ProductsState productsState, IProductInfo productInfo, IAccountStateDelta states, + public static IAccount Cancel(ProductsState productsState, IProductInfo productInfo, IAccount states, AvatarState avatarState, IActionContext context) { var productId = productInfo.ProductId; diff --git a/Lib9c/Action/ChargeActionPoint.cs b/Lib9c/Action/ChargeActionPoint.cs index 114a287c2..fb9b92f5b 100644 --- a/Lib9c/Action/ChargeActionPoint.cs +++ b/Lib9c/Action/ChargeActionPoint.cs @@ -31,7 +31,7 @@ public class ChargeActionPoint : GameAction, IChargeActionPointV1 Address IChargeActionPointV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ChargeActionPoint0.cs b/Lib9c/Action/ChargeActionPoint0.cs index 2803cd215..736a5a9be 100644 --- a/Lib9c/Action/ChargeActionPoint0.cs +++ b/Lib9c/Action/ChargeActionPoint0.cs @@ -24,7 +24,7 @@ public class ChargeActionPoint0 : GameAction, IChargeActionPointV1 Address IChargeActionPointV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ChargeActionPoint2.cs b/Lib9c/Action/ChargeActionPoint2.cs index 1ff088cec..9c27aa9b0 100644 --- a/Lib9c/Action/ChargeActionPoint2.cs +++ b/Lib9c/Action/ChargeActionPoint2.cs @@ -23,7 +23,7 @@ public class ChargeActionPoint2 : GameAction, IChargeActionPointV1 Address IChargeActionPointV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ClaimMonsterCollectionReward.cs b/Lib9c/Action/ClaimMonsterCollectionReward.cs index 38441bc15..44e350a27 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward.cs @@ -31,16 +31,16 @@ public class ClaimMonsterCollectionReward : GameAction, IClaimMonsterCollectionR Address IClaimMonsterCollectionRewardV2.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); return Claim(context, avatarAddress, addressesHex); } - public static IAccountStateDelta Claim(IActionContext context, Address avatarAddress, string addressesHex) + public static IAccount Claim(IActionContext context, Address avatarAddress, string addressesHex) { - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; Address inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); Address worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); Address questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/ClaimMonsterCollectionReward0.cs b/Lib9c/Action/ClaimMonsterCollectionReward0.cs index 52f445b96..06767761c 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward0.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward0.cs @@ -26,10 +26,10 @@ public class ClaimMonsterCollectionReward0 : GameAction, IClaimMonsterCollection Address IClaimMonsterCollectionRewardV1.AvatarAddress => avatarAddress; int IClaimMonsterCollectionRewardV1.CollectionRound => collectionRound; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; Address collectionAddress = MonsterCollectionState0.DeriveAddress(context.Signer, collectionRound); if (context.Rehearsal) diff --git a/Lib9c/Action/ClaimMonsterCollectionReward2.cs b/Lib9c/Action/ClaimMonsterCollectionReward2.cs index 7523b52ca..2a56b158e 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward2.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward2.cs @@ -25,10 +25,10 @@ public class ClaimMonsterCollectionReward2 : GameAction, IClaimMonsterCollection Address IClaimMonsterCollectionRewardV2.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; Address inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); Address worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); Address questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/ClaimRaidReward.cs b/Lib9c/Action/ClaimRaidReward.cs index efebb42bc..de6935cc9 100644 --- a/Lib9c/Action/ClaimRaidReward.cs +++ b/Lib9c/Action/ClaimRaidReward.cs @@ -33,10 +33,10 @@ public ClaimRaidReward(Address avatarAddress) AvatarAddress = avatarAddress; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index d2e3330c6..e8bd87716 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -197,7 +197,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -358,9 +358,9 @@ public override IAccountStateDelta Execute(IActionContext context) : new List(); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedFav, diff --git a/Lib9c/Action/ClaimStakeReward1.cs b/Lib9c/Action/ClaimStakeReward1.cs index 20ed67fa9..8131ec40b 100644 --- a/Lib9c/Action/ClaimStakeReward1.cs +++ b/Lib9c/Action/ClaimStakeReward1.cs @@ -31,7 +31,7 @@ public ClaimStakeReward1() : base() { } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); CheckObsolete(ObsoleteIndex, context); diff --git a/Lib9c/Action/ClaimStakeReward2.cs b/Lib9c/Action/ClaimStakeReward2.cs index 7bd8ac2b8..37fd24ff3 100644 --- a/Lib9c/Action/ClaimStakeReward2.cs +++ b/Lib9c/Action/ClaimStakeReward2.cs @@ -35,7 +35,7 @@ public ClaimStakeReward2() { } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c/Action/ClaimStakeReward3.cs b/Lib9c/Action/ClaimStakeReward3.cs index b32991500..a38bae2d3 100644 --- a/Lib9c/Action/ClaimStakeReward3.cs +++ b/Lib9c/Action/ClaimStakeReward3.cs @@ -105,9 +105,9 @@ public ClaimStakeReward3() }.ToImmutableSortedDictionary(); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedAmount, @@ -165,7 +165,7 @@ private IAccountStateDelta ProcessReward( return states; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) diff --git a/Lib9c/Action/ClaimStakeReward4.cs b/Lib9c/Action/ClaimStakeReward4.cs index f3e121963..81129a4dc 100644 --- a/Lib9c/Action/ClaimStakeReward4.cs +++ b/Lib9c/Action/ClaimStakeReward4.cs @@ -123,7 +123,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { CheckObsolete(ObsoleteBlockIndex, context); context.UseGas(1); @@ -250,9 +250,9 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.inventory.Serialize()); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedAmount, diff --git a/Lib9c/Action/ClaimStakeReward5.cs b/Lib9c/Action/ClaimStakeReward5.cs index 4c02fb458..3ebfaf349 100644 --- a/Lib9c/Action/ClaimStakeReward5.cs +++ b/Lib9c/Action/ClaimStakeReward5.cs @@ -123,7 +123,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { CheckObsolete(ObsoleteBlockIndex, context); context.UseGas(1); @@ -250,9 +250,9 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.inventory.Serialize()); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedAmount, diff --git a/Lib9c/Action/ClaimStakeReward6.cs b/Lib9c/Action/ClaimStakeReward6.cs index f7fca8b7d..a433d62d8 100644 --- a/Lib9c/Action/ClaimStakeReward6.cs +++ b/Lib9c/Action/ClaimStakeReward6.cs @@ -199,7 +199,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -360,9 +360,9 @@ public override IAccountStateDelta Execute(IActionContext context) : new List(); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedFav, diff --git a/Lib9c/Action/ClaimStakeReward7.cs b/Lib9c/Action/ClaimStakeReward7.cs index 50b8664ce..f97d03f83 100644 --- a/Lib9c/Action/ClaimStakeReward7.cs +++ b/Lib9c/Action/ClaimStakeReward7.cs @@ -199,7 +199,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { CheckObsolete(ObsoleteBlockIndex, context); context.UseGas(1); @@ -361,9 +361,9 @@ public override IAccountStateDelta Execute(IActionContext context) : new List(); } - private IAccountStateDelta ProcessReward( + private IAccount ProcessReward( IActionContext context, - IAccountStateDelta states, + IAccount states, ref AvatarState avatarState, ItemSheet itemSheet, FungibleAssetValue stakedFav, diff --git a/Lib9c/Action/ClaimWordBossKillReward.cs b/Lib9c/Action/ClaimWordBossKillReward.cs index 195e7077f..b4e63481b 100644 --- a/Lib9c/Action/ClaimWordBossKillReward.cs +++ b/Lib9c/Action/ClaimWordBossKillReward.cs @@ -23,10 +23,10 @@ public class ClaimWordBossKillReward : GameAction, IClaimWordBossKillRewardV1 Address IClaimWordBossKillRewardV1.AvatarAddress => AvatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/CombinationConsumable.cs b/Lib9c/Action/CombinationConsumable.cs index 5b48fd35b..2db3de1d1 100644 --- a/Lib9c/Action/CombinationConsumable.cs +++ b/Lib9c/Action/CombinationConsumable.cs @@ -58,7 +58,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment10.cs b/Lib9c/Action/CombinationEquipment10.cs index 6e39365ad..b2e5a0b27 100644 --- a/Lib9c/Action/CombinationEquipment10.cs +++ b/Lib9c/Action/CombinationEquipment10.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal( subRecipeId = plainValue[SubRecipeIdKey].ToNullableInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/CombinationEquipment11.cs b/Lib9c/Action/CombinationEquipment11.cs index 6fa7a039a..831af8305 100644 --- a/Lib9c/Action/CombinationEquipment11.cs +++ b/Lib9c/Action/CombinationEquipment11.cs @@ -61,7 +61,7 @@ protected override void LoadPlainValueInternal( subRecipeId = plainValue[SubRecipeIdKey].ToNullableInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/CombinationEquipment12.cs b/Lib9c/Action/CombinationEquipment12.cs index 347d970ba..79a2be545 100644 --- a/Lib9c/Action/CombinationEquipment12.cs +++ b/Lib9c/Action/CombinationEquipment12.cs @@ -69,7 +69,7 @@ protected override void LoadPlainValueInternal( payByCrystal = plainValue[PayByCrystalKey].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/CombinationEquipment13.cs b/Lib9c/Action/CombinationEquipment13.cs index b9e311010..891a2dbcd 100644 --- a/Lib9c/Action/CombinationEquipment13.cs +++ b/Lib9c/Action/CombinationEquipment13.cs @@ -77,7 +77,7 @@ protected override void LoadPlainValueInternal( useHammerPoint = plainValue[UseHammerPointKey].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -454,8 +454,8 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(context.Signer, agentState.Serialize()); } - private IAccountStateDelta UseAssetsBySuperCraft( - IAccountStateDelta states, + private IAccount UseAssetsBySuperCraft( + IAccount states, IActionContext context, CrystalHammerPointSheet.Row row, HammerPointState hammerPointState) @@ -475,8 +475,8 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointCost); } - private IAccountStateDelta UseAssetsByNormalCombination( - IAccountStateDelta states, + private IAccount UseAssetsByNormalCombination( + IAccount states, IActionContext context, AvatarState avatarState, HammerPointState hammerPointState, diff --git a/Lib9c/Action/CombinationEquipment14.cs b/Lib9c/Action/CombinationEquipment14.cs index 4c7624b9c..706c037a9 100644 --- a/Lib9c/Action/CombinationEquipment14.cs +++ b/Lib9c/Action/CombinationEquipment14.cs @@ -78,7 +78,7 @@ protected override void LoadPlainValueInternal( useHammerPoint = plainValue[UseHammerPointKey].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -464,8 +464,8 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(context.Signer, agentState.Serialize()); } - private IAccountStateDelta UseAssetsBySuperCraft( - IAccountStateDelta states, + private IAccount UseAssetsBySuperCraft( + IAccount states, IActionContext context, CrystalHammerPointSheet.Row row, HammerPointState hammerPointState) @@ -485,8 +485,8 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointCost); } - private IAccountStateDelta UseAssetsByNormalCombination( - IAccountStateDelta states, + private IAccount UseAssetsByNormalCombination( + IAccount states, IActionContext context, AvatarState avatarState, HammerPointState hammerPointState, diff --git a/Lib9c/Action/CombinationEquipment15.cs b/Lib9c/Action/CombinationEquipment15.cs index 75e9efcd7..55f741e42 100644 --- a/Lib9c/Action/CombinationEquipment15.cs +++ b/Lib9c/Action/CombinationEquipment15.cs @@ -78,7 +78,7 @@ protected override void LoadPlainValueInternal( useHammerPoint = plainValue[UseHammerPointKey].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -465,8 +465,8 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(context.Signer, agentState.Serialize()); } - private IAccountStateDelta UseAssetsBySuperCraft( - IAccountStateDelta states, + private IAccount UseAssetsBySuperCraft( + IAccount states, IActionContext context, CrystalHammerPointSheet.Row row, HammerPointState hammerPointState) @@ -486,8 +486,8 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointCost); } - private IAccountStateDelta UseAssetsByNormalCombination( - IAccountStateDelta states, + private IAccount UseAssetsByNormalCombination( + IAccount states, IActionContext context, AvatarState avatarState, HammerPointState hammerPointState, diff --git a/Lib9c/Action/CombinationEquipment2.cs b/Lib9c/Action/CombinationEquipment2.cs index 6db709174..b11c9dd0d 100644 --- a/Lib9c/Action/CombinationEquipment2.cs +++ b/Lib9c/Action/CombinationEquipment2.cs @@ -37,7 +37,7 @@ public class CombinationEquipment2 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment3.cs b/Lib9c/Action/CombinationEquipment3.cs index a64392666..80a078916 100644 --- a/Lib9c/Action/CombinationEquipment3.cs +++ b/Lib9c/Action/CombinationEquipment3.cs @@ -37,7 +37,7 @@ public class CombinationEquipment3 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment4.cs b/Lib9c/Action/CombinationEquipment4.cs index 404af7726..8e39b0bf7 100644 --- a/Lib9c/Action/CombinationEquipment4.cs +++ b/Lib9c/Action/CombinationEquipment4.cs @@ -37,7 +37,7 @@ public class CombinationEquipment4 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment5.cs b/Lib9c/Action/CombinationEquipment5.cs index 481d89c94..d88972ec2 100644 --- a/Lib9c/Action/CombinationEquipment5.cs +++ b/Lib9c/Action/CombinationEquipment5.cs @@ -37,7 +37,7 @@ public class CombinationEquipment5 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment6.cs b/Lib9c/Action/CombinationEquipment6.cs index 1d9eb7663..d35e93bad 100644 --- a/Lib9c/Action/CombinationEquipment6.cs +++ b/Lib9c/Action/CombinationEquipment6.cs @@ -38,7 +38,7 @@ public class CombinationEquipment6 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment7.cs b/Lib9c/Action/CombinationEquipment7.cs index 7e3baacf3..ad0812b0e 100644 --- a/Lib9c/Action/CombinationEquipment7.cs +++ b/Lib9c/Action/CombinationEquipment7.cs @@ -37,7 +37,7 @@ public class CombinationEquipment7 : GameAction, ICombinationEquipmentV1 int ICombinationEquipmentV1.SlotIndex => SlotIndex; int? ICombinationEquipmentV1.SubRecipeId => SubRecipeId; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/CombinationEquipment8.cs b/Lib9c/Action/CombinationEquipment8.cs index d95c2a186..6887857e2 100644 --- a/Lib9c/Action/CombinationEquipment8.cs +++ b/Lib9c/Action/CombinationEquipment8.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal( subRecipeId = plainValue[SubRecipeIdKey].ToNullableInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/CombinationEquipment9.cs b/Lib9c/Action/CombinationEquipment9.cs index 7daeb0493..defe1a970 100644 --- a/Lib9c/Action/CombinationEquipment9.cs +++ b/Lib9c/Action/CombinationEquipment9.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal( subRecipeId = plainValue[SubRecipeIdKey].ToNullableInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Coupons/IssueCoupons.cs b/Lib9c/Action/Coupons/IssueCoupons.cs index c5bea21a1..94a256d97 100644 --- a/Lib9c/Action/Coupons/IssueCoupons.cs +++ b/Lib9c/Action/Coupons/IssueCoupons.cs @@ -27,7 +27,7 @@ public IssueCoupons(IImmutableDictionary rewards, Address recip public Address Recipient { get; private set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Coupons/RedeemCoupon.cs b/Lib9c/Action/Coupons/RedeemCoupon.cs index 81605fc36..89c0ceac6 100644 --- a/Lib9c/Action/Coupons/RedeemCoupon.cs +++ b/Lib9c/Action/Coupons/RedeemCoupon.cs @@ -29,7 +29,7 @@ public RedeemCoupon(Guid couponId, Address avatarAddress) AvatarAddress = avatarAddress; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Coupons/TransferCoupons.cs b/Lib9c/Action/Coupons/TransferCoupons.cs index c32fead38..d51f35f32 100644 --- a/Lib9c/Action/Coupons/TransferCoupons.cs +++ b/Lib9c/Action/Coupons/TransferCoupons.cs @@ -28,7 +28,7 @@ public IImmutableDictionary> CouponsPerRecipient private set; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 5d951a34e..2040fb4f4 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -65,7 +65,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary AddOption( return optionIds; } - public static IAccountStateDelta AddRunesForTest( + public static IAccount AddRunesForTest( IActionContext context, Address avatarAddress, - IAccountStateDelta states) + IAccount states) { var runeSheet = states.GetSheet(); foreach (var row in runeSheet.Values) diff --git a/Lib9c/Action/CreateAvatar2.cs b/Lib9c/Action/CreateAvatar2.cs index b1d134044..fa03444c0 100644 --- a/Lib9c/Action/CreateAvatar2.cs +++ b/Lib9c/Action/CreateAvatar2.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary states) PendingActivations = states.Select(pa => (pa.address.ToByteArray(), pa.Nonce, pa.PublicKey.Format(true))).ToImmutableList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); CheckObsolete(ActionObsoleteConfig.V200030ObsoleteIndex, context); diff --git a/Lib9c/Action/CreatePledge.cs b/Lib9c/Action/CreatePledge.cs index 956ac2c53..88d9ea6dc 100644 --- a/Lib9c/Action/CreatePledge.cs +++ b/Lib9c/Action/CreatePledge.cs @@ -46,7 +46,7 @@ public override void LoadPlainValue(IValue plainValue) AgentAddresses = agentAddresses; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); CheckPermission(context); diff --git a/Lib9c/Action/DailyReward.cs b/Lib9c/Action/DailyReward.cs index 08b7a3ae1..3e43a8875 100644 --- a/Lib9c/Action/DailyReward.cs +++ b/Lib9c/Action/DailyReward.cs @@ -28,7 +28,7 @@ public class DailyReward : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/DailyReward0.cs b/Lib9c/Action/DailyReward0.cs index 73367be4d..857329972 100644 --- a/Lib9c/Action/DailyReward0.cs +++ b/Lib9c/Action/DailyReward0.cs @@ -20,7 +20,7 @@ public class DailyReward0 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/DailyReward2.cs b/Lib9c/Action/DailyReward2.cs index 79d1f7a4d..5db7c3506 100644 --- a/Lib9c/Action/DailyReward2.cs +++ b/Lib9c/Action/DailyReward2.cs @@ -27,7 +27,7 @@ public class DailyReward2 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/DailyReward3.cs b/Lib9c/Action/DailyReward3.cs index a039c5f91..dcfdccc11 100644 --- a/Lib9c/Action/DailyReward3.cs +++ b/Lib9c/Action/DailyReward3.cs @@ -26,7 +26,7 @@ public class DailyReward3 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/DailyReward4.cs b/Lib9c/Action/DailyReward4.cs index 5723486a1..b040f30cc 100644 --- a/Lib9c/Action/DailyReward4.cs +++ b/Lib9c/Action/DailyReward4.cs @@ -27,7 +27,7 @@ public class DailyReward4 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/DailyReward5.cs b/Lib9c/Action/DailyReward5.cs index 22f674c3a..2b2fd9e7e 100644 --- a/Lib9c/Action/DailyReward5.cs +++ b/Lib9c/Action/DailyReward5.cs @@ -22,7 +22,7 @@ public class DailyReward5 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/DailyReward6.cs b/Lib9c/Action/DailyReward6.cs index d07d986fe..7fad85616 100644 --- a/Lib9c/Action/DailyReward6.cs +++ b/Lib9c/Action/DailyReward6.cs @@ -29,7 +29,7 @@ public class DailyReward6 : GameAction, IDailyRewardV1 Address IDailyRewardV1.AvatarAddress => avatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EndPledge.cs b/Lib9c/Action/EndPledge.cs index a3af17a72..76ca25fdb 100644 --- a/Lib9c/Action/EndPledge.cs +++ b/Lib9c/Action/EndPledge.cs @@ -26,7 +26,7 @@ public override void LoadPlainValue(IValue plainValue) AgentAddress = ((Dictionary)plainValue)["values"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); Address signer = context.Signer; diff --git a/Lib9c/Action/EventConsumableItemCrafts.cs b/Lib9c/Action/EventConsumableItemCrafts.cs index cfd2c2d1c..a7296a947 100644 --- a/Lib9c/Action/EventConsumableItemCrafts.cs +++ b/Lib9c/Action/EventConsumableItemCrafts.cs @@ -76,7 +76,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EventDungeonBattleV1.cs b/Lib9c/Action/EventDungeonBattleV1.cs index db093108f..cc0b87d19 100644 --- a/Lib9c/Action/EventDungeonBattleV1.cs +++ b/Lib9c/Action/EventDungeonBattleV1.cs @@ -109,7 +109,7 @@ protected override void LoadPlainValueInternal( BuyTicketIfNeeded = list[7].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EventDungeonBattleV2.cs b/Lib9c/Action/EventDungeonBattleV2.cs index 4bc258bba..6adcfddcb 100644 --- a/Lib9c/Action/EventDungeonBattleV2.cs +++ b/Lib9c/Action/EventDungeonBattleV2.cs @@ -109,7 +109,7 @@ protected override void LoadPlainValueInternal( BuyTicketIfNeeded = list[7].ToBoolean(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EventDungeonBattleV3.cs b/Lib9c/Action/EventDungeonBattleV3.cs index 47e72fc95..62fe54da6 100644 --- a/Lib9c/Action/EventDungeonBattleV3.cs +++ b/Lib9c/Action/EventDungeonBattleV3.cs @@ -117,7 +117,7 @@ protected override void LoadPlainValueInternal( RuneInfos = list[8].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EventDungeonBattleV4.cs b/Lib9c/Action/EventDungeonBattleV4.cs index f70986581..b0070bc7d 100644 --- a/Lib9c/Action/EventDungeonBattleV4.cs +++ b/Lib9c/Action/EventDungeonBattleV4.cs @@ -116,7 +116,7 @@ protected override void LoadPlainValueInternal( RuneInfos = list[8].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/EventMaterialItemCrafts.cs b/Lib9c/Action/EventMaterialItemCrafts.cs index 1ae6a452a..3a7fce549 100644 --- a/Lib9c/Action/EventMaterialItemCrafts.cs +++ b/Lib9c/Action/EventMaterialItemCrafts.cs @@ -84,7 +84,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary IGrindingV1.EquipmentsIds => EquipmentIds; bool IGrindingV1.ChargeAp => ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - IAccountStateDelta states = ctx.PreviousState; + IAccount states = ctx.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Grinding0.cs b/Lib9c/Action/Grinding0.cs index 050706639..c6474f25e 100644 --- a/Lib9c/Action/Grinding0.cs +++ b/Lib9c/Action/Grinding0.cs @@ -33,11 +33,11 @@ public class Grinding0 : GameAction, IGrindingV1 List IGrindingV1.EquipmentsIds => EquipmentIds; bool IGrindingV1.ChargeAp => ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - IAccountStateDelta states = ctx.PreviousState; + IAccount states = ctx.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/HackAndSlash.cs b/Lib9c/Action/HackAndSlash.cs index 0fea9d3f2..9062c1056 100644 --- a/Lib9c/Action/HackAndSlash.cs +++ b/Lib9c/Action/HackAndSlash.cs @@ -96,7 +96,7 @@ protected override void LoadPlainValueInternal( ApStoneCount = plainValue["apStoneCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -111,8 +111,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash0.cs b/Lib9c/Action/HackAndSlash0.cs index 13eaa4c49..b01e042f8 100644 --- a/Lib9c/Action/HackAndSlash0.cs +++ b/Lib9c/Action/HackAndSlash0.cs @@ -70,7 +70,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash10.cs b/Lib9c/Action/HackAndSlash10.cs index 853895efc..d09612d8a 100644 --- a/Lib9c/Action/HackAndSlash10.cs +++ b/Lib9c/Action/HackAndSlash10.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( rankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash11.cs b/Lib9c/Action/HackAndSlash11.cs index 5649d653a..089956b17 100644 --- a/Lib9c/Action/HackAndSlash11.cs +++ b/Lib9c/Action/HackAndSlash11.cs @@ -63,7 +63,7 @@ protected override void LoadPlainValueInternal( avatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash12.cs b/Lib9c/Action/HackAndSlash12.cs index 61cadd734..fe44a36ad 100644 --- a/Lib9c/Action/HackAndSlash12.cs +++ b/Lib9c/Action/HackAndSlash12.cs @@ -63,7 +63,7 @@ protected override void LoadPlainValueInternal( avatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash13.cs b/Lib9c/Action/HackAndSlash13.cs index 044e8e421..5174cce20 100644 --- a/Lib9c/Action/HackAndSlash13.cs +++ b/Lib9c/Action/HackAndSlash13.cs @@ -67,7 +67,7 @@ protected override void LoadPlainValueInternal( avatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash14.cs b/Lib9c/Action/HackAndSlash14.cs index 6216e5efe..1c7139fe3 100644 --- a/Lib9c/Action/HackAndSlash14.cs +++ b/Lib9c/Action/HackAndSlash14.cs @@ -85,7 +85,7 @@ protected override void LoadPlainValueInternal( avatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash15.cs b/Lib9c/Action/HackAndSlash15.cs index 85ff5463e..bc2c4d213 100644 --- a/Lib9c/Action/HackAndSlash15.cs +++ b/Lib9c/Action/HackAndSlash15.cs @@ -82,7 +82,7 @@ protected override void LoadPlainValueInternal( avatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); CheckObsolete(ActionObsoleteConfig.V200030ObsoleteIndex, context); @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute(IAccountStateDelta states, + public IAccount Execute(IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash16.cs b/Lib9c/Action/HackAndSlash16.cs index 06b46a021..8a83f3b37 100644 --- a/Lib9c/Action/HackAndSlash16.cs +++ b/Lib9c/Action/HackAndSlash16.cs @@ -88,7 +88,7 @@ protected override void LoadPlainValueInternal( PlayCount = plainValue["playCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -105,8 +105,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash17.cs b/Lib9c/Action/HackAndSlash17.cs index bd4a61c71..d9112dee3 100644 --- a/Lib9c/Action/HackAndSlash17.cs +++ b/Lib9c/Action/HackAndSlash17.cs @@ -86,7 +86,7 @@ protected override void LoadPlainValueInternal( PlayCount = plainValue["playCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -102,8 +102,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash18.cs b/Lib9c/Action/HackAndSlash18.cs index dbabaa1fa..217e1637f 100644 --- a/Lib9c/Action/HackAndSlash18.cs +++ b/Lib9c/Action/HackAndSlash18.cs @@ -86,7 +86,7 @@ protected override void LoadPlainValueInternal( PlayCount = plainValue["playCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -103,8 +103,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash19.cs b/Lib9c/Action/HackAndSlash19.cs index 287029fed..cdc213c6a 100644 --- a/Lib9c/Action/HackAndSlash19.cs +++ b/Lib9c/Action/HackAndSlash19.cs @@ -91,7 +91,7 @@ protected override void LoadPlainValueInternal( PlayCount = plainValue["playCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -108,8 +108,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash2.cs b/Lib9c/Action/HackAndSlash2.cs index 14eb19277..e64f5697c 100644 --- a/Lib9c/Action/HackAndSlash2.cs +++ b/Lib9c/Action/HackAndSlash2.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash20.cs b/Lib9c/Action/HackAndSlash20.cs index 32ed1addb..c56d830fa 100644 --- a/Lib9c/Action/HackAndSlash20.cs +++ b/Lib9c/Action/HackAndSlash20.cs @@ -98,7 +98,7 @@ protected override void LoadPlainValueInternal( ApStoneCount = plainValue["apStoneCount"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (context.Rehearsal) @@ -113,8 +113,8 @@ public override IAccountStateDelta Execute(IActionContext context) context.Random); } - public IAccountStateDelta Execute( - IAccountStateDelta states, + public IAccount Execute( + IAccount states, Address signer, long blockIndex, IRandom random) diff --git a/Lib9c/Action/HackAndSlash3.cs b/Lib9c/Action/HackAndSlash3.cs index 8c669ba88..417e0ac0c 100644 --- a/Lib9c/Action/HackAndSlash3.cs +++ b/Lib9c/Action/HackAndSlash3.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash4.cs b/Lib9c/Action/HackAndSlash4.cs index da49d3233..664b006ea 100644 --- a/Lib9c/Action/HackAndSlash4.cs +++ b/Lib9c/Action/HackAndSlash4.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash5.cs b/Lib9c/Action/HackAndSlash5.cs index 01e03b9b4..2326f3601 100644 --- a/Lib9c/Action/HackAndSlash5.cs +++ b/Lib9c/Action/HackAndSlash5.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash6.cs b/Lib9c/Action/HackAndSlash6.cs index 228cbc75e..d9feb7411 100644 --- a/Lib9c/Action/HackAndSlash6.cs +++ b/Lib9c/Action/HackAndSlash6.cs @@ -69,7 +69,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash7.cs b/Lib9c/Action/HackAndSlash7.cs index ce36c8ddd..df06c7f95 100644 --- a/Lib9c/Action/HackAndSlash7.cs +++ b/Lib9c/Action/HackAndSlash7.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( RankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash8.cs b/Lib9c/Action/HackAndSlash8.cs index dbf4e617f..d8ec905ce 100644 --- a/Lib9c/Action/HackAndSlash8.cs +++ b/Lib9c/Action/HackAndSlash8.cs @@ -64,7 +64,7 @@ protected override void LoadPlainValueInternal( rankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlash9.cs b/Lib9c/Action/HackAndSlash9.cs index 6f9719fd4..c67dbe407 100644 --- a/Lib9c/Action/HackAndSlash9.cs +++ b/Lib9c/Action/HackAndSlash9.cs @@ -68,7 +68,7 @@ protected override void LoadPlainValueInternal( rankingMapAddress = plainValue["rankingMapAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/HackAndSlashRandomBuff.cs b/Lib9c/Action/HackAndSlashRandomBuff.cs index 9a942f7cf..b3989c3c5 100644 --- a/Lib9c/Action/HackAndSlashRandomBuff.cs +++ b/Lib9c/Action/HackAndSlashRandomBuff.cs @@ -44,7 +44,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary avatarAddress; int IItemEnhancementV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement10.cs b/Lib9c/Action/ItemEnhancement10.cs index ea713f95c..2029d320a 100644 --- a/Lib9c/Action/ItemEnhancement10.cs +++ b/Lib9c/Action/ItemEnhancement10.cs @@ -119,7 +119,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement3.cs b/Lib9c/Action/ItemEnhancement3.cs index a8164fc3d..587741b18 100644 --- a/Lib9c/Action/ItemEnhancement3.cs +++ b/Lib9c/Action/ItemEnhancement3.cs @@ -38,7 +38,7 @@ public class ItemEnhancement3 : GameAction, IItemEnhancementV2 Address IItemEnhancementV2.AvatarAddress => avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement4.cs b/Lib9c/Action/ItemEnhancement4.cs index ecac56ec5..56733534f 100644 --- a/Lib9c/Action/ItemEnhancement4.cs +++ b/Lib9c/Action/ItemEnhancement4.cs @@ -36,7 +36,7 @@ public class ItemEnhancement4 : GameAction, IItemEnhancementV2 Address IItemEnhancementV2.AvatarAddress => avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement5.cs b/Lib9c/Action/ItemEnhancement5.cs index c60e948f0..d24f439d6 100644 --- a/Lib9c/Action/ItemEnhancement5.cs +++ b/Lib9c/Action/ItemEnhancement5.cs @@ -36,7 +36,7 @@ public class ItemEnhancement5 : GameAction, IItemEnhancementV2 Address IItemEnhancementV2.AvatarAddress => avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement6.cs b/Lib9c/Action/ItemEnhancement6.cs index 18e05c3e1..0f763d40f 100644 --- a/Lib9c/Action/ItemEnhancement6.cs +++ b/Lib9c/Action/ItemEnhancement6.cs @@ -38,7 +38,7 @@ public class ItemEnhancement6 : GameAction, IItemEnhancementV2 Address IItemEnhancementV2.AvatarAddress => avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement7.cs b/Lib9c/Action/ItemEnhancement7.cs index ffa0aba8d..f0a31cc6d 100644 --- a/Lib9c/Action/ItemEnhancement7.cs +++ b/Lib9c/Action/ItemEnhancement7.cs @@ -75,7 +75,7 @@ public override IValue Serialize() => #pragma warning restore LAA1002 } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement8.cs b/Lib9c/Action/ItemEnhancement8.cs index f1b537764..9caf738a6 100644 --- a/Lib9c/Action/ItemEnhancement8.cs +++ b/Lib9c/Action/ItemEnhancement8.cs @@ -39,7 +39,7 @@ public class ItemEnhancement8 : GameAction, IItemEnhancementV2 Address IItemEnhancementV2.AvatarAddress => avatarAddress; int IItemEnhancementV2.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/ItemEnhancement9.cs b/Lib9c/Action/ItemEnhancement9.cs index fe05e9088..e2baa8ab3 100644 --- a/Lib9c/Action/ItemEnhancement9.cs +++ b/Lib9c/Action/ItemEnhancement9.cs @@ -115,7 +115,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/JoinArena1.cs b/Lib9c/Action/JoinArena1.cs index d19cf2211..3e6228a7d 100644 --- a/Lib9c/Action/JoinArena1.cs +++ b/Lib9c/Action/JoinArena1.cs @@ -61,7 +61,7 @@ protected override void LoadPlainValueInternal( equipments = ((List)plainValue["equipments"]).Select(e => e.ToGuid()).ToList(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/JoinArena2.cs b/Lib9c/Action/JoinArena2.cs index 175e34692..6f4b7ec28 100644 --- a/Lib9c/Action/JoinArena2.cs +++ b/Lib9c/Action/JoinArena2.cs @@ -67,7 +67,7 @@ protected override void LoadPlainValueInternal( runeInfos = plainValue["runeInfos"].ToList(x => new RuneSlotInfo((List)x)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MigrateMonsterCollection.cs b/Lib9c/Action/MigrateMonsterCollection.cs index 0a09d93d0..215e7febe 100644 --- a/Lib9c/Action/MigrateMonsterCollection.cs +++ b/Lib9c/Action/MigrateMonsterCollection.cs @@ -42,7 +42,7 @@ public override void LoadPlainValue(IValue plainValue) AvatarAddress = dictionary[AvatarAddressKey].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MigrationActivatedAccountsState.cs b/Lib9c/Action/MigrationActivatedAccountsState.cs index 02a165ba4..df6739e5e 100644 --- a/Lib9c/Action/MigrationActivatedAccountsState.cs +++ b/Lib9c/Action/MigrationActivatedAccountsState.cs @@ -18,7 +18,7 @@ namespace Nekoyume.Action [ActionType("migration_activated_accounts_state")] public class MigrationActivatedAccountsState : GameAction, IMigrationActivatedAccountsStateV1 { - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MigrationAvatarState.cs b/Lib9c/Action/MigrationAvatarState.cs index 6bf760d28..2e4a45474 100644 --- a/Lib9c/Action/MigrationAvatarState.cs +++ b/Lib9c/Action/MigrationAvatarState.cs @@ -22,7 +22,7 @@ public class MigrationAvatarState : GameAction, IMigrationAvatarStateV1 IEnumerable IMigrationAvatarStateV1.AvatarStates => avatarStates; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MigrationLegacyShop.cs b/Lib9c/Action/MigrationLegacyShop.cs index e1a0e1599..74ecbc303 100644 --- a/Lib9c/Action/MigrationLegacyShop.cs +++ b/Lib9c/Action/MigrationLegacyShop.cs @@ -24,7 +24,7 @@ namespace Nekoyume.Action [ActionObsolete(ActionObsoleteConfig.V200030ObsoleteIndex)] public class MigrationLegacyShop : GameAction, IMigrationLegacyShopV1 { - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MigrationLegacyShop0.cs b/Lib9c/Action/MigrationLegacyShop0.cs index 8f41bc603..a38fa660a 100644 --- a/Lib9c/Action/MigrationLegacyShop0.cs +++ b/Lib9c/Action/MigrationLegacyShop0.cs @@ -17,7 +17,7 @@ namespace Nekoyume.Action [ActionType("migration_legacy_shop")] public class MigrationLegacyShop0 : GameAction, IMigrationLegacyShopV1 { - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MimisbrunnrBattle.cs b/Lib9c/Action/MimisbrunnrBattle.cs index 1ba8c9418..dfc42182f 100644 --- a/Lib9c/Action/MimisbrunnrBattle.cs +++ b/Lib9c/Action/MimisbrunnrBattle.cs @@ -78,7 +78,7 @@ protected override void LoadPlainValueInternal( AvatarAddress = plainValue["avatarAddress"].ToAddress(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/MimisbrunnrBattle0.cs b/Lib9c/Action/MimisbrunnrBattle0.cs index 6ff09d410..cc710d62e 100644 --- a/Lib9c/Action/MimisbrunnrBattle0.cs +++ b/Lib9c/Action/MimisbrunnrBattle0.cs @@ -69,7 +69,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary level; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/MonsterCollect0.cs b/Lib9c/Action/MonsterCollect0.cs index 026cb0bac..9e5ac8b2d 100644 --- a/Lib9c/Action/MonsterCollect0.cs +++ b/Lib9c/Action/MonsterCollect0.cs @@ -24,10 +24,10 @@ public class MonsterCollect0 : GameAction, IMonsterCollectV1 int IMonsterCollectV1.Level => level; int IMonsterCollectV1.CollectionRound => collectionRound; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; Address monsterCollectionAddress = MonsterCollectionState0.DeriveAddress(context.Signer, collectionRound); if (context.Rehearsal) { diff --git a/Lib9c/Action/MonsterCollect2.cs b/Lib9c/Action/MonsterCollect2.cs index cfc1298c3..a1765fb60 100644 --- a/Lib9c/Action/MonsterCollect2.cs +++ b/Lib9c/Action/MonsterCollect2.cs @@ -22,10 +22,10 @@ public class MonsterCollect2 : GameAction, IMonsterCollectV2 int IMonsterCollectV2.Level => level; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/PatchTableSheet.cs b/Lib9c/Action/PatchTableSheet.cs index b0e18e02c..52345f9fc 100644 --- a/Lib9c/Action/PatchTableSheet.cs +++ b/Lib9c/Action/PatchTableSheet.cs @@ -35,7 +35,7 @@ public class PatchTableSheet : GameAction, IPatchTableSheetV1 string IPatchTableSheetV1.TableName => TableName; string IPatchTableSheetV1.TableCsv => TableCsv; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/PetEnhancement.cs b/Lib9c/Action/PetEnhancement.cs index f697b87f0..4299ef0d2 100644 --- a/Lib9c/Action/PetEnhancement.cs +++ b/Lib9c/Action/PetEnhancement.cs @@ -39,7 +39,7 @@ protected override void LoadPlainValueInternal( TargetLevel = plainValue["t"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/PrepareRewardAssets.cs b/Lib9c/Action/PrepareRewardAssets.cs index 69e04ae6d..c5d2499cb 100644 --- a/Lib9c/Action/PrepareRewardAssets.cs +++ b/Lib9c/Action/PrepareRewardAssets.cs @@ -42,10 +42,10 @@ public override void LoadPlainValue(IValue plainValue) Assets = serialized["a"].ToList(StateExtensions.ToFungibleAssetValue); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { foreach (var asset in Assets) diff --git a/Lib9c/Action/Raid.cs b/Lib9c/Action/Raid.cs index 410e385df..0c94bf0c7 100644 --- a/Lib9c/Action/Raid.cs +++ b/Lib9c/Action/Raid.cs @@ -42,10 +42,10 @@ public class Raid : GameAction, IRaidV2 IEnumerable IRaidV2.RuneSlotInfos => RuneInfos.Select(x => x.Serialize()); bool IRaidV2.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid1.cs b/Lib9c/Action/Raid1.cs index aa26de3e5..c987fd0c8 100644 --- a/Lib9c/Action/Raid1.cs +++ b/Lib9c/Action/Raid1.cs @@ -35,10 +35,10 @@ public class Raid1 : GameAction, IRaidV1 IEnumerable IRaidV1.FoodIds => FoodIds; bool IRaidV1.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid2.cs b/Lib9c/Action/Raid2.cs index 0bf006f6d..e5da2dcc1 100644 --- a/Lib9c/Action/Raid2.cs +++ b/Lib9c/Action/Raid2.cs @@ -39,10 +39,10 @@ public class Raid2 : GameAction, IRaidV1 IEnumerable IRaidV1.FoodIds => FoodIds; bool IRaidV1.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid3.cs b/Lib9c/Action/Raid3.cs index f9a52e0d5..67e37488c 100644 --- a/Lib9c/Action/Raid3.cs +++ b/Lib9c/Action/Raid3.cs @@ -43,10 +43,10 @@ public class Raid3 : GameAction, IRaidV2 IEnumerable IRaidV2.RuneSlotInfos => RuneInfos.Select(x => x.Serialize()); bool IRaidV2.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid4.cs b/Lib9c/Action/Raid4.cs index b0928ba16..8fe54c6ef 100644 --- a/Lib9c/Action/Raid4.cs +++ b/Lib9c/Action/Raid4.cs @@ -44,10 +44,10 @@ public class Raid4 : GameAction, IRaidV2 IEnumerable IRaidV2.RuneSlotInfos => RuneInfos.Select(x => x.Serialize()); bool IRaidV2.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid5.cs b/Lib9c/Action/Raid5.cs index b7d06c36c..b8a504efb 100644 --- a/Lib9c/Action/Raid5.cs +++ b/Lib9c/Action/Raid5.cs @@ -43,10 +43,10 @@ public class Raid5 : GameAction, IRaidV2 IEnumerable IRaidV2.RuneSlotInfos => RuneInfos.Select(x => x.Serialize()); bool IRaidV2.PayNcg => PayNcg; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RankingBattle.cs b/Lib9c/Action/RankingBattle.cs index b6e24090f..837e453cb 100644 --- a/Lib9c/Action/RankingBattle.cs +++ b/Lib9c/Action/RankingBattle.cs @@ -43,7 +43,7 @@ public class RankingBattle : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var ctx = context; diff --git a/Lib9c/Action/RankingBattle0.cs b/Lib9c/Action/RankingBattle0.cs index cbacc7b54..662adc1b0 100644 --- a/Lib9c/Action/RankingBattle0.cs +++ b/Lib9c/Action/RankingBattle0.cs @@ -39,7 +39,7 @@ public class RankingBattle0 : GameAction, IRankingBattleV1 IEnumerable IRankingBattleV1.EquipmentIds => equipmentIds; IEnumerable IRankingBattleV1.ConsumableIds => consumableIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle10.cs b/Lib9c/Action/RankingBattle10.cs index 0446370e1..0115feaef 100644 --- a/Lib9c/Action/RankingBattle10.cs +++ b/Lib9c/Action/RankingBattle10.cs @@ -42,7 +42,7 @@ public class RankingBattle10 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle11.cs b/Lib9c/Action/RankingBattle11.cs index 3671ac2c8..cadf4a00c 100644 --- a/Lib9c/Action/RankingBattle11.cs +++ b/Lib9c/Action/RankingBattle11.cs @@ -50,7 +50,7 @@ public class RankingBattle11 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; @@ -323,9 +323,9 @@ public override IAccountStateDelta Execute(IActionContext context) return BackwardCompatibleExecute(rawWeeklyArenaState, sheets, avatarState, costumeStatSheet, sw, addressesHex, enemyAvatarState, ctx, states, inventoryAddress, questListAddress, migrationRequired, worldInformationAddress, started); } - private IAccountStateDelta BackwardCompatibleExecute(Dictionary rawWeeklyArenaState, Dictionary sheets, + private IAccount BackwardCompatibleExecute(Dictionary rawWeeklyArenaState, Dictionary sheets, AvatarState avatarState, CostumeStatSheet costumeStatSheet, Stopwatch sw, string addressesHex, - AvatarState enemyAvatarState, IActionContext ctx, IAccountStateDelta states, Address inventoryAddress, + AvatarState enemyAvatarState, IActionContext ctx, IAccount states, Address inventoryAddress, Address questListAddress, bool migrationRequired, Address worldInformationAddress, DateTimeOffset started) { Dictionary weeklyArenaMap = (Dictionary) rawWeeklyArenaState["map"]; diff --git a/Lib9c/Action/RankingBattle2.cs b/Lib9c/Action/RankingBattle2.cs index 9ff7f646a..848b4b170 100644 --- a/Lib9c/Action/RankingBattle2.cs +++ b/Lib9c/Action/RankingBattle2.cs @@ -40,7 +40,7 @@ public class RankingBattle2 : GameAction, IRankingBattleV1 IEnumerable IRankingBattleV1.EquipmentIds => equipmentIds; IEnumerable IRankingBattleV1.ConsumableIds => consumableIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle3.cs b/Lib9c/Action/RankingBattle3.cs index a696b754d..99b12a464 100644 --- a/Lib9c/Action/RankingBattle3.cs +++ b/Lib9c/Action/RankingBattle3.cs @@ -40,7 +40,7 @@ public class RankingBattle3 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; IEnumerable IRankingBattleV2.ConsumableIds => consumableIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle4.cs b/Lib9c/Action/RankingBattle4.cs index 7b262c8c0..335fbf2f2 100644 --- a/Lib9c/Action/RankingBattle4.cs +++ b/Lib9c/Action/RankingBattle4.cs @@ -40,7 +40,7 @@ public class RankingBattle4 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; IEnumerable IRankingBattleV2.ConsumableIds => consumableIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle5.cs b/Lib9c/Action/RankingBattle5.cs index 6aa29055d..36584cb63 100644 --- a/Lib9c/Action/RankingBattle5.cs +++ b/Lib9c/Action/RankingBattle5.cs @@ -41,7 +41,7 @@ public class RankingBattle5 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; IEnumerable IRankingBattleV2.ConsumableIds => consumableIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle6.cs b/Lib9c/Action/RankingBattle6.cs index f78895373..842d91df3 100644 --- a/Lib9c/Action/RankingBattle6.cs +++ b/Lib9c/Action/RankingBattle6.cs @@ -40,7 +40,7 @@ public class RankingBattle6 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle7.cs b/Lib9c/Action/RankingBattle7.cs index 70e6e150a..7258ca442 100644 --- a/Lib9c/Action/RankingBattle7.cs +++ b/Lib9c/Action/RankingBattle7.cs @@ -40,7 +40,7 @@ public class RankingBattle7 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle8.cs b/Lib9c/Action/RankingBattle8.cs index 0eaa5a6c3..1c488c6a8 100644 --- a/Lib9c/Action/RankingBattle8.cs +++ b/Lib9c/Action/RankingBattle8.cs @@ -43,7 +43,7 @@ public class RankingBattle8 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RankingBattle9.cs b/Lib9c/Action/RankingBattle9.cs index 49c905e9e..84efb75d6 100644 --- a/Lib9c/Action/RankingBattle9.cs +++ b/Lib9c/Action/RankingBattle9.cs @@ -43,7 +43,7 @@ public class RankingBattle9 : GameAction, IRankingBattleV2 IEnumerable IRankingBattleV2.CostumeIds => costumeIds; IEnumerable IRankingBattleV2.EquipmentIds => equipmentIds; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/RapidCombination.cs b/Lib9c/Action/RapidCombination.cs index 79ff3fc08..f8c59fb1b 100644 --- a/Lib9c/Action/RapidCombination.cs +++ b/Lib9c/Action/RapidCombination.cs @@ -32,7 +32,7 @@ public class RapidCombination : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination0.cs b/Lib9c/Action/RapidCombination0.cs index 2df755913..69963e53b 100644 --- a/Lib9c/Action/RapidCombination0.cs +++ b/Lib9c/Action/RapidCombination0.cs @@ -50,7 +50,7 @@ public override IValue Serialize() => Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination2.cs b/Lib9c/Action/RapidCombination2.cs index 430edaad6..88a618347 100644 --- a/Lib9c/Action/RapidCombination2.cs +++ b/Lib9c/Action/RapidCombination2.cs @@ -25,7 +25,7 @@ public class RapidCombination2 : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination3.cs b/Lib9c/Action/RapidCombination3.cs index 0f7d0e432..1240e5b05 100644 --- a/Lib9c/Action/RapidCombination3.cs +++ b/Lib9c/Action/RapidCombination3.cs @@ -25,7 +25,7 @@ public class RapidCombination3 : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination4.cs b/Lib9c/Action/RapidCombination4.cs index de59e5d11..db5dacf77 100644 --- a/Lib9c/Action/RapidCombination4.cs +++ b/Lib9c/Action/RapidCombination4.cs @@ -26,7 +26,7 @@ public class RapidCombination4 : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination5.cs b/Lib9c/Action/RapidCombination5.cs index 20d6dde2d..151c24402 100644 --- a/Lib9c/Action/RapidCombination5.cs +++ b/Lib9c/Action/RapidCombination5.cs @@ -53,7 +53,7 @@ public override IValue Serialize() => Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination6.cs b/Lib9c/Action/RapidCombination6.cs index d0ad37a45..3ef020308 100644 --- a/Lib9c/Action/RapidCombination6.cs +++ b/Lib9c/Action/RapidCombination6.cs @@ -32,7 +32,7 @@ public class RapidCombination6 : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination7.cs b/Lib9c/Action/RapidCombination7.cs index 8082eb153..664be118c 100644 --- a/Lib9c/Action/RapidCombination7.cs +++ b/Lib9c/Action/RapidCombination7.cs @@ -30,7 +30,7 @@ public class RapidCombination7 : GameAction, IRapidCombinationV1 Address IRapidCombinationV1.AvatarAddress => avatarAddress; int IRapidCombinationV1.SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RapidCombination8.cs b/Lib9c/Action/RapidCombination8.cs index 03d04e0e7..b8fb61d38 100644 --- a/Lib9c/Action/RapidCombination8.cs +++ b/Lib9c/Action/RapidCombination8.cs @@ -31,7 +31,7 @@ public class RapidCombination8 : GameAction, IRapidCombinationV1 public Address AvatarAddress => avatarAddress; public int SlotIndex => slotIndex; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ReRegisterProduct.cs b/Lib9c/Action/ReRegisterProduct.cs index ba2f40d95..e2c44bc35 100644 --- a/Lib9c/Action/ReRegisterProduct.cs +++ b/Lib9c/Action/ReRegisterProduct.cs @@ -24,10 +24,10 @@ public class ReRegisterProduct : GameAction public List<(IProductInfo, IRegisterInfo)> ReRegisterInfos; public bool ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/ReRegisterProduct0.cs b/Lib9c/Action/ReRegisterProduct0.cs index d7bad249d..6529ae67c 100644 --- a/Lib9c/Action/ReRegisterProduct0.cs +++ b/Lib9c/Action/ReRegisterProduct0.cs @@ -24,10 +24,10 @@ public class ReRegisterProduct0 : GameAction public List<(IProductInfo, IRegisterInfo)> ReRegisterInfos; public bool ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousState; + IAccount states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RedeemCode.cs b/Lib9c/Action/RedeemCode.cs index 2aaee6472..f3cdab8c9 100644 --- a/Lib9c/Action/RedeemCode.cs +++ b/Lib9c/Action/RedeemCode.cs @@ -41,7 +41,7 @@ public RedeemCode(string code, Address avatarAddress) AvatarAddress = avatarAddress; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RedeemCode0.cs b/Lib9c/Action/RedeemCode0.cs index 80e3cf71a..384a28a99 100644 --- a/Lib9c/Action/RedeemCode0.cs +++ b/Lib9c/Action/RedeemCode0.cs @@ -36,7 +36,7 @@ public RedeemCode0(string code, Address avatarAddress) AvatarAddress = avatarAddress; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RedeemCode2.cs b/Lib9c/Action/RedeemCode2.cs index 06732272f..582d51bbc 100644 --- a/Lib9c/Action/RedeemCode2.cs +++ b/Lib9c/Action/RedeemCode2.cs @@ -37,7 +37,7 @@ public RedeemCode2(string code, Address avatarAddress) AvatarAddress = avatarAddress; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index 2c59913a4..35583fb87 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -25,7 +25,7 @@ public class RegisterProduct : GameAction public IEnumerable RegisterInfos; public bool ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -103,8 +103,8 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - public static IAccountStateDelta Register(IActionContext context, IRegisterInfo info, AvatarState avatarState, - ProductsState productsState, IAccountStateDelta states) + public static IAccount Register(IActionContext context, IRegisterInfo info, AvatarState avatarState, + ProductsState productsState, IAccount states) { switch (info) { diff --git a/Lib9c/Action/RegisterProduct0.cs b/Lib9c/Action/RegisterProduct0.cs index 40692f60a..f973a3b77 100644 --- a/Lib9c/Action/RegisterProduct0.cs +++ b/Lib9c/Action/RegisterProduct0.cs @@ -25,7 +25,7 @@ public class RegisterProduct0 : GameAction public IEnumerable RegisterInfos; public bool ChargeAp; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -103,8 +103,8 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - public static IAccountStateDelta Register(IActionContext context, IRegisterInfo info, AvatarState avatarState, - ProductsState productsState, IAccountStateDelta states) + public static IAccount Register(IActionContext context, IRegisterInfo info, AvatarState avatarState, + ProductsState productsState, IAccount states) { switch (info) { diff --git a/Lib9c/Action/RenewAdminState.cs b/Lib9c/Action/RenewAdminState.cs index 59d6af91e..47bb6c69f 100644 --- a/Lib9c/Action/RenewAdminState.cs +++ b/Lib9c/Action/RenewAdminState.cs @@ -32,7 +32,7 @@ public RenewAdminState(long newValidUntil) NewValidUntil = newValidUntil; } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RequestPledge.cs b/Lib9c/Action/RequestPledge.cs index 3ae6de290..5f05d38d8 100644 --- a/Lib9c/Action/RequestPledge.cs +++ b/Lib9c/Action/RequestPledge.cs @@ -34,7 +34,7 @@ public override void LoadPlainValue(IValue plainValue) RefillMead = values[1].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RewardGold.cs b/Lib9c/Action/RewardGold.cs index 00839c982..c56c981a1 100644 --- a/Lib9c/Action/RewardGold.cs +++ b/Lib9c/Action/RewardGold.cs @@ -34,7 +34,7 @@ public override void LoadPlainValue(IValue plainValue) { } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -57,7 +57,7 @@ public override IAccountStateDelta Execute(IActionContext context) return MinerReward(context, states); } - public IAccountStateDelta GenesisGoldDistribution(IActionContext ctx, IAccountStateDelta states) + public IAccount GenesisGoldDistribution(IActionContext ctx, IAccount states) { IEnumerable goldDistributions = states.GetGoldDistribution(); var index = ctx.BlockIndex; @@ -93,7 +93,7 @@ public IAccountStateDelta GenesisGoldDistribution(IActionContext ctx, IAccountSt } [Obsolete("Use WeeklyArenaRankingBoard2 for performance.")] - public IAccountStateDelta WeeklyArenaRankingBoard(IActionContext ctx, IAccountStateDelta states) + public IAccount WeeklyArenaRankingBoard(IActionContext ctx, IAccount states) { var gameConfigState = states.GetGameConfigState(); var index = Math.Max((int) ctx.BlockIndex / gameConfigState.WeeklyArenaInterval, 0); @@ -126,14 +126,14 @@ public IAccountStateDelta WeeklyArenaRankingBoard(IActionContext ctx, IAccountSt return states; } - public IAccountStateDelta WeeklyArenaRankingBoard2(IActionContext ctx, IAccountStateDelta states) + public IAccount WeeklyArenaRankingBoard2(IActionContext ctx, IAccount states) { states = PrepareNextArena(ctx, states); states = ResetChallengeCount(ctx, states); return states; } - public IAccountStateDelta PrepareNextArena(IActionContext ctx, IAccountStateDelta states) + public IAccount PrepareNextArena(IActionContext ctx, IAccount states) { var gameConfigState = states.GetGameConfigState(); var index = Math.Max((int) ctx.BlockIndex / gameConfigState.WeeklyArenaInterval, 0); @@ -238,7 +238,7 @@ public IAccountStateDelta PrepareNextArena(IActionContext ctx, IAccountStateDelt return states; } - public IAccountStateDelta ResetChallengeCount(IActionContext ctx, IAccountStateDelta states) + public IAccount ResetChallengeCount(IActionContext ctx, IAccount states) { var gameConfigState = states.GetGameConfigState(); var index = Math.Max((int) ctx.BlockIndex / gameConfigState.WeeklyArenaInterval, 0); @@ -279,7 +279,7 @@ public IAccountStateDelta ResetChallengeCount(IActionContext ctx, IAccountStateD return states; } - public IAccountStateDelta MinerReward(IActionContext ctx, IAccountStateDelta states) + public IAccount MinerReward(IActionContext ctx, IAccount states) { // 마이닝 보상 // https://www.notion.so/planetarium/Mining-Reward-b7024ef463c24ebca40a2623027d497d @@ -302,7 +302,7 @@ public IAccountStateDelta MinerReward(IActionContext ctx, IAccountStateDelta sta return states; } - public static IAccountStateDelta TransferMead(IActionContext context, IAccountStateDelta states) + public static IAccount TransferMead(IActionContext context, IAccount states) { #pragma warning disable LAA1002 var targetAddresses = states diff --git a/Lib9c/Action/RuneEnhancement.cs b/Lib9c/Action/RuneEnhancement.cs index 678ec16d2..68190bcbe 100644 --- a/Lib9c/Action/RuneEnhancement.cs +++ b/Lib9c/Action/RuneEnhancement.cs @@ -43,7 +43,7 @@ protected override void LoadPlainValueInternal( TryCount = plainValue["t"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/RuneEnhancement0.cs b/Lib9c/Action/RuneEnhancement0.cs index ac2443687..3624397af 100644 --- a/Lib9c/Action/RuneEnhancement0.cs +++ b/Lib9c/Action/RuneEnhancement0.cs @@ -44,7 +44,7 @@ protected override void LoadPlainValueInternal( TryCount = plainValue["t"].ToInteger(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/SecureMiningReward.cs b/Lib9c/Action/SecureMiningReward.cs index 7b80813a3..7d6ffd846 100644 --- a/Lib9c/Action/SecureMiningReward.cs +++ b/Lib9c/Action/SecureMiningReward.cs @@ -55,10 +55,10 @@ public SecureMiningReward(Address recipient) .Add("type_id", "secure_mining_reward") .Add("values", Recipient.Bencoded); - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousState; + IAccount state = context.PreviousState; if (context.Rehearsal) { return state.MarkBalanceChanged( diff --git a/Lib9c/Action/Sell.cs b/Lib9c/Action/Sell.cs index 65bca601e..f15718382 100644 --- a/Lib9c/Action/Sell.cs +++ b/Lib9c/Action/Sell.cs @@ -61,7 +61,7 @@ protected override void LoadPlainValueInternal( orderId = plainValue[OrderIdKey].ToGuid(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Sell0.cs b/Lib9c/Action/Sell0.cs index 897863369..70a0b7358 100644 --- a/Lib9c/Action/Sell0.cs +++ b/Lib9c/Action/Sell0.cs @@ -41,7 +41,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/Sell5.cs b/Lib9c/Action/Sell5.cs index 71c6d9d0a..6356d5ed4 100644 --- a/Lib9c/Action/Sell5.cs +++ b/Lib9c/Action/Sell5.cs @@ -59,7 +59,7 @@ protected override void LoadPlainValueInternal( itemSubType = plainValue[ItemSubTypeKey].ToEnum(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Sell6.cs b/Lib9c/Action/Sell6.cs index ce604a16e..2735ffaef 100644 --- a/Lib9c/Action/Sell6.cs +++ b/Lib9c/Action/Sell6.cs @@ -58,7 +58,7 @@ protected override void LoadPlainValueInternal( itemSubType = plainValue[ItemSubTypeKey].ToEnum(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Sell7.cs b/Lib9c/Action/Sell7.cs index ee143900f..d872721e5 100644 --- a/Lib9c/Action/Sell7.cs +++ b/Lib9c/Action/Sell7.cs @@ -59,7 +59,7 @@ protected override void LoadPlainValueInternal( orderId = plainValue[OrderIdKey].ToGuid(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Sell8.cs b/Lib9c/Action/Sell8.cs index cada6e520..fc682aadf 100644 --- a/Lib9c/Action/Sell8.cs +++ b/Lib9c/Action/Sell8.cs @@ -59,7 +59,7 @@ protected override void LoadPlainValueInternal( orderId = plainValue[OrderIdKey].ToGuid(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/Sell9.cs b/Lib9c/Action/Sell9.cs index 880b472a6..64a270e0c 100644 --- a/Lib9c/Action/Sell9.cs +++ b/Lib9c/Action/Sell9.cs @@ -58,7 +58,7 @@ protected override void LoadPlainValueInternal( orderId = plainValue[OrderIdKey].ToGuid(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/SellCancellation.cs b/Lib9c/Action/SellCancellation.cs index 58cc5e8b9..db5584891 100644 --- a/Lib9c/Action/SellCancellation.cs +++ b/Lib9c/Action/SellCancellation.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; diff --git a/Lib9c/Action/SellCancellation6.cs b/Lib9c/Action/SellCancellation6.cs index 6d8fb3e75..f7b0d065d 100644 --- a/Lib9c/Action/SellCancellation6.cs +++ b/Lib9c/Action/SellCancellation6.cs @@ -47,7 +47,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary(); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/SellCancellation7.cs b/Lib9c/Action/SellCancellation7.cs index 012c7401e..748591269 100644 --- a/Lib9c/Action/SellCancellation7.cs +++ b/Lib9c/Action/SellCancellation7.cs @@ -82,7 +82,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary IUnlockEquipmentRecipeV1.RecipeIds => RecipeIds; Address IUnlockEquipmentRecipeV1.AvatarAddress => AvatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -107,7 +107,7 @@ public override IAccountStateDelta Execute(IActionContext context) } public static List UnlockedIds( - IAccountStateDelta states, + IAccount states, Address unlockedRecipeIdsAddress, EquipmentItemRecipeSheet equipmentRecipeSheet, WorldInformation worldInformation, diff --git a/Lib9c/Action/UnlockEquipmentRecipe1.cs b/Lib9c/Action/UnlockEquipmentRecipe1.cs index 456d909d3..95ff4993a 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe1.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe1.cs @@ -29,7 +29,7 @@ public class UnlockEquipmentRecipe1: GameAction, IUnlockEquipmentRecipeV1 IEnumerable IUnlockEquipmentRecipeV1.RecipeIds => RecipeIds; Address IUnlockEquipmentRecipeV1.AvatarAddress => AvatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -109,7 +109,7 @@ public override IAccountStateDelta Execute(IActionContext context) } public static List UnlockedIds( - IAccountStateDelta states, + IAccount states, Address unlockedRecipeIdsAddress, EquipmentItemRecipeSheet equipmentRecipeSheet, WorldInformation worldInformation, diff --git a/Lib9c/Action/UnlockRuneSlot.cs b/Lib9c/Action/UnlockRuneSlot.cs index ed9dfb776..679503b3c 100644 --- a/Lib9c/Action/UnlockRuneSlot.cs +++ b/Lib9c/Action/UnlockRuneSlot.cs @@ -40,7 +40,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary IUnlockWorldV1.WorldIds => WorldIds; Address IUnlockWorldV1.AvatarAddress => AvatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/UnlockWorld1.cs b/Lib9c/Action/UnlockWorld1.cs index 017d9084f..f53f2a123 100644 --- a/Lib9c/Action/UnlockWorld1.cs +++ b/Lib9c/Action/UnlockWorld1.cs @@ -25,7 +25,7 @@ public class UnlockWorld1: GameAction, IUnlockWorldV1 IEnumerable IUnlockWorldV1.WorldIds => WorldIds; Address IUnlockWorldV1.AvatarAddress => AvatarAddress; - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/UpdateSell.cs b/Lib9c/Action/UpdateSell.cs index 3742293be..3acb49c6f 100644 --- a/Lib9c/Action/UpdateSell.cs +++ b/Lib9c/Action/UpdateSell.cs @@ -51,7 +51,7 @@ protected override void LoadPlainValueInternal( .ToEnumerable(info => new UpdateSellInfo((List)info)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; @@ -175,7 +175,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states; } - public static IAccountStateDelta Cancel(IAccountStateDelta states, + public static IAccount Cancel(IAccount states, UpdateSellInfo updateSellInfo, string addressesHex, AvatarState avatarState, OrderDigestListState digestList, IActionContext context, Address sellerAvatarAddress) { diff --git a/Lib9c/Action/UpdateSell0.cs b/Lib9c/Action/UpdateSell0.cs index f7572cc46..4b53ccff8 100644 --- a/Lib9c/Action/UpdateSell0.cs +++ b/Lib9c/Action/UpdateSell0.cs @@ -65,7 +65,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new UpdateSellInfo((List)info)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/UpdateSell4.cs b/Lib9c/Action/UpdateSell4.cs index 36ca37c70..2b615c856 100644 --- a/Lib9c/Action/UpdateSell4.cs +++ b/Lib9c/Action/UpdateSell4.cs @@ -53,7 +53,7 @@ protected override void LoadPlainValueInternal( .ToEnumerable(info => new UpdateSellInfo((List)info)); } - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousState; diff --git a/Lib9c/Action/ValidatorSetOperate.cs b/Lib9c/Action/ValidatorSetOperate.cs index d9eb8bef7..987b734a1 100644 --- a/Lib9c/Action/ValidatorSetOperate.cs +++ b/Lib9c/Action/ValidatorSetOperate.cs @@ -68,7 +68,7 @@ public override bool Equals(object obj) public override int GetHashCode() => (Error, (int)Operator, Operand).GetHashCode(); - public override IAccountStateDelta Execute(IActionContext context) + public override IAccount Execute(IActionContext context) { context.UseGas(1); if (Error != null) @@ -78,7 +78,7 @@ public override IAccountStateDelta Execute(IActionContext context) CheckPermission(context); - IAccountStateDelta previousState = context.PreviousState; + IAccount previousState = context.PreviousState; ValidatorSet validatorSet = previousState.GetValidatorSet(); Func func = Operator.ToFunc(); From 0d6d271119d30ad9e421dc06cae02bd5948ad838 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 5 Sep 2023 16:28:18 +0900 Subject: [PATCH 102/134] Check nullable variable --- Lib9c/Model/State/GameConfigState.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib9c/Model/State/GameConfigState.cs b/Lib9c/Model/State/GameConfigState.cs index 1c78a52ae..3f9cbb8e4 100644 --- a/Lib9c/Model/State/GameConfigState.cs +++ b/Lib9c/Model/State/GameConfigState.cs @@ -215,7 +215,12 @@ public override IValue Serialize() public void Set(GameConfigSheet sheet) { - foreach (var row in sheet.OrderedList!) + if (sheet.OrderedList is not { } orderedList) + { + throw new NullReferenceException(nameof(sheet.OrderedList)); + } + + foreach (var row in orderedList) { Update(row); } From 010ac3e8c5ac31574792ed436eceb3bdbfba7477 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 5 Sep 2023 16:30:44 +0900 Subject: [PATCH 103/134] Delay V200080ObsoleteIndex --- Lib9c/ActionObsoleteConfig.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib9c/ActionObsoleteConfig.cs b/Lib9c/ActionObsoleteConfig.cs index 39a6ed6d7..889db7622 100644 --- a/Lib9c/ActionObsoleteConfig.cs +++ b/Lib9c/ActionObsoleteConfig.cs @@ -80,8 +80,7 @@ public static class ActionObsoleteConfig public const long V200071ObsoleteIndex = 7_718_878L; - // NOTE: This is temporary value. - public const long V200080ObsoleteIndex = 7_770_000L; + public const long V200080ObsoleteIndex = 7_974_443L; // While v200020, the action obsolete wasn't work well. // So other previous `V*ObsoletedIndex`s lost its meaning and From 5a5f2e2585c79007a546146c6e8a751a9e4e2160 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 5 Sep 2023 16:55:39 +0900 Subject: [PATCH 104/134] Update summon namespaces - Change sheet name from `AuraSummonSheet` to `SummonSheet` - `SummonSheet` will manage all the summon data. - Also change CSV sheet model. - Move `AuraSummon` action inside `Summon` directory - To prepare another type of summon. --- .Lib9c.Tests/Action/{ => Summon}/AuraSummonTest.cs | 2 +- .Lib9c.Tests/TableSheets.cs | 2 +- Lib9c/Action/AuraSummon.cs | 4 ++-- Lib9c/Helper/SummonHelper.cs | 2 +- Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta | 7 ------- .../Summon/{AuraSummonSheet.csv => SummonSheet.csv} | 0 .../Summon/{AuraSummonSheet.cs => SummonSheet.cs} | 5 ++--- 7 files changed, 7 insertions(+), 15 deletions(-) rename .Lib9c.Tests/Action/{ => Summon}/AuraSummonTest.cs (99%) delete mode 100644 Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta rename Lib9c/TableCSV/Summon/{AuraSummonSheet.csv => SummonSheet.csv} (100%) rename Lib9c/TableData/Summon/{AuraSummonSheet.cs => SummonSheet.cs} (95%) diff --git a/.Lib9c.Tests/Action/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs similarity index 99% rename from .Lib9c.Tests/Action/AuraSummonTest.cs rename to .Lib9c.Tests/Action/Summon/AuraSummonTest.cs index b2a40c54d..ed8aa407a 100644 --- a/.Lib9c.Tests/Action/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -1,4 +1,4 @@ -namespace Lib9c.Tests.Action +namespace Lib9c.Tests.Action.Summon { using System; using System.Data; diff --git a/.Lib9c.Tests/TableSheets.cs b/.Lib9c.Tests/TableSheets.cs index faec682f2..a685ff8cd 100644 --- a/.Lib9c.Tests/TableSheets.cs +++ b/.Lib9c.Tests/TableSheets.cs @@ -232,7 +232,7 @@ public StakeActionPointCoefficientSheet StakeActionPointCoefficientSheet public LoadIntoMyGaragesCostSheet LoadIntoMyGaragesCostSheet { get; private set; } - public AuraSummonSheet AuraSummonSheet { get; private set; } + public SummonSheet SummonSheet { get; private set; } public void ItemSheetInitialize() { diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 14bb57e57..2f2a9b98b 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -90,7 +90,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Validate Work Dictionary sheets = states.GetSheets(sheetTypes: new[] { - typeof(AuraSummonSheet), + typeof(SummonSheet), typeof(EquipmentItemRecipeSheet), typeof(EquipmentItemSheet), typeof(MaterialItemSheet), @@ -99,7 +99,7 @@ public override IAccountStateDelta Execute(IActionContext context) typeof(SkillSheet), }); - var summonSheet = sheets.GetSheet(); + var summonSheet = sheets.GetSheet(); var summonRow = summonSheet.OrderedList.FirstOrDefault(row => row.GroupId == GroupId); if (summonRow is null) { diff --git a/Lib9c/Helper/SummonHelper.cs b/Lib9c/Helper/SummonHelper.cs index be4b0cc9c..f889a5a8b 100644 --- a/Lib9c/Helper/SummonHelper.cs +++ b/Lib9c/Helper/SummonHelper.cs @@ -5,7 +5,7 @@ namespace Nekoyume.Helper { public class SummonHelper { - public static int PickAuraSummonRecipe(AuraSummonSheet.Row summonRow, IRandom random) + public static int PickAuraSummonRecipe(SummonSheet.Row summonRow, IRandom random) { var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); if (recipeValue <= summonRow.CumulativeRecipe1Ratio) diff --git a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta b/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta deleted file mode 100644 index 0c7de032b..000000000 --- a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1d659cdee0a104444a99ca342a32267c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Lib9c/TableCSV/Summon/AuraSummonSheet.csv b/Lib9c/TableCSV/Summon/SummonSheet.csv similarity index 100% rename from Lib9c/TableCSV/Summon/AuraSummonSheet.csv rename to Lib9c/TableCSV/Summon/SummonSheet.csv diff --git a/Lib9c/TableData/Summon/AuraSummonSheet.cs b/Lib9c/TableData/Summon/SummonSheet.cs similarity index 95% rename from Lib9c/TableData/Summon/AuraSummonSheet.cs rename to Lib9c/TableData/Summon/SummonSheet.cs index 4f2f05884..04bafa080 100644 --- a/Lib9c/TableData/Summon/AuraSummonSheet.cs +++ b/Lib9c/TableData/Summon/SummonSheet.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; -using Bencodex.Types; using static Nekoyume.TableData.TableExtensions; namespace Nekoyume.TableData.Summon { - public class AuraSummonSheet : Sheet + public class SummonSheet : Sheet { public class Row : SheetRow { @@ -69,7 +68,7 @@ private void SetCumulativeRatio() } } - public AuraSummonSheet() : base(nameof(AuraSummonSheet)) + public SummonSheet() : base(nameof(SummonSheet)) { } } From 6af8356dc415fec1ff3448f59855970206158804 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 5 Sep 2023 17:35:24 +0900 Subject: [PATCH 105/134] Use list instead of individual recipes --- Lib9c/Helper/SummonHelper.cs | 28 +++++----- Lib9c/TableData/Summon/SummonSheet.cs | 79 +++++++++++++++------------ 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/Lib9c/Helper/SummonHelper.cs b/Lib9c/Helper/SummonHelper.cs index f889a5a8b..e7038592e 100644 --- a/Lib9c/Helper/SummonHelper.cs +++ b/Lib9c/Helper/SummonHelper.cs @@ -10,28 +10,30 @@ public static int PickAuraSummonRecipe(SummonSheet.Row summonRow, IRandom random var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); if (recipeValue <= summonRow.CumulativeRecipe1Ratio) { - return summonRow.Recipe1; + return summonRow.Recipes[0].Item1; } - else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) - { - return summonRow.Recipe2; - } - else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) + + if (recipeValue <= summonRow.CumulativeRecipe2Ratio) { - return summonRow.Recipe3; + return summonRow.Recipes[1].Item1; } - else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) + + if (recipeValue <= summonRow.CumulativeRecipe3Ratio) { - return summonRow.Recipe4; + return summonRow.Recipes[2].Item1; } - else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) + + if (recipeValue <= summonRow.CumulativeRecipe4Ratio) { - return summonRow.Recipe5; + return summonRow.Recipes[3].Item1; } - else + + if (recipeValue <= summonRow.CumulativeRecipe5Ratio) { - return summonRow.Recipe6; + return summonRow.Recipes[4].Item1; } + + return summonRow.Recipes[5].Item1; } } } diff --git a/Lib9c/TableData/Summon/SummonSheet.cs b/Lib9c/TableData/Summon/SummonSheet.cs index 04bafa080..04bf616d4 100644 --- a/Lib9c/TableData/Summon/SummonSheet.cs +++ b/Lib9c/TableData/Summon/SummonSheet.cs @@ -13,19 +13,8 @@ public class Row : SheetRow public int CostMaterial { get; private set; } public int CostMaterialCount { get; private set; } public int CostNcg { get; private set; } - public int Recipe1 { get; private set; } - public int Recipe2 { get; private set; } - public int Recipe3 { get; private set; } - public int Recipe4 { get; private set; } - public int Recipe5 { get; private set; } - public int Recipe6 { get; private set; } - public int Recipe1Ratio { get; private set; } - public int Recipe2Ratio { get; private set; } - public int Recipe3Ratio { get; private set; } - public int Recipe4Ratio { get; private set; } - public int Recipe5Ratio { get; private set; } - public int Recipe6Ratio { get; private set; } + public readonly List<(int, int)> Recipes = new List<(int, int)>(); // For convenience public int CumulativeRecipe1Ratio { get; private set; } public int CumulativeRecipe2Ratio { get; private set; } @@ -40,31 +29,51 @@ public override void Set(IReadOnlyList fields) CostMaterial = ParseInt(fields[1]); CostMaterialCount = ParseInt(fields[2]); CostNcg = ParseInt(fields[3]); - // WARNING: Be aware of fields index!! - Recipe1 = ParseInt(fields[4]); - Recipe2 = ParseInt(fields[6]); - Recipe3 = TryParseInt(fields[8], out _) ? ParseInt(fields[8]) : 0; - Recipe4 = TryParseInt(fields[10], out _) ? ParseInt(fields[10]) : 0; - Recipe5 = TryParseInt(fields[12], out _) ? ParseInt(fields[12]) : 0; - Recipe6 = TryParseInt(fields[14], out _) ? ParseInt(fields[14]) : 0; - Recipe1Ratio = ParseInt(fields[5]); - Recipe2Ratio = ParseInt(fields[7]); - Recipe3Ratio = TryParseInt(fields[9], out _) ? ParseInt(fields[9]) : 0; - Recipe4Ratio = TryParseInt(fields[11], out _) ? ParseInt(fields[11]) : 0; - Recipe5Ratio = TryParseInt(fields[13], out _) ? ParseInt(fields[13]) : 0; - Recipe6Ratio = TryParseInt(fields[15], out _) ? ParseInt(fields[15]) : 0; + // Min. Two recipes are necessary + Recipes.Add((ParseInt(fields[4]), ParseInt(fields[5]))); + CumulativeRecipe1Ratio = ParseInt(fields[5]); + Recipes.Add((ParseInt(fields[6]), ParseInt(fields[7]))); + CumulativeRecipe2Ratio = CumulativeRecipe1Ratio + ParseInt(fields[7]); - SetCumulativeRatio(); - } + // Recipe3 ~ 6 are optional + if (TryParseInt(fields[8], out _) && TryParseInt(fields[9], out _)) + { + Recipes.Add((ParseInt(fields[8]), ParseInt(fields[9]))); + CumulativeRecipe3Ratio = CumulativeRecipe2Ratio + ParseInt(fields[9]); + } + else + { + CumulativeRecipe3Ratio = CumulativeRecipe2Ratio; + } - private void SetCumulativeRatio() - { - CumulativeRecipe1Ratio = Recipe1Ratio; - CumulativeRecipe2Ratio = CumulativeRecipe1Ratio + Recipe2Ratio; - CumulativeRecipe3Ratio = CumulativeRecipe2Ratio + Recipe3Ratio; - CumulativeRecipe4Ratio = CumulativeRecipe3Ratio + Recipe4Ratio; - CumulativeRecipe5Ratio = CumulativeRecipe4Ratio + Recipe5Ratio; - CumulativeRecipe6Ratio = CumulativeRecipe5Ratio + Recipe6Ratio; + if (TryParseInt(fields[10], out _) && TryParseInt(fields[11], out _)) + { + Recipes.Add((ParseInt(fields[10]), ParseInt(fields[11]))); + CumulativeRecipe4Ratio = CumulativeRecipe3Ratio + ParseInt(fields[11]); + } + else + { + CumulativeRecipe4Ratio = CumulativeRecipe3Ratio; + } + + if (TryParseInt(fields[12], out _) && TryParseInt(fields[13], out _)) + { + Recipes.Add((ParseInt(fields[12]), ParseInt(fields[13]))); + CumulativeRecipe5Ratio = CumulativeRecipe4Ratio + ParseInt(fields[13]); + } + else + { + CumulativeRecipe5Ratio = CumulativeRecipe4Ratio; + } + if (TryParseInt(fields[14], out _) && TryParseInt(fields[15], out _)) + { + Recipes.Add((ParseInt(fields[14]), ParseInt(fields[15]))); + CumulativeRecipe6Ratio = CumulativeRecipe5Ratio + ParseInt(fields[15]); + } + else + { + CumulativeRecipe6Ratio = CumulativeRecipe5Ratio; + } } } From a633827f620114944b18cb788f8bb753df178f03 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 5 Sep 2023 17:53:12 +0900 Subject: [PATCH 106/134] Update AuraSummon action - Add execution time log - Add SummonLimit to limit max. summon count - Remove useless ordering --- .Lib9c.Tests/Action/Summon/AuraSummonTest.cs | 4 +++- Lib9c/Action/AuraSummon.cs | 14 ++++++++++++- .../Exceptions/InvalidSummonCountException.cs | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Lib9c/Action/Exceptions/InvalidSummonCountException.cs diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index ed8aa407a..ff9923c2a 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -8,6 +8,7 @@ namespace Lib9c.Tests.Action.Summon using Libplanet.Types.Assets; using Nekoyume; using Nekoyume.Action; + using Nekoyume.Action.Exceptions; using Nekoyume.Model.Item; using Nekoyume.Model.State; using Xunit; @@ -89,7 +90,8 @@ public AuraSummonTest() // fail by not enough material [InlineData(10001, 1, 600201, 1, 0, new int[] { }, typeof(NotEnoughMaterialException))] [InlineData(10001, 2, 600201, 1, 0, new int[] { }, typeof(NotEnoughMaterialException))] - // TODO: Fail by not enough NCG + // Fail by exceeding summon limit + [InlineData(10001, 11, 600201, 22, 1, new int[] { }, typeof(InvalidSummonCountException))] public void Execute( int groupId, int summonCount, diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 2f2a9b98b..89e255f72 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -8,6 +8,7 @@ using Libplanet.Action; using Libplanet.Action.State; using Libplanet.Crypto; +using Nekoyume.Action.Exceptions; using Nekoyume.Extensions; using Nekoyume.Helper; using Nekoyume.Model.Item; @@ -33,6 +34,8 @@ public class AuraSummon : GameAction, IAuraSummonV1 public const string SummonCountKey = "sc"; public int SummonCount; + private const int SummonLimit = 10; + Address IAuraSummonV1.AvatarAddress => AvatarAddress; int IAuraSummonV1.GroupId => GroupId; int IAuraSummonV1.SummonCount => SummonCount; @@ -87,6 +90,13 @@ public override IAccountStateDelta Execute(IActionContext context) $"{addressesHex} Aborted as the avatar state of the signer was failed to load."); } + if (SummonCount <= 0 || SummonCount > SummonLimit) + { + throw new InvalidSummonCountException( + $"{addressesHex} Given summonCount {SummonCount} is not valid. Please use between 1 and 10" + ); + } + // Validate Work Dictionary sheets = states.GetSheets(sheetTypes: new[] { @@ -213,6 +223,9 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.UpdateQuestRewards(materialSheet); } + Log.Debug( + $"{addressesHex} AuraSummon Exec. finished: {DateTimeOffset.UtcNow - started} Elapsed"); + avatarState.blockIndex = context.BlockIndex; avatarState.updatedAt = context.BlockIndex; @@ -235,7 +248,6 @@ SkillSheet skillSheet { foreach (var optionInfo in subRecipe.Options .OrderByDescending(e => e.Ratio) - .ThenBy(e => e.RequiredBlockIndex) .ThenBy(e => e.Id)) { if (!optionSheet.TryGetValue(optionInfo.Id, out var optionRow)) diff --git a/Lib9c/Action/Exceptions/InvalidSummonCountException.cs b/Lib9c/Action/Exceptions/InvalidSummonCountException.cs new file mode 100644 index 000000000..3a51953db --- /dev/null +++ b/Lib9c/Action/Exceptions/InvalidSummonCountException.cs @@ -0,0 +1,21 @@ +using System; +using System.Runtime.Serialization; + +namespace Nekoyume.Action.Exceptions +{ + public class InvalidSummonCountException : ArgumentException + { + public InvalidSummonCountException() + { + } + + public InvalidSummonCountException(string msg) : base(msg) + { + } + + protected InvalidSummonCountException(SerializationInfo info, StreamingContext context) : + base(info, context) + { + } + } +} From a278d65fb517b42048ad551582782a84b238f164 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 5 Sep 2023 18:09:25 +0900 Subject: [PATCH 107/134] Fix wrong material removing problem --- .Lib9c.Tests/Action/Summon/AuraSummonTest.cs | 3 ++ Lib9c/Action/AuraSummon.cs | 32 ++++++++------------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index ff9923c2a..86ccccc51 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -155,6 +155,9 @@ Type expectedExc Assert.Equal(1, resultEquipment.RequiredBlockIndex); Assert.True(resultEquipment.optionCountFromCombination > 0); } + + nextState.GetAvatarStateV2(_avatarAddress).inventory.TryGetItem((int)materialId!, out var resultMaterial); + Assert.Equal(0, resultMaterial?.count ?? 0); } else { diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 89e255f72..9d9ea36ca 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -109,6 +109,13 @@ public override IAccountStateDelta Execute(IActionContext context) typeof(SkillSheet), }); + var recipeSheet = sheets.GetSheet(); + var materialSheet = sheets.GetSheet(); + var equipmentItemSheet = sheets.GetSheet(); + var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); + var optionSheet = sheets.GetSheet(); + var skillSheet = sheets.GetSheet(); + var summonSheet = sheets.GetSheet(); var summonRow = summonSheet.OrderedList.FirstOrDefault(row => row.GroupId == GroupId); if (summonRow is null) @@ -117,15 +124,14 @@ public override IAccountStateDelta Execute(IActionContext context) $"{addressesHex} Failed to get {GroupId} in AuraSummonSheet"); } - // Validate requirements + // Use materials var inventory = avatarState.inventory; - var itemCount = inventory.TryGetItem(summonRow.CostMaterial, out var item) - ? item.count - : 0; - if (itemCount < summonRow.CostMaterialCount * SummonCount) + var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); + if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, + summonRow.CostMaterialCount * SummonCount)) { throw new NotEnoughMaterialException( - $"{addressesHex} Not enough material to summon"); + $"{addressesHex} Aborted as the player has no enough material ({summonRow.CostMaterial} * {summonRow.CostMaterialCount})"); } // Transfer Cost NCG first for fast-fail @@ -144,12 +150,6 @@ public override IAccountStateDelta Execute(IActionContext context) ); } - var recipeSheet = sheets.GetSheet(); - var materialSheet = sheets.GetSheet(); - var equipmentItemSheet = sheets.GetSheet(); - var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); - var optionSheet = sheets.GetSheet(); - var skillSheet = sheets.GetSheet(); for (var i = 0; i < SummonCount; i++) { @@ -192,14 +192,6 @@ public override IAccountStateDelta Execute(IActionContext context) ); } - // Use materials - var material = materialSheet.OrderedList.First(m => m.Id == summonRow.CostMaterial); - if (!inventory.RemoveFungibleItem(material.ItemId, context.BlockIndex, - summonRow.CostMaterialCount)) - { - throw new NotEnoughMaterialException( - $"{addressesHex} Aborted as the player has no enough material ({summonRow.CostMaterial} * {summonRow.CostMaterialCount})"); - } // Create Equipment var equipment = (Equipment)ItemFactory.CreateItemUsable( From 36a7a3ff08c858419861bd0e4d934a9f153c719b Mon Sep 17 00:00:00 2001 From: hyeon Date: Wed, 6 Sep 2023 10:18:46 +0900 Subject: [PATCH 108/134] Fix csv error --- Lib9c/TableCSV/Summon/SummonSheet.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib9c/TableCSV/Summon/SummonSheet.csv b/Lib9c/TableCSV/Summon/SummonSheet.csv index 2d895b259..a50db806e 100644 --- a/Lib9c/TableCSV/Summon/SummonSheet.csv +++ b/Lib9c/TableCSV/Summon/SummonSheet.csv @@ -1,4 +1,3 @@ groupID,cost_material,cost_material_count,cost_ncg,recipe1ID,recipe1ratio,recipe2ID,recipe2ratio,recipe3ID,recipe3ratio,recipe4ID,recipe4ratio,recipe5ID,recipe5ratio,recipe6ID,recipe6ratio 10001,600201,2,0,171,70,172,29,173,1,,,,,, 10002,600202,2,0,174,50,175,30,176,17,177,3,,,, -,, From 7683768cd880de16047960049deaa9d678ee12dc Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 6 Sep 2023 10:36:00 +0900 Subject: [PATCH 109/134] add comments --- Lib9c/Model/Stake/StakeStateUtils.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib9c/Model/Stake/StakeStateUtils.cs b/Lib9c/Model/Stake/StakeStateUtils.cs index d6b08dfd3..9d27c29ae 100644 --- a/Lib9c/Model/Stake/StakeStateUtils.cs +++ b/Lib9c/Model/Stake/StakeStateUtils.cs @@ -20,18 +20,21 @@ public static bool TryMigrate( return false; } + // NOTE: StakeStateV2 is serialized as Bencodex List. if (serialized is List list) { stakeStateV2 = new StakeStateV2(list); return true; } + // NOTE: StakeState is serialized as Bencodex Dictionary. if (serialized is not Dictionary dict) { stakeStateV2 = default; return false; } + // NOTE: Migration needs GameConfigState. var gameConfigState = state.GetGameConfigState(); if (gameConfigState is null) { @@ -39,6 +42,24 @@ public static bool TryMigrate( return false; } + // NOTE: Below is the migration logic from StakeState to StakeStateV2. + // The migration logic is based on the following assumptions: + // - The migration target is StakeState which is serialized as Bencodex Dictionary. + // - The started block index of StakeState is less than or equal to ActionObsoleteConfig.V200080ObsoleteIndex. + // - Migrated StakeStateV2 will be contracted by StakeStateV2.Contract. + // - StakeStateV2.Contract.StakeRegularFixedRewardSheetTableName is one of the following: + // - "StakeRegularFixedRewardSheet_V1" + // - "StakeRegularFixedRewardSheet_V2" + // - StakeStateV2.Contract.StakeRegularRewardSheetTableName is one of the following: + // - "StakeRegularRewardSheet_V1" + // - "StakeRegularRewardSheet_V2" + // - "StakeRegularRewardSheet_V3" + // - "StakeRegularRewardSheet_V4" + // - "StakeRegularRewardSheet_V5" + // - StakeStateV2.Contract.RewardInterval is StakeState.RewardInterval. + // - StakeStateV2.Contract.LockupInterval is StakeState.LockupInterval. + // - StakeStateV2.StartedBlockIndex is StakeState.StartedBlockIndex. + // - StakeStateV2.ReceivedBlockIndex is StakeState.ReceivedBlockIndex. var stakeStateV1 = new StakeState(dict); var stakeRegularFixedRewardSheetTableName = stakeStateV1.StartedBlockIndex < From c1e214e9407271a09ca41efd3640551bc9196639 Mon Sep 17 00:00:00 2001 From: tyrosine1153 Date: Wed, 6 Sep 2023 13:29:44 +0900 Subject: [PATCH 110/134] add sheet meta file (unity) --- Lib9c/TableCSV/Summon/SummonSheet.csv.meta | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Lib9c/TableCSV/Summon/SummonSheet.csv.meta diff --git a/Lib9c/TableCSV/Summon/SummonSheet.csv.meta b/Lib9c/TableCSV/Summon/SummonSheet.csv.meta new file mode 100644 index 000000000..ef25df310 --- /dev/null +++ b/Lib9c/TableCSV/Summon/SummonSheet.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9649cafeff91b8a4d86a63c6ed34d971 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 6efe4233b20335e9bfb10af8e823c4720879e5ae Mon Sep 17 00:00:00 2001 From: Atralupus Date: Thu, 7 Sep 2023 01:23:40 +0900 Subject: [PATCH 111/134] Add .gitallowed for git secrets --- .gitallowed | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .gitallowed diff --git a/.gitallowed b/.gitallowed new file mode 100644 index 000000000..8015d188f --- /dev/null +++ b/.gitallowed @@ -0,0 +1,17 @@ +# For LoadIntoMyGaragesCostSheetTest.cs +00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe +3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a +1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820 +f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0 +1234567890123456789012345678901234567890123456789012345678901234 + +# For ActivationKeyTest.cs +ac84ad2eb0bc62c63e8c4e4f22f7c19d283b36e60fdc4eed182d4d7a7bb4c716 + +# For TransferAsset0SnapshotTest.cs +810234bc093e2b66406b06dd0c2d2d3320bc5f19caef7acd3f800424bd46cb60 +f8960846e9ae4ad1c23686f74c8e5f80f22336b6f2175be21db82afa8823c92d + +# For NCStagePolicy.cs +300826da62b595d8cd663dadf04995a7411534d1cdc17dac75ce88754472f774 +210d1374d8f068de657de6b991e63888da9cadbc68e505ac917b35568b5340f8 From e1cc9060e925f4de1dd8e1e917a9e470f0025a5a Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 7 Sep 2023 08:27:11 +0900 Subject: [PATCH 112/134] add throw unit test case for Contract constructor --- .Lib9c.Tests/Model/Stake/ContractTest.cs | 6 ++++++ Lib9c/Model/Stake/Contract.cs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Model/Stake/ContractTest.cs b/.Lib9c.Tests/Model/Stake/ContractTest.cs index 710b7ce21..5c5bf3e8c 100644 --- a/.Lib9c.Tests/Model/Stake/ContractTest.cs +++ b/.Lib9c.Tests/Model/Stake/ContractTest.cs @@ -118,6 +118,12 @@ public void Constructor_Throws_ArgumentOutOfRangeException( lockupInterval)); } + [Fact] + public void Constructor_With_StakePolicySheet_Throw_ArgumentNullException() + { + Assert.Throws(() => new Contract((StakePolicySheet)null)); + } + [Theory] [InlineData(StakePolicySheetFixtures.V1)] [InlineData(StakePolicySheetFixtures.V2)] diff --git a/Lib9c/Model/Stake/Contract.cs b/Lib9c/Model/Stake/Contract.cs index 1063aafea..738ed66b0 100644 --- a/Lib9c/Model/Stake/Contract.cs +++ b/Lib9c/Model/Stake/Contract.cs @@ -21,7 +21,9 @@ public const string StakeRegularRewardSheetPrefix public long LockupInterval { get; } public Contract(StakePolicySheet stakePolicySheet) : this( - stakePolicySheet.StakeRegularFixedRewardSheetValue, + stakePolicySheet?.StakeRegularFixedRewardSheetValue ?? throw new ArgumentNullException( + nameof(stakePolicySheet), + $"{nameof(stakePolicySheet)} is null"), stakePolicySheet.StakeRegularRewardSheetValue, stakePolicySheet.RewardIntervalValue, stakePolicySheet.LockupIntervalValue) From 7243ba0b6b6c5d50707f1c19062f55927c9275a5 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 7 Sep 2023 08:28:20 +0900 Subject: [PATCH 113/134] rename a few unit tests --- .Lib9c.Tests/Model/Stake/ContractTest.cs | 4 ++-- .Lib9c.Tests/Model/Stake/StakeStateV2Test.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.Lib9c.Tests/Model/Stake/ContractTest.cs b/.Lib9c.Tests/Model/Stake/ContractTest.cs index 5c5bf3e8c..739c8b83e 100644 --- a/.Lib9c.Tests/Model/Stake/ContractTest.cs +++ b/.Lib9c.Tests/Model/Stake/ContractTest.cs @@ -19,7 +19,7 @@ public class ContractTest Contract.StakeRegularRewardSheetPrefix + "test", long.MaxValue, long.MaxValue)] - public void Constructor_Default( + public void Constructor( string stakeRegularFixedRewardSheetTableName, string stakeRegularRewardSheetTableName, long rewardInterval, @@ -127,7 +127,7 @@ public void Constructor_With_StakePolicySheet_Throw_ArgumentNullException() [Theory] [InlineData(StakePolicySheetFixtures.V1)] [InlineData(StakePolicySheetFixtures.V2)] - public void Constructor_StakePolicySheet(string stakePolicySheetCsv) + public void Constructor_With_StakePolicySheet(string stakePolicySheetCsv) { var sheet = new StakePolicySheet(); sheet.Set(stakePolicySheetCsv); diff --git a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs index f637384f1..924baefb0 100644 --- a/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs +++ b/.Lib9c.Tests/Model/Stake/StakeStateV2Test.cs @@ -19,7 +19,7 @@ public void DeriveAddress() [Theory] [InlineData(0, 0)] [InlineData(long.MaxValue, long.MaxValue)] - public void Constructor_Default(long startedBlockIndex, long receivedBlockIndex) + public void Constructor(long startedBlockIndex, long receivedBlockIndex) { var contract = new Contract( Contract.StakeRegularFixedRewardSheetPrefix, @@ -60,7 +60,7 @@ public void Constructor_Throw_ArgumentOutOfRangeException( [InlineData(0, 0)] [InlineData(long.MaxValue, null)] [InlineData(long.MaxValue, long.MaxValue)] - public void Constructor_StakeState(long startedBlockIndex, long? receivedBlockIndex) + public void Constructor_With_StakeState(long startedBlockIndex, long? receivedBlockIndex) { var stakeState = new StakeState( new PrivateKey().ToAddress(), @@ -82,7 +82,7 @@ public void Constructor_StakeState(long startedBlockIndex, long? receivedBlockIn } [Fact] - public void Constructor_StakeState_Throw_ArgumentNullException() + public void Constructor_With_StakeState_Throw_ArgumentNullException() { var stakeState = new StakeState(new PrivateKey().ToAddress(), 0); var contract = new Contract( From 1482ce66c21368a7fb169783b2a2cab44f157b52 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 7 Sep 2023 15:08:23 +0900 Subject: [PATCH 114/134] Fix aura duplicate equip --- .../Action/Scenario/AuraScenarioTest.cs | 17 ++++++++++++++++- Lib9c/GameConfig.cs | 1 + Lib9c/Model/State/AvatarState.cs | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index a104777eb..84a505b9e 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -104,6 +104,7 @@ public void HackAndSlash() Equipments = new List { _aura.ItemId, + _aura.ItemId, }, Costumes = new List(), Foods = new List(), @@ -111,12 +112,26 @@ public void HackAndSlash() RuneInfos = new List(), }; - var nextState = has.Execute(new ActionContext + Assert.Throws(() => has.Execute(new ActionContext { BlockIndex = 2, PreviousState = _initialState, Random = new TestRandom(), Signer = _agentAddress, + })); + + has.Equipments = new List + { + _aura.ItemId, + }; + + // equip aura because auraIgnoreSheet is empty + var nextState = has.Execute(new ActionContext + { + BlockIndex = 3, + PreviousState = _initialState, + Random = new TestRandom(), + Signer = _agentAddress, }); var avatarState = _initialState.GetAvatarStateV2(_avatarAddress); diff --git a/Lib9c/GameConfig.cs b/Lib9c/GameConfig.cs index 959245b7d..208a4eea1 100644 --- a/Lib9c/GameConfig.cs +++ b/Lib9c/GameConfig.cs @@ -129,6 +129,7 @@ public static class MaxEquipmentSlotCount public const int Belt = 1; public const int Necklace = 1; public const int Ring = 2; + public const int Aura = 1; } } } diff --git a/Lib9c/Model/State/AvatarState.cs b/Lib9c/Model/State/AvatarState.cs index 01fefbb2c..847a756d7 100644 --- a/Lib9c/Model/State/AvatarState.cs +++ b/Lib9c/Model/State/AvatarState.cs @@ -672,6 +672,7 @@ public List ValidateEquipmentsV2(List equipmentIds, long blockI : int.MaxValue; break; case ItemSubType.Aura: + isSlotEnough = countMap[type] <= GameConfig.MaxEquipmentSlotCount.Aura; requiredLevel = 1; break; default: From 771567583c5c3033ace854680b82ff119f5e3f66 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 7 Sep 2023 21:04:43 +0900 Subject: [PATCH 115/134] Bump libplanet to 3.3.0 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index 97b3d2e59..aa72117b8 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit 97b3d2e597c067f06b4f45c8a7b8ccb2ac4ae3f3 +Subproject commit aa72117b8887ec9e189cac97cefc3fa77966dd81 From 64a44b71dbfff50d895d0ac7ade24feab66c0586 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Wed, 6 Sep 2023 10:57:45 +0900 Subject: [PATCH 116/134] Accommodate API changes --- .Lib9c.Tests/Action/MockState.cs | 3 +++ .Lib9c.Tests/Action/MockStateDelta.cs | 3 +++ .../AccountStateDelta.cs | 3 +++ .../RemoteActionEvaluator.cs | 2 +- .../RemoteBlockChainStates.cs | 2 +- .../RemoteBlockState.cs | 5 ++++- Lib9c.MessagePack/AccountStateDelta.cs | 3 +++ Lib9c/Action/ActionBaseExtensions.cs | 3 +++ 8 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.Lib9c.Tests/Action/MockState.cs b/.Lib9c.Tests/Action/MockState.cs index 16d71e0c5..5a1ded150 100644 --- a/.Lib9c.Tests/Action/MockState.cs +++ b/.Lib9c.Tests/Action/MockState.cs @@ -10,6 +10,7 @@ namespace Lib9c.Tests.Action using Bencodex.Types; using Libplanet.Action.State; using Libplanet.Crypto; + using Libplanet.Store.Trie; using Libplanet.Types.Assets; using Libplanet.Types.Consensus; @@ -79,6 +80,8 @@ private MockState( public static MockState Empty => _empty; + public ITrie Trie => throw new NotSupportedException(); + public IImmutableDictionary States => _states; public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => _fungibles; diff --git a/.Lib9c.Tests/Action/MockStateDelta.cs b/.Lib9c.Tests/Action/MockStateDelta.cs index dfad94be1..18a0486a2 100644 --- a/.Lib9c.Tests/Action/MockStateDelta.cs +++ b/.Lib9c.Tests/Action/MockStateDelta.cs @@ -12,6 +12,7 @@ namespace Lib9c.Tests.Action using Libplanet.Action; using Libplanet.Action.State; using Libplanet.Crypto; + using Libplanet.Store.Trie; using Libplanet.Types.Assets; using Libplanet.Types.Consensus; @@ -41,6 +42,8 @@ private MockStateDelta(IAccountState baseState, IAccountDelta delta) TotalUpdatedFungibles = ImmutableDictionary<(Address, Currency), BigInteger>.Empty; } + public ITrie Trie => throw new NotSupportedException(); + /// public IAccountDelta Delta { get; private set; } diff --git a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs index b7485ceef..da9f57dce 100644 --- a/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs +++ b/.Libplanet.Extensions.ActionEvaluatorCommonComponents/AccountStateDelta.cs @@ -5,6 +5,7 @@ using Libplanet.Action; using Libplanet.Action.State; using Libplanet.Crypto; +using Libplanet.Store.Trie; using Libplanet.Types.Assets; using Libplanet.Types.Consensus; @@ -118,6 +119,8 @@ public AccountStateDelta(byte[] bytes) { } + public ITrie Trie => throw new NotSupportedException(); + public IAccountDelta Delta => _delta; public IValue? GetState(Address address) => diff --git a/.Libplanet.Extensions.RemoteActionEvaluator/RemoteActionEvaluator.cs b/.Libplanet.Extensions.RemoteActionEvaluator/RemoteActionEvaluator.cs index 819011c44..1961bd374 100644 --- a/.Libplanet.Extensions.RemoteActionEvaluator/RemoteActionEvaluator.cs +++ b/.Libplanet.Extensions.RemoteActionEvaluator/RemoteActionEvaluator.cs @@ -49,7 +49,7 @@ public IReadOnlyList Evaluate(IPreEvaluationBlock block) else { actionEvaluations[i].InputContext.PreviousState.BaseState = - _blockChainStates.GetBlockState(block.PreviousHash); + _blockChainStates.GetAccountState(block.PreviousHash); } actionEvaluations[i].OutputState.BaseState = diff --git a/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockChainStates.cs b/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockChainStates.cs index 040b02207..2c1ece892 100644 --- a/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockChainStates.cs +++ b/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockChainStates.cs @@ -39,7 +39,7 @@ public ValidatorSet GetValidatorSet(BlockHash? offset) return new RemoteBlockState(_explorerEndpoint, offset).GetValidatorSet(); } - public IBlockState GetBlockState(BlockHash? offset) + public IAccountState GetAccountState(BlockHash? offset) { return new RemoteBlockState(_explorerEndpoint, offset); } diff --git a/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockState.cs b/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockState.cs index 08e047e54..65527dda1 100644 --- a/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockState.cs +++ b/.Libplanet.Extensions.RemoteBlockChainStates/RemoteBlockState.cs @@ -9,10 +9,11 @@ using Libplanet.Types.Blocks; using Libplanet.Types.Consensus; using Libplanet.Crypto; +using Libplanet.Store.Trie; namespace Libplanet.Extensions.RemoteBlockChainStates; -public class RemoteBlockState : IBlockState +public class RemoteBlockState : IAccountState { private readonly Uri _explorerEndpoint; private readonly GraphQLHttpClient _graphQlHttpClient; @@ -164,6 +165,8 @@ public ValidatorSet GetValidatorSet() .ToList()); } + public ITrie Trie => throw new NotSupportedException(); + public BlockHash? BlockHash { get; } private class GetStatesResponseType diff --git a/Lib9c.MessagePack/AccountStateDelta.cs b/Lib9c.MessagePack/AccountStateDelta.cs index 60fc978b4..864d8eea5 100644 --- a/Lib9c.MessagePack/AccountStateDelta.cs +++ b/Lib9c.MessagePack/AccountStateDelta.cs @@ -8,6 +8,7 @@ using Libplanet.Action; using Libplanet.Action.State; using Libplanet.Crypto; +using Libplanet.Store.Trie; using Libplanet.Types.Assets; using Libplanet.Types.Consensus; @@ -63,6 +64,8 @@ public AccountStateDelta(byte[] bytes) { } + public ITrie Trie => throw new NotSupportedException(); + public IAccountDelta Delta => _delta; public IValue? GetState(Address address) => diff --git a/Lib9c/Action/ActionBaseExtensions.cs b/Lib9c/Action/ActionBaseExtensions.cs index 240215e53..94d5534e2 100644 --- a/Lib9c/Action/ActionBaseExtensions.cs +++ b/Lib9c/Action/ActionBaseExtensions.cs @@ -8,6 +8,7 @@ using Libplanet.Action.State; using Libplanet.Common; using Libplanet.Crypto; +using Libplanet.Store.Trie; using Libplanet.Types.Assets; using Libplanet.Types.Blocks; using Libplanet.Types.Consensus; @@ -88,6 +89,8 @@ public AddressTraceStateDelta(AddressTraceDelta delta) _delta = delta; } + public ITrie Trie => throw new NotSupportedException(); + public IAccountDelta Delta => _delta; public IImmutableSet
UpdatedAddresses => _delta.UpdatedAddresses; From c78374a68040c20f8095a6cf27a535169ba06624 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 8 Sep 2023 12:35:05 +0900 Subject: [PATCH 117/134] Bump libplanet to 3.3.1 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index aa72117b8..7fbe52e2b 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit aa72117b8887ec9e189cac97cefc3fa77966dd81 +Subproject commit 7fbe52e2b3351d4811ecc6da2a09a2f45f4aabeb From 0a5c15f89df552f13a374b526f8363fc029e643f Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 11 Sep 2023 19:03:22 +0900 Subject: [PATCH 118/134] revert changes of PatchTableSheet action --- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 28 ---------------------- Lib9c/Action/PatchTableSheet.cs | 7 ------ 2 files changed, 35 deletions(-) diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 39ac3a889..d5e7bb3c5 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -153,33 +153,5 @@ public void ExecuteNewTable() Assert.NotNull(nextState.GetSheet()); } - - [Theory] - [InlineData("StakeRegularFixedRewardSheet_")] - [InlineData("StakeRegularRewardSheet_")] - public void Execute_Throw_ArgumentException(string tableName) - { - var action = new PatchTableSheet - { - TableName = tableName, - TableCsv = string.Empty, - }; - var initialState = new MockStateDelta(); - var nextState = action.Execute(new ActionContext - { - BlockIndex = 0, - PreviousState = initialState, - Rehearsal = false, - }); - Assert.Throws(() => - { - action.Execute(new ActionContext - { - BlockIndex = 0, - PreviousState = nextState, - Rehearsal = false, - }); - }); - } } } diff --git a/Lib9c/Action/PatchTableSheet.cs b/Lib9c/Action/PatchTableSheet.cs index e9cf549e8..4ac1a61c4 100644 --- a/Lib9c/Action/PatchTableSheet.cs +++ b/Lib9c/Action/PatchTableSheet.cs @@ -68,13 +68,6 @@ public override IAccount Execute(IActionContext context) #endif var sheet = states.GetState(sheetAddress); - if (sheet is not null && - StakePolicySheet.SheetPrefixRules.Any(tuple => TableName.StartsWith(tuple.value))) - { - var msg = $"{TableName} already exists."; - throw new ArgumentException(nameof(TableName), msg); - } - var value = sheet is null ? string.Empty : sheet.ToDotnetString(); Log.Verbose( From 9a2de5d44f023fec7ae280012f65b4a667ed2781 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 11:50:18 +0900 Subject: [PATCH 119/134] 10+1 for summon --- Lib9c/Action/AuraSummon.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 7606e4b5c..460ca4cbd 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -150,6 +150,11 @@ public override IAccount Execute(IActionContext context) ); } + // Ten plus one for summon + if (SummonCount == 10) + { + SummonCount += 1; + } for (var i = 0; i < SummonCount; i++) { From 5a715d814d48062277b82b69480611c4a9565ae5 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 11:50:27 +0900 Subject: [PATCH 120/134] Update tests - Add 10+1 cases - Check ItemId for result items to avoid false positive --- .Lib9c.Tests/Action/Summon/AuraSummonTest.cs | 47 +++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index c30dbb0ce..911b8746b 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -1,6 +1,7 @@ namespace Lib9c.Tests.Action.Summon { using System; + using System.Collections.Generic; using System.Data; using System.Linq; using Libplanet.Action.State; @@ -85,6 +86,44 @@ public AuraSummonTest() // success second group [InlineData(10002, 1, 600202, 2, 1, new[] { 10620001 }, null)] [InlineData(10002, 2, 600202, 4, 4, new[] { 10630001, 10640001 }, null)] + // Nine plus zero + [InlineData( + 10001, + 9, + 600201, + 18, + 0, + new[] { 10620000, 10620000, 10620000, 10620000, 10620000, 10620000, 10630000, 10630000, 10630000 }, + null + )] + [InlineData( + 10002, + 9, + 600202, + 18, + 0, + new[] { 10620001, 10620001, 10620001, 10620001, 10630001, 10630001, 10630001, 10640001, 10640001 }, + null + )] + // Ten plus one + [InlineData( + 10001, + 10, + 600201, + 20, + 0, + new[] { 10620000, 10620000, 10620000, 10620000, 10620000, 10620000, 10620000, 10630000, 10630000, 10630000, 10630000 }, + null + )] + [InlineData( + 10002, + 10, + 600202, + 20, + 0, + new[] { 10620001, 10620001, 10620001, 10620001, 10630001, 10630001, 10630001, 10630001, 10640001, 10640001, 10640001 }, + null + )] // fail by invalid group [InlineData(100003, 1, null, 0, 0, new int[] { }, typeof(RowNotInTableException))] // fail by not enough material @@ -147,16 +186,20 @@ Type expectedExc Random = random, }); + var checkedEquipments = new List(); foreach (var equipmentId in expectedEquipmentId) { var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory - .Equipments.FirstOrDefault(e => e.Id == equipmentId); + .Equipments.First(e => + e.Id == equipmentId && !checkedEquipments.Contains(e.ItemId)); + checkedEquipments.Add(resultEquipment.ItemId); Assert.NotNull(resultEquipment); Assert.Equal(1, resultEquipment.RequiredBlockIndex); Assert.True(resultEquipment.optionCountFromCombination > 0); } - nextState.GetAvatarStateV2(_avatarAddress).inventory.TryGetItem((int)materialId!, out var resultMaterial); + nextState.GetAvatarStateV2(_avatarAddress).inventory + .TryGetItem((int)materialId!, out var resultMaterial); Assert.Equal(0, resultMaterial?.count ?? 0); } else From 0f119a8cb3923af3351666313eba27b0c9c1e594 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 14:34:55 +0900 Subject: [PATCH 121/134] Move recipe picking logic into action --- Lib9c/Action/AuraSummon.cs | 39 +++++++++++++++++++++++++++++++++--- Lib9c/Helper/SummonHelper.cs | 39 ------------------------------------ 2 files changed, 36 insertions(+), 42 deletions(-) delete mode 100644 Lib9c/Helper/SummonHelper.cs diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index 460ca4cbd..ff44a59ea 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -67,6 +67,39 @@ protected override void LoadPlainValueInternal( SummonCount = plainValue[SummonCountKey].ToInteger(); } + public static IEnumerable PickRecipe(SummonSheet.Row summonRow, int summonCount, IRandom random) + { + var result = new List(); + for (var i = 0; i < summonCount; i++) + { + var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); + if (recipeValue <= summonRow.CumulativeRecipe1Ratio) + { + result.Add(summonRow.Recipes[0].Item1); + } + else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) + { + result.Add(summonRow.Recipes[1].Item1); + } + else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) + { + result.Add(summonRow.Recipes[2].Item1); + } + else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) + { + result.Add(summonRow.Recipes[3].Item1); + } + else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) + { + result.Add(summonRow.Recipes[4].Item1); + } + + result.Add(summonRow.Recipes[5].Item1); + } + + return result; + } + public override IAccount Execute(IActionContext context) { context.UseGas(1); @@ -156,10 +189,10 @@ public override IAccount Execute(IActionContext context) SummonCount += 1; } - for (var i = 0; i < SummonCount; i++) - { - var recipeId = SummonHelper.PickAuraSummonRecipe(summonRow, context.Random); + var summonResult = PickRecipe(summonRow, SummonCount, context.Random); + foreach (var recipeId in summonResult) + { // Validate RecipeId var recipeRow = recipeSheet.OrderedList.FirstOrDefault(r => r.Id == recipeId); if (recipeRow is null) diff --git a/Lib9c/Helper/SummonHelper.cs b/Lib9c/Helper/SummonHelper.cs deleted file mode 100644 index e7038592e..000000000 --- a/Lib9c/Helper/SummonHelper.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Libplanet.Action; -using Nekoyume.TableData.Summon; - -namespace Nekoyume.Helper -{ - public class SummonHelper - { - public static int PickAuraSummonRecipe(SummonSheet.Row summonRow, IRandom random) - { - var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); - if (recipeValue <= summonRow.CumulativeRecipe1Ratio) - { - return summonRow.Recipes[0].Item1; - } - - if (recipeValue <= summonRow.CumulativeRecipe2Ratio) - { - return summonRow.Recipes[1].Item1; - } - - if (recipeValue <= summonRow.CumulativeRecipe3Ratio) - { - return summonRow.Recipes[2].Item1; - } - - if (recipeValue <= summonRow.CumulativeRecipe4Ratio) - { - return summonRow.Recipes[3].Item1; - } - - if (recipeValue <= summonRow.CumulativeRecipe5Ratio) - { - return summonRow.Recipes[4].Item1; - } - - return summonRow.Recipes[5].Item1; - } - } -} From eafb486f304a1e26e0f3faf12110739e3ba447e2 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 15:54:30 +0900 Subject: [PATCH 122/134] Extract all summon logic to static function --- Lib9c/Action/AuraSummon.cs | 175 +++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 83 deletions(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index ff44a59ea..e1cdbcb2d 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -67,34 +67,116 @@ protected override void LoadPlainValueInternal( SummonCount = plainValue[SummonCountKey].ToInteger(); } - public static IEnumerable PickRecipe(SummonSheet.Row summonRow, int summonCount, IRandom random) + public static IEnumerable SimulateSummon( + IActionContext context, string addressesHex, + AgentState agentState, AvatarState avatarState, + Dictionary sheets, + SummonSheet.Row summonRow, + int summonCount + ) { - var result = new List(); + // Setup + var random = context.Random; + var recipeSheet = sheets.GetSheet(); + var materialSheet = sheets.GetSheet(); + var equipmentItemSheet = sheets.GetSheet(); + var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); + var optionSheet = sheets.GetSheet(); + var skillSheet = sheets.GetSheet(); + + // Ten plus one + if (summonCount == 10) + { + summonCount += 1; + } + + var result = new List(); + int recipeId; for (var i = 0; i < summonCount; i++) { var recipeValue = random.Next(1, summonRow.CumulativeRecipe6Ratio + 1); if (recipeValue <= summonRow.CumulativeRecipe1Ratio) { - result.Add(summonRow.Recipes[0].Item1); + recipeId = summonRow.Recipes[0].Item1; } else if (recipeValue <= summonRow.CumulativeRecipe2Ratio) { - result.Add(summonRow.Recipes[1].Item1); + recipeId = summonRow.Recipes[1].Item1; } else if (recipeValue <= summonRow.CumulativeRecipe3Ratio) { - result.Add(summonRow.Recipes[2].Item1); + recipeId = summonRow.Recipes[2].Item1; } else if (recipeValue <= summonRow.CumulativeRecipe4Ratio) { - result.Add(summonRow.Recipes[3].Item1); + recipeId = summonRow.Recipes[3].Item1; } else if (recipeValue <= summonRow.CumulativeRecipe5Ratio) { - result.Add(summonRow.Recipes[4].Item1); + recipeId = summonRow.Recipes[4].Item1; + } + else + { + recipeId = summonRow.Recipes[5].Item1; + } + + // Validate RecipeId + var recipeRow = recipeSheet.OrderedList.FirstOrDefault(r => r.Id == recipeId); + if (recipeRow is null) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(EquipmentItemRecipeSheet), + recipeId); + } + + // Validate Recipe ResultEquipmentId + if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, + out var equipmentRow)) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(equipmentItemSheet), + recipeRow.ResultEquipmentId); } - result.Add(summonRow.Recipes[5].Item1); + // Validate subRecipeId + if (recipeRow.SubRecipeIds.Count == 0) + { + throw new InvalidRecipeIdException( + $"Recipe {recipeId} does not have any subRecipe."); + } + + var subRecipeId = recipeRow.SubRecipeIds[0]; + if (!equipmentItemSubRecipeSheetV2.TryGetValue(subRecipeId, out var subRecipeRow)) + { + throw new SheetRowNotFoundException( + addressesHex, + nameof(EquipmentItemSubRecipeSheetV2), + subRecipeId + ); + } + + // Create Equipment + var equipment = (Equipment)ItemFactory.CreateItemUsable( + equipmentRow, + context.Random.GenerateRandomGuid(), + context.BlockIndex + ); + + AddAndUnlockOption( + agentState, + equipment, + context.Random, + subRecipeRow, + optionSheet, + skillSheet + ); + + // Add or update equipment + avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); + avatarState.UpdateFromCombination(equipment); + avatarState.UpdateQuestRewards(materialSheet); } return result; @@ -142,14 +224,9 @@ public override IAccount Execute(IActionContext context) typeof(SkillSheet), }); - var recipeSheet = sheets.GetSheet(); + var summonSheet = sheets.GetSheet(); var materialSheet = sheets.GetSheet(); - var equipmentItemSheet = sheets.GetSheet(); - var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); - var optionSheet = sheets.GetSheet(); - var skillSheet = sheets.GetSheet(); - var summonSheet = sheets.GetSheet(); var summonRow = summonSheet.OrderedList.FirstOrDefault(row => row.GroupId == GroupId); if (summonRow is null) { @@ -183,75 +260,7 @@ public override IAccount Execute(IActionContext context) ); } - // Ten plus one for summon - if (SummonCount == 10) - { - SummonCount += 1; - } - - var summonResult = PickRecipe(summonRow, SummonCount, context.Random); - - foreach (var recipeId in summonResult) - { - // Validate RecipeId - var recipeRow = recipeSheet.OrderedList.FirstOrDefault(r => r.Id == recipeId); - if (recipeRow is null) - { - throw new SheetRowNotFoundException( - addressesHex, - nameof(EquipmentItemRecipeSheet), - recipeId); - } - - // Validate Recipe ResultEquipmentId - if (!equipmentItemSheet.TryGetValue(recipeRow.ResultEquipmentId, - out var equipmentRow)) - { - throw new SheetRowNotFoundException( - addressesHex, - nameof(equipmentItemSheet), - recipeRow.ResultEquipmentId); - } - - // Validate subRecipeId - if (recipeRow.SubRecipeIds.Count == 0) - { - throw new InvalidRecipeIdException( - $"Recipe {recipeId} does not have any subRecipe."); - } - - var subRecipeId = recipeRow.SubRecipeIds[0]; - if (!equipmentItemSubRecipeSheetV2.TryGetValue(subRecipeId, out var subRecipeRow)) - { - throw new SheetRowNotFoundException( - addressesHex, - nameof(EquipmentItemSubRecipeSheetV2), - subRecipeId - ); - } - - - // Create Equipment - var equipment = (Equipment)ItemFactory.CreateItemUsable( - equipmentRow, - context.Random.GenerateRandomGuid(), - context.BlockIndex - ); - - AddAndUnlockOption( - agentState, - equipment, - context.Random, - subRecipeRow, - optionSheet, - skillSheet - ); - - // Add or update equipment - avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); - avatarState.UpdateFromCombination(equipment); - avatarState.UpdateQuestRewards(materialSheet); - } + var summonResult = SimulateSummon(context, addressesHex, agentState, avatarState, sheets, summonRow, SummonCount); Log.Debug( $"{addressesHex} AuraSummon Exec. finished: {DateTimeOffset.UtcNow - started} Elapsed"); From 0bb38ea9505827db5f466d053290810e460ba503 Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 15:56:08 +0900 Subject: [PATCH 123/134] Check summoned equipment count --- .Lib9c.Tests/Action/Summon/AuraSummonTest.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index 911b8746b..cdbb195ce 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -186,12 +186,17 @@ Type expectedExc Random = random, }); + var equipments = nextState.GetAvatarStateV2(_avatarAddress).inventory.Equipments + .ToList(); + Assert.Equal(expectedEquipmentId.Length, equipments.Count); + var checkedEquipments = new List(); foreach (var equipmentId in expectedEquipmentId) { - var resultEquipment = nextState.GetAvatarStateV2(_avatarAddress).inventory - .Equipments.First(e => - e.Id == equipmentId && !checkedEquipments.Contains(e.ItemId)); + var resultEquipment = equipments.First(e => + e.Id == equipmentId && !checkedEquipments.Contains(e.ItemId) + ); + checkedEquipments.Add(resultEquipment.ItemId); Assert.NotNull(resultEquipment); Assert.Equal(1, resultEquipment.RequiredBlockIndex); From 2bde31116999468be9c126281066b432f2348aca Mon Sep 17 00:00:00 2001 From: hyeon Date: Tue, 12 Sep 2023 16:21:53 +0900 Subject: [PATCH 124/134] Update summon logic - Simulation returns list of (recipeId, Equipment) - AvatarState changing logic moved out from simulate to execute --- Lib9c/Action/AuraSummon.cs | 59 ++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/Lib9c/Action/AuraSummon.cs b/Lib9c/Action/AuraSummon.cs index e1cdbcb2d..4380f0c2f 100644 --- a/Lib9c/Action/AuraSummon.cs +++ b/Lib9c/Action/AuraSummon.cs @@ -10,7 +10,6 @@ using Libplanet.Crypto; using Nekoyume.Action.Exceptions; using Nekoyume.Extensions; -using Nekoyume.Helper; using Nekoyume.Model.Item; using Nekoyume.Model.Stat; using Nekoyume.Model.State; @@ -67,30 +66,27 @@ protected override void LoadPlainValueInternal( SummonCount = plainValue[SummonCountKey].ToInteger(); } - public static IEnumerable SimulateSummon( - IActionContext context, string addressesHex, - AgentState agentState, AvatarState avatarState, - Dictionary sheets, + public static IEnumerable<(int, Equipment)> SimulateSummon( + string addressesHex, + AgentState agentState, + EquipmentItemRecipeSheet recipeSheet, + EquipmentItemSheet equipmentItemSheet, + EquipmentItemSubRecipeSheetV2 equipmentItemSubRecipeSheetV2, + EquipmentItemOptionSheet optionSheet, + SkillSheet skillSheet, SummonSheet.Row summonRow, - int summonCount + int summonCount, + IRandom random, + long blockIndex ) { - // Setup - var random = context.Random; - var recipeSheet = sheets.GetSheet(); - var materialSheet = sheets.GetSheet(); - var equipmentItemSheet = sheets.GetSheet(); - var equipmentItemSubRecipeSheetV2 = sheets.GetSheet(); - var optionSheet = sheets.GetSheet(); - var skillSheet = sheets.GetSheet(); - // Ten plus one if (summonCount == 10) { summonCount += 1; } - var result = new List(); + var result = new List<(int, Equipment)>(); int recipeId; for (var i = 0; i < summonCount; i++) { @@ -160,23 +156,19 @@ int summonCount // Create Equipment var equipment = (Equipment)ItemFactory.CreateItemUsable( equipmentRow, - context.Random.GenerateRandomGuid(), - context.BlockIndex + random.GenerateRandomGuid(), + blockIndex ); AddAndUnlockOption( agentState, equipment, - context.Random, + random, subRecipeRow, optionSheet, skillSheet ); - - // Add or update equipment - avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); - avatarState.UpdateFromCombination(equipment); - avatarState.UpdateQuestRewards(materialSheet); + result.Add((recipeId, equipment)); } return result; @@ -260,7 +252,24 @@ public override IAccount Execute(IActionContext context) ); } - var summonResult = SimulateSummon(context, addressesHex, agentState, avatarState, sheets, summonRow, SummonCount); + var summonResult = SimulateSummon( + addressesHex, agentState, + sheets.GetSheet(), + sheets.GetSheet(), + sheets.GetSheet(), + sheets.GetSheet(), + sheets.GetSheet(), + summonRow, SummonCount, + context.Random, context.BlockIndex + ); + + foreach (var (recipeId, equipment) in summonResult) + { + // Add or update equipment + avatarState.questList.UpdateCombinationEquipmentQuest(recipeId); + avatarState.UpdateFromCombination(equipment); + avatarState.UpdateQuestRewards(materialSheet); + } Log.Debug( $"{addressesHex} AuraSummon Exec. finished: {DateTimeOffset.UtcNow - started} Elapsed"); From 2e37baa2460436a57c84cc66761ac4288ae7d30a Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:23:24 +0900 Subject: [PATCH 125/134] Focus on staking balance, not state --- Lib9c/Action/AccountStateExtensions.cs | 8 ++++++++ Lib9c/Action/Grinding.cs | 14 ++++---------- Lib9c/Action/Grinding0.cs | 13 +++---------- Lib9c/Action/HackAndSlash.cs | 7 ++++--- Lib9c/Action/HackAndSlash18.cs | 6 +++--- Lib9c/Action/HackAndSlash19.cs | 6 +++--- Lib9c/Action/HackAndSlash20.cs | 6 +++--- Lib9c/Action/HackAndSlashSweep.cs | 6 +++--- Lib9c/Action/HackAndSlashSweep6.cs | 6 +++--- Lib9c/Action/HackAndSlashSweep7.cs | 6 +++--- Lib9c/Action/HackAndSlashSweep8.cs | 6 +++--- Lib9c/Action/ItemEnhancement11.cs | 13 +++---------- 12 files changed, 43 insertions(+), 54 deletions(-) diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index 139d74ccf..07502efbb 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -961,6 +961,14 @@ public static bool TryGetStakeState( return false; } + public static FungibleAssetValue GetStakedAmount( + this IAccountState state, + Address agentAddr) + { + var goldCurrency = state.GetGoldCurrency(); + return state.GetBalance(StakeState.DeriveAddress(agentAddr), goldCurrency); + } + public static bool TryGetStakeStateV2( this IAccountState state, Address agentAddr, diff --git a/Lib9c/Action/Grinding.cs b/Lib9c/Action/Grinding.cs index b690032b4..39d994b08 100644 --- a/Lib9c/Action/Grinding.cs +++ b/Lib9c/Action/Grinding.cs @@ -86,17 +86,11 @@ public override IAccount Execute(IActionContext context) }); Currency currency = states.GetGoldCurrency(); - FungibleAssetValue stakedAmount = 0 * currency; - if (states.TryGetStakeState(context.Signer, out StakeState stakeState)) + FungibleAssetValue stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount == currency * 0 && + states.TryGetState(monsterCollectionAddress, out Dictionary _)) { - stakedAmount = states.GetBalance(stakeState.address, currency); - } - else - { - if (states.TryGetState(monsterCollectionAddress, out Dictionary _)) - { - stakedAmount = states.GetBalance(monsterCollectionAddress, currency); - } + stakedAmount = states.GetBalance(monsterCollectionAddress, currency); } if (avatarState.actionPoint < CostAp) diff --git a/Lib9c/Action/Grinding0.cs b/Lib9c/Action/Grinding0.cs index c6474f25e..f69865231 100644 --- a/Lib9c/Action/Grinding0.cs +++ b/Lib9c/Action/Grinding0.cs @@ -86,17 +86,10 @@ public override IAccount Execute(IActionContext context) }); Currency currency = states.GetGoldCurrency(); - FungibleAssetValue stakedAmount = 0 * currency; - if (states.TryGetStakeState(context.Signer, out StakeState stakeState)) + FungibleAssetValue stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount == currency * 0 && states.TryGetState(monsterCollectionAddress, out Dictionary _)) { - stakedAmount = states.GetBalance(stakeState.address, currency); - } - else - { - if (states.TryGetState(monsterCollectionAddress, out Dictionary _)) - { - stakedAmount = states.GetBalance(monsterCollectionAddress, currency); - } + stakedAmount = states.GetBalance(monsterCollectionAddress, currency); } if (avatarState.actionPoint < CostAp) diff --git a/Lib9c/Action/HackAndSlash.cs b/Lib9c/Action/HackAndSlash.cs index 9062c1056..2d382ac70 100644 --- a/Lib9c/Action/HackAndSlash.cs +++ b/Lib9c/Action/HackAndSlash.cs @@ -195,11 +195,12 @@ public IAccount Execute( sw.Restart(); var stakingLevel = 0; StakeActionPointCoefficientSheet actionPointCoefficientSheet = null; - if (states.TryGetStakeState(signer, out var stakeState) && + + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(signer); + if (stakedAmount > goldCurrency * 0 && sheets.TryGetSheet(out actionPointCoefficientSheet)) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); stakingLevel = actionPointCoefficientSheet.FindLevelByStakedAmount(signer, stakedAmount); } diff --git a/Lib9c/Action/HackAndSlash18.cs b/Lib9c/Action/HackAndSlash18.cs index 217e1637f..1fc4b7bf0 100644 --- a/Lib9c/Action/HackAndSlash18.cs +++ b/Lib9c/Action/HackAndSlash18.cs @@ -195,11 +195,11 @@ public IAccount Execute( sw.Restart(); var stakingLevel = 0; StakeActionPointCoefficientSheet actionPointCoefficientSheet = null; - if (states.TryGetStakeState(signer, out var stakeState) && + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(signer); + if (stakedAmount > goldCurrency * 0 && sheets.TryGetSheet(out actionPointCoefficientSheet)) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); stakingLevel = actionPointCoefficientSheet.FindLevelByStakedAmount(signer, stakedAmount); } diff --git a/Lib9c/Action/HackAndSlash19.cs b/Lib9c/Action/HackAndSlash19.cs index cdc213c6a..6e6b1d755 100644 --- a/Lib9c/Action/HackAndSlash19.cs +++ b/Lib9c/Action/HackAndSlash19.cs @@ -174,11 +174,11 @@ public IAccount Execute( sw.Restart(); var stakingLevel = 0; StakeActionPointCoefficientSheet actionPointCoefficientSheet = null; - if (states.TryGetStakeState(signer, out var stakeState) && + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(signer); + if (stakedAmount > goldCurrency * 0 && sheets.TryGetSheet(out actionPointCoefficientSheet)) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); stakingLevel = actionPointCoefficientSheet.FindLevelByStakedAmount(signer, stakedAmount); } diff --git a/Lib9c/Action/HackAndSlash20.cs b/Lib9c/Action/HackAndSlash20.cs index c56d830fa..491a5e4f4 100644 --- a/Lib9c/Action/HackAndSlash20.cs +++ b/Lib9c/Action/HackAndSlash20.cs @@ -193,11 +193,11 @@ public IAccount Execute( sw.Restart(); var stakingLevel = 0; StakeActionPointCoefficientSheet actionPointCoefficientSheet = null; - if (states.TryGetStakeState(signer, out var stakeState) && + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(signer); + if (stakedAmount > goldCurrency * 0 && sheets.TryGetSheet(out actionPointCoefficientSheet)) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); stakingLevel = actionPointCoefficientSheet.FindLevelByStakedAmount(signer, stakedAmount); } diff --git a/Lib9c/Action/HackAndSlashSweep.cs b/Lib9c/Action/HackAndSlashSweep.cs index fbdae208a..d8a3bcb97 100644 --- a/Lib9c/Action/HackAndSlashSweep.cs +++ b/Lib9c/Action/HackAndSlashSweep.cs @@ -285,10 +285,10 @@ public override IAccount Execute(IActionContext context) // burn ap avatarState.actionPoint -= actionPoint; var costAp = sheets.GetSheet()[stageId].CostAP; - if (states.TryGetStakeState(context.Signer, out var stakeState)) + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount > goldCurrency * 0) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); var actionPointCoefficientSheet = sheets.GetSheet(); var stakingLevel = diff --git a/Lib9c/Action/HackAndSlashSweep6.cs b/Lib9c/Action/HackAndSlashSweep6.cs index 87462b6c5..6790e0642 100644 --- a/Lib9c/Action/HackAndSlashSweep6.cs +++ b/Lib9c/Action/HackAndSlashSweep6.cs @@ -210,10 +210,10 @@ public override IAccount Execute(IActionContext context) // burn ap avatarState.actionPoint -= actionPoint; var costAp = sheets.GetSheet()[stageId].CostAP; - if (states.TryGetStakeState(context.Signer, out var stakeState)) + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount > goldCurrency * 0) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); var actionPointCoefficientSheet = sheets.GetSheet(); var stakingLevel = actionPointCoefficientSheet.FindLevelByStakedAmount(context.Signer, stakedAmount); costAp = actionPointCoefficientSheet.GetActionPointByStaking( diff --git a/Lib9c/Action/HackAndSlashSweep7.cs b/Lib9c/Action/HackAndSlashSweep7.cs index 7b7f52df2..61fd1570d 100644 --- a/Lib9c/Action/HackAndSlashSweep7.cs +++ b/Lib9c/Action/HackAndSlashSweep7.cs @@ -219,10 +219,10 @@ public override IAccount Execute(IActionContext context) // burn ap avatarState.actionPoint -= actionPoint; var costAp = sheets.GetSheet()[stageId].CostAP; - if (states.TryGetStakeState(context.Signer, out var stakeState)) + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount > goldCurrency * 0) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); var actionPointCoefficientSheet = sheets.GetSheet(); var stakingLevel = diff --git a/Lib9c/Action/HackAndSlashSweep8.cs b/Lib9c/Action/HackAndSlashSweep8.cs index ae706236d..bbd79edb6 100644 --- a/Lib9c/Action/HackAndSlashSweep8.cs +++ b/Lib9c/Action/HackAndSlashSweep8.cs @@ -288,10 +288,10 @@ public override IAccount Execute(IActionContext context) // burn ap avatarState.actionPoint -= actionPoint; var costAp = sheets.GetSheet()[stageId].CostAP; - if (states.TryGetStakeState(context.Signer, out var stakeState)) + var goldCurrency = states.GetGoldCurrency(); + var stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount > goldCurrency * 0) { - var currency = states.GetGoldCurrency(); - var stakedAmount = states.GetBalance(stakeState.address, currency); var actionPointCoefficientSheet = sheets.GetSheet(); var stakingLevel = diff --git a/Lib9c/Action/ItemEnhancement11.cs b/Lib9c/Action/ItemEnhancement11.cs index 6f21f63d4..56c52b1e7 100644 --- a/Lib9c/Action/ItemEnhancement11.cs +++ b/Lib9c/Action/ItemEnhancement11.cs @@ -318,17 +318,10 @@ public override IAccount Execute(IActionContext context) ); Currency currency = states.GetGoldCurrency(); - FungibleAssetValue stakedAmount = 0 * currency; - if (states.TryGetStakeState(context.Signer, out StakeState stakeState)) + FungibleAssetValue stakedAmount = states.GetStakedAmount(context.Signer); + if (stakedAmount == currency * 0 && states.TryGetState(monsterCollectionAddress, out Dictionary _)) { - stakedAmount = states.GetBalance(stakeState.address, currency); - } - else - { - if (states.TryGetState(monsterCollectionAddress, out Dictionary _)) - { - stakedAmount = states.GetBalance(monsterCollectionAddress, currency); - } + stakedAmount = states.GetBalance(monsterCollectionAddress, currency); } crystal = CrystalCalculator.CalculateCrystal( From f5239a50a06341d11ab79c4806d0930ce8a1b8ab Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:38:45 +0900 Subject: [PATCH 126/134] Restrict `stake2` action if `StakeStateV2` state exists --- .Lib9c.Tests/Action/Stake2Test.cs | 22 ++++++++++++++++++++++ Lib9c/Action/Stake2.cs | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/.Lib9c.Tests/Action/Stake2Test.cs b/.Lib9c.Tests/Action/Stake2Test.cs index f7d817b1c..949912d83 100644 --- a/.Lib9c.Tests/Action/Stake2Test.cs +++ b/.Lib9c.Tests/Action/Stake2Test.cs @@ -1,11 +1,13 @@ namespace Lib9c.Tests.Action { + using System; using Bencodex.Types; using Libplanet.Action.State; using Libplanet.Crypto; using Libplanet.Types.Assets; using Nekoyume; using Nekoyume.Action; + using Nekoyume.Model.Stake; using Nekoyume.Model.State; using Nekoyume.TableData; using Serilog; @@ -244,6 +246,26 @@ public void Update() Assert.Equal(_currency * 0, states.GetBalance(_signerAddress, _currency)); } + [Fact] + public void RestrictForStakeStateV2() + { + var action = new Stake2(50); + Assert.Throws(() => action.Execute(new ActionContext + { + PreviousState = _initialState.SetState( + StakeState.DeriveAddress(_signerAddress), + new StakeStateV2( + new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 50400, + 201600), + 0).Serialize()), + Signer = _signerAddress, + BlockIndex = 0, + })); + } + [Fact] public void Serialization() { diff --git a/Lib9c/Action/Stake2.cs b/Lib9c/Action/Stake2.cs index e39d07af7..60764a53a 100644 --- a/Lib9c/Action/Stake2.cs +++ b/Lib9c/Action/Stake2.cs @@ -98,6 +98,12 @@ public override IAccount Execute(IActionContext context) // Stake if it doesn't exist yet. if (!states.TryGetStakeState(context.Signer, out StakeState stakeState)) { + if (states.TryGetStakeStateV2(context.Signer, out _)) + { + throw new InvalidOperationException( + $"{context.Signer} has already staked as versions above 2."); + } + stakeState = new StakeState(stakeStateAddress, context.BlockIndex); return states .SetState( From 50bbd1b466a3ac4454e8f82630e166f302d2b959 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:43:27 +0900 Subject: [PATCH 127/134] Correct incorrect constructor usage --- .Lib9c.Tests/Action/TransferAssetTest0.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 23c3bb935..23a086c81 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -40,7 +40,7 @@ public class TransferAssetTest0 public void Constructor_ThrowsMemoLengthOverflowException() { Assert.Throws(() => - new TransferAsset(_sender, _recipient, _currency * 100, new string(' ', 100))); + new TransferAsset0(_sender, _recipient, _currency * 100, new string(' ', 100))); } [Fact] From b8820e3707b30043bb6e443e7dfdc8984bdb5163 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:44:37 +0900 Subject: [PATCH 128/134] Use `ITransferAsset` interface --- .Lib9c.Tools/SubCommand/Account.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Lib9c.Tools/SubCommand/Account.cs b/.Lib9c.Tools/SubCommand/Account.cs index 43ff4c5cc..4d93e26b9 100644 --- a/.Lib9c.Tools/SubCommand/Account.cs +++ b/.Lib9c.Tools/SubCommand/Account.cs @@ -70,7 +70,7 @@ public void Balance( .Select(txId => store.GetTransaction(new TxId(txId.ToArray()))) .SelectMany(tx => tx.Actions is { } ca ? ca.Select(a => actionLoader.LoadAction(digest.Index, a)) - .SelectMany(a => a is TransferAsset t + .SelectMany(a => a is ITransferAsset t ? new[] { t.Sender, t.Recipient } : a is InitializeStates i && i.GoldDistributions is Bencodex.Types.List l From c7d4b5df03999ddf2f7f9dfd3d8a5a7db9956c33 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:45:17 +0900 Subject: [PATCH 129/134] Obsolete `transfer_asset4` --- ...sferAssetTest.cs => TransferAsset4Test.cs} | 28 +++++++++---------- .../{TransferAsset.cs => TransferAsset4.cs} | 12 ++++---- 2 files changed, 21 insertions(+), 19 deletions(-) rename .Lib9c.Tests/Action/{TransferAssetTest.cs => TransferAsset4Test.cs} (93%) rename Lib9c/Action/{TransferAsset.cs => TransferAsset4.cs} (90%) diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAsset4Test.cs similarity index 93% rename from .Lib9c.Tests/Action/TransferAssetTest.cs rename to .Lib9c.Tests/Action/TransferAsset4Test.cs index c9547e6ba..61d946028 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAsset4Test.cs @@ -16,7 +16,7 @@ namespace Lib9c.Tests.Action using Nekoyume.Model.State; using Xunit; - public class TransferAssetTest + public class TransferAsset4Test { private static readonly Address _sender = new Address( new byte[] @@ -42,7 +42,7 @@ public class TransferAssetTest public void Constructor_ThrowsMemoLengthOverflowException() { Assert.Throws(() => - new TransferAsset(_sender, _recipient, _currency * 100, new string(' ', 100))); + new TransferAsset4(_sender, _recipient, _currency * 100, new string(' ', 100))); } [Fact] @@ -54,7 +54,7 @@ public void Execute() MockState.Empty .SetBalance(_sender, _currency * 1000) .SetBalance(_recipient, _currency * 10)); - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: _currency * 100 @@ -79,7 +79,7 @@ public void Execute_Throw_InvalidTransferSignerException() .SetBalance(_sender, _currency * 1000) .SetBalance(_recipient, _currency * 10) .SetBalance(_sender, Currencies.Mead * 1)); - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: _currency * 100 @@ -110,7 +110,7 @@ public void Execute_Throw_InvalidTransferRecipientException() .SetBalance(_sender, _currency * 1000) .SetBalance(_sender, Currencies.Mead * 1)); // Should not allow TransferAsset with same sender and recipient. - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _sender, amount: _currency * 100 @@ -139,7 +139,7 @@ public void Execute_Throw_InsufficientBalanceException() .SetState(_recipient, new AgentState(_recipient).Serialize()) .SetBalance(_sender, _currency * 1000) .SetBalance(_recipient, _currency * 10)); - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: _currency * 100000 @@ -176,7 +176,7 @@ public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) .SetBalance(_sender, currencyBySender * 1000) .SetBalance(_recipient, currencyBySender * 10) .SetBalance(_sender, Currencies.Mead * 1)); - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: currencyBySender * 100 @@ -200,7 +200,7 @@ public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) [Fact] public void Rehearsal() { - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: _currency * 100 @@ -232,7 +232,7 @@ public void Rehearsal() [InlineData("Nine Chronicles")] public void PlainValue(string memo) { - var action = new TransferAsset(_sender, _recipient, _currency * 100, memo); + var action = new TransferAsset4(_sender, _recipient, _currency * 100, memo); Dictionary plainValue = (Dictionary)action.PlainValue; Dictionary values = (Dictionary)plainValue["values"]; @@ -265,7 +265,7 @@ public void LoadPlainValue(string memo) var plainValue = Dictionary.Empty .Add("type_id", "transfer_asset3") .Add("values", new Dictionary(pairs)); - var action = new TransferAsset(); + var action = new TransferAsset4(); action.LoadPlainValue(plainValue); Assert.Equal(_sender, action.Sender); @@ -283,7 +283,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) .SetBalance(_sender, crystal * 1000) .SetBalance(_sender, Currencies.Mead * 1)); - var action = new TransferAsset( + var action = new TransferAsset4( sender: _sender, recipient: _recipient, amount: 1000 * crystal @@ -300,7 +300,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() [Fact] public void LoadPlainValue_ThrowsMemoLengthOverflowException() { - var action = new TransferAsset(); + var action = new TransferAsset4(); var plainValue = Dictionary.Empty .Add("type_id", "transfer_asset3") .Add("values", new Dictionary(new[] @@ -320,13 +320,13 @@ public void LoadPlainValue_ThrowsMemoLengthOverflowException() public void SerializeWithDotnetAPI(string memo) { var formatter = new BinaryFormatter(); - var action = new TransferAsset(_sender, _recipient, _currency * 100, memo); + var action = new TransferAsset4(_sender, _recipient, _currency * 100, memo); using var ms = new MemoryStream(); formatter.Serialize(ms, action); ms.Seek(0, SeekOrigin.Begin); - var deserialized = (TransferAsset)formatter.Deserialize(ms); + var deserialized = (TransferAsset4)formatter.Deserialize(ms); Assert.Equal(_sender, deserialized.Sender); Assert.Equal(_recipient, deserialized.Recipient); diff --git a/Lib9c/Action/TransferAsset.cs b/Lib9c/Action/TransferAsset4.cs similarity index 90% rename from Lib9c/Action/TransferAsset.cs rename to Lib9c/Action/TransferAsset4.cs index 99bc571bd..18cf7feeb 100644 --- a/Lib9c/Action/TransferAsset.cs +++ b/Lib9c/Action/TransferAsset4.cs @@ -19,20 +19,22 @@ namespace Nekoyume.Action { /// /// Hard forked at https://github.com/planetarium/lib9c/pull/636 - /// Updated at https://github.com/planetarium/lib9c/pull/1718 + /// Updated at https://github.com/planetarium/lib9c/pull/2143 /// [Serializable] [ActionType(TypeIdentifier)] - public class TransferAsset : ActionBase, ISerializable, ITransferAsset, ITransferAssetV1 + [ActionObsolete(ObsoleteBlockIndex)] + public class TransferAsset4 : ActionBase, ISerializable, ITransferAsset, ITransferAssetV1 { private const int MemoMaxLength = 80; public const string TypeIdentifier = "transfer_asset4"; + public const long ObsoleteBlockIndex = ActionObsoleteConfig.V200080ObsoleteIndex; - public TransferAsset() + public TransferAsset4() { } - public TransferAsset(Address sender, Address recipient, FungibleAssetValue amount, string memo = null) + public TransferAsset4(Address sender, Address recipient, FungibleAssetValue amount, string memo = null) { Sender = sender; Recipient = recipient; @@ -42,7 +44,7 @@ public TransferAsset(Address sender, Address recipient, FungibleAssetValue amoun Memo = memo; } - protected TransferAsset(SerializationInfo info, StreamingContext context) + protected TransferAsset4(SerializationInfo info, StreamingContext context) { var rawBytes = (byte[])info.GetValue("serialized", typeof(byte[])); Dictionary pv = (Dictionary) new Codec().Decode(rawBytes); From 8886fce7a0b44ce04e8e78cbda131bfb5dc2f20c Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 20:49:12 +0900 Subject: [PATCH 130/134] Introduce `transfer_asset5` --- .Lib9c.Tests/Action/TransferAssetTest.cs | 337 +++++++++++++++++++++++ Lib9c/Action/TransferAsset.cs | 159 +++++++++++ 2 files changed, 496 insertions(+) create mode 100644 .Lib9c.Tests/Action/TransferAssetTest.cs create mode 100644 Lib9c/Action/TransferAsset.cs diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs new file mode 100644 index 000000000..c8b2287e0 --- /dev/null +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -0,0 +1,337 @@ +namespace Lib9c.Tests.Action +{ + using System.Collections.Generic; + using System.Collections.Immutable; + using System.IO; + using System.Linq; + using System.Runtime.Serialization.Formatters.Binary; + using Bencodex.Types; + using Libplanet.Action.State; + using Libplanet.Crypto; + using Libplanet.Types.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Helper; + using Nekoyume.Model; + using Nekoyume.Model.State; + using Xunit; + + public class TransferAssetTest + { + private static readonly Address _sender = new Address( + new byte[] + { + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + } + ); + + private static readonly Address _recipient = new Address(new byte[] + { + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + } + ); + +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + private static readonly Currency _currency = Currency.Legacy("NCG", 2, null); +#pragma warning restore CS0618 + + [Fact] + public void Constructor_ThrowsMemoLengthOverflowException() + { + Assert.Throws(() => + new TransferAsset(_sender, _recipient, _currency * 100, new string(' ', 100))); + } + + [Fact] + public void Execute() + { + var contractAddress = _sender.Derive(nameof(RequestPledge)); + var patronAddress = new PrivateKey().ToAddress(); + var prevState = new MockStateDelta( + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: _currency * 100 + ); + IAccount nextState = action.Execute(new ActionContext() + { + PreviousState = prevState, + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + }); + + Assert.Equal(_currency * 900, nextState.GetBalance(_sender, _currency)); + Assert.Equal(_currency * 110, nextState.GetBalance(_recipient, _currency)); + } + + [Fact] + public void Execute_Throw_InvalidTransferSignerException() + { + var prevState = new MockStateDelta( + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10) + .SetBalance(_sender, Currencies.Mead * 1)); + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: _currency * 100 + ); + + var exc = Assert.Throws(() => + { + _ = action.Execute(new ActionContext() + { + PreviousState = prevState, + // 송금자가 직접 사인하지 않으면 실패해야 합니다. + Signer = _recipient, + Rehearsal = false, + BlockIndex = 1, + }); + }); + + Assert.Equal(exc.Sender, _sender); + Assert.Equal(exc.Recipient, _recipient); + Assert.Equal(exc.TxSigner, _recipient); + } + + [Fact] + public void Execute_Throw_InvalidTransferRecipientException() + { + var prevState = new MockStateDelta( + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_sender, Currencies.Mead * 1)); + // Should not allow TransferAsset with same sender and recipient. + var action = new TransferAsset( + sender: _sender, + recipient: _sender, + amount: _currency * 100 + ); + + var exc = Assert.Throws(() => + { + _ = action.Execute(new ActionContext() + { + PreviousState = prevState, + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + }); + }); + + Assert.Equal(exc.Sender, _sender); + Assert.Equal(exc.Recipient, _sender); + } + + [Fact] + public void Execute_Throw_InsufficientBalanceException() + { + var prevState = new MockStateDelta( + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: _currency * 100000 + ); + + InsufficientBalanceException exc = Assert.Throws(() => + { + action.Execute(new ActionContext() + { + PreviousState = prevState, + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + }); + }); + + Assert.Equal(_sender, exc.Address); + Assert.Equal(_currency, exc.Balance.Currency); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) + { + Address minter = minterAsSender ? _sender : _recipient; +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + var currencyBySender = Currency.Legacy("NCG", 2, minter); +#pragma warning restore CS0618 + var prevState = new MockStateDelta( + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10) + .SetBalance(_sender, Currencies.Mead * 1)); + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: currencyBySender * 100 + ); + var ex = Assert.Throws(() => + { + action.Execute(new ActionContext() + { + PreviousState = prevState, + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + }); + }); + + Assert.Equal(new[] { minter }, ex.Minters); + Assert.Equal(_sender, ex.Sender); + Assert.Equal(_recipient, ex.Recipient); + } + + [Fact] + public void Rehearsal() + { + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: _currency * 100 + ); + + var context = new ActionContext(); + IAccount nextState = action.Execute(new ActionContext() + { + PreviousState = new MockStateDelta().MintAsset(context, _sender, Currencies.Mead * 1), + Signer = default, + Rehearsal = true, + BlockIndex = 1, + }); + + Assert.Equal( + ImmutableHashSet.Create( + _sender, + _recipient + ), + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + ); + Assert.Equal( + new[] { _currency, Currencies.Mead, }.ToImmutableHashSet(), + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + } + + [Theory] + [InlineData(null)] + [InlineData("Nine Chronicles")] + public void PlainValue(string memo) + { + var action = new TransferAsset(_sender, _recipient, _currency * 100, memo); + Dictionary plainValue = (Dictionary)action.PlainValue; + Dictionary values = (Dictionary)plainValue["values"]; + + Assert.Equal((Text)"transfer_asset5", plainValue["type_id"]); + Assert.Equal(_sender, values["sender"].ToAddress()); + Assert.Equal(_recipient, values["recipient"].ToAddress()); + Assert.Equal(_currency * 100, values["amount"].ToFungibleAssetValue()); + if (!(memo is null)) + { + Assert.Equal(memo, values["memo"].ToDotnetString()); + } + } + + [Theory] + [InlineData(null)] + [InlineData("Nine Chronicles")] + public void LoadPlainValue(string memo) + { + IEnumerable> pairs = new[] + { + new KeyValuePair((Text)"sender", _sender.Serialize()), + new KeyValuePair((Text)"recipient", _recipient.Serialize()), + new KeyValuePair((Text)"amount", (_currency * 100).Serialize()), + }; + if (!(memo is null)) + { + pairs = pairs.Append(new KeyValuePair((Text)"memo", memo.Serialize())); + } + + var plainValue = Dictionary.Empty + .Add("type_id", "transfer_asset5") + .Add("values", new Dictionary(pairs)); + var action = new TransferAsset(); + action.LoadPlainValue(plainValue); + + Assert.Equal(_sender, action.Sender); + Assert.Equal(_recipient, action.Recipient); + Assert.Equal(_currency * 100, action.Amount); + Assert.Equal(memo, action.Memo); + } + + [Fact] + public void Execute_Throw_InvalidTransferCurrencyException() + { + var crystal = CrystalCalculator.CRYSTAL; + var prevState = new MockStateDelta( + MockState.Empty + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetBalance(_sender, crystal * 1000) + .SetBalance(_sender, Currencies.Mead * 1)); + var action = new TransferAsset( + sender: _sender, + recipient: _recipient, + amount: 1000 * crystal + ); + Assert.Throws(() => action.Execute(new ActionContext() + { + PreviousState = prevState, + Signer = _sender, + Rehearsal = false, + BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, + })); + } + + [Fact] + public void LoadPlainValue_ThrowsMemoLengthOverflowException() + { + var action = new TransferAsset(); + var plainValue = Dictionary.Empty + .Add("type_id", "transfer_asset5") + .Add("values", new Dictionary(new[] + { + new KeyValuePair((Text)"sender", _sender.Serialize()), + new KeyValuePair((Text)"recipient", _recipient.Serialize()), + new KeyValuePair((Text)"amount", (_currency * 100).Serialize()), + new KeyValuePair((Text)"memo", new string(' ', 81).Serialize()), + })); + + Assert.Throws(() => action.LoadPlainValue(plainValue)); + } + + [Theory] + [InlineData(null)] + [InlineData("Nine Chronicles")] + public void SerializeWithDotnetAPI(string memo) + { + var formatter = new BinaryFormatter(); + var action = new TransferAsset(_sender, _recipient, _currency * 100, memo); + + using var ms = new MemoryStream(); + formatter.Serialize(ms, action); + + ms.Seek(0, SeekOrigin.Begin); + var deserialized = (TransferAsset)formatter.Deserialize(ms); + + Assert.Equal(_sender, deserialized.Sender); + Assert.Equal(_recipient, deserialized.Recipient); + Assert.Equal(_currency * 100, deserialized.Amount); + Assert.Equal(memo, deserialized.Memo); + } + } +} diff --git a/Lib9c/Action/TransferAsset.cs b/Lib9c/Action/TransferAsset.cs new file mode 100644 index 000000000..bf39b5f2d --- /dev/null +++ b/Lib9c/Action/TransferAsset.cs @@ -0,0 +1,159 @@ +using Bencodex; +using Bencodex.Types; +using Libplanet.Action; +using Libplanet.Action.State; +using Libplanet.Crypto; +using Libplanet.Types.Assets; +using Nekoyume.Model.State; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using Lib9c; +using Lib9c.Abstractions; +using Nekoyume.Helper; +using Nekoyume.Model; +using Serilog; + +namespace Nekoyume.Action +{ + /// + /// Hard forked at https://github.com/planetarium/lib9c/pull/2143 + /// Updated at https://github.com/planetarium/lib9c/pull/2143 + /// + [Serializable] + [ActionType(TypeIdentifier)] + public class TransferAsset : ActionBase, ISerializable, ITransferAsset, ITransferAssetV1 + { + private const int MemoMaxLength = 80; + public const string TypeIdentifier = "transfer_asset5"; + + public TransferAsset() + { + } + + public TransferAsset(Address sender, Address recipient, FungibleAssetValue amount, string memo = null) + { + Sender = sender; + Recipient = recipient; + Amount = amount; + + CheckMemoLength(memo); + Memo = memo; + } + + protected TransferAsset(SerializationInfo info, StreamingContext context) + { + var rawBytes = (byte[])info.GetValue("serialized", typeof(byte[])); + Dictionary pv = (Dictionary) new Codec().Decode(rawBytes); + + LoadPlainValue(pv); + } + + public Address Sender { get; private set; } + public Address Recipient { get; private set; } + public FungibleAssetValue Amount { get; private set; } + public string Memo { get; private set; } + + Address ITransferAssetV1.Sender => Sender; + Address ITransferAssetV1.Recipient => Recipient; + FungibleAssetValue ITransferAssetV1.Amount => Amount; + string ITransferAssetV1.Memo => Memo; + + public override IValue PlainValue + { + get + { + IEnumerable> pairs = new[] + { + new KeyValuePair((Text) "sender", Sender.Serialize()), + new KeyValuePair((Text) "recipient", Recipient.Serialize()), + new KeyValuePair((Text) "amount", Amount.Serialize()), + }; + + if (!(Memo is null)) + { + pairs = pairs.Append(new KeyValuePair((Text) "memo", Memo.Serialize())); + } + + return Dictionary.Empty + .Add("type_id", TypeIdentifier) + .Add("values", new Dictionary(pairs)); + } + } + + public override IAccount Execute(IActionContext context) + { + context.UseGas(4); + Address signer = context.Signer; + var state = context.PreviousState; + if (context.Rehearsal) + { + return state.MarkBalanceChanged(context, Amount.Currency, new[] {Sender, Recipient}); + } + + var addressesHex = GetSignerAndOtherAddressesHex(context, signer); + var started = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}TransferAsset5 exec started", addressesHex); + if (Sender != signer) + { + throw new InvalidTransferSignerException(signer, Sender, Recipient); + } + + if (Sender == Recipient) + { + throw new InvalidTransferRecipientException(Sender, Recipient); + } + + Currency currency = Amount.Currency; + if (!(currency.Minters is null) && + (currency.Minters.Contains(Sender) || currency.Minters.Contains(Recipient))) + { + throw new InvalidTransferMinterException( + currency.Minters, + Sender, + Recipient + ); + } + + TransferAsset3.CheckCrystalSender(currency, context.BlockIndex, Sender); + if (state.TryGetStakeStateV2(Recipient, out _)) + { + throw new ArgumentException( + "You can't send assets to StakeState.", + nameof(Recipient)); + } + + var ended = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}TransferAsset5 Total Executed Time: {Elapsed}", addressesHex, ended - started); + return state.TransferAsset(context, Sender, Recipient, Amount); + } + + public override void LoadPlainValue(IValue plainValue) + { + var asDict = (Dictionary)((Dictionary)plainValue)["values"]; + + Sender = asDict["sender"].ToAddress(); + Recipient = asDict["recipient"].ToAddress(); + Amount = asDict["amount"].ToFungibleAssetValue(); + Memo = asDict.TryGetValue((Text) "memo", out IValue memo) ? memo.ToDotnetString() : null; + + CheckMemoLength(Memo); + } + + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + info.AddValue("serialized", new Codec().Encode(PlainValue)); + } + + private void CheckMemoLength(string memo) + { + if (memo?.Length > MemoMaxLength) + { + string msg = $"The length of the memo, {memo.Length}, " + + $"is overflowed than the max length, {MemoMaxLength}."; + throw new MemoLengthOverflowException(msg); + } + } + } +} From da45fc165bb29afc2a4fd6a37a84222ef5e24135 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 12 Sep 2023 21:12:55 +0900 Subject: [PATCH 131/134] Restrict sending assets to staking state --- .Lib9c.Tests/Action/TransferAssetTest.cs | 75 ++++++++++++++++++++++ Lib9c/Action/TransferAsset.cs | 80 ++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 4 deletions(-) diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index c8b2287e0..9f8435be3 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -1,5 +1,6 @@ namespace Lib9c.Tests.Action { + using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; @@ -13,7 +14,9 @@ namespace Lib9c.Tests.Action using Nekoyume.Action; using Nekoyume.Helper; using Nekoyume.Model; + using Nekoyume.Model.Stake; using Nekoyume.Model.State; + using Nekoyume.TableData; using Xunit; public class TransferAssetTest @@ -314,6 +317,78 @@ public void LoadPlainValue_ThrowsMemoLengthOverflowException() Assert.Throws(() => action.LoadPlainValue(plainValue)); } + [Fact] + public void Execute_Throw_ArgumentException() + { + var baseState = new MockStateDelta( + MockState.Empty + .SetBalance(_sender, _currency * 1000)); + var action = new TransferAsset( + sender: _sender, + recipient: StakeState.DeriveAddress(_recipient), + amount: _currency * 100 + ); + // 스테이킹 주소에 송금하려고 하면 실패합니다. + Assert.Throws("Recipient", () => action.Execute(new ActionContext() + { + PreviousState = baseState + .SetState( + StakeState.DeriveAddress(_recipient), + new StakeState(StakeState.DeriveAddress(_recipient), 0).SerializeV2()), + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + })); + Assert.Throws("Recipient", () => action.Execute(new ActionContext() + { + PreviousState = baseState + .SetState( + StakeState.DeriveAddress(_recipient), + new StakeStateV2( + new Contract( + "StakeRegularFixedRewardSheet_V1", + "StakeRegularRewardSheet_V1", + 50400, + 201600), + 0).Serialize()), + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + })); + Assert.Throws("Recipient", () => action.Execute(new ActionContext() + { + PreviousState = baseState + .SetState( + StakeState.DeriveAddress(_recipient), + new MonsterCollectionState( + MonsterCollectionState.DeriveAddress(_sender, 0), + 1, + 0) + .Serialize()), + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + })); + var monsterCollectionRewardSheet = new MonsterCollectionRewardSheet(); + monsterCollectionRewardSheet.Set( + "level,required_gold,reward_id\n1,500,1\n2,1800,2\n3,7200,3\n4,54000,4\n5,270000,5\n6,480000,6\n7,1500000,7\n"); + Assert.Throws("Recipient", () => action.Execute(new ActionContext() + { + PreviousState = baseState + .SetState( + StakeState.DeriveAddress(_recipient), + new MonsterCollectionState0( + MonsterCollectionState.DeriveAddress(_sender, 0), + 1, + 0, + monsterCollectionRewardSheet) + .Serialize()), + Signer = _sender, + Rehearsal = false, + BlockIndex = 1, + })); + } + [Theory] [InlineData(null)] [InlineData("Nine Chronicles")] diff --git a/Lib9c/Action/TransferAsset.cs b/Lib9c/Action/TransferAsset.cs index bf39b5f2d..caa937ff5 100644 --- a/Lib9c/Action/TransferAsset.cs +++ b/Lib9c/Action/TransferAsset.cs @@ -13,6 +13,7 @@ using Lib9c.Abstractions; using Nekoyume.Helper; using Nekoyume.Model; +using Nekoyume.Model.Stake; using Serilog; namespace Nekoyume.Action @@ -117,11 +118,82 @@ public override IAccount Execute(IActionContext context) } TransferAsset3.CheckCrystalSender(currency, context.BlockIndex, Sender); - if (state.TryGetStakeStateV2(Recipient, out _)) + if (state.TryGetState(Recipient, out IValue serializedStakeState)) { - throw new ArgumentException( - "You can't send assets to StakeState.", - nameof(Recipient)); + bool isStakeStateOrMonsterCollectionState; + if (serializedStakeState is Dictionary dictionary) + { + try + { + _ = new StakeState(dictionary); + isStakeStateOrMonsterCollectionState = true; + } + catch (Exception) + { + isStakeStateOrMonsterCollectionState = false; + } + + if (isStakeStateOrMonsterCollectionState) + { + throw new ArgumentException( + "You can't send assets to staking state.", + nameof(Recipient)); + } + + try + { + _ = new MonsterCollectionState0(dictionary); + isStakeStateOrMonsterCollectionState = true; + } + catch (Exception) + { + isStakeStateOrMonsterCollectionState = false; + } + + if (isStakeStateOrMonsterCollectionState) + { + throw new ArgumentException( + "You can't send assets to staking state.", + nameof(Recipient)); + } + + try + { + _ = new MonsterCollectionState(dictionary); + isStakeStateOrMonsterCollectionState = true; + } + catch (Exception) + { + isStakeStateOrMonsterCollectionState = false; + } + + if (isStakeStateOrMonsterCollectionState) + { + throw new ArgumentException( + "You can't send assets to staking state.", + nameof(Recipient)); + } + } + + if (serializedStakeState is List serializedStakeStateV2) + { + try + { + _ = new StakeStateV2(serializedStakeStateV2); + isStakeStateOrMonsterCollectionState = true; + } + catch (Exception) + { + isStakeStateOrMonsterCollectionState = false; + } + + if (isStakeStateOrMonsterCollectionState) + { + throw new ArgumentException( + "You can't send assets to staking state.", + nameof(Recipient)); + } + } } var ended = DateTimeOffset.UtcNow; From 25a5162bbcd0d335881f4710e53764ed56b80a9e Mon Sep 17 00:00:00 2001 From: moreal Date: Wed, 13 Sep 2023 11:20:44 +0900 Subject: [PATCH 132/134] Update Lib9c version to 1.1.0 --- Lib9c/Lib9c.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/Lib9c.csproj b/Lib9c/Lib9c.csproj index 9a727488a..5968cbbfc 100644 --- a/Lib9c/Lib9c.csproj +++ b/Lib9c/Lib9c.csproj @@ -9,7 +9,7 @@ .obj Nekoyume 9 - 0.5.0 + 1.1.0 true Debug;Release AnyCPU From 351d48a1bac65b13f21c237aa6bd53e0f33acb37 Mon Sep 17 00:00:00 2001 From: jonny Date: Wed, 13 Sep 2023 15:10:48 +0900 Subject: [PATCH 133/134] add aura slot and equip level limit config --- Lib9c/GameConfig.cs | 1 + Lib9c/Model/State/AvatarState.cs | 3 ++- Lib9c/TableData/UnlockHelper.cs | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib9c/GameConfig.cs b/Lib9c/GameConfig.cs index 208a4eea1..a911571a8 100644 --- a/Lib9c/GameConfig.cs +++ b/Lib9c/GameConfig.cs @@ -73,6 +73,7 @@ public static class RequireCharacterLevel public const int CharacterEquipmentSlotNecklace = IsEditor ? 1 : 8; public const int CharacterEquipmentSlotRing1 = IsEditor ? 1 : 13; public const int CharacterEquipmentSlotRing2 = IsEditor ? 1 : 46; + public const int CharacterEquipmentSlotAura = 1; #endregion diff --git a/Lib9c/Model/State/AvatarState.cs b/Lib9c/Model/State/AvatarState.cs index 847a756d7..a1aefde57 100644 --- a/Lib9c/Model/State/AvatarState.cs +++ b/Lib9c/Model/State/AvatarState.cs @@ -673,7 +673,8 @@ public List ValidateEquipmentsV2(List equipmentIds, long blockI break; case ItemSubType.Aura: isSlotEnough = countMap[type] <= GameConfig.MaxEquipmentSlotCount.Aura; - requiredLevel = 1; + requiredLevel = isSlotEnough ? + GameConfig.RequireCharacterLevel.CharacterEquipmentSlotAura : int.MaxValue; break; default: throw new ArgumentOutOfRangeException($"{equipment.ItemSubType} / invalid equipment type"); diff --git a/Lib9c/TableData/UnlockHelper.cs b/Lib9c/TableData/UnlockHelper.cs index cc2eed51e..b2411e8a4 100644 --- a/Lib9c/TableData/UnlockHelper.cs +++ b/Lib9c/TableData/UnlockHelper.cs @@ -36,6 +36,10 @@ public static class UnlockHelper availableSlots.Add((ItemSubType.Ring, 1)); } } + if (level >= GameConfig.RequireCharacterLevel.CharacterEquipmentSlotAura) + { + availableSlots.Add((ItemSubType.Aura, 1)); + } return availableSlots; } From 315ecb2252d06c0ac39a8d90ba4b90a390b26747 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 19 Sep 2023 14:21:47 +0900 Subject: [PATCH 134/134] Update V200080BObsoleteIndex --- Lib9c/ActionObsoleteConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/ActionObsoleteConfig.cs b/Lib9c/ActionObsoleteConfig.cs index 889db7622..54f065283 100644 --- a/Lib9c/ActionObsoleteConfig.cs +++ b/Lib9c/ActionObsoleteConfig.cs @@ -80,7 +80,7 @@ public static class ActionObsoleteConfig public const long V200071ObsoleteIndex = 7_718_878L; - public const long V200080ObsoleteIndex = 7_974_443L; + public const long V200080ObsoleteIndex = 7_983_895L; // While v200020, the action obsolete wasn't work well. // So other previous `V*ObsoletedIndex`s lost its meaning and