From f7b857e4c64eb9a9d13951baf837cfad478604af Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:08:41 +0900 Subject: [PATCH 01/68] Implement methods for ITradableFungibleItem on Inventory --- Lib9c/Model/Item/Inventory.cs | 147 ++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/Lib9c/Model/Item/Inventory.cs b/Lib9c/Model/Item/Inventory.cs index 241c9547bd..7f97e8b193 100644 --- a/Lib9c/Model/Item/Inventory.cs +++ b/Lib9c/Model/Item/Inventory.cs @@ -275,6 +275,49 @@ public Item AddNonFungibleItem(ItemBase itemBase, ILock iLock = null) return nonFungibleItem; } + /// + /// Add tradable fungible item. + /// If there is same item which is not locked, add count to it. + /// The same item is item which has same item sheet id, fungible id, tradable id and + /// same required block index. + /// If there is no same item, add new item. + /// + /// + /// + public Item AddTradableFungibleItem( + ITradableFungibleItem tradableFungibleItem, + int count) + { + if (tradableFungibleItem is null) + { + throw new ArgumentNullException(nameof(tradableFungibleItem)); + } + + Item item; + if (!TryGetTradableFungibleItems( + tradableFungibleItem.FungibleId, + tradableFungibleItem.RequiredBlockIndex, + null, + out var outItems)) + { + item = new Item((ItemBase)tradableFungibleItem, count); + _items.Add(item); + return item; + } + + item = outItems.First(); + if (item.count > int.MaxValue - count) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + $"Aborted because {nameof(item.count)} is overflow"); + } + + item.count += count; + return item; + } + #endregion #region Remove @@ -496,6 +539,52 @@ i.item is ITradableItem item && return true; } + /// + /// Remove tradable item from inventory. + /// Use the requiredBlockIndex when you want to remove the item that + /// has same requiredBlockIndex. + /// Use the blockIndex when you want to remove the item that has requiredBlockIndex + /// less than or equal to blockIndex. + /// Do not use both requiredBlockIndex and blockIndex at the same time. + /// + /// + public bool RemoveTradableFungibleItem( + HashDigest fungibleId, + long? requiredBlockIndex, + long? blockIndex, + int count) + { + if (!TryGetTradableFungibleItems( + fungibleId, + requiredBlockIndex, + blockIndex, + out var outItems)) + { + return false; + } + + var itemArray = outItems as Item[] ?? outItems.ToArray(); + if (itemArray.Sum(item => item.count) < count) + { + return false; + } + + foreach (var item in itemArray) + { + if (item.count > count) + { + item.count -= count; + break; + } + + count -= item.count; + item.count = 0; + _items.Remove(item); + } + + return true; + } + #endregion #region Try Get @@ -626,6 +715,38 @@ i.item is ITradableItem item && return !(outItem is null); } + /// + /// Get ITradableFungibleItem from the inventory. + /// This method check the item is not locked, + /// and the item's required block index is less than or equal to the given block index. + /// Do not use both requiredBlockIndex and blockIndex at the same time. + /// + /// + public bool TryGetTradableFungibleItems( + HashDigest fungibleId, + long? requiredBlockIndex, + long? blockIndex, + out IEnumerable outItems) + { + if (requiredBlockIndex is null && blockIndex is null) + { + throw new ArgumentNullException( + $"{nameof(requiredBlockIndex)} and {nameof(blockIndex)} cannot be null " + + "at the same time"); + } + + var tradableId = TradableMaterial.DeriveTradableId(fungibleId); + outItems = _items + .Where(e => + !e.Locked && + e.item is ITradableFungibleItem tradableFungibleItem && + tradableFungibleItem.FungibleId.Equals(fungibleId) && + tradableFungibleItem.TradableId.Equals(tradableId) && + (requiredBlockIndex is null || tradableFungibleItem.RequiredBlockIndex == requiredBlockIndex) && + (blockIndex is null || tradableFungibleItem.RequiredBlockIndex <= blockIndex)); + return outItems.Any(); + } + public bool TryGetLockedItem(ILock iLock, out Item outItem) { outItem = _items.FirstOrDefault(i => i.Locked && i.Lock.Equals(iLock)); @@ -681,6 +802,32 @@ i.item is ITradableItem tradableItem && tradableItem.RequiredBlockIndex <= blockIndex) .Sum(i => i.count) >= count; + public bool HasTradableFungibleItem( + HashDigest fungibleId, + long? requiredBlockIndex, + long? blockIndex, + int count) + { + if (requiredBlockIndex is null && blockIndex is null) + { + throw new ArgumentNullException( + $"{nameof(requiredBlockIndex)} and {nameof(blockIndex)} cannot be null " + + "at the same time"); + } + + var tradableId = TradableMaterial.DeriveTradableId(fungibleId); + return _items + .Where(e => + !e.Locked && + e.item is ITradableFungibleItem tradableFungibleItem && + tradableFungibleItem.FungibleId.Equals(fungibleId) && + tradableFungibleItem.TradableId.Equals(tradableId) && + (requiredBlockIndex is null || + tradableFungibleItem.RequiredBlockIndex == requiredBlockIndex) && + (blockIndex is null || tradableFungibleItem.RequiredBlockIndex <= blockIndex)) + .Sum(e => e.count) >= count; + } + #endregion public bool HasNotification( From 29a71defd6c488d0c80fb722855f81d6f596d4ad Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:28:07 +0900 Subject: [PATCH 02/68] Implement some methods of Currencies --- Lib9c/Currencies.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Lib9c/Currencies.cs b/Lib9c/Currencies.cs index 90b8c5f6fe..2547ac0930 100644 --- a/Lib9c/Currencies.cs +++ b/Lib9c/Currencies.cs @@ -1,6 +1,7 @@ #nullable enable using System; +using System.Globalization; using System.Linq; using Libplanet.Assets; using Nekoyume.TableData; @@ -56,12 +57,12 @@ public static Currency GetMinterlessCurrency(string? ticker) return Garage; } - if (ticker.StartsWith("RUNE_")) + if (IsRuneTicker(ticker)) { return GetRune(ticker); } - if (ticker.StartsWith("SOULSTONE_")) + if (IsSoulstoneTicker(ticker)) { return GetSoulStone(ticker); } @@ -69,6 +70,12 @@ public static Currency GetMinterlessCurrency(string? ticker) throw new ArgumentException($"Invalid ticker: {ticker}", nameof(ticker)); } + public static bool IsRuneTicker(string ticker) + { + ticker = ticker.ToLower(CultureInfo.InvariantCulture); + return ticker.StartsWith("rune_") || ticker.StartsWith("runestone_"); + } + public static Currency GetRune(string? ticker) => string.IsNullOrEmpty(ticker) ? throw new ArgumentNullException(nameof(ticker)) @@ -90,6 +97,9 @@ public static IOrderedEnumerable GetRunes(RuneSheet? sheet) => .Select(GetRune) .OrderBy(rune => rune.Hash.GetHashCode()); + public static bool IsSoulstoneTicker(string ticker) => + ticker.ToLower(CultureInfo.InvariantCulture).StartsWith("soulstone_"); + public static Currency GetSoulStone(string? ticker) => string.IsNullOrEmpty(ticker) ? throw new ArgumentNullException(nameof(ticker)) From eba2211a26c4830a93f1f3a1a9ed76d8e0701e28 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:29:41 +0900 Subject: [PATCH 03/68] Implement some methods of AccountStateViewExtensions --- Lib9c/Action/AccountStateViewExtensions.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lib9c/Action/AccountStateViewExtensions.cs b/Lib9c/Action/AccountStateViewExtensions.cs index ccd1e386f8..a809bcf6dd 100644 --- a/Lib9c/Action/AccountStateViewExtensions.cs +++ b/Lib9c/Action/AccountStateViewExtensions.cs @@ -17,7 +17,9 @@ using Serilog; using static Lib9c.SerializeKeys; using System.Collections.Immutable; +using Nekoyume.Exceptions; using Nekoyume.Model.Coupons; +using Nekoyume.Model.Item; namespace Nekoyume.Action { @@ -1334,5 +1336,26 @@ public static RaiderState GetRaiderState(this IAccountStateView states, return states.GetSheets(sheetTypeList.Distinct().ToArray()); } + + public static IValue GetInventoryState( + this IAccountStateView accountStateView, + Address inventoryAddr) + { + var inventoryState = accountStateView.GetState(inventoryAddr); + if (inventoryState is null || inventoryState is Null) + { + throw new StateNullException(inventoryAddr); + } + + return inventoryState; + } + + public static Inventory GetInventory( + this IAccountStateView accountStateView, + Address inventoryAddr) + { + var inventoryState = GetInventoryState(accountStateView, inventoryAddr); + return new Inventory((List)inventoryState); + } } } From a2166625ef32517787e0bb9a1e65604e629e26f0 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:30:31 +0900 Subject: [PATCH 04/68] Implement some methods to Addresses --- Lib9c/Action/PetEnhancement.cs | 2 +- Lib9c/Addresses.cs | 65 +++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Lib9c/Action/PetEnhancement.cs b/Lib9c/Action/PetEnhancement.cs index 387234a9ff..a7c1f8f320 100644 --- a/Lib9c/Action/PetEnhancement.cs +++ b/Lib9c/Action/PetEnhancement.cs @@ -50,7 +50,7 @@ public override IAccountStateDelta Execute(IActionContext context) var addresses = GetSignerAndOtherAddressesHex(context, AvatarAddress); // NOTE: The `AvatarAddress` must contained in `Signer`'s `AgentState.avatarAddresses`. - if (!Addresses.IsContainedInAgent(context.Signer, AvatarAddress)) + if (!Addresses.CheckAvatarAddrIsContainedInAgent(context.Signer, AvatarAddress)) { throw new InvalidActionFieldException( ActionTypeIdentifier, diff --git a/Lib9c/Addresses.cs b/Lib9c/Addresses.cs index f7ed889b98..0c204a54f6 100644 --- a/Lib9c/Addresses.cs +++ b/Lib9c/Addresses.cs @@ -1,10 +1,12 @@ using System; using System.Globalization; using System.Linq; +using System.Security.Cryptography; using Libplanet; using Nekoyume.Action; using Nekoyume.Model.State; using Nekoyume.TableData; +using static Lib9c.SerializeKeys; namespace Nekoyume { @@ -80,27 +82,64 @@ public static Address GetAvatarAddress(Address agentAddr, int index) $"Index must be between 0 and {Nekoyume.GameConfig.SlotCount - 1}."); } - return agentAddr.Derive( - string.Format( - CultureInfo.InvariantCulture, - CreateAvatar.DeriveFormat, - index - )); + var deriveKey = string.Format( + CultureInfo.InvariantCulture, + CreateAvatar.DeriveFormat, + index); + return agentAddr.Derive(deriveKey); + } + + public static Address GetInventoryAddress(Address agentAddr, int avatarIndex) + { + return GetAvatarAddress(agentAddr, avatarIndex) + .Derive(LegacyInventoryKey); } public static Address GetCombinationSlotAddress(Address avatarAddr, int index) { - return avatarAddr.Derive( - string.Format( - CultureInfo.InvariantCulture, - CombinationSlotState.DeriveFormat, - index - )); + var deriveKey = string.Format( + CultureInfo.InvariantCulture, + CombinationSlotState.DeriveFormat, + index); + return avatarAddr.Derive(deriveKey); + } + + public static Address GetGarageBalanceAddress(Address agentAddr) + { + return agentAddr.Derive("garage-balance"); + } + + public static Address GetGarageAddress( + Address agentAddr, + HashDigest fungibleId) + { + return agentAddr + .Derive("garage") + .Derive(fungibleId.ToString()); } - public static bool IsContainedInAgent(Address agentAddr, Address avatarAddr) => + public static bool CheckAvatarAddrIsContainedInAgent( + Address agentAddr, + Address avatarAddr) => Enumerable.Range(0, Nekoyume.GameConfig.SlotCount) .Select(index => GetAvatarAddress(agentAddr, index)) .Contains(avatarAddr); + + public static bool CheckAgentHasPermissionOnBalanceAddr( + Address agentAddr, + Address balanceAddr) => + agentAddr == balanceAddr || + Enumerable.Range(0, Nekoyume.GameConfig.SlotCount) + .Select(index => GetAvatarAddress(agentAddr, index)) + .Contains(balanceAddr); + + public static bool CheckInventoryAddrIsContainedInAgent( + Address agentAddr, + Address inventoryAddr) => + Enumerable.Range(0, Nekoyume.GameConfig.SlotCount) + .Select(index => GetInventoryAddress(agentAddr, index)) + .Contains(inventoryAddr); + + } } From d3ea8097f2ba7cae51b80cbabd9dd942b6633aaf Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:31:09 +0900 Subject: [PATCH 05/68] Enable nullable to InvalidActionFieldException --- Lib9c/Exceptions/InvalidActionFieldException.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib9c/Exceptions/InvalidActionFieldException.cs b/Lib9c/Exceptions/InvalidActionFieldException.cs index aaf2a3d59d..fd9bcfc664 100644 --- a/Lib9c/Exceptions/InvalidActionFieldException.cs +++ b/Lib9c/Exceptions/InvalidActionFieldException.cs @@ -1,4 +1,6 @@ -using System; +#nullable enable + +using System; using System.Runtime.Serialization; namespace Nekoyume.Exceptions @@ -6,13 +8,13 @@ namespace Nekoyume.Exceptions [Serializable] public class InvalidActionFieldException : Exception { - public InvalidActionFieldException(string message) : base(message) + public InvalidActionFieldException(string? message = null) : base(message) { } public InvalidActionFieldException( - string message, - Exception innerException = null) + string? message = null, + Exception? innerException = null) : base(message, innerException) { } @@ -22,7 +24,7 @@ public InvalidActionFieldException( string addressesHex, string fieldName, string message, - Exception innerException = null) + Exception? innerException = null) : base( $"[{actionType}][{addressesHex}]" + $" Invalid field({fieldName}): {message}", From a36f195a9a0c3e141065bdcf9600a1c6658c2373 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:32:22 +0900 Subject: [PATCH 06/68] Introduce LoadIntoMyGaragesCostSheet --- .../Garages/LoadIntoMyGaragesCostSheetTest.cs | 264 ++++++++++++++++++ .Lib9c.Tests/TableSheets.cs | 15 +- .../Garages/LoadIntoMyGaragesCostSheet.csv | 11 + .../Garages/LoadIntoMyGaragesCostSheet.cs | 146 ++++++++++ 4 files changed, 434 insertions(+), 2 deletions(-) create mode 100644 .Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs create mode 100644 Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv create mode 100644 Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs diff --git a/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs b/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs new file mode 100644 index 0000000000..b6d9e68c64 --- /dev/null +++ b/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs @@ -0,0 +1,264 @@ +namespace Lib9c.Tests.TableData.Garages +{ + using System; + using System.Globalization; + using System.Linq; + using System.Security.Cryptography; + using System.Text; + using Libplanet; + using Libplanet.Assets; + using Nekoyume.TableData.Garages; + using Xunit; + + public class LoadIntoMyGaragesCostSheetTest + { + private readonly LoadIntoMyGaragesCostSheet _sheet; + + public LoadIntoMyGaragesCostSheetTest() + { + var sb = new StringBuilder(); + sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine( + "1,ITEM,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16"); + sb.AppendLine( + "2,ITEM,,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016"); + sb.AppendLine( + "3,ITEM,,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1"); + sb.AppendLine( + "4,ITEM,,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10"); + sb.AppendLine("5,CURRENCY,RUNE_GOLDENLEAF,,10"); + _sheet = new LoadIntoMyGaragesCostSheet(); + _sheet.Set(sb.ToString()); + } + + [Fact] + public void Set() + { + Assert.NotNull(_sheet.OrderedList); + Assert.Equal(5, _sheet.Count); + var row = _sheet.OrderedList[0]; + Assert.Equal(1, row.Id); + Assert.Equal("ITEM", row.CostKind); + Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); + Assert.Equal( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe", + row.FungibleId.ToString()); + Assert.Equal(0.16m, row.GarageCostPerUnit); + row = _sheet.OrderedList[1]; + Assert.Equal(2, row.Id); + Assert.Equal("ITEM", row.CostKind); + Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); + Assert.Equal( + "3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a", + row.FungibleId.ToString()); + Assert.Equal(0.0016m, row.GarageCostPerUnit); + row = _sheet.OrderedList[2]; + Assert.Equal(3, row.Id); + Assert.Equal("ITEM", row.CostKind); + Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); + Assert.Equal( + "1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820", + row.FungibleId.ToString()); + Assert.Equal(1m, row.GarageCostPerUnit); + row = _sheet.OrderedList[3]; + Assert.Equal(4, row.Id); + Assert.Equal("ITEM", row.CostKind); + Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); + Assert.Equal( + "f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0", + row.FungibleId.ToString()); + Assert.Equal(10m, row.GarageCostPerUnit); + row = _sheet.OrderedList[4]; + Assert.Equal(5, row.Id); + Assert.Equal("CURRENCY", row.CostKind); + Assert.Equal("RUNE_GOLDENLEAF", row.CurrencyTicker); + Assert.Null(row.FungibleId); + Assert.Equal(10m, row.GarageCostPerUnit); + } + + [Fact] + public void Set_InvalidCostKind() + { + var sb = new StringBuilder(); + sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine( + "1,INVALID,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16"); + + var sheet = new LoadIntoMyGaragesCostSheet(); + Assert.Throws(() => sheet.Set(sb.ToString())); + } + + [Fact] + public void Set_InvalidFungibleId() + { + var sb = new StringBuilder(); + sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine( + "1,ITEM,,INVALID,0.16"); + + var sheet = new LoadIntoMyGaragesCostSheet(); + Assert.Throws(() => sheet.Set(sb.ToString())); + } + + [Fact] + public void Set_InvalidGarageCostPerUnit() + { + var sb = new StringBuilder(); + sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine( + "1,ITEM,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,INVALID"); + + var sheet = new LoadIntoMyGaragesCostSheet(); + Assert.Throws(() => sheet.Set(sb.ToString())); + } + + [Theory] + [InlineData("RUNE_GOLDENLEAF", 10)] + public void GetGarageCostPerUnit_CurrencyTicker( + string currencyTicker, + decimal expect) + { + var actual = _sheet.GetGarageCostPerUnit(currencyTicker); + Assert.Equal(expect, actual); + } + + [Fact] + public void GetGarageCostPerUnit_CurrencyTicker_Failure() + { + Assert.Throws(() => _sheet.GetGarageCostPerUnit("INVALID")); + } + + [Theory] + [InlineData( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe", + 0.16)] + [InlineData( + "3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a", + 0.0016)] + [InlineData( + "1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820", + 1)] + [InlineData( + "f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0", + 10)] + public void GetGarageCostPerUnit_FungibleId( + string fungibleIdHex, + decimal expect) + { + var fungibleId = HashDigest.FromString(fungibleIdHex); + var actual = _sheet.GetGarageCostPerUnit(fungibleId); + Assert.Equal(expect, actual); + } + + [Fact] + public void GetGarageCostPerUnit_FungibleId_Failure() + { + var fungibleId = HashDigest.FromString( + "1234567890123456789012345678901234567890123456789012345678901234"); + Assert.Throws(() => _sheet.GetGarageCostPerUnit(fungibleId)); + } + + [Theory] + [InlineData("RUNE_GOLDENLEAF", 0, 0, 0)] + [InlineData("RUNE_GOLDENLEAF", 1, 0, 10)] + [InlineData("RUNE_GOLDENLEAF", 10, 0, 100)] + public void GetGarageCost_FungibleAssetValue( + string currencyTicker, + long majorUnit, + long minorUnit, + decimal expect) + { + var currency = Currencies.GetMinterlessCurrency(currencyTicker); + var fav = new FungibleAssetValue(currency, majorUnit, minorUnit); + var actual = _sheet.GetGarageCost(fav); + var expectGarage = FungibleAssetValue.Parse( + Currencies.Garage, + expect.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(expectGarage, actual); + } + + [Theory] + [InlineData( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe", + 0, + 0)] + [InlineData( + "3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a", + 1, + 0.0016)] + [InlineData( + "1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820", + 10, + 10)] + [InlineData( + "f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0", + 100, + 1000)] + public void GetGarageCost_FungibleId_Count( + string fungibleIdHex, + int count, + decimal expect) + { + var fungibleId = HashDigest.FromString(fungibleIdHex); + var actual = _sheet.GetGarageCost(fungibleId, count); + var expectGarage = FungibleAssetValue.Parse( + Currencies.Garage, + expect.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(expectGarage, actual); + } + + [Fact] + public void GetGarageCost_FungibleId_Count_Failure() + { + var fungibleId = HashDigest.FromString( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe"); + Assert.Throws(() => _sheet.GetGarageCost(fungibleId, -1)); + } + + [Fact] + public void GetGarageCost() + { + var currency = Currencies.GetMinterlessCurrency("RUNE_GOLDENLEAF"); + var favTuples = Enumerable.Range(1, 10) + .Select(i => ( + fav: new FungibleAssetValue(currency, i, 0), + expect: i * 10m)) + .ToArray(); + var fungibleIdAndCountTuples = Enumerable.Range(1, 10) + .Select(i => ( + fungibleId: HashDigest.FromString( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe"), + count: i, + expect: i * 0.16m)) + .ToArray(); + var expect = favTuples.Select(t => t.expect).Sum() + + fungibleIdAndCountTuples.Select(t => t.expect).Sum(); + var favArr = favTuples.Select(t => t.fav).ToArray(); + var fungibleIdAndCountArr = fungibleIdAndCountTuples + .Select(t => (t.fungibleId, t.count)).ToArray(); + var actual = _sheet.GetGarageCost(favArr, fungibleIdAndCountArr); + var expectGarage = FungibleAssetValue.Parse( + Currencies.Garage, + expect.ToString(CultureInfo.InvariantCulture)); + Assert.Equal(expectGarage, actual); + } + + [Fact] + public void HasCost_CurrencyTicker() + { + Assert.True(_sheet.HasCost("RUNE_GOLDENLEAF")); + Assert.False(_sheet.HasCost("INVALID")); + } + + [Fact] + public void HasCost_FungibleId() + { + var fungibleId = HashDigest.FromString( + "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe"); + Assert.True(_sheet.HasCost(fungibleId)); + fungibleId = HashDigest.FromString( + "1234567890123456789012345678901234567890123456789012345678901234"); + Assert.False(_sheet.HasCost(fungibleId)); + } + } +} diff --git a/.Lib9c.Tests/TableSheets.cs b/.Lib9c.Tests/TableSheets.cs index ac813a1155..96e46ad40e 100644 --- a/.Lib9c.Tests/TableSheets.cs +++ b/.Lib9c.Tests/TableSheets.cs @@ -6,6 +6,7 @@ namespace Lib9c.Tests using Nekoyume.TableData; using Nekoyume.TableData.Crystal; using Nekoyume.TableData.Event; + using Nekoyume.TableData.Garages; using Nekoyume.TableData.GrandFinale; using Nekoyume.TableData.Pet; @@ -148,7 +149,11 @@ public TableSheets(Dictionary sheets) public CrystalEquipmentGrindingSheet CrystalEquipmentGrindingSheet { get; private set; } - public CrystalMonsterCollectionMultiplierSheet CrystalMonsterCollectionMultiplierSheet { get; private set; } + public CrystalMonsterCollectionMultiplierSheet CrystalMonsterCollectionMultiplierSheet + { + get; + private set; + } public CrystalMaterialCostSheet CrystalMaterialCostSheet { get; private set; } @@ -174,7 +179,11 @@ public TableSheets(Dictionary sheets) public EventMaterialItemRecipeSheet EventMaterialItemRecipeSheet { get; private set; } - public StakeActionPointCoefficientSheet StakeActionPointCoefficientSheet { get; private set; } + public StakeActionPointCoefficientSheet StakeActionPointCoefficientSheet + { + get; + private set; + } public WorldBossListSheet WorldBossListSheet { get; private set; } @@ -218,6 +227,8 @@ public TableSheets(Dictionary sheets) public PetCostSheet PetCostSheet { get; private set; } + public LoadIntoMyGaragesCostSheet LoadIntoMyGaragesCostSheet { get; private set; } + public void ItemSheetInitialize() { ItemSheet ??= new ItemSheet(); diff --git a/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv new file mode 100644 index 0000000000..7c90a90288 --- /dev/null +++ b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv @@ -0,0 +1,11 @@ +id,_memo,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit +_id,int +_cost_kind,CURRENCY|ITEM +_currency_ticker,(empty)|NCG|CRYSTAL... +_fungible_id,(empty)|3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a|00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe... +_garage_cost_per_unit,1|100|0.001... +1,ap portion(500000),Item,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16 +2,hourglass(400000),Item,,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016 +3,golden meat(800201),Item,,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1 +4,golden dust(600201),Item,,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10 +5,golden leaf runestone,Currency,RUNE_GOLDENLEAF,,10 diff --git a/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs b/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs new file mode 100644 index 0000000000..125bd4774f --- /dev/null +++ b/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Security.Cryptography; +using Lib9c; +using Libplanet; +using Libplanet.Assets; +using static Nekoyume.TableData.TableExtensions; + +namespace Nekoyume.TableData.Garages +{ + [Serializable] + public class LoadIntoMyGaragesCostSheet : Sheet + { + [Serializable] + public class Row : SheetRow + { + public override int Key => Id; + + public int Id { get; private set; } + + /// + /// CURRENCY | ITEM + /// + public string CostKind { get; private set; } + + public string CurrencyTicker { get; private set; } + + public HashDigest? FungibleId { get; private set; } + + public decimal GarageCostPerUnit { get; private set; } + + public override void Set(IReadOnlyList fields) + { + Id = ParseInt(fields[0]); + CostKind = string.IsNullOrEmpty(fields[1]) + ? null + : fields[1].ToUpperInvariant(); + if (CostKind != "CURRENCY" && + CostKind != "ITEM") + { + throw new ArgumentException( + $"CostKind must be CURRENCY or ITEM but {CostKind}.", + nameof(fields)); + } + + CurrencyTicker = fields[2]; + FungibleId = string.IsNullOrEmpty(fields[3]) + ? (HashDigest?)null + : HashDigest.FromString(fields[3]); + GarageCostPerUnit = ParseDecimal(fields[4]); + } + } + + public LoadIntoMyGaragesCostSheet() : base(nameof(LoadIntoMyGaragesCostSheet)) + { + } + + public decimal GetGarageCostPerUnit(string currencyTicker) + { + var row = OrderedList!.First(r => + r.CostKind == "CURRENCY" && + r.CurrencyTicker == currencyTicker); + return row.GarageCostPerUnit; + } + + public decimal GetGarageCostPerUnit(HashDigest fungibleId) + { + var row = OrderedList!.First(r => + r.CostKind == "ITEM" && + r.FungibleId.Equals(fungibleId)); + return row.GarageCostPerUnit; + } + + public FungibleAssetValue GetGarageCost(FungibleAssetValue fav) + { + var unitCost = GetGarageCostPerUnit(fav.Currency.Ticker); + var quantity = decimal.Parse( + fav.GetQuantityString(), + CultureInfo.InvariantCulture); + return FungibleAssetValue.Parse( + Currencies.Garage, + (unitCost * quantity).ToString(CultureInfo.InvariantCulture)); + } + + public FungibleAssetValue GetGarageCost(HashDigest fungibleId, int count) + { + if (count < 0) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + "count must be positive."); + } + + if (count == 0) + { + return new FungibleAssetValue(Currencies.Garage); + } + + var unitCost = GetGarageCostPerUnit(fungibleId); + return FungibleAssetValue.Parse( + Currencies.Garage, + (unitCost * count).ToString(CultureInfo.InvariantCulture)); + } + + public FungibleAssetValue GetGarageCost( + IEnumerable fungibleAssetValues, + IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) + { + var cost = new FungibleAssetValue(Currencies.Garage); + if (fungibleAssetValues is { }) + { + foreach (var fav in fungibleAssetValues) + { + cost += GetGarageCost(fav); + } + } + + if (fungibleIdAndCounts is { }) + { + foreach (var (fungibleId, count) in fungibleIdAndCounts) + { + cost += GetGarageCost(fungibleId, count); + } + } + + return cost; + } + + public bool HasCost(string currencyTicker) + { + return OrderedList!.Any(r => + r.CostKind == "CURRENCY" && + r.CurrencyTicker == currencyTicker); + } + + public bool HasCost(HashDigest fungibleId) + { + return OrderedList!.Any(r => + r.CostKind == "ITEM" && + r.FungibleId.Equals(fungibleId)); + } + } +} From 5237347150737965361970bd1d4362330d487333 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:32:50 +0900 Subject: [PATCH 07/68] Introduce FungibleItemGarage --- .../Model/Garages/FungibleItemGarageTest.cs | 177 ++++++++++++++++++ Lib9c/Model/Garages/FungibleItemGarage.cs | 117 ++++++++++++ Lib9c/Model/Garages/IFungibleItemGarage.cs | 10 + Lib9c/Model/Garages/IGarage.cs | 9 + 4 files changed, 313 insertions(+) create mode 100644 .Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs create mode 100644 Lib9c/Model/Garages/FungibleItemGarage.cs create mode 100644 Lib9c/Model/Garages/IFungibleItemGarage.cs create mode 100644 Lib9c/Model/Garages/IGarage.cs diff --git a/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs b/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs new file mode 100644 index 0000000000..e615976a2b --- /dev/null +++ b/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs @@ -0,0 +1,177 @@ +namespace Lib9c.Tests.Model.Garages +{ + using System; + using Bencodex.Types; + using Nekoyume.Model.Garages; + using Nekoyume.Model.Item; + using Nekoyume.TableData; + using Xunit; + + public class FungibleItemGarageTest + { + private static TradableMaterial _tradableMaterial; + private static TradableMaterial _tradableMaterial2; + + public FungibleItemGarageTest() + { + if (!TableSheetsImporter.TryGetCsv( + nameof(MaterialItemSheet), + out var materialItemSheetCsv)) + { + throw new Exception("Failed to load MaterialItemSheet.csv"); + } + + var materialItemSheet = new MaterialItemSheet(); + materialItemSheet.Set(materialItemSheetCsv); + _tradableMaterial = + ItemFactory.CreateTradableMaterial(materialItemSheet.OrderedList![0]); + _tradableMaterial2 = + ItemFactory.CreateTradableMaterial(materialItemSheet.OrderedList![1]); + } + + [Theory] + [InlineData(0)] + [InlineData(int.MaxValue)] + public void Constructor_Success(int count) + { + var garage = new FungibleItemGarage(_tradableMaterial, count); + Assert.Equal(_tradableMaterial, garage.Item); + Assert.Equal(count, garage.Count); + AssertSerialization(garage); + garage = new FungibleItemGarage(_tradableMaterial2, count); + Assert.Equal(_tradableMaterial2, garage.Item); + Assert.Equal(count, garage.Count); + AssertSerialization(garage); + } + + [Theory] + [InlineData(0)] + [InlineData(int.MaxValue)] + public void Constructor_Failure_With_Null_Item(int count) + { + Assert.Throws(() => + new FungibleItemGarage(null!, count)); + } + + [Theory] + [InlineData(int.MinValue)] + [InlineData(-1)] + public void Constructor_Failure_With_Negative_Count(int count) + { + Assert.Throws(() => + new FungibleItemGarage(_tradableMaterial, count)); + Assert.Throws(() => + new FungibleItemGarage(_tradableMaterial2, count)); + } + + [Fact] + public void Constructor_With_IValue_Failure() + { + Assert.Throws(() => + new FungibleItemGarage(null)); + Assert.Throws(() => + new FungibleItemGarage(Null.Value)); + } + + [Theory] + [InlineData(0, 1)] + [InlineData(0, int.MaxValue)] + [InlineData(int.MaxValue - 1, 1)] + public void Load_Success(int count1, int count2) + { + var garage = new FungibleItemGarage(_tradableMaterial, count1); + Assert.Equal(count1, garage.Count); + garage.Load(count2); + Assert.Equal(count1 + count2, garage.Count); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(0, -1)] + [InlineData(1, -1)] + [InlineData(1, int.MaxValue)] + [InlineData(int.MaxValue, 1)] + public void Load_Failure(int count1, int count2) + { + var garage = new FungibleItemGarage(_tradableMaterial, count1); + Assert.Throws(() => + garage.Load(count2)); + } + + [Theory] + [InlineData(1, 1)] + [InlineData(2, 1)] + [InlineData(int.MaxValue, 1)] + public void Deliver_Success(int count1, int count2) + { + var garage1 = new FungibleItemGarage(_tradableMaterial, count1); + var garage2 = new FungibleItemGarage(_tradableMaterial, 0); + garage1.Deliver(garage2, count2); + Assert.Equal(count1 - count2, garage1.Count); + Assert.Equal(count2, garage2.Count); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(0, 1)] + [InlineData(0, -1)] + [InlineData(1, -1)] + [InlineData(2, -1)] + public void Deliver_Failure_With_Invalid_Count(int count1, int count2) + { + var garage1 = new FungibleItemGarage(_tradableMaterial, count1); + var garage2 = new FungibleItemGarage(_tradableMaterial, 0); + Assert.Throws(() => + garage1.Deliver(garage2, count2)); + } + + [Fact] + public void Deliver_Failure_With_Mismatch_Item() + { + var garage1 = new FungibleItemGarage(_tradableMaterial, 1); + var garage2 = new FungibleItemGarage(_tradableMaterial2, 0); + Assert.Throws(() => + garage1.Deliver(garage2, 1)); + } + + [Theory] + [InlineData(1, 1)] + [InlineData(int.MaxValue, 1)] + [InlineData(int.MaxValue, int.MaxValue)] + public void Unload_Success(int count1, int count2) + { + var garage = new FungibleItemGarage(_tradableMaterial, count1); + Assert.Equal(count1, garage.Count); + garage.Unload(count2); + Assert.Equal(count1 - count2, garage.Count); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(0, 1)] + [InlineData(1, 2)] + [InlineData(int.MaxValue - 1, int.MaxValue)] + public void Unload_Failure(int count1, int count2) + { + var garage = new FungibleItemGarage(_tradableMaterial, count1); + Assert.Throws(() => + garage.Unload(count2)); + } + + private static void AssertSerialization(FungibleItemGarage garage) + { + var serialized = garage.Serialize(); + if (garage.Count == 0) + { + Assert.Equal(Null.Value, serialized); + return; + } + + var deserialized = new FungibleItemGarage(serialized); + Assert.Equal(garage.Item, deserialized.Item); + Assert.Equal(garage.Count, deserialized.Count); + var serialized2 = deserialized.Serialize(); + Assert.Equal(serialized, serialized2); + } + } +} diff --git a/Lib9c/Model/Garages/FungibleItemGarage.cs b/Lib9c/Model/Garages/FungibleItemGarage.cs new file mode 100644 index 0000000000..cef5f80e25 --- /dev/null +++ b/Lib9c/Model/Garages/FungibleItemGarage.cs @@ -0,0 +1,117 @@ +#nullable enable + +using System; +using Bencodex.Types; +using Nekoyume.Model.Item; + +namespace Nekoyume.Model.Garages +{ + public class FungibleItemGarage : IFungibleItemGarage + { + public IFungibleItem Item { get; } + public int Count { get; private set; } + + public FungibleItemGarage(IFungibleItem item, int count) + { + Item = item ?? throw new ArgumentNullException(nameof(item)); + + if (count < 0) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + "Count must be greater than or equal to 0."); + } + + Count = count; + } + + public FungibleItemGarage(IValue? serialized) + { + if (serialized is null || serialized is Null) + { + throw new ArgumentNullException(nameof(serialized)); + } + + var list = (List)serialized; + Item = list[0].Kind == ValueKind.Null + ? throw new ArgumentNullException(nameof(serialized), "Item is null.") + : (IFungibleItem)ItemFactory.Deserialize((Dictionary)list[0]); + Count = (Integer)list[1]; + } + + public IValue Serialize() => Count == 0 + ? (IValue)Null.Value + : new List( + Item?.Serialize() ?? Null.Value, + (Integer)Count); + + public void Load(int count) + { + if (count <= 0) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + $"Count must be greater than or equal to 0."); + } + + if (count > int.MaxValue - Count) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + $"Count must be less than or equal to {int.MaxValue - Count}."); + } + + Count += count; + } + + public void Unload(int count) + { + if (count <= 0) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + $"Count must be greater than or equal to 0."); + } + + if (count > Count) + { + throw new ArgumentOutOfRangeException( + nameof(count), + count, + $"Count must be less than or equal to {Count}."); + } + + Count -= count; + } + + public void Deliver(IFungibleItemGarage to, int count) + { + if (to is null) + { + throw new ArgumentNullException(nameof(to)); + } + + // NOTE: + // Why not compare the garage.Item with this.Item directly? + // Because the ITradableFungibleItem.Equals() method compares the + // ITradableItem.RequiredBlockIndex property. + // The IFungibleItem.FungibleId property fully contains the + // specification of the fungible item. + // So ITradableItem.RequiredBlockIndex property does not considered + // when transferring items via garage. + if (!to.Item.FungibleId.Equals(Item.FungibleId)) + { + throw new ArgumentException( + $"Item type mismatched. {to.Item.FungibleId} != {Item.FungibleId}", + nameof(to)); + } + + Unload(count); + to.Load(count); + } + } +} diff --git a/Lib9c/Model/Garages/IFungibleItemGarage.cs b/Lib9c/Model/Garages/IFungibleItemGarage.cs new file mode 100644 index 0000000000..2f1605dd84 --- /dev/null +++ b/Lib9c/Model/Garages/IFungibleItemGarage.cs @@ -0,0 +1,10 @@ +using Nekoyume.Model.Item; + +namespace Nekoyume.Model.Garages +{ + public interface IFungibleItemGarage : IGarage + { + IFungibleItem Item { get; } + int Count { get; } + } +} diff --git a/Lib9c/Model/Garages/IGarage.cs b/Lib9c/Model/Garages/IGarage.cs new file mode 100644 index 0000000000..edd207bef7 --- /dev/null +++ b/Lib9c/Model/Garages/IGarage.cs @@ -0,0 +1,9 @@ +namespace Nekoyume.Model.Garages +{ + public interface IGarage where T1 : IGarage + { + void Load(T2 amount); + void Deliver(T1 to, T2 amount); + void Unload(T2 amount); + } +} From facc056c8c7a26f677aedf3aef531e67c38d0574 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:33:42 +0900 Subject: [PATCH 08/68] Introduce some exceptions --- .Lib9c.Tests/Action/ExceptionTest.cs | 3 ++ Lib9c/Exceptions/ItemNotFoundException.cs | 49 ++++++++++++++++++++++ Lib9c/Exceptions/NotEnoughItemException.cs | 46 ++++++++++++++++++++ Lib9c/Exceptions/StateNullException.cs | 41 ++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 Lib9c/Exceptions/ItemNotFoundException.cs create mode 100644 Lib9c/Exceptions/NotEnoughItemException.cs create mode 100644 Lib9c/Exceptions/StateNullException.cs diff --git a/.Lib9c.Tests/Action/ExceptionTest.cs b/.Lib9c.Tests/Action/ExceptionTest.cs index 4be549cae3..e22e4a8a0f 100644 --- a/.Lib9c.Tests/Action/ExceptionTest.cs +++ b/.Lib9c.Tests/Action/ExceptionTest.cs @@ -69,6 +69,9 @@ public ExceptionTest() [InlineData(typeof(InvalidCurrencyException))] [InlineData(typeof(InvalidProductTypeException))] [InlineData(typeof(ProductNotFoundException))] + [InlineData(typeof(ItemNotFoundException))] + [InlineData(typeof(NotEnoughItemException))] + [InlineData(typeof(StateNullException))] public void Exception_Serializable(Type excType) { if (Activator.CreateInstance(excType, "for testing") is Exception exc) diff --git a/Lib9c/Exceptions/ItemNotFoundException.cs b/Lib9c/Exceptions/ItemNotFoundException.cs new file mode 100644 index 0000000000..b6f122be61 --- /dev/null +++ b/Lib9c/Exceptions/ItemNotFoundException.cs @@ -0,0 +1,49 @@ +#nullable enable + +using System; +using System.Runtime.Serialization; +using System.Security.Cryptography; +using Libplanet; + +namespace Nekoyume.Exceptions +{ + [Serializable] + public class ItemNotFoundException : Exception + { + public ItemNotFoundException() + { + } + + public ItemNotFoundException(string? message) : base(message) + { + } + + public ItemNotFoundException(string? message, Exception? innerException) : + base(message, innerException) + { + } + + public ItemNotFoundException( + Address inventoryAddr, + HashDigest fungibleId, + Exception? innerException = null) : + base($"Item not found: {inventoryAddr} {fungibleId}", innerException) + { + } + + public ItemNotFoundException( + Address inventoryAddr, + Guid nonFungibleId, + Exception? innerException = null) : + base($"Item not found: {inventoryAddr} {nonFungibleId}", innerException) + { + } + + protected ItemNotFoundException( + SerializationInfo info, + StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/Lib9c/Exceptions/NotEnoughItemException.cs b/Lib9c/Exceptions/NotEnoughItemException.cs new file mode 100644 index 0000000000..0053a13c46 --- /dev/null +++ b/Lib9c/Exceptions/NotEnoughItemException.cs @@ -0,0 +1,46 @@ +#nullable enable + +using System; +using System.Runtime.Serialization; +using System.Security.Cryptography; +using Libplanet; + +namespace Nekoyume.Exceptions +{ + [Serializable] + public class NotEnoughItemException : Exception + { + public NotEnoughItemException() + { + } + + public NotEnoughItemException(string? message) : base(message) + { + } + + public NotEnoughItemException(string? message, Exception? innerException) : + base(message, innerException) + { + } + + public NotEnoughItemException( + Address inventoryAddr, + HashDigest fungibleId, + int expectedCount, + int actualCount, + Exception? innerException = null) : + base( + $"Not enough item: {inventoryAddr} {fungibleId}, " + + $"expected: {expectedCount}, actual: {actualCount}", + innerException) + { + } + + protected NotEnoughItemException( + SerializationInfo info, + StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/Lib9c/Exceptions/StateNullException.cs b/Lib9c/Exceptions/StateNullException.cs new file mode 100644 index 0000000000..0c53162ad3 --- /dev/null +++ b/Lib9c/Exceptions/StateNullException.cs @@ -0,0 +1,41 @@ +#nullable enable + +using System; +using System.Runtime.Serialization; +using Libplanet; + +namespace Nekoyume.Exceptions +{ + [Serializable] + public class StateNullException : Exception + { + public StateNullException() + { + } + + public StateNullException(string? message) : base(message) + { + } + + public StateNullException( + string? message, + Exception? innerException) + : base(message, innerException) + { + } + + public StateNullException( + Address address, + Exception? innerException = null) + : base($"State is null or Null.Value: {address}", innerException) + { + } + + protected StateNullException( + SerializationInfo info, + StreamingContext context) + : base(info, context) + { + } + } +} From a2822f5c1f446bc187c4ab50469b0b7405d73376 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 17:01:49 +0900 Subject: [PATCH 09/68] Introduce copy constructor of ItemBase and Material --- Lib9c/Model/Item/ItemBase.cs | 9 +++++++++ Lib9c/Model/Item/Material.cs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/Lib9c/Model/Item/ItemBase.cs b/Lib9c/Model/Item/ItemBase.cs index ea7875a38d..a86dbda433 100644 --- a/Lib9c/Model/Item/ItemBase.cs +++ b/Lib9c/Model/Item/ItemBase.cs @@ -27,6 +27,15 @@ protected ItemBase(ItemSheet.Row data) ElementalType = data.ElementalType; } + protected ItemBase(ItemBase other) + { + Id = other.Id; + Grade = other.Grade; + ItemType = other.ItemType; + ItemSubType = other.ItemSubType; + ElementalType = other.ElementalType; + } + protected ItemBase(Dictionary serialized) { if (serialized.TryGetValue((Text) "id", out var id)) diff --git a/Lib9c/Model/Item/Material.cs b/Lib9c/Model/Item/Material.cs index 7f8b38e4b8..6dcf6b11f5 100644 --- a/Lib9c/Model/Item/Material.cs +++ b/Lib9c/Model/Item/Material.cs @@ -20,6 +20,11 @@ public Material(MaterialItemSheet.Row data) : base(data) ItemId = data.ItemId; } + public Material(Material other) : base(other) + { + ItemId = other.ItemId; + } + public Material(Dictionary serialized) : base(serialized) { if (serialized.TryGetValue((Text) "item_id", out var itemId)) From e8d5aa88dd085f1492fda5b2810ce3aaa4898080 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 20:59:20 +0900 Subject: [PATCH 10/68] Introduce GarageWallet address --- Lib9c/Addresses.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib9c/Addresses.cs b/Lib9c/Addresses.cs index 0c204a54f6..c95d457654 100644 --- a/Lib9c/Addresses.cs +++ b/Lib9c/Addresses.cs @@ -36,6 +36,7 @@ public static class Addresses public static readonly Address Raid = new Address("0000000000000000000000000000000000000015"); public static readonly Address Rune = new Address("0000000000000000000000000000000000000016"); public static readonly Address Market = new Address("0000000000000000000000000000000000000017"); + public static readonly Address GarageWallet = new Address("0000000000000000000000000000000000000018"); public static Address GetSheetAddress() where T : ISheet => GetSheetAddress(typeof(T).Name); From f51053c3d67aac6f0eb5de455d0c8e725e43102e Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 15 Jun 2023 16:34:01 +0900 Subject: [PATCH 11/68] Introduce LoadIntoMyGarages --- .../Action/Garages/LoadIntoMyGaragesTest.cs | 508 ++++++++++++++++++ .Lib9c.Tests/CurrenciesTest.cs | 74 ++- Lib9c.Abstractions/ILoadIntoMyGarages.cs | 21 + Lib9c.sln.DotSettings | 3 + Lib9c/Action/Garages/GarageUtils.cs | 305 +++++++++++ Lib9c/Action/Garages/LoadIntoMyGarages.cs | 289 ++++++++++ 6 files changed, 1199 insertions(+), 1 deletion(-) create mode 100644 .Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs create mode 100644 Lib9c.Abstractions/ILoadIntoMyGarages.cs create mode 100644 Lib9c/Action/Garages/GarageUtils.cs create mode 100644 Lib9c/Action/Garages/LoadIntoMyGarages.cs diff --git a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs new file mode 100644 index 0000000000..bc956c38e5 --- /dev/null +++ b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs @@ -0,0 +1,508 @@ +namespace Lib9c.Tests.Action.Garages +{ +#nullable enable + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography; + using Bencodex.Types; + using Lib9c.Abstractions; + using Lib9c.Tests.Util; + using Libplanet; + using Libplanet.Action; + using Libplanet.Assets; + using Libplanet.Crypto; + using Libplanet.State; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Action.Garages; + using Nekoyume.Exceptions; + using Nekoyume.Model.Garages; + using Nekoyume.Model.Item; + using Xunit; + + public class LoadIntoMyGaragesTest + { + private const int AvatarIndex = 0; + private static readonly Address AgentAddr = Addresses.Admin; + + private readonly TableSheets _tableSheets; + private readonly Address _avatarAddress; + private readonly IAccountStateDelta _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; + + public LoadIntoMyGaragesTest() + { + // NOTE: Garage actions does not consider the avatar state v1. + ( + _tableSheets, + _, + _avatarAddress, + _, + _initialStatesWithAvatarStateV2 + ) = InitializeUtil.InitializeStates( + agentAddr: AgentAddr, + avatarIndex: AvatarIndex); + _ncg = _initialStatesWithAvatarStateV2.GetGoldCurrency(); + ( + _fungibleAssetValues, + _inventoryAddr, + _fungibleIdAndCounts, + _cost, + _tradableFungibleItems, + _previousStates + ) = GetSuccessfulPreviousStatesWithPlainValue(); + } + + public static IEnumerable Get_Sample_PlainValue() + { + var avatarAddr = Addresses.GetAvatarAddress(AgentAddr, AvatarIndex); + var fungibleAssetValues = GetFungibleAssetValues(AgentAddr, avatarAddr); + var inventoryAddr = Addresses.GetInventoryAddress(Addresses.Admin, AvatarIndex); + + var hex = string.Join( + string.Empty, + Enumerable.Range(0, 64).Select(i => (i % 10).ToString())); + var fungibleIdAndCounts = new[] + { + (HashDigest.FromString(hex), 1), + (HashDigest.FromString(hex), int.MaxValue), + }; + + yield return new object[] + { + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + "memo", + }; + } + + [Theory] + [MemberData(nameof(Get_Sample_PlainValue))] + public void Serialize( + (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, + Address inventoryAddr, + (HashDigest fungibleId, int count)[] fungibleIdAndCounts, + string? memo) + { + var actions = new[] + { + new LoadIntoMyGarages(), + new LoadIntoMyGarages( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo), + }; + foreach (var action in actions) + { + var ser = action.PlainValue; + var des = new LoadIntoMyGarages(); + des.LoadPlainValue(ser); + Assert.True(action.FungibleAssetValues?.SequenceEqual(des.FungibleAssetValues!) ?? + des.FungibleAssetValues is null); + Assert.Equal(action.InventoryAddr, des.InventoryAddr); + Assert.True(action.FungibleIdAndCounts?.SequenceEqual(des.FungibleIdAndCounts!) ?? + des.FungibleIdAndCounts is null); + Assert.Equal(action.Memo, des.Memo); + Assert.Equal(ser, des.PlainValue); + + var actionInter = (ILoadIntoMyGarages)action; + var desInter = (ILoadIntoMyGarages)des; + Assert.True( + actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? + desInter.FungibleAssetValues is null); + Assert.Equal(actionInter.InventoryAddr, desInter.InventoryAddr); + Assert.True( + actionInter.FungibleIdAndCounts?.SequenceEqual(desInter.FungibleIdAndCounts!) ?? + desInter.FungibleIdAndCounts is null); + Assert.Equal(actionInter.Memo, desInter.Memo); + } + } + + [Fact] + public void Execute_Success() + { + var (action, nextStates) = Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + _fungibleAssetValues, + _inventoryAddr, + _fungibleIdAndCounts, + "memo"); + Assert.Equal( + new FungibleAssetValue(Currencies.Garage), + nextStates.GetBalance(AgentAddr, Currencies.Garage)); + Assert.Equal( + _cost, + nextStates.GetBalance(Addresses.GarageWallet, Currencies.Garage)); + var garageBalanceAddr = + Addresses.GetGarageBalanceAddress(AgentAddr); + if (action.FungibleAssetValues is { }) + { + foreach (var (balanceAddr, value) in action.FungibleAssetValues) + { + Assert.Equal( + value.Currency * 0, + nextStates.GetBalance(balanceAddr, value.Currency)); + Assert.Equal( + value, + nextStates.GetBalance(garageBalanceAddr, value.Currency)); + } + } + + if (action.InventoryAddr is null || + action.FungibleIdAndCounts is null) + { + return; + } + + var inventoryState = nextStates.GetState(action.InventoryAddr.Value)!; + var inventory = new Inventory((List)inventoryState); + foreach (var (fungibleId, count) in action.FungibleIdAndCounts) + { + Assert.False(inventory.HasTradableFungibleItem( + fungibleId, + requiredBlockIndex: null, + blockIndex: 0, + 1)); + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + fungibleId); + var garage = new FungibleItemGarage(nextStates.GetState(garageAddr)); + Assert.Equal(fungibleId, garage.Item.FungibleId); + Assert.Equal(count, garage.Count); + } + } + + [Fact] + public void Execute_Throws_InvalidActionFieldException() + { + // FungibleAssetValues and FungibleIdAndCounts are null. + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + null, + null)); + + // Signer does not have permission of balance address. + var invalidSignerAddr = new PrivateKey().ToAddress(); + Assert.Throws(() => Execute( + invalidSignerAddr, + 0, + _previousStates, + new TestRandom(), + _fungibleAssetValues, + null, + null)); + + // FungibleAssetValues contains negative value. + var negativeFungibleAssetValues = _fungibleAssetValues.Select(tuple => ( + tuple.balanceAddr, + tuple.value * -1)); + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + negativeFungibleAssetValues, + null, + null)); + + // InventoryAddr is null when FungibleIdAndCounts is not null. + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + null, + _fungibleIdAndCounts)); + + // AgentAddr does not have permission of inventory address. + var invalidInventoryAddr = new PrivateKey().ToAddress(); + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + invalidInventoryAddr, + _fungibleIdAndCounts)); + + // Count of fungible id is negative. + var negativeFungibleIdAndCounts = _fungibleIdAndCounts.Select(tuple => ( + tuple.fungibleId, + tuple.count * -1)); + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + _inventoryAddr, + negativeFungibleIdAndCounts)); + } + + [Fact] + public void Execute_Throws_Exception() + { + // Balance does not enough to pay cost. + var previousStatesWithNotEnoughCost = _previousStates + .BurnAsset(AgentAddr, new FungibleAssetValue(Currencies.Garage, 1, 0)); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNotEnoughCost, + new TestRandom(), + _fungibleAssetValues, + _inventoryAddr, + _fungibleIdAndCounts)); + + // Balance does not enough to send. + var previousStatesWithEmptyBalances = _previousStates; + foreach (var (balanceAddr, value) in _fungibleAssetValues) + { + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances + .BurnAsset(balanceAddr, value); + } + + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithEmptyBalances, + new TestRandom(), + _fungibleAssetValues, + null, + null)); + + // Inventory state is null. + var previousStatesWithNullInventoryState = + _previousStates.SetState(_inventoryAddr!.Value, Null.Value); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNullInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + + // The state in InventoryAddr is not Inventory. + foreach (var invalidInventoryState in new IValue[] + { + new Integer(0), + Dictionary.Empty, + }) + { + var previousStatesWithInvalidInventoryState = + _previousStates.SetState(_inventoryAddr.Value, invalidInventoryState); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithInvalidInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + + // Inventory does not contain the tradable fungible item. + var previousStatesWithEmptyInventoryState = + _previousStates.SetState(_inventoryAddr.Value, new Inventory().Serialize()); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithEmptyInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + + // Inventory does not have enough tradable fungible item. + var notEnoughInventory = _previousStates.GetInventory(_inventoryAddr.Value); + foreach (var (fungibleId, count) in _fungibleIdAndCounts) + { + notEnoughInventory.RemoveTradableFungibleItem( + fungibleId, + requiredBlockIndex: null, + blockIndex: 0, + count - 1); + } + + var previousStatesWithNotEnoughInventoryState = + _previousStates.SetState(_inventoryAddr.Value, notEnoughInventory.Serialize()); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNotEnoughInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + + // Fungible item garage's item mismatch with fungible id. + for (var i = 0; i < _fungibleIdAndCounts.Length; i++) + { + var (fungibleId, _) = _fungibleIdAndCounts[i]; + var addr = Addresses.GetGarageAddress(AgentAddr, fungibleId); + var nextIndex = (i + 1) % _fungibleIdAndCounts.Length; + var garage = new FungibleItemGarage(_tradableFungibleItems[nextIndex], 1); + var previousStatesWithInvalidGarageState = + _previousStates.SetState(addr, garage.Serialize()); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithInvalidGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + + // Fungible item garages can be overflowed. + for (var i = 0; i < _fungibleIdAndCounts.Length; i++) + { + var (fungibleId, _) = _fungibleIdAndCounts[i]; + var addr = Addresses.GetGarageAddress(AgentAddr, fungibleId); + var garage = new FungibleItemGarage(_tradableFungibleItems[i], int.MaxValue); + var previousStatesWithInvalidGarageState = + _previousStates.SetState(addr, garage.Serialize()); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithInvalidGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + } + + private static (LoadIntoMyGarages action, IAccountStateDelta nextStates) Execute( + Address signer, + long blockIndex, + IAccountStateDelta previousStates, + IRandom random, + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo = null) + { + var action = new LoadIntoMyGarages( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo); + return ( + action, + action.Execute(new ActionContext + { + Signer = signer, + BlockIndex = blockIndex, + Rehearsal = false, + PreviousStates = previousStates, + Random = random, + })); + } + + private static (Address balanceAddr, FungibleAssetValue value)[] + GetFungibleAssetValues( + Address agentAddr, + Address avatarAddr, + TableSheets? tableSheets = null) + { + return CurrenciesTest.GetSampleCurrencies() + .Select(objects => (FungibleAssetValue)objects[0]) + .Where(fav => + (tableSheets?.LoadIntoMyGaragesCostSheet.HasCost(fav.Currency.Ticker) ?? + true) && + fav.Sign > 0) + .Select(fav => + { + if (Currencies.IsRuneTicker(fav.Currency.Ticker) || + Currencies.IsSoulstoneTicker(fav.Currency.Ticker)) + { + return (avatarAddr, fav); + } + + return (agentAddr, fav); + }) + .ToArray(); + } + + private ( + (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, + Address? inventoryAddr, + (HashDigest fungibleId, int count)[] fungibleIdAndCounts, + FungibleAssetValue cost, + ITradableFungibleItem[] _tradableFungibleItems, + IAccountStateDelta previousStates) + GetSuccessfulPreviousStatesWithPlainValue() + { + var previousStates = _initialStatesWithAvatarStateV2; + var fungibleAssetValues = GetFungibleAssetValues( + AgentAddr, + _avatarAddress, + _tableSheets); + foreach (var (balanceAddr, value) in fungibleAssetValues) + { + if (value.Currency.Equals(_ncg)) + { + previousStates = previousStates.TransferAsset( + Addresses.Admin, + balanceAddr, + value); + continue; + } + + previousStates = previousStates.MintAsset( + balanceAddr, + value); + } + + var inventoryAddr = Addresses.GetInventoryAddress(AgentAddr, AvatarIndex); + var inventoryState = (List)previousStates.GetState(inventoryAddr)!; + var inventory = new Inventory(inventoryState); + var fungibleItemAndCounts = _tableSheets.MaterialItemSheet.OrderedList! + .Where(row => _tableSheets.LoadIntoMyGaragesCostSheet.HasCost(row.ItemId)) + .Select(ItemFactory.CreateTradableMaterial) + .Select((tradableMaterial, index) => + { + inventory.AddFungibleItem(tradableMaterial, index + 1); + return ( + tradableFungibleItem: (ITradableFungibleItem)tradableMaterial, + count: index + 1); + }).ToArray(); + var garageCost = _tableSheets.LoadIntoMyGaragesCostSheet.GetGarageCost( + fungibleAssetValues.Select(tuple => tuple.value), + fungibleItemAndCounts + .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count))); + previousStates = previousStates.MintAsset( + AgentAddr, + garageCost); + return ( + fungibleAssetValues, + inventoryAddr, + fungibleItemAndCounts + .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count)) + .ToArray(), + garageCost, + fungibleItemAndCounts.Select(tuple => tuple.tradableFungibleItem).ToArray(), + previousStates.SetState(inventoryAddr, inventory.Serialize()) + ); + } + } +} diff --git a/.Lib9c.Tests/CurrenciesTest.cs b/.Lib9c.Tests/CurrenciesTest.cs index c964621e84..7aca9bf95b 100644 --- a/.Lib9c.Tests/CurrenciesTest.cs +++ b/.Lib9c.Tests/CurrenciesTest.cs @@ -1,14 +1,86 @@ namespace Lib9c.Tests { #nullable enable - using System; + using System.Collections.Generic; using System.Linq; + using System.Numerics; + using Libplanet.Assets; using Nekoyume.TableData; using Xunit; public class CurrenciesTest { + public static IEnumerable GetSampleCurrencies() + { + var currencies = new[] + { + // Currencies.NCG, + Currencies.Crystal, + Currencies.StakeRune, + Currencies.DailyRewardRune, + Currencies.Garage, + Currencies.GetRune("RUNE_FOR_TEST"), + Currencies.GetRune("RUNESTONE_FOR_TEST"), + Currencies.GetSoulStone("Soulstone_FOR_TEST"), + }; + var majorUnits = new[] + { + BigInteger.MinusOne, + BigInteger.Zero, + BigInteger.One, + }; + foreach (var currency in currencies) + { + if (currency.DecimalPlaces == 0) + { + foreach (var majorUnit in majorUnits) + { + yield return new object[] + { + new FungibleAssetValue(currency, majorUnit, BigInteger.Zero), + }; + } + + continue; + } + + var maxMinorUnit = (long)Math.Pow(10, currency.DecimalPlaces) - 1; + foreach (var majorUnit in majorUnits) + { + if (majorUnit.IsZero) + { + foreach (var minorUnit in new[] + { + BigInteger.Zero, + maxMinorUnit * BigInteger.One, + maxMinorUnit * BigInteger.MinusOne, + }) + { + yield return new object[] + { + new FungibleAssetValue(currency, majorUnit, minorUnit), + }; + } + } + else + { + foreach (var minorUnit in new[] + { + BigInteger.Zero, + maxMinorUnit * BigInteger.One, + }) + { + yield return new object[] + { + new FungibleAssetValue(currency, majorUnit, minorUnit), + }; + } + } + } + } + } + [Fact] public void GetRune() { diff --git a/Lib9c.Abstractions/ILoadIntoMyGarages.cs b/Lib9c.Abstractions/ILoadIntoMyGarages.cs new file mode 100644 index 0000000000..e288ad81ba --- /dev/null +++ b/Lib9c.Abstractions/ILoadIntoMyGarages.cs @@ -0,0 +1,21 @@ +#nullable enable + +using System.Linq; +using System.Security.Cryptography; +using Libplanet; +using Libplanet.Assets; + +namespace Lib9c.Abstractions +{ + public interface ILoadIntoMyGarages + { + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues + { + get; + } + + Address? InventoryAddr { get; } + IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; } + string? Memo { get; } + } +} diff --git a/Lib9c.sln.DotSettings b/Lib9c.sln.DotSettings index b0e5632ba0..f0ba53d29f 100644 --- a/Lib9c.sln.DotSettings +++ b/Lib9c.sln.DotSettings @@ -5,10 +5,13 @@ True True True + True True True True True + True + True True True True \ No newline at end of file diff --git a/Lib9c/Action/Garages/GarageUtils.cs b/Lib9c/Action/Garages/GarageUtils.cs new file mode 100644 index 0000000000..b0cb1ba67a --- /dev/null +++ b/Lib9c/Action/Garages/GarageUtils.cs @@ -0,0 +1,305 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using Bencodex.Types; +using Libplanet; +using Libplanet.Assets; +using Libplanet.State; +using Nekoyume.Exceptions; +using Nekoyume.Model.Garages; +using Nekoyume.Model.State; + +namespace Nekoyume.Action.Garages +{ + public static class GarageUtils + { + public static ( + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + Deserialize(IValue? serialized) + { + if (serialized is null || serialized is Null) + { + throw new ArgumentNullException(nameof(serialized)); + } + + if (!(serialized is List list)) + { + throw new ArgumentException( + $"The type of {nameof(serialized)} must be bencodex list."); + } + + var fungibleAssetValues = list[0].Kind == ValueKind.Null + ? null + : ((List)list[0]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToAddress(), + l2[1].ToFungibleAssetValue()); + }); + var inventoryAddr = list[1].Kind == ValueKind.Null + ? (Address?)null + : list[1].ToAddress(); + var fungibleIdAndCounts = list[2].Kind == ValueKind.Null + ? null + : ((List)list[2]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToItemId(), + (int)((Integer)l2[1]).Value); + }); + var memo = list[3].Kind == ValueKind.Null + ? null + : (string)(Text)list[3]; + return MergeAndSort( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo); + } + + public static ( + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + MergeAndSort( + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + ( + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? + fungibleAssetValues, + Address? inventoryAddr, + IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + result = (null, null, null, null); + var favArr = fungibleAssetValues as (Address balanceAddr, FungibleAssetValue value)[] ?? + fungibleAssetValues?.ToArray(); + if (favArr is null || + favArr.Length == 0) + { + result.fungibleAssetValues = null; + } + else + { + var dict = new Dictionary>(); + foreach (var (balanceAddr, value) in favArr) + { + if (!dict.ContainsKey(balanceAddr)) + { + dict[balanceAddr] = new Dictionary(); + } + + if (dict[balanceAddr].ContainsKey(value.Currency)) + { + dict[balanceAddr][value.Currency] += value; + } + else + { + dict[balanceAddr][value.Currency] = value; + } + } + +#pragma warning disable LAA1002 + var arr = dict +#pragma warning restore LAA1002 + .Select(pair => ( + balanceAddr: pair.Key, + value: pair.Value.Values.ToArray())) + .SelectMany(tuple => + tuple.value.Select(value => (tuple.balanceAddr, value))) + .Where(tuple => tuple.value.Sign != 0) + .ToArray(); + result.fungibleAssetValues = arr.Any() + ? arr + .OrderBy(tuple => tuple.balanceAddr) + .ThenBy(tuple => tuple.value.GetHashCode()) + : null; + } + + result.inventoryAddr = inventoryAddr; + + var fiArr = fungibleIdAndCounts as (HashDigest fungibleId, int count)[] ?? + fungibleIdAndCounts?.ToArray(); + if (fiArr is null || + fiArr.Length == 0) + { + result.fungibleIdAndCounts = null; + } + else + { + var dict = new Dictionary, int>(); + foreach (var (fungibleId, count) in fiArr) + { + if (dict.ContainsKey(fungibleId)) + { + dict[fungibleId] += count; + } + else + { + dict[fungibleId] = count; + } + } + +#pragma warning disable LAA1002 + var arr = dict +#pragma warning restore LAA1002 + .Select(pair => (fungibleId: pair.Key, count: pair.Value)) + .Where(tuple => tuple.count != 0) + .ToArray(); + result.fungibleIdAndCounts = arr.Any() + ? arr + .OrderBy(tuple => tuple.fungibleId.GetHashCode()) + .ThenBy(tuple => tuple.count) + : null; + } + + result.memo = string.IsNullOrEmpty(memo) + ? null + : memo; + return result; + } + + public static IOrderedEnumerable<( + HashDigest fungibleId, + int count, + Address garageAddr, + IValue? garageState)> WithGarageStateTuples( + Address agentAddr, + IAccountStateView states, + IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) + { + var withGarageAddr = fungibleIdAndCounts + .Select(tuple => + { + var garageAddr = Addresses.GetGarageAddress( + agentAddr, + tuple.fungibleId); + return (tuple.fungibleId, tuple.count, garageAddr); + }).ToArray(); + var garageAddresses = withGarageAddr.Select(tuple => tuple.garageAddr).ToArray(); + var garageStates = states.GetStates(garageAddresses); + return withGarageAddr + .Zip(garageStates, (tuple, garageState) => ( + tuple.fungibleId, + tuple.count, + tuple.garageAddr, + garageState)) + .OrderBy(tuple => tuple.fungibleId.GetHashCode()); + } + + public static IOrderedEnumerable<( + HashDigest fungibleId, + int count, + Address senderGarageAddr, + FungibleItemGarage senderGarage, + Address recipientGarageAddr, + IValue? recipientGarageState)> WithGarageStateTuples( + Address senderAgentAddr, + Address recipientAgentAddr, + IAccountStateView states, + IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) + { + var withGarageAddr = fungibleIdAndCounts + .Select(tuple => + { + var senderGarageAddr = Addresses.GetGarageAddress( + senderAgentAddr, + tuple.fungibleId); + var recipientGarageAddr = Addresses.GetGarageAddress( + recipientAgentAddr, + tuple.fungibleId); + return ( + tuple.fungibleId, + tuple.count, + senderGarageAddr, + recipientGarageAddr); + }).ToArray(); + var garageAddresses = withGarageAddr + .Select(tuple => tuple.senderGarageAddr) + .Concat(withGarageAddr.Select(tuple => tuple.recipientGarageAddr)) + .ToArray(); + var garageStates = states.GetStates(garageAddresses); + if (garageStates.Count != garageAddresses.Length) + { + throw new Exception($"garageStates.Count({garageStates.Count}) != " + + $"garageAddresses.Length({garageAddresses.Length})"); + } + + var garageStatesHalfCount = garageStates.Count / 2; + return withGarageAddr + .Select((tuple, index) => + { + var senderGarageState = garageStates[index]; + var senderGarage = ConvertToFungibleItemGarage( + senderGarageState, + tuple.senderGarageAddr, + tuple.fungibleId); + return ( + tuple.fungibleId, + tuple.count, + tuple.senderGarageAddr, + senderGarage, + tuple.recipientGarageAddr, + recipientGarageState: garageStates[index + garageStatesHalfCount]); + }) + .OrderBy(tuple => tuple.fungibleId.GetHashCode()); + } + + public static IOrderedEnumerable<( + HashDigest fungibleId, + int count, + Address garageAddr, + FungibleItemGarage garage)> WithGarageTuples( + Address agentAddr, + IAccountStateView states, + IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) + { + return WithGarageStateTuples(agentAddr, states, fungibleIdAndCounts) + .Select(tuple => + { + var (fungibleId, count, garageAddr, garageState) = tuple; + var garage = ConvertToFungibleItemGarage( + garageState, + garageAddr, + fungibleId); + return ( + fungibleId, + count, + garageAddr, + garage); + }) + .OrderBy(tuple => tuple.fungibleId.GetHashCode()); + } + + public static FungibleItemGarage ConvertToFungibleItemGarage( + IValue? garageState, + Address garageAddr, + HashDigest fungibleId) + { + if (garageState is null || garageState is Null) + { + throw new StateNullException(garageAddr); + } + + var garage = new FungibleItemGarage(garageState); + if (!garage.Item.FungibleId.Equals(fungibleId)) + { + throw new Exception( + $"{garageAddr} is not a garage of {fungibleId}."); + } + + return garage; + } + } +} diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs new file mode 100644 index 0000000000..dae82c12b9 --- /dev/null +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -0,0 +1,289 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Security.Cryptography; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet; +using Libplanet.Action; +using Libplanet.Assets; +using Libplanet.State; +using Nekoyume.Exceptions; +using Nekoyume.Model.Garages; +using Nekoyume.Model.Item; +using Nekoyume.Model.State; +using Nekoyume.TableData.Garages; + +namespace Nekoyume.Action.Garages +{ + [ActionType("load_into_my_garages")] + public class LoadIntoMyGarages : GameAction, ILoadIntoMyGarages, IAction + { + public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? + FungibleAssetValues { get; private set; } + + /// + /// This address should belong to one of the signer's avatars. + /// If the avatar state is v1, there is no separate inventory, + /// so it should be execute another action first to migrate the avatar state to v2. + /// And then, the inventory address will be set. + /// + public Address? InventoryAddr { get; private set; } + + public IOrderedEnumerable<(HashDigest fungibleId, int count)>? + FungibleIdAndCounts { get; private set; } + + public string? Memo { get; private set; } + + protected override IImmutableDictionary PlainValueInternal => + new Dictionary + { + { + "l", + new List( + FungibleAssetValues is null + ? (IValue)Null.Value + : new List(FungibleAssetValues.Select(tuple => new List( + tuple.balanceAddr.Serialize(), + tuple.value.Serialize()))), + InventoryAddr is null + ? Null.Value + : InventoryAddr.Serialize(), + FungibleIdAndCounts is null + ? (IValue)Null.Value + : new List(FungibleIdAndCounts.Select(tuple => new List( + tuple.fungibleId.Serialize(), + (Integer)tuple.count))), + Memo is null + ? (IValue)Null.Value + : (Text)Memo) + } + }.ToImmutableDictionary(); + + public LoadIntoMyGarages( + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + ( + FungibleAssetValues, + InventoryAddr, + FungibleIdAndCounts, + Memo + ) = GarageUtils.MergeAndSort( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo); + } + + public LoadIntoMyGarages() + { + } + + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) + { + ( + FungibleAssetValues, + InventoryAddr, + FungibleIdAndCounts, + Memo + ) = GarageUtils.Deserialize(plainValue["l"]); + } + + public override IAccountStateDelta Execute(IActionContext context) + { + var states = context.PreviousStates; + if (context.Rehearsal) + { + return states; + } + + var addressesHex = GetSignerAndOtherAddressesHex(context); + ValidateFields( + context.Signer, + addressesHex); + + var sheet = states.GetSheet(); + var garageCost = sheet.GetGarageCost( + FungibleAssetValues?.Select(tuple => tuple.value), + FungibleIdAndCounts); + states = states.TransferAsset( + context.Signer, + Addresses.GarageWallet, + garageCost); + + states = TransferFungibleAssetValues( + context.Signer, + states); + return TransferFungibleItems( + context.Signer, + context.BlockIndex, + states); + } + + private void ValidateFields( + Address signer, + string addressesHex) + { + if (FungibleAssetValues is null && + FungibleIdAndCounts is null) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Either FungibleAssetValues or FungibleIdAndCounts " + + "must be set."); + } + + if (FungibleAssetValues != null) + { + foreach (var (balanceAddr, value) in FungibleAssetValues) + { + if (!Addresses.CheckAgentHasPermissionOnBalanceAddr( + signer, + balanceAddr)) + { + throw new InvalidActionFieldException( + innerException: new InvalidAddressException( + $"[{addressesHex}] {signer} doesn't have permission for " + + $"{balanceAddr}.")); + } + + if (value.Sign < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] FungibleAssetValue.Sign must be positive."); + } + } + } + + if (FungibleIdAndCounts is null) + { + return; + } + + if (!InventoryAddr.HasValue) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] {nameof(InventoryAddr)} is required when " + + $"{nameof(FungibleIdAndCounts)} is set."); + } + + if (!Addresses.CheckInventoryAddrIsContainedInAgent( + signer, + InventoryAddr.Value)) + { + throw new InvalidActionFieldException( + innerException: new InvalidAddressException( + $"[{addressesHex}] {signer} doesn't have permission for {InventoryAddr}.")); + } + + foreach (var (fungibleId, count) in FungibleIdAndCounts) + { + if (count < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Count of fungible id must be positive." + + $" {fungibleId}, {count}"); + } + } + } + + private IAccountStateDelta TransferFungibleAssetValues( + Address signer, + IAccountStateDelta states) + { + if (FungibleAssetValues is null) + { + return states; + } + + var garageBalanceAddress = + Addresses.GetGarageBalanceAddress(signer); + foreach (var (balanceAddr, value) in FungibleAssetValues) + { + states = states.TransferAsset(balanceAddr, garageBalanceAddress, value); + } + + return states; + } + + private IAccountStateDelta TransferFungibleItems( + Address signer, + long blockIndex, + IAccountStateDelta states) + { + if (InventoryAddr is null || + FungibleIdAndCounts is null) + { + return states; + } + + var inventory = states.GetInventory(InventoryAddr.Value); + var fungibleItemTuples = GarageUtils.WithGarageStateTuples( + signer, + states, + FungibleIdAndCounts); + foreach (var (fungibleId, count, garageAddr, garageState) in fungibleItemTuples) + { + if (!inventory.TryGetTradableFungibleItems( + fungibleId, + requiredBlockIndex: null, + blockIndex: blockIndex, + out var outItems)) + { + throw new ItemNotFoundException(InventoryAddr.Value, fungibleId); + } + + var itemArr = outItems as Inventory.Item[] ?? outItems.ToArray(); + var tradableFungibleItem = (ITradableFungibleItem)itemArr[0].item; + if (!inventory.RemoveTradableFungibleItem( + fungibleId, + requiredBlockIndex: null, + blockIndex: blockIndex, + count)) + { + throw new NotEnoughItemException( + InventoryAddr.Value, + fungibleId, + count, + itemArr.Sum(item => item.count)); + } + + IFungibleItem fungibleItem = tradableFungibleItem switch + { + TradableMaterial tradableMaterial => new Material(tradableMaterial), + _ => throw new InvalidCastException( + $"Invalid type of {nameof(tradableFungibleItem)}: " + + $"{tradableFungibleItem.GetType()}") + }; + + var garage = garageState is null || garageState is Null + ? new FungibleItemGarage(fungibleItem, 0) + : new FungibleItemGarage(garageState); + // NOTE: + // Why not compare the garage.Item with tradableFungibleItem? + // Because the ITradableFungibleItem.Equals() method compares the + // ITradableItem.RequiredBlockIndex property. + // The IFungibleItem.FungibleId property fully contains the + // specification of the fungible item. + // So ITradableItem.RequiredBlockIndex property does not considered + // when transferring items via garages. + if (!garage.Item.FungibleId.Equals(fungibleId)) + { + throw new Exception( + $"{garageAddr} is not a garage of {fungibleId}."); + } + + garage.Load(count); + states = states.SetState(garageAddr, garage.Serialize()); + } + + return states.SetState(InventoryAddr.Value, inventory.Serialize()); + } + } +} From 9bce9bf3ac54a5a26e4698619ed777a1abf01c7e Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 16 Jun 2023 15:47:39 +0900 Subject: [PATCH 12/68] Introduce DeliverToOthersGarages action --- .../Garages/DeliverToOthersGaragesTest.cs | 420 ++++++++++++++++++ Lib9c.Abstractions/IDeliverToOthersGarages.cs | 15 + .../Action/Garages/DeliverToOthersGarages.cs | 279 ++++++++++++ 3 files changed, 714 insertions(+) create mode 100644 .Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs create mode 100644 Lib9c.Abstractions/IDeliverToOthersGarages.cs create mode 100644 Lib9c/Action/Garages/DeliverToOthersGarages.cs diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs new file mode 100644 index 0000000000..31842c043f --- /dev/null +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -0,0 +1,420 @@ +namespace Lib9c.Tests.Action.Garages +{ +#nullable enable + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography; + using Bencodex.Types; + using Lib9c.Abstractions; + using Lib9c.Tests.Util; + using Libplanet; + using Libplanet.Action; + using Libplanet.Assets; + using Libplanet.Crypto; + using Libplanet.State; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Action.Garages; + using Nekoyume.Exceptions; + using Nekoyume.Model.Garages; + using Nekoyume.Model.Item; + using Xunit; + + public class DeliverToOthersGaragesTest + { + private const int AvatarIndex = 0; + private static readonly Address SenderAgentAddr = Addresses.Admin; + + private readonly TableSheets _tableSheets; + private readonly IAccountStateDelta _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; + + public DeliverToOthersGaragesTest() + { + // NOTE: Garage actions does not consider the avatar state v1. + ( + _tableSheets, + _, + _, + _, + _initialStatesWithAvatarStateV2 + ) = InitializeUtil.InitializeStates( + agentAddr: SenderAgentAddr, + avatarIndex: AvatarIndex); + _ncg = _initialStatesWithAvatarStateV2.GetGoldCurrency(); + ( + _recipientAgentAddr, + _fungibleAssetValues, + _fungibleIdAndCounts, + _tradableFungibleItems, + _previousStates + ) = GetSuccessfulPreviousStatesWithPlainValue(); + } + + public static IEnumerable Get_Sample_PlainValue() + { + var recipientAddr = new PrivateKey().ToAddress(); + var fungibleAssetValues = GetFungibleAssetValues(); + var hex = string.Join( + string.Empty, + Enumerable.Range(0, 64).Select(i => (i % 10).ToString())); + var fungibleIdAndCounts = new[] + { + (HashDigest.FromString(hex), 1), + (HashDigest.FromString(hex), int.MaxValue), + }; + + yield return new object[] + { + recipientAddr, + fungibleAssetValues, + fungibleIdAndCounts, + "memo", + }; + } + + [Theory] + [MemberData(nameof(Get_Sample_PlainValue))] + public void Serialize( + Address recipientAddr, + FungibleAssetValue[] fungibleAssetValues, + (HashDigest fungibleId, int count)[] fungibleIdAndCounts, + string? memo) + { + var actions = new[] + { + new DeliverToOthersGarages(), + new DeliverToOthersGarages( + recipientAddr, + fungibleAssetValues, + fungibleIdAndCounts, + memo), + }; + foreach (var action in actions) + { + var ser = action.PlainValue; + var des = new DeliverToOthersGarages(); + des.LoadPlainValue(ser); + Assert.Equal(action.RecipientAgentAddr, des.RecipientAgentAddr); + Assert.True(action.FungibleAssetValues?.SequenceEqual(des.FungibleAssetValues!) ?? + des.FungibleAssetValues is null); + Assert.True(action.FungibleIdAndCounts?.SequenceEqual(des.FungibleIdAndCounts!) ?? + des.FungibleIdAndCounts is null); + Assert.Equal(action.Memo, des.Memo); + Assert.Equal(ser, des.PlainValue); + + var actionInter = (IDeliverToOthersGarages)action; + var desInter = (IDeliverToOthersGarages)des; + Assert.Equal(actionInter.RecipientAgentAddr, desInter.RecipientAgentAddr); + Assert.True( + actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? + desInter.FungibleAssetValues is null); + Assert.True( + actionInter.FungibleIdAndCounts?.SequenceEqual(desInter.FungibleIdAndCounts!) ?? + desInter.FungibleIdAndCounts is null); + Assert.Equal(actionInter.Memo, desInter.Memo); + } + } + + [Fact] + public void Execute_Success() + { + var (action, nextStates) = Execute( + SenderAgentAddr, + 0, + _previousStates, + new TestRandom(), + _recipientAgentAddr, + _fungibleAssetValues, + _fungibleIdAndCounts, + "memo"); + if (action.FungibleAssetValues is { }) + { + var senderGarageBalanceAddr = + Addresses.GetGarageBalanceAddress(SenderAgentAddr); + var recipientGarageBalanceAddr = + Addresses.GetGarageBalanceAddress(_recipientAgentAddr); + foreach (var fav in action.FungibleAssetValues) + { + Assert.Equal( + fav.Currency * 0, + nextStates.GetBalance(senderGarageBalanceAddr, fav.Currency)); + Assert.Equal( + fav, + nextStates.GetBalance(recipientGarageBalanceAddr, fav.Currency)); + } + } + + if (action.FungibleIdAndCounts is null) + { + return; + } + + foreach (var (fungibleId, count) in action.FungibleIdAndCounts) + { + var senderGarageAddr = Addresses.GetGarageAddress( + SenderAgentAddr, + fungibleId); + Assert.Equal( + Null.Value, + nextStates.GetState(senderGarageAddr)); + var recipientGarageAddr = Addresses.GetGarageAddress( + _recipientAgentAddr, + fungibleId); + Assert.Equal( + count, + new FungibleItemGarage(nextStates.GetState(recipientGarageAddr)).Count); + } + } + + [Fact] + public void Execute_Throws_InvalidActionFieldException() + { + // FungibleAssetValues and FungibleIdAndCounts are null. + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + _previousStates, + new TestRandom(), + _recipientAgentAddr, + null, + null)); + + // FungibleAssetValues contains negative value. + var negativeFungibleAssetValues = _fungibleAssetValues.Select(fav => fav * -1); + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + _previousStates, + new TestRandom(), + _recipientAgentAddr, + negativeFungibleAssetValues, + null)); + + // Count of fungible id is negative. + var negativeFungibleIdAndCounts = _fungibleIdAndCounts.Select(tuple => ( + tuple.fungibleId, + tuple.count * -1)); + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + _previousStates, + new TestRandom(), + _recipientAgentAddr, + null, + negativeFungibleIdAndCounts)); + } + + [Fact] + public void Execute_Throws_Exception() + { + // Sender's FungibleAssetValue Garage does not have enough balance. + var previousStatesWithEmptyBalances = _previousStates; + var senderFungibleAssetValueGarageAddr = + Addresses.GetGarageBalanceAddress(SenderAgentAddr); + foreach (var vaf in _fungibleAssetValues) + { + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances + .BurnAsset(senderFungibleAssetValueGarageAddr, vaf); + } + + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithEmptyBalances, + new TestRandom(), + _recipientAgentAddr, + _fungibleAssetValues, + null)); + + // Sender's fungible item Garage state is null. + foreach (var (fungibleId, _) in _fungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + SenderAgentAddr, + fungibleId); + var previousStatesWithNullGarageState = + _previousStates.SetState(garageAddr, Null.Value); + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithNullGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); + } + + // Mismatch fungible id between sender's and recipient's fungible item Garage. + for (var i = 0; i < _fungibleIdAndCounts.Length; i++) + { + var (fungibleId, _) = _fungibleIdAndCounts[i]; + var addr = Addresses.GetGarageAddress(_recipientAgentAddr, fungibleId); + var nextIndex = (i + 1) % _fungibleIdAndCounts.Length; + var garage = new FungibleItemGarage(_tradableFungibleItems[nextIndex], 1); + var previousStatesWithInvalidGarageState = + _previousStates.SetState(addr, garage.Serialize()); + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithInvalidGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); + } + + // Sender's fungible item Garage does not contain enough items. + foreach (var (fungibleId, _) in _fungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + SenderAgentAddr, + fungibleId); + var garageState = _previousStates.GetState(garageAddr); + var garage = new FungibleItemGarage(garageState); + garage.Unload(1); + var previousStatesWithNotEnoughCountOfGarageState = + _previousStates.SetState(garageAddr, garage.Serialize()); + if (garage.Count == 0) + { + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); + } + else + { + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); + } + } + + // Recipient's fungible item Garages can be overflowed. + for (var i = 0; i < _fungibleIdAndCounts.Length; i++) + { + var (fungibleId, _) = _fungibleIdAndCounts[i]; + var addr = Addresses.GetGarageAddress(_recipientAgentAddr, fungibleId); + var garage = new FungibleItemGarage(_tradableFungibleItems[i], int.MaxValue); + var previousStatesWithInvalidGarageState = + _previousStates.SetState(addr, garage.Serialize()); + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithInvalidGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); + } + } + + private static (DeliverToOthersGarages action, IAccountStateDelta nextStates) Execute( + Address signer, + long blockIndex, + IAccountStateDelta previousStates, + IRandom random, + Address recipientAgentAddr, + IEnumerable? fungibleAssetValues, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo = null) + { + var action = new DeliverToOthersGarages( + recipientAgentAddr, + fungibleAssetValues, + fungibleIdAndCounts, + memo); + return ( + action, + action.Execute(new ActionContext + { + Signer = signer, + BlockIndex = blockIndex, + Rehearsal = false, + PreviousStates = previousStates, + Random = random, + })); + } + + private static FungibleAssetValue[] GetFungibleAssetValues() + { + return CurrenciesTest.GetSampleCurrencies() + .Select(objects => (FungibleAssetValue)objects[0]) + .Where(fav => fav.Sign > 0) + .ToArray(); + } + + private ( + Address recipientAddr, + FungibleAssetValue[] fungibleAssetValues, + (HashDigest fungibleId, int count)[] fungibleIdAndCounts, + ITradableFungibleItem[] _tradableFungibleItems, + IAccountStateDelta previousStates) + GetSuccessfulPreviousStatesWithPlainValue() + { + var previousStates = _initialStatesWithAvatarStateV2; + var senderFavGarageBalanceAddr = + Addresses.GetGarageBalanceAddress(SenderAgentAddr); + var fungibleAssetValues = GetFungibleAssetValues(); + foreach (var fav in fungibleAssetValues) + { + if (fav.Currency.Equals(_ncg)) + { + previousStates = previousStates.TransferAsset( + Addresses.Admin, + senderFavGarageBalanceAddr, + fav); + continue; + } + + previousStates = previousStates.MintAsset( + senderFavGarageBalanceAddr, + fav); + } + + var fungibleIdAndCounts = _tableSheets.MaterialItemSheet.OrderedList! + .Take(3) + .Select(ItemFactory.CreateTradableMaterial) + .Select((tradableMaterial, index) => + { + var senderGarageAddr = Addresses.GetGarageAddress( + SenderAgentAddr, + tradableMaterial.FungibleId); + var garageState = previousStates.GetState(senderGarageAddr); + var garage = garageState is null + ? new FungibleItemGarage(tradableMaterial, 0) + : new FungibleItemGarage(garageState); + garage.Load(index + 1); + previousStates = previousStates + .SetState(senderGarageAddr, garage.Serialize()); + + return ( + tradableFungibleItem: (ITradableFungibleItem)tradableMaterial, + count: index + 1); + }).ToArray(); + return ( + new PrivateKey().ToAddress(), + fungibleAssetValues, + fungibleIdAndCounts + .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count)) + .ToArray(), + fungibleIdAndCounts.Select(tuple => tuple.tradableFungibleItem).ToArray(), + previousStates); + } + } +} diff --git a/Lib9c.Abstractions/IDeliverToOthersGarages.cs b/Lib9c.Abstractions/IDeliverToOthersGarages.cs new file mode 100644 index 0000000000..242852d89f --- /dev/null +++ b/Lib9c.Abstractions/IDeliverToOthersGarages.cs @@ -0,0 +1,15 @@ +using System.Linq; +using System.Security.Cryptography; +using Libplanet; +using Libplanet.Assets; + +namespace Lib9c.Abstractions +{ + public interface IDeliverToOthersGarages + { + Address RecipientAgentAddr { get; } + IOrderedEnumerable? FungibleAssetValues { get; } + IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; } + string? Memo { get; } + } +} diff --git a/Lib9c/Action/Garages/DeliverToOthersGarages.cs b/Lib9c/Action/Garages/DeliverToOthersGarages.cs new file mode 100644 index 0000000000..01d728a4c2 --- /dev/null +++ b/Lib9c/Action/Garages/DeliverToOthersGarages.cs @@ -0,0 +1,279 @@ +#nullable enable + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Security.Cryptography; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet; +using Libplanet.Action; +using Libplanet.Assets; +using Libplanet.State; +using Nekoyume.Exceptions; +using Nekoyume.Model.Garages; +using Nekoyume.Model.State; + +namespace Nekoyume.Action.Garages +{ + [ActionType("deliver_to_others_garages")] + public class DeliverToOthersGarages : GameAction, IDeliverToOthersGarages, IAction + { + public Address RecipientAgentAddr { get; private set; } + public IOrderedEnumerable? FungibleAssetValues { get; private set; } + + public IOrderedEnumerable<(HashDigest fungibleId, int count)>? + FungibleIdAndCounts { get; private set; } + + public string? Memo { get; private set; } + + protected override IImmutableDictionary PlainValueInternal => + new Dictionary + { + { + "l", + new List( + RecipientAgentAddr.Serialize(), + FungibleAssetValues is null + ? (IValue)Null.Value + : new List(FungibleAssetValues.Select(fav => fav.Serialize())), + FungibleIdAndCounts is null + ? (IValue)Null.Value + : new List(FungibleIdAndCounts.Select(tuple => new List( + tuple.fungibleId.Serialize(), + (Integer)tuple.count))), + Memo is null + ? (IValue)Null.Value + : (Text)Memo) + } + }.ToImmutableDictionary(); + + public DeliverToOthersGarages( + Address recipientAgentAddr, + IEnumerable? fungibleAssetValues, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + RecipientAgentAddr = recipientAgentAddr; + SetInternal(fungibleAssetValues, fungibleIdAndCounts, memo); + } + + public DeliverToOthersGarages() + { + } + + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) + { + var list = (List)plainValue["l"]; + RecipientAgentAddr = list[0].ToAddress(); + var fungibleAssetValues = list[1].Kind == ValueKind.Null + ? null + : ((List)list[1]).Select(e => e.ToFungibleAssetValue()); + var fungibleIdAndCounts = list[2].Kind == ValueKind.Null + ? null + : ((List)list[2]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToItemId(), + (int)((Integer)l2[1]).Value); + }); + var memo = list[3].Kind == ValueKind.Null + ? null + : (string)(Text)list[3]; + SetInternal(fungibleAssetValues, fungibleIdAndCounts, memo); + } + + private void SetInternal( + IEnumerable? fungibleAssetValues, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + var favArr = fungibleAssetValues as FungibleAssetValue[] ?? + fungibleAssetValues?.ToArray(); + if (favArr is null || + favArr.Length == 0) + { + FungibleAssetValues = null; + } + else + { + var dict = new Dictionary(); + foreach (var fav in favArr) + { + if (dict.ContainsKey(fav.Currency)) + { + dict[fav.Currency] += fav; + } + else + { + dict[fav.Currency] = fav; + } + } + + var arr = dict.Values + .Where(fav => fav.Sign != 0) + .ToArray(); + FungibleAssetValues = arr.Any() + ? arr.OrderBy(fav => fav.GetHashCode()) + : null; + } + + var fiArr = fungibleIdAndCounts as (HashDigest fungibleId, int count)[] ?? + fungibleIdAndCounts?.ToArray(); + if (fiArr is null || + fiArr.Length == 0) + { + FungibleIdAndCounts = null; + } + else + { + var dict = new Dictionary, int>(); + foreach (var (fungibleId, count) in fiArr) + { + if (dict.ContainsKey(fungibleId)) + { + dict[fungibleId] += count; + } + else + { + dict[fungibleId] = count; + } + } + +#pragma warning disable LAA1002 + var arr = dict +#pragma warning restore LAA1002 + .Select(pair => (fungibleId: pair.Key, count: pair.Value)) + .Where(tuple => tuple.count != 0) + .ToArray(); + FungibleIdAndCounts = arr.Any() + ? arr + .OrderBy(tuple => tuple.fungibleId.GetHashCode()) + .ThenBy(tuple => tuple.count) + : null; + } + + Memo = string.IsNullOrEmpty(memo) + ? null + : memo; + } + + public override IAccountStateDelta Execute(IActionContext context) + { + var states = context.PreviousStates; + if (context.Rehearsal) + { + return states; + } + + var addressesHex = GetSignerAndOtherAddressesHex(context); + ValidateFields(addressesHex); + states = SendBalances( + context.Signer, + states); + return SendFungibleItems( + context.Signer, + states); + } + + private void ValidateFields(string addressesHex) + { + if (FungibleAssetValues is null && + FungibleIdAndCounts is null) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Either FungibleAssetValues or FungibleIdAndCounts " + + "must be set."); + } + + if (FungibleAssetValues != null) + { + foreach (var fav in FungibleAssetValues) + { + if (fav.Sign < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] FungibleAssetValue.Sign must be positive."); + } + } + } + + if (FungibleIdAndCounts is null) + { + return; + } + + foreach (var (fungibleId, count) in FungibleIdAndCounts) + { + if (count < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Count of fungible id must be positive." + + $" {fungibleId}, {count}"); + } + } + } + + private IAccountStateDelta SendBalances( + Address signer, + IAccountStateDelta states) + { + if (FungibleAssetValues is null) + { + return states; + } + + var senderGarageBalanceAddress = + Addresses.GetGarageBalanceAddress(signer); + var recipientGarageBalanceAddr = + Addresses.GetGarageBalanceAddress(RecipientAgentAddr); + foreach (var fav in FungibleAssetValues) + { + states = states.TransferAsset( + senderGarageBalanceAddress, + recipientGarageBalanceAddr, + fav); + } + + return states; + } + + private IAccountStateDelta SendFungibleItems( + Address signer, + IAccountStateDelta states) + { + if (FungibleIdAndCounts is null) + { + return states; + } + + var fungibleItemTuples = GarageUtils.WithGarageStateTuples( + signer, + RecipientAgentAddr, + states, + FungibleIdAndCounts); + foreach (var ( + _, + count, + senderGarageAddr, + senderGarage, + recipientGarageAddr, + recipientGarageState) in + fungibleItemTuples) + { + var recipientGarage = + recipientGarageState is null || recipientGarageState is Null + ? new FungibleItemGarage(senderGarage.Item, 0) + : new FungibleItemGarage(recipientGarageState); + senderGarage.Deliver(recipientGarage, count); + states = states + .SetState(senderGarageAddr, senderGarage.Serialize()) + .SetState(recipientGarageAddr, recipientGarage.Serialize()); + } + + return states; + } + } +} From d569453c7464b6ccc6cfc645027e97546c8bd3cc Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 16 Jun 2023 20:58:23 +0900 Subject: [PATCH 13/68] Introduce UnloadFromMyGarages action --- .../Action/Garages/UnloadFromMyGaragesTest.cs | 440 ++++++++++++++++++ Lib9c.Abstractions/IUnloadFromMyGarages.cs | 21 + Lib9c/Action/Garages/UnloadFromMyGarages.cs | 205 ++++++++ 3 files changed, 666 insertions(+) create mode 100644 .Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs create mode 100644 Lib9c.Abstractions/IUnloadFromMyGarages.cs create mode 100644 Lib9c/Action/Garages/UnloadFromMyGarages.cs diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs new file mode 100644 index 0000000000..cffd8f34b8 --- /dev/null +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -0,0 +1,440 @@ +namespace Lib9c.Tests.Action.Garages +{ +#nullable enable + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography; + using Bencodex.Types; + using Lib9c.Abstractions; + using Lib9c.Tests.Util; + using Libplanet; + using Libplanet.Action; + using Libplanet.Assets; + using Libplanet.Crypto; + using Libplanet.State; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Action.Garages; + using Nekoyume.Exceptions; + using Nekoyume.Model.Garages; + using Nekoyume.Model.Item; + using Xunit; + + public class UnloadFromMyGaragesTest + { + private static readonly Address AgentAddr = new PrivateKey().ToAddress(); + private static readonly int AvatarIndex = 0; + + private static readonly Address AvatarAddr = + Addresses.GetAvatarAddress(AgentAddr, AvatarIndex); + + private readonly TableSheets _tableSheets; + private readonly IAccountStateDelta _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 ITradableFungibleItem[] _tradableFungibleItems; + private readonly IAccountStateDelta _previousStates; + + public UnloadFromMyGaragesTest() + { + // NOTE: Garage actions does not consider the avatar state v1. + ( + _tableSheets, + _, + _, + _, + _initialStatesWithAvatarStateV2 + ) = InitializeUtil.InitializeStates( + agentAddr: AgentAddr, + avatarIndex: AvatarIndex); + _ncg = _initialStatesWithAvatarStateV2.GetGoldCurrency(); + ( + _fungibleAssetValues, + _inventoryAddr, + _fungibleIdAndCounts, + _tradableFungibleItems, + _previousStates + ) = GetSuccessfulPreviousStatesWithPlainValue(); + } + + public static IEnumerable Get_Sample_PlainValue() => + LoadIntoMyGaragesTest.Get_Sample_PlainValue(); + + [Theory] + [MemberData(nameof(Get_Sample_PlainValue))] + public void Serialize( + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + var actions = new[] + { + new UnloadFromMyGarages(), + new UnloadFromMyGarages( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo), + }; + foreach (var action in actions) + { + var ser = action.PlainValue; + var des = new UnloadFromMyGarages(); + des.LoadPlainValue(ser); + Assert.True(action.FungibleAssetValues?.SequenceEqual(des.FungibleAssetValues!) ?? + des.FungibleAssetValues is null); + Assert.Equal(action.InventoryAddr, des.InventoryAddr); + Assert.True(action.FungibleIdAndCounts?.SequenceEqual(des.FungibleIdAndCounts!) ?? + des.FungibleIdAndCounts is null); + Assert.Equal(action.Memo, des.Memo); + + Assert.Equal(ser, des.PlainValue); + + var actionInter = (IUnloadFromMyGarages)action; + var desInter = (IUnloadFromMyGarages)des; + Assert.True( + actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? + desInter.FungibleAssetValues is null); + Assert.Equal(actionInter.InventoryAddr, desInter.InventoryAddr); + Assert.True( + actionInter.FungibleIdAndCounts?.SequenceEqual(desInter.FungibleIdAndCounts!) ?? + desInter.FungibleIdAndCounts is null); + Assert.Equal(actionInter.Memo, desInter.Memo); + } + } + + [Fact] + public void Execute_Success() + { + var (action, nextStates) = Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + _fungibleAssetValues, + _inventoryAddr, + _fungibleIdAndCounts, + "memo"); + var garageBalanceAddr = + Addresses.GetGarageBalanceAddress(AgentAddr); + if (action.FungibleAssetValues is { }) + { + foreach (var (balanceAddr, value) in action.FungibleAssetValues) + { + Assert.Equal( + value, + nextStates.GetBalance(balanceAddr, value.Currency)); + Assert.Equal( + value.Currency * 0, + nextStates.GetBalance(garageBalanceAddr, value.Currency)); + } + } + + if (action.InventoryAddr is null || + action.FungibleIdAndCounts is null) + { + return; + } + + var inventoryState = nextStates.GetState(action.InventoryAddr.Value)!; + var inventory = new Inventory((List)inventoryState); + foreach (var (fungibleId, count) in action.FungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + fungibleId); + Assert.True(nextStates.GetState(garageAddr) is Null); + Assert.True(inventory.HasTradableFungibleItem( + fungibleId, + requiredBlockIndex: null, + blockIndex: 0, + count)); + } + } + + [Fact] + public void Execute_Throws_InvalidActionFieldException() + { + // FungibleAssetValues and FungibleIdAndCounts are null. + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + _inventoryAddr, + null)); + + // FungibleAssetValues contains negative value. + var negativeFungibleAssetValues = _fungibleAssetValues.Select(tuple => + (tuple.balanceAddr, tuple.value * -1)); + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + negativeFungibleAssetValues, + _inventoryAddr, + null)); + + // InventoryAddr is null when FungibleIdAndCounts is not null. + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + null, + _fungibleIdAndCounts)); + + // Count of fungible id is negative. + var negativeFungibleIdAndCounts = _fungibleIdAndCounts.Select(tuple => ( + tuple.fungibleId, + tuple.count * -1)); + Assert.Throws(() => Execute( + AgentAddr, + 0, + _previousStates, + new TestRandom(), + null, + _inventoryAddr, + negativeFungibleIdAndCounts)); + } + + [Fact] + public void Execute_Throws_Exception() + { + // Agent's FungibleAssetValue garages does not have enough balance. + var previousStatesWithEmptyBalances = _previousStates; + var garageBalanceAddress = Addresses.GetGarageBalanceAddress(AgentAddr); + foreach (var (_, value) in _fungibleAssetValues) + { + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances + .BurnAsset(garageBalanceAddress, value); + } + + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithEmptyBalances, + new TestRandom(), + _fungibleAssetValues, + null, + null)); + + // Inventory state is null. + var previousStatesWithNullInventoryState = + _previousStates.SetState(_inventoryAddr!.Value, Null.Value); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNullInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + + // The state in InventoryAddr is not Inventory. + foreach (var invalidInventoryState in new IValue[] + { + new Integer(0), + Dictionary.Empty, + }) + { + var previousStatesWithInvalidInventoryState = + _previousStates.SetState(_inventoryAddr.Value, invalidInventoryState); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithInvalidInventoryState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + + // Agent's fungible item garage state is null. + foreach (var (fungibleId, _) in _fungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + fungibleId); + var previousStatesWithNullGarageState = + _previousStates.SetState(garageAddr, Null.Value); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNullGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + + // Agent's fungible item garage does not contain enough items. + foreach (var (fungibleId, _) in _fungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + fungibleId); + var garageState = _previousStates.GetState(garageAddr); + var garage = new FungibleItemGarage(garageState); + garage.Unload(1); + var previousStatesWithNotEnoughCountOfGarageState = + _previousStates.SetState(garageAddr, garage.Serialize()); + if (garage.Count == 0) + { + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + else + { + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + } + + // Inventory can be overflowed. + for (var i = 0; i < _fungibleIdAndCounts.Length; i++) + { + var item = _tradableFungibleItems[i]; + var inventory = _previousStates.GetInventory(_inventoryAddr.Value); + inventory.AddTradableFungibleItem(item, int.MaxValue); + var previousStatesWithInvalidGarageState = + _previousStates.SetState(_inventoryAddr.Value, inventory.Serialize()); + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithInvalidGarageState, + new TestRandom(), + null, + _inventoryAddr, + _fungibleIdAndCounts)); + } + } + + private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execute( + Address signer, + long blockIndex, + IAccountStateDelta previousStates, + IRandom random, + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo = null) + { + var action = new UnloadFromMyGarages( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo); + return ( + action, + action.Execute(new ActionContext + { + Signer = signer, + BlockIndex = blockIndex, + Rehearsal = false, + PreviousStates = previousStates, + Random = random, + })); + } + + private static (Address balanceAddr, FungibleAssetValue value)[] + GetFungibleAssetValues( + Address agentAddr, + Address avatarAddr) + { + return CurrenciesTest.GetSampleCurrencies() + .Select(objects => (FungibleAssetValue)objects[0]) + .Where(fav => fav.Sign > 0) + .Select(fav => + { + if (Currencies.IsRuneTicker(fav.Currency.Ticker) || + Currencies.IsSoulstoneTicker(fav.Currency.Ticker)) + { + return (avatarAddr, fav); + } + + return (agentAddr, fav); + }) + .ToArray(); + } + + private ( + (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, + Address? inventoryAddr, + (HashDigest fungibleId, int count)[] fungibleIdAndCounts, + ITradableFungibleItem[] _tradableFungibleItems, + IAccountStateDelta previousStates) + GetSuccessfulPreviousStatesWithPlainValue() + { + var previousStates = _initialStatesWithAvatarStateV2; + var garageBalanceAddress = Addresses.GetGarageBalanceAddress(AgentAddr); + var fungibleAssetValues = GetFungibleAssetValues( + AgentAddr, + AvatarAddr); + foreach (var (_, value) in fungibleAssetValues) + { + if (value.Currency.Equals(_ncg)) + { + previousStates = previousStates.TransferAsset( + Addresses.Admin, + garageBalanceAddress, + value); + continue; + } + + previousStates = previousStates.MintAsset( + garageBalanceAddress, + value); + } + + var fungibleItemAndCounts = _tableSheets.MaterialItemSheet.OrderedList! + .Take(3) + .Select(ItemFactory.CreateTradableMaterial) + .Select((tradableMaterial, index) => + { + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + tradableMaterial.FungibleId); + var count = index + 1; + var garage = new FungibleItemGarage(tradableMaterial, count); + previousStates = previousStates.SetState( + garageAddr, + garage.Serialize()); + + return ( + tradableFungibleItem: (ITradableFungibleItem)tradableMaterial, + count); + }).ToArray(); + return ( + fungibleAssetValues, + inventoryAddr: Addresses.GetInventoryAddress( + AgentAddr, + AvatarIndex), + fungibleItemAndCounts + .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count)) + .ToArray(), + fungibleItemAndCounts.Select(tuple => tuple.tradableFungibleItem).ToArray(), + previousStates + ); + } + } +} diff --git a/Lib9c.Abstractions/IUnloadFromMyGarages.cs b/Lib9c.Abstractions/IUnloadFromMyGarages.cs new file mode 100644 index 0000000000..1adb8cad16 --- /dev/null +++ b/Lib9c.Abstractions/IUnloadFromMyGarages.cs @@ -0,0 +1,21 @@ +#nullable enable + +using System.Linq; +using System.Security.Cryptography; +using Libplanet; +using Libplanet.Assets; + +namespace Lib9c.Abstractions +{ + public interface IUnloadFromMyGarages + { + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues + { + get; + } + + Address? InventoryAddr { get; } + IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; } + string? Memo { get; } + } +} diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs new file mode 100644 index 0000000000..646a5aa4cc --- /dev/null +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -0,0 +1,205 @@ +#nullable enable + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Security.Cryptography; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet; +using Libplanet.Action; +using Libplanet.Assets; +using Libplanet.State; +using Nekoyume.Exceptions; +using Nekoyume.Model.Item; +using Nekoyume.Model.State; + +namespace Nekoyume.Action.Garages +{ + [ActionType("unload_from_my_garages")] + public class UnloadFromMyGarages : GameAction, IUnloadFromMyGarages, IAction + { + public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? + FungibleAssetValues { get; private set; } + + /// + /// This address does not need to consider its owner. + /// If the avatar state is v1, there is no separate inventory, + /// so it should be execute another action first to migrate the avatar state to v2. + /// And then, the inventory address will be set. + /// + public Address? InventoryAddr { get; private set; } + + public IOrderedEnumerable<(HashDigest fungibleId, int count)>? + FungibleIdAndCounts { get; private set; } + + public string? Memo { get; private set; } + + protected override IImmutableDictionary PlainValueInternal => + new Dictionary + { + { + "l", + new List( + FungibleAssetValues is null + ? (IValue)Null.Value + : new List(FungibleAssetValues.Select(tuple => new List( + tuple.balanceAddr.Serialize(), + tuple.value.Serialize()))), + InventoryAddr is null + ? Null.Value + : InventoryAddr.Serialize(), + FungibleIdAndCounts is null + ? (IValue)Null.Value + : new List(FungibleIdAndCounts.Select(tuple => new List( + tuple.fungibleId.Serialize(), + (Integer)tuple.count))), + Memo is null + ? (IValue)Null.Value + : (Text)Memo) + } + }.ToImmutableDictionary(); + + public UnloadFromMyGarages( + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + Address? inventoryAddr, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + ( + FungibleAssetValues, + InventoryAddr, + FungibleIdAndCounts, + Memo + ) = GarageUtils.MergeAndSort( + fungibleAssetValues, + inventoryAddr, + fungibleIdAndCounts, + memo); + } + + public UnloadFromMyGarages() + { + } + + protected override void LoadPlainValueInternal( + IImmutableDictionary plainValue) + { + ( + FungibleAssetValues, + InventoryAddr, + FungibleIdAndCounts, + Memo + ) = GarageUtils.Deserialize(plainValue["l"]); + } + + public override IAccountStateDelta Execute(IActionContext context) + { + var states = context.PreviousStates; + if (context.Rehearsal) + { + return states; + } + + var addressesHex = GetSignerAndOtherAddressesHex(context); + ValidateFields(addressesHex); + states = TransferFungibleAssetValues( + context.Signer, + states); + return TransferFungibleItems( + context.Signer, + states); + } + + private void ValidateFields(string addressesHex) + { + if (FungibleAssetValues is null && + FungibleIdAndCounts is null) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Either FungibleAssetValues or FungibleIdAndCounts " + + "must be set."); + } + + if (FungibleAssetValues != null) + { + foreach (var (_, value) in FungibleAssetValues) + { + if (value.Sign < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] FungibleAssetValue.Sign must be positive."); + } + } + } + + if (FungibleIdAndCounts is null) + { + return; + } + + if (!InventoryAddr.HasValue) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] {nameof(InventoryAddr)} is required when " + + $"{nameof(FungibleIdAndCounts)} is set."); + } + + foreach (var (fungibleId, count) in FungibleIdAndCounts) + { + if (count < 0) + { + throw new InvalidActionFieldException( + $"[{addressesHex}] Count of fungible id must be positive." + + $" {fungibleId}, {count}"); + } + } + } + + private IAccountStateDelta TransferFungibleAssetValues( + Address signer, + IAccountStateDelta states) + { + if (FungibleAssetValues is null) + { + return states; + } + + var garageBalanceAddress = + Addresses.GetGarageBalanceAddress(signer); + foreach (var (balanceAddr, value) in FungibleAssetValues) + { + states = states.TransferAsset(garageBalanceAddress, balanceAddr, value); + } + + return states; + } + + private IAccountStateDelta TransferFungibleItems( + Address signer, + IAccountStateDelta states) + { + if (InventoryAddr is null || + FungibleIdAndCounts is null) + { + return states; + } + + var inventory = states.GetInventory(InventoryAddr.Value); + var fungibleItemTuples = GarageUtils.WithGarageTuples( + signer, + states, + FungibleIdAndCounts); + foreach (var (_, count, garageAddr, garage) in fungibleItemTuples) + { + garage.Unload(count); + inventory.AddTradableFungibleItem( + (ITradableFungibleItem)garage.Item, + count); + states = states.SetState(garageAddr, garage.Serialize()); + } + + return states.SetState(InventoryAddr.Value, inventory.Serialize()); + } + } +} From 13060fd653d7bc706cf7f6e8bae5cd3b19dfd2a5 Mon Sep 17 00:00:00 2001 From: area363 Date: Thu, 22 Jun 2023 09:43:30 +0900 Subject: [PATCH 14/68] update submodule-updater to bump release/* branches --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fb9fd2e36..a2f648fec0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -121,7 +121,7 @@ jobs: destination_dir: ${{ github.ref_name }} update-submodule: - if: github.ref_type == 'branch' && startsWith(github.ref_name, 'rc-v') + if: ${{ (github.ref_type == 'branch' && startsWith(github.ref_name, 'rc-v')) || github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} runs-on: ubuntu-latest steps: - name: Update other repos referring lib9c as submodules From 988fa1d546e314f4dc3b7b3aed4b685cb513881d Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 22 Jun 2023 14:35:02 +0900 Subject: [PATCH 15/68] Add meta files --- Lib9c/TableCSV/Garages.meta | 8 ++++++++ .../TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv.meta | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 Lib9c/TableCSV/Garages.meta create mode 100644 Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv.meta diff --git a/Lib9c/TableCSV/Garages.meta b/Lib9c/TableCSV/Garages.meta new file mode 100644 index 0000000000..4b7befd18f --- /dev/null +++ b/Lib9c/TableCSV/Garages.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfc44322e59a646c9a880c7447dda9e9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv.meta b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv.meta new file mode 100644 index 0000000000..b87049be42 --- /dev/null +++ b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 419156b97eb224023967dc1eda68e11d +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 7e10195284291d6579e7d7730f3dd8c6a59cb6c6 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 22 Jun 2023 16:07:26 +0900 Subject: [PATCH 16/68] Bump libplanet to 2.2.0 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index 278c0421ae..c59018e3f7 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit 278c0421ae8276ff3ea9dac2efaba18de37a6531 +Subproject commit c59018e3f7b058437f3ded9b3e3cc54e59ec2c53 From 060e92dc6bf9ecea2490071a66621b7fab0ca24b Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 22 Jun 2023 16:16:41 +0900 Subject: [PATCH 17/68] Pass context for states in non-extension methods --- Lib9c/Action/ActionBaseExtensions.cs | 7 +++++-- Lib9c/Action/BattleArena.cs | 2 +- Lib9c/Action/BattleArena10.cs | 2 +- Lib9c/Action/BattleArena11.cs | 2 +- Lib9c/Action/BattleArena2.cs | 2 +- Lib9c/Action/BattleArena3.cs | 2 +- Lib9c/Action/BattleArena4.cs | 2 +- Lib9c/Action/BattleArena5.cs | 1 + Lib9c/Action/BattleArena6.cs | 2 +- Lib9c/Action/BattleArena7.cs | 2 +- Lib9c/Action/BattleArena8.cs | 2 +- Lib9c/Action/BattleArena9.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 | 8 +++++--- Lib9c/Action/BuyProduct0.cs | 8 +++++--- Lib9c/Action/CancelMonsterCollect.cs | 2 +- Lib9c/Action/CancelProductRegistration.cs | 2 +- Lib9c/Action/ClaimMonsterCollectionReward0.cs | 2 +- Lib9c/Action/ClaimRaidReward.cs | 4 ++-- Lib9c/Action/ClaimStakeReward.cs | 3 ++- Lib9c/Action/ClaimStakeReward3.cs | 2 +- Lib9c/Action/CombinationEquipment.cs | 4 +++- Lib9c/Action/CombinationEquipment0.cs | 1 + Lib9c/Action/CombinationEquipment10.cs | 1 + Lib9c/Action/CombinationEquipment11.cs | 1 + Lib9c/Action/CombinationEquipment12.cs | 3 ++- Lib9c/Action/CombinationEquipment13.cs | 4 +++- Lib9c/Action/CombinationEquipment14.cs | 4 +++- Lib9c/Action/CombinationEquipment15.cs | 4 +++- Lib9c/Action/CombinationEquipment2.cs | 1 + Lib9c/Action/CombinationEquipment3.cs | 1 + Lib9c/Action/CombinationEquipment4.cs | 1 + Lib9c/Action/CombinationEquipment5.cs | 1 + Lib9c/Action/CombinationEquipment6.cs | 1 + Lib9c/Action/CombinationEquipment7.cs | 1 + Lib9c/Action/CombinationEquipment8.cs | 1 + Lib9c/Action/CombinationEquipment9.cs | 1 + Lib9c/Action/CreateAvatar.cs | 2 +- Lib9c/Action/CreateAvatar0.cs | 3 ++- Lib9c/Action/CreatePledge.cs | 2 +- Lib9c/Action/DailyReward.cs | 1 + Lib9c/Action/DailyReward6.cs | 1 + Lib9c/Action/EndPledge.cs | 2 +- Lib9c/Action/EventDungeonBattle.cs | 1 + Lib9c/Action/EventDungeonBattleV1.cs | 1 + Lib9c/Action/EventDungeonBattleV2.cs | 1 + Lib9c/Action/EventDungeonBattleV3.cs | 1 + Lib9c/Action/EventDungeonBattleV4.cs | 1 + Lib9c/Action/Grinding.cs | 2 +- Lib9c/Action/HackAndSlashRandomBuff.cs | 2 +- Lib9c/Action/InitializeStates.cs | 2 +- Lib9c/Action/ItemEnhancement.cs | 4 ++-- Lib9c/Action/ItemEnhancement0.cs | 1 + Lib9c/Action/ItemEnhancement10.cs | 2 +- Lib9c/Action/ItemEnhancement2.cs | 1 + Lib9c/Action/ItemEnhancement3.cs | 1 + Lib9c/Action/ItemEnhancement4.cs | 1 + Lib9c/Action/ItemEnhancement5.cs | 1 + Lib9c/Action/ItemEnhancement6.cs | 1 + Lib9c/Action/ItemEnhancement7.cs | 1 + Lib9c/Action/ItemEnhancement8.cs | 1 + Lib9c/Action/ItemEnhancement9.cs | 2 +- Lib9c/Action/JoinArena.cs | 2 +- Lib9c/Action/JoinArena1.cs | 2 +- Lib9c/Action/JoinArena2.cs | 2 +- Lib9c/Action/MigrateMonsterCollection.cs | 1 + Lib9c/Action/MonsterCollect.cs | 4 ++-- Lib9c/Action/MonsterCollect0.cs | 2 +- Lib9c/Action/MonsterCollect2.cs | 4 ++-- Lib9c/Action/PetEnhancement.cs | 3 ++- Lib9c/Action/PrepareRewardAssets.cs | 2 +- Lib9c/Action/Raid.cs | 8 ++++---- Lib9c/Action/Raid1.cs | 8 ++++---- Lib9c/Action/Raid2.cs | 8 ++++---- Lib9c/Action/Raid3.cs | 8 ++++---- Lib9c/Action/Raid4.cs | 8 ++++---- Lib9c/Action/Raid5.cs | 8 ++++---- Lib9c/Action/RankingBattle0.cs | 1 + Lib9c/Action/RedeemCode.cs | 1 + Lib9c/Action/RedeemCode0.cs | 1 + Lib9c/Action/RedeemCode2.cs | 1 + Lib9c/Action/RegisterProduct.cs | 2 +- Lib9c/Action/RegisterProduct0.cs | 2 +- Lib9c/Action/RequestPledge.cs | 2 +- Lib9c/Action/RewardGold.cs | 2 ++ Lib9c/Action/RuneEnhancement.cs | 6 +++--- Lib9c/Action/RuneEnhancement0.cs | 6 +++--- Lib9c/Action/SecureMiningReward.cs | 6 +++--- Lib9c/Action/Stake.cs | 12 +++++++----- Lib9c/Action/Stake0.cs | 12 +++++++----- Lib9c/Action/TransferAsset.cs | 2 +- Lib9c/Action/TransferAsset0.cs | 2 +- Lib9c/Action/TransferAsset2.cs | 2 +- Lib9c/Action/TransferAsset3.cs | 2 +- Lib9c/Action/TransferAssets.cs | 7 ++++--- Lib9c/Action/TransferAssets0.cs | 7 ++++--- Lib9c/Action/UnlockEquipmentRecipe.cs | 2 +- Lib9c/Action/UnlockEquipmentRecipe1.cs | 2 +- Lib9c/Action/UnlockRuneSlot.cs | 2 +- Lib9c/Action/UnlockWorld.cs | 2 +- Lib9c/Action/UnlockWorld1.cs | 2 +- 113 files changed, 197 insertions(+), 112 deletions(-) diff --git a/Lib9c/Action/ActionBaseExtensions.cs b/Lib9c/Action/ActionBaseExtensions.cs index a85d44be82..3e4ff7d71a 100644 --- a/Lib9c/Action/ActionBaseExtensions.cs +++ b/Lib9c/Action/ActionBaseExtensions.cs @@ -48,6 +48,8 @@ private class RehearsalActionContext : IActionContext public long BlockIndex => default; + public int BlockProtocolVersion => default; + public bool Rehearsal => true; public IAccountStateDelta PreviousStates => new AddressTraceStateDelta(); @@ -104,7 +106,7 @@ public IImmutableDictionary> TotalUpdatedFungib public IImmutableSet TotalSupplyUpdatedCurrencies => ImmutableHashSet.Empty; - public IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value) + public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { return new AddressTraceStateDelta(_updatedAddresses.Union(new [] { owner })); } @@ -129,7 +131,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) throw new NotSupportedException(); } - public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) + public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { return new AddressTraceStateDelta(_updatedAddresses.Union(new[] { recipient })); } @@ -140,6 +142,7 @@ public IAccountStateDelta SetState(Address address, IValue state) } public IAccountStateDelta TransferAsset( + IActionContext context, Address sender, Address recipient, FungibleAssetValue value, diff --git a/Lib9c/Action/BattleArena.cs b/Lib9c/Action/BattleArena.cs index 2adade4c05..9af310a2b2 100644 --- a/Lib9c/Action/BattleArena.cs +++ b/Lib9c/Action/BattleArena.cs @@ -335,7 +335,7 @@ public override IAccountStateDelta Execute(IActionContext context) purchasedCountDuringInterval++; states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, purchasedCountDuringInterval); } diff --git a/Lib9c/Action/BattleArena10.cs b/Lib9c/Action/BattleArena10.cs index 71b9ec7b02..7729246b7b 100644 --- a/Lib9c/Action/BattleArena10.cs +++ b/Lib9c/Action/BattleArena10.cs @@ -338,7 +338,7 @@ public override IAccountStateDelta Execute(IActionContext context) purchasedCountDuringInterval++; states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, purchasedCountDuringInterval); } diff --git a/Lib9c/Action/BattleArena11.cs b/Lib9c/Action/BattleArena11.cs index 8a045d7d69..785934d1c2 100644 --- a/Lib9c/Action/BattleArena11.cs +++ b/Lib9c/Action/BattleArena11.cs @@ -336,7 +336,7 @@ public override IAccountStateDelta Execute(IActionContext context) purchasedCountDuringInterval++; states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, purchasedCountDuringInterval); } diff --git a/Lib9c/Action/BattleArena2.cs b/Lib9c/Action/BattleArena2.cs index 375dcf275c..5cc391397d 100644 --- a/Lib9c/Action/BattleArena2.cs +++ b/Lib9c/Action/BattleArena2.cs @@ -262,7 +262,7 @@ public override IAccountStateDelta Execute(IActionContext context) for (var i = 0; i < ticket; i++) { var ticketBalance = ArenaHelper.GetTicketPrice(roundData, arenaInformation, goldCurrency); - states = states.TransferAsset(context.Signer, arenaAdr, ticketBalance); + states = states.TransferAsset(context, context.Signer, arenaAdr, ticketBalance); arenaInformation.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } diff --git a/Lib9c/Action/BattleArena3.cs b/Lib9c/Action/BattleArena3.cs index 8d236fa996..a70a25d5f4 100644 --- a/Lib9c/Action/BattleArena3.cs +++ b/Lib9c/Action/BattleArena3.cs @@ -263,7 +263,7 @@ public override IAccountStateDelta Execute(IActionContext context) for (var i = 0; i < ticket; i++) { var ticketBalance = ArenaHelper.GetTicketPrice(roundData, arenaInformation, goldCurrency); - states = states.TransferAsset(context.Signer, arenaAdr, ticketBalance); + states = states.TransferAsset(context, context.Signer, arenaAdr, ticketBalance); arenaInformation.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } diff --git a/Lib9c/Action/BattleArena4.cs b/Lib9c/Action/BattleArena4.cs index 7bb4f8a20a..5d20931849 100644 --- a/Lib9c/Action/BattleArena4.cs +++ b/Lib9c/Action/BattleArena4.cs @@ -281,7 +281,7 @@ public override IAccountStateDelta Execute(IActionContext context) for (var i = 0; i < ticket; i++) { var ticketBalance = ArenaHelper.GetTicketPrice(roundData, arenaInformation, goldCurrency); - states = states.TransferAsset(context.Signer, arenaAdr, ticketBalance); + states = states.TransferAsset(context, context.Signer, arenaAdr, ticketBalance); arenaInformation.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } diff --git a/Lib9c/Action/BattleArena5.cs b/Lib9c/Action/BattleArena5.cs index 5b4cf7a049..5e71cbbe02 100644 --- a/Lib9c/Action/BattleArena5.cs +++ b/Lib9c/Action/BattleArena5.cs @@ -294,6 +294,7 @@ public override IAccountStateDelta Execute(IActionContext context) var ticketBalance = ArenaHelper.GetTicketPrice(roundData, arenaInformation, goldCurrency); states = states.TransferAsset( + context, context.Signer, arenaAdr, ticketBalance); diff --git a/Lib9c/Action/BattleArena6.cs b/Lib9c/Action/BattleArena6.cs index ee975c98e5..2af8379a6d 100644 --- a/Lib9c/Action/BattleArena6.cs +++ b/Lib9c/Action/BattleArena6.cs @@ -316,7 +316,7 @@ public override IAccountStateDelta Execute(IActionContext context) } states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, ++purchasedCountDuringInterval); } } diff --git a/Lib9c/Action/BattleArena7.cs b/Lib9c/Action/BattleArena7.cs index a49efaabb1..039ab847f4 100644 --- a/Lib9c/Action/BattleArena7.cs +++ b/Lib9c/Action/BattleArena7.cs @@ -338,7 +338,7 @@ public override IAccountStateDelta Execute(IActionContext context) } states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, ++purchasedCountDuringInterval); } } diff --git a/Lib9c/Action/BattleArena8.cs b/Lib9c/Action/BattleArena8.cs index a58c829f70..1d5ab92314 100644 --- a/Lib9c/Action/BattleArena8.cs +++ b/Lib9c/Action/BattleArena8.cs @@ -344,7 +344,7 @@ public override IAccountStateDelta Execute(IActionContext context) purchasedCountDuringInterval++; states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, purchasedCountDuringInterval); } diff --git a/Lib9c/Action/BattleArena9.cs b/Lib9c/Action/BattleArena9.cs index 0104eb287f..8511bdaa23 100644 --- a/Lib9c/Action/BattleArena9.cs +++ b/Lib9c/Action/BattleArena9.cs @@ -341,7 +341,7 @@ public override IAccountStateDelta Execute(IActionContext context) purchasedCountDuringInterval++; states = states - .TransferAsset(context.Signer, arenaAdr, ticketBalance) + .TransferAsset(context, context.Signer, arenaAdr, ticketBalance) .SetState(purchasedCountAddr, purchasedCountDuringInterval); } diff --git a/Lib9c/Action/Buy.cs b/Lib9c/Action/Buy.cs index 9648f4e886..d6531cd9b2 100644 --- a/Lib9c/Action/Buy.cs +++ b/Lib9c/Action/Buy.cs @@ -263,12 +263,14 @@ public override IAccountStateDelta Execute(IActionContext context) var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); var feeStoreAddress = Addresses.GetShopFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy0.cs b/Lib9c/Action/Buy0.cs index c3c1643975..d0cb49f15d 100644 --- a/Lib9c/Action/Buy0.cs +++ b/Lib9c/Action/Buy0.cs @@ -163,12 +163,14 @@ public override IAccountStateDelta Execute(IActionContext context) // 세금을 송금한다. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // 구매자의 돈을 판매자에게 송금한다. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy10.cs b/Lib9c/Action/Buy10.cs index 75d4189108..c1fe84dd0b 100644 --- a/Lib9c/Action/Buy10.cs +++ b/Lib9c/Action/Buy10.cs @@ -286,12 +286,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy11.cs b/Lib9c/Action/Buy11.cs index 33d8733c6e..d58a318600 100644 --- a/Lib9c/Action/Buy11.cs +++ b/Lib9c/Action/Buy11.cs @@ -305,12 +305,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GetFeeStoreAddress(), tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy2.cs b/Lib9c/Action/Buy2.cs index 19f6c06ce4..288c1271df 100644 --- a/Lib9c/Action/Buy2.cs +++ b/Lib9c/Action/Buy2.cs @@ -165,12 +165,14 @@ public override IAccountStateDelta Execute(IActionContext context) // 세금을 송금한다. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // 구매자의 돈을 판매자에게 송금한다. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy3.cs b/Lib9c/Action/Buy3.cs index 3aecf4de77..1e4888eccd 100644 --- a/Lib9c/Action/Buy3.cs +++ b/Lib9c/Action/Buy3.cs @@ -162,12 +162,14 @@ public override IAccountStateDelta Execute(IActionContext context) // 세금을 송금한다. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // 구매자의 돈을 판매자에게 송금한다. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy4.cs b/Lib9c/Action/Buy4.cs index 2a0221c155..a9fe7d1a3c 100644 --- a/Lib9c/Action/Buy4.cs +++ b/Lib9c/Action/Buy4.cs @@ -159,12 +159,14 @@ public override IAccountStateDelta Execute(IActionContext context) // 세금을 송금한다. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // 구매자의 돈을 판매자에게 송금한다. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy5.cs b/Lib9c/Action/Buy5.cs index c338762b20..5a3a9a7dea 100644 --- a/Lib9c/Action/Buy5.cs +++ b/Lib9c/Action/Buy5.cs @@ -221,12 +221,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy6.cs b/Lib9c/Action/Buy6.cs index 476a50dfdc..22a298117a 100644 --- a/Lib9c/Action/Buy6.cs +++ b/Lib9c/Action/Buy6.cs @@ -230,12 +230,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy7.cs b/Lib9c/Action/Buy7.cs index 718ec04ed1..bbbec30db6 100644 --- a/Lib9c/Action/Buy7.cs +++ b/Lib9c/Action/Buy7.cs @@ -402,12 +402,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy8.cs b/Lib9c/Action/Buy8.cs index 26d718c92a..b80b9145cc 100644 --- a/Lib9c/Action/Buy8.cs +++ b/Lib9c/Action/Buy8.cs @@ -283,12 +283,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/Buy9.cs b/Lib9c/Action/Buy9.cs index 83b8fcd7e5..825f8b0e15 100644 --- a/Lib9c/Action/Buy9.cs +++ b/Lib9c/Action/Buy9.cs @@ -289,12 +289,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax. states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/BuyMultiple.cs b/Lib9c/Action/BuyMultiple.cs index 4fcbf333b1..9794060d86 100644 --- a/Lib9c/Action/BuyMultiple.cs +++ b/Lib9c/Action/BuyMultiple.cs @@ -370,12 +370,14 @@ public override IAccountStateDelta Execute(IActionContext context) // Transfer tax states = states.TransferAsset( + context, context.Signer, GoldCurrencyState.Address, tax); // Transfer paid money (taxed) to the seller. states = states.TransferAsset( + context, context.Signer, productInfo.sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/BuyProduct.cs b/Lib9c/Action/BuyProduct.cs index d2a8036e03..ab9a2f4b07 100644 --- a/Lib9c/Action/BuyProduct.cs +++ b/Lib9c/Action/BuyProduct.cs @@ -142,7 +142,7 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, switch (product) { case FavProduct favProduct: - states = states.TransferAsset(productAddress, AvatarAddress, favProduct.Asset); + states = states.TransferAsset(context, productAddress, AvatarAddress, favProduct.Asset); break; case ItemProduct itemProduct: { @@ -205,8 +205,8 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, .SetState(sellerAvatarAddress, sellerAvatarState.SerializeV2()) .SetState(sellerAvatarAddress.Derive(LegacyQuestListKey), sellerAvatarState.questList.Serialize()) .SetState(ProductReceipt.DeriveAddress(productId), receipt.Serialize()) - .TransferAsset(context.Signer, feeStoreAddress, tax) - .TransferAsset(context.Signer, sellerAgentAddress, taxedPrice); + .TransferAsset(context, context.Signer, feeStoreAddress, tax) + .TransferAsset(context, context.Signer, sellerAgentAddress, taxedPrice); if (sellerMigrationRequired) { @@ -337,12 +337,14 @@ private static IAccountStateDelta Buy_Order(PurchaseInfo purchaseInfo, IActionCo var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); var feeStoreAddress = Addresses.GetShopFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/BuyProduct0.cs b/Lib9c/Action/BuyProduct0.cs index 02f2616fed..affdddbc7b 100644 --- a/Lib9c/Action/BuyProduct0.cs +++ b/Lib9c/Action/BuyProduct0.cs @@ -142,7 +142,7 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, switch (product) { case FavProduct favProduct: - states = states.TransferAsset(productAddress, AvatarAddress, favProduct.Asset); + states = states.TransferAsset(context, productAddress, AvatarAddress, favProduct.Asset); break; case ItemProduct itemProduct: { @@ -195,8 +195,8 @@ private IAccountStateDelta Buy(IActionContext context, IProductInfo productInfo, .SetState(sellerAvatarAddress, sellerAvatarState.SerializeV2()) .SetState(sellerAvatarAddress.Derive(LegacyQuestListKey), sellerAvatarState.questList.Serialize()) .SetState(ProductReceipt.DeriveAddress(productId), receipt.Serialize()) - .TransferAsset(context.Signer, feeStoreAddress, tax) - .TransferAsset(context.Signer, sellerAgentAddress, taxedPrice); + .TransferAsset(context, context.Signer, feeStoreAddress, tax) + .TransferAsset(context, context.Signer, sellerAgentAddress, taxedPrice); if (sellerMigrationRequired) { @@ -327,12 +327,14 @@ private static IAccountStateDelta Buy_Order(PurchaseInfo purchaseInfo, IActionCo var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); var feeStoreAddress = Addresses.GetShopFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, tax); // Transfer seller. states = states.TransferAsset( + context, context.Signer, sellerAgentAddress, taxedPrice diff --git a/Lib9c/Action/CancelMonsterCollect.cs b/Lib9c/Action/CancelMonsterCollect.cs index 0e703c5521..dc9fc8c6ce 100644 --- a/Lib9c/Action/CancelMonsterCollect.cs +++ b/Lib9c/Action/CancelMonsterCollect.cs @@ -87,7 +87,7 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}CancelMonsterCollect Total Executed Time: {Elapsed}", addressesHex, ended - started); return states .SetState(collectionAddress, monsterCollectionState.Serialize()) - .TransferAsset(collectionAddress, context.Signer, balance); + .TransferAsset(context, collectionAddress, context.Signer, balance); } protected override IImmutableDictionary PlainValueInternal => diff --git a/Lib9c/Action/CancelProductRegistration.cs b/Lib9c/Action/CancelProductRegistration.cs index c752e8153f..034aafb9d0 100644 --- a/Lib9c/Action/CancelProductRegistration.cs +++ b/Lib9c/Action/CancelProductRegistration.cs @@ -162,7 +162,7 @@ public static IAccountStateDelta Cancel(ProductsState productsState, IProductInf switch (product) { case FavProduct favProduct: - states = states.TransferAsset(productAddress, avatarState.address, + states = states.TransferAsset(context, productAddress, avatarState.address, favProduct.Asset); break; case ItemProduct itemProduct: diff --git a/Lib9c/Action/ClaimMonsterCollectionReward0.cs b/Lib9c/Action/ClaimMonsterCollectionReward0.cs index dc2fd4c069..56c4936215 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward0.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward0.cs @@ -106,7 +106,7 @@ public override IAccountStateDelta Execute(IActionContext context) states = states.SetState(context.Signer, agentState.Serialize()); if (gold > currency * 0) { - states = states.TransferAsset(collectionAddress, context.Signer, gold); + states = states.TransferAsset(context, collectionAddress, context.Signer, gold); } } diff --git a/Lib9c/Action/ClaimRaidReward.cs b/Lib9c/Action/ClaimRaidReward.cs index cf085c8439..6668a68685 100644 --- a/Lib9c/Action/ClaimRaidReward.cs +++ b/Lib9c/Action/ClaimRaidReward.cs @@ -85,11 +85,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (reward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, reward); + states = states.MintAsset(context, context.Signer, reward); } else { - states = states.MintAsset(AvatarAddress, reward); + states = states.MintAsset(context, AvatarAddress, reward); } } } diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index af031ecf10..bbda002147 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -288,7 +288,7 @@ private IAccountStateDelta ProcessReward( continue; } - states = states.MintAsset(AvatarAddress, runeReward); + states = states.MintAsset(context, AvatarAddress, runeReward); break; case StakeRegularRewardSheet.StakeRewardType.Currency: if (string.IsNullOrEmpty(reward.CurrencyTicker)) @@ -306,6 +306,7 @@ private IAccountStateDelta ProcessReward( } states = states.MintAsset( + context, context.Signer, rewardCurrencyQuantity * currencyRewardStep * rewardCurrency); break; diff --git a/Lib9c/Action/ClaimStakeReward3.cs b/Lib9c/Action/ClaimStakeReward3.cs index 991baa84a6..cb8a3368b8 100644 --- a/Lib9c/Action/ClaimStakeReward3.cs +++ b/Lib9c/Action/ClaimStakeReward3.cs @@ -146,7 +146,7 @@ private IAccountStateDelta ProcessReward( continue; } - states = states.MintAsset(AvatarAddress, runeReward); + states = states.MintAsset(context, AvatarAddress, runeReward); break; default: break; diff --git a/Lib9c/Action/CombinationEquipment.cs b/Lib9c/Action/CombinationEquipment.cs index 6997c3fde2..09179d6a71 100644 --- a/Lib9c/Action/CombinationEquipment.cs +++ b/Lib9c/Action/CombinationEquipment.cs @@ -392,6 +392,7 @@ public override IAccountStateDelta Execute(IActionContext context) var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, states.GetGoldCurrency() * costNcg @@ -533,6 +534,7 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointState.ResetHammerPoint(); return states.TransferAsset( + context, context.Signer, Addresses.SuperCraft, hammerPointCost); @@ -632,7 +634,7 @@ private IAccountStateDelta UseAssetsByNormalCombination( states = states .SetState(dailyCostState.Address, dailyCostState.Serialize()) .SetState(weeklyCostState.Address, weeklyCostState.Serialize()) - .TransferAsset(context.Signer, Addresses.MaterialCost, costCrystal); + .TransferAsset(context, context.Signer, Addresses.MaterialCost, costCrystal); } int hammerPoint; diff --git a/Lib9c/Action/CombinationEquipment0.cs b/Lib9c/Action/CombinationEquipment0.cs index 221357435b..c7daaadb30 100644 --- a/Lib9c/Action/CombinationEquipment0.cs +++ b/Lib9c/Action/CombinationEquipment0.cs @@ -200,6 +200,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment10.cs b/Lib9c/Action/CombinationEquipment10.cs index a349fcf1f3..aaa083b4a5 100644 --- a/Lib9c/Action/CombinationEquipment10.cs +++ b/Lib9c/Action/CombinationEquipment10.cs @@ -267,6 +267,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (costNCG > 0L) { states = states.TransferAsset( + context, context.Signer, BlacksmithAddress, states.GetGoldCurrency() * costNCG diff --git a/Lib9c/Action/CombinationEquipment11.cs b/Lib9c/Action/CombinationEquipment11.cs index 6a6b91e62d..95d39e58eb 100644 --- a/Lib9c/Action/CombinationEquipment11.cs +++ b/Lib9c/Action/CombinationEquipment11.cs @@ -282,6 +282,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (costNCG > 0L) { states = states.TransferAsset( + context, context.Signer, ItemEnhancement10.GetFeeStoreAddress(), states.GetGoldCurrency() * costNCG diff --git a/Lib9c/Action/CombinationEquipment12.cs b/Lib9c/Action/CombinationEquipment12.cs index 3cf51cc80c..1c5fc16daa 100644 --- a/Lib9c/Action/CombinationEquipment12.cs +++ b/Lib9c/Action/CombinationEquipment12.cs @@ -324,7 +324,7 @@ public override IAccountStateDelta Execute(IActionContext context) states = states .SetState(dailyCostState.Address, dailyCostState.Serialize()) .SetState(weeklyCostState.Address, weeklyCostState.Serialize()) - .TransferAsset(context.Signer, Addresses.MaterialCost, costCrystal); + .TransferAsset(context, context.Signer, Addresses.MaterialCost, costCrystal); } // Subtract Required ActionPoint @@ -349,6 +349,7 @@ public override IAccountStateDelta Execute(IActionContext context) var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, states.GetGoldCurrency() * costNCG diff --git a/Lib9c/Action/CombinationEquipment13.cs b/Lib9c/Action/CombinationEquipment13.cs index a2a637ed2a..14869a7a22 100644 --- a/Lib9c/Action/CombinationEquipment13.cs +++ b/Lib9c/Action/CombinationEquipment13.cs @@ -354,6 +354,7 @@ public override IAccountStateDelta Execute(IActionContext context) var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, states.GetGoldCurrency() * costNcg @@ -467,6 +468,7 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointState.ResetHammerPoint(); return states.TransferAsset( + context, context.Signer, Addresses.SuperCraft, hammerPointCost); @@ -552,7 +554,7 @@ private IAccountStateDelta UseAssetsByNormalCombination( states = states .SetState(dailyCostState.Address, dailyCostState.Serialize()) .SetState(weeklyCostState.Address, weeklyCostState.Serialize()) - .TransferAsset(context.Signer, Addresses.MaterialCost, costCrystal); + .TransferAsset(context, context.Signer, Addresses.MaterialCost, costCrystal); } var isBasicSubRecipe = !subRecipeId.HasValue || diff --git a/Lib9c/Action/CombinationEquipment14.cs b/Lib9c/Action/CombinationEquipment14.cs index e84ef23796..0e2f59e67b 100644 --- a/Lib9c/Action/CombinationEquipment14.cs +++ b/Lib9c/Action/CombinationEquipment14.cs @@ -363,6 +363,7 @@ public override IAccountStateDelta Execute(IActionContext context) var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, states.GetGoldCurrency() * costNcg @@ -478,6 +479,7 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointState.ResetHammerPoint(); return states.TransferAsset( + context, context.Signer, Addresses.SuperCraft, hammerPointCost); @@ -563,7 +565,7 @@ private IAccountStateDelta UseAssetsByNormalCombination( states = states .SetState(dailyCostState.Address, dailyCostState.Serialize()) .SetState(weeklyCostState.Address, weeklyCostState.Serialize()) - .TransferAsset(context.Signer, Addresses.MaterialCost, costCrystal); + .TransferAsset(context, context.Signer, Addresses.MaterialCost, costCrystal); } var isBasicSubRecipe = !subRecipeId.HasValue || diff --git a/Lib9c/Action/CombinationEquipment15.cs b/Lib9c/Action/CombinationEquipment15.cs index b506b215db..ccd6bcf86c 100644 --- a/Lib9c/Action/CombinationEquipment15.cs +++ b/Lib9c/Action/CombinationEquipment15.cs @@ -364,6 +364,7 @@ public override IAccountStateDelta Execute(IActionContext context) var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); states = states.TransferAsset( + context, context.Signer, feeStoreAddress, states.GetGoldCurrency() * costNcg @@ -479,6 +480,7 @@ private IAccountStateDelta UseAssetsBySuperCraft( hammerPointState.ResetHammerPoint(); return states.TransferAsset( + context, context.Signer, Addresses.SuperCraft, hammerPointCost); @@ -564,7 +566,7 @@ private IAccountStateDelta UseAssetsByNormalCombination( states = states .SetState(dailyCostState.Address, dailyCostState.Serialize()) .SetState(weeklyCostState.Address, weeklyCostState.Serialize()) - .TransferAsset(context.Signer, Addresses.MaterialCost, costCrystal); + .TransferAsset(context, context.Signer, Addresses.MaterialCost, costCrystal); } var isBasicSubRecipe = !subRecipeId.HasValue || diff --git a/Lib9c/Action/CombinationEquipment2.cs b/Lib9c/Action/CombinationEquipment2.cs index 5996efa705..4bd14f9253 100644 --- a/Lib9c/Action/CombinationEquipment2.cs +++ b/Lib9c/Action/CombinationEquipment2.cs @@ -200,6 +200,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment3.cs b/Lib9c/Action/CombinationEquipment3.cs index fd48d82cbe..d6db5412df 100644 --- a/Lib9c/Action/CombinationEquipment3.cs +++ b/Lib9c/Action/CombinationEquipment3.cs @@ -209,6 +209,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment4.cs b/Lib9c/Action/CombinationEquipment4.cs index a47188eb8d..ff582d00d1 100644 --- a/Lib9c/Action/CombinationEquipment4.cs +++ b/Lib9c/Action/CombinationEquipment4.cs @@ -209,6 +209,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment5.cs b/Lib9c/Action/CombinationEquipment5.cs index d5ff3a8b62..d3f4b9c024 100644 --- a/Lib9c/Action/CombinationEquipment5.cs +++ b/Lib9c/Action/CombinationEquipment5.cs @@ -209,6 +209,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment6.cs b/Lib9c/Action/CombinationEquipment6.cs index 61fad69d67..c0fb09000c 100644 --- a/Lib9c/Action/CombinationEquipment6.cs +++ b/Lib9c/Action/CombinationEquipment6.cs @@ -216,6 +216,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment7.cs b/Lib9c/Action/CombinationEquipment7.cs index 628287a133..5f9196541c 100644 --- a/Lib9c/Action/CombinationEquipment7.cs +++ b/Lib9c/Action/CombinationEquipment7.cs @@ -217,6 +217,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredGold > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredGold diff --git a/Lib9c/Action/CombinationEquipment8.cs b/Lib9c/Action/CombinationEquipment8.cs index 640315bf85..f6a2d3fac4 100644 --- a/Lib9c/Action/CombinationEquipment8.cs +++ b/Lib9c/Action/CombinationEquipment8.cs @@ -267,6 +267,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (costNCG > 0L) { states = states.TransferAsset( + context, context.Signer, BlacksmithAddress, states.GetGoldCurrency() * costNCG diff --git a/Lib9c/Action/CombinationEquipment9.cs b/Lib9c/Action/CombinationEquipment9.cs index 3d3f36841e..6e0af06a7e 100644 --- a/Lib9c/Action/CombinationEquipment9.cs +++ b/Lib9c/Action/CombinationEquipment9.cs @@ -267,6 +267,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (costNCG > 0L) { states = states.TransferAsset( + context, context.Signer, BlacksmithAddress, states.GetGoldCurrency() * costNCG diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 56872fdca0..85be38c698 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -267,7 +267,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(worldInformationAddress, avatarState.worldInformation.Serialize()) .SetState(questListAddress, avatarState.questList.Serialize()) .SetState(avatarAddress, avatarState.SerializeV2()) - .MintAsset(signer, 50 * CrystalCalculator.CRYSTAL); + .MintAsset(ctx, signer, 50 * CrystalCalculator.CRYSTAL); } } } diff --git a/Lib9c/Action/CreateAvatar0.cs b/Lib9c/Action/CreateAvatar0.cs index ad0c494c09..caf4cda219 100644 --- a/Lib9c/Action/CreateAvatar0.cs +++ b/Lib9c/Action/CreateAvatar0.cs @@ -341,6 +341,7 @@ private static HashSet AddOption( } public static IAccountStateDelta AddRunesForTest( + IActionContext context, Address avatarAddress, IAccountStateDelta states) { @@ -348,7 +349,7 @@ public static IAccountStateDelta AddRunesForTest( foreach (var row in runeSheet.Values) { var rune = RuneHelper.ToFungibleAssetValue(row, int.MaxValue); - states = states.MintAsset(avatarAddress, rune); + states = states.MintAsset(context, avatarAddress, rune); } return states; } diff --git a/Lib9c/Action/CreatePledge.cs b/Lib9c/Action/CreatePledge.cs index 60fcd93d7b..a0e23dadfa 100644 --- a/Lib9c/Action/CreatePledge.cs +++ b/Lib9c/Action/CreatePledge.cs @@ -58,7 +58,7 @@ public override IAccountStateDelta Execute(IActionContext context) foreach (var (agentAddress, pledgeAddress) in AgentAddresses) { states = states - .TransferAsset(PatronAddress, agentAddress, mead) + .TransferAsset(context, PatronAddress, agentAddress, mead) .SetState(pledgeAddress, contractList); } return states; diff --git a/Lib9c/Action/DailyReward.cs b/Lib9c/Action/DailyReward.cs index 637a035b80..c03672b9ed 100644 --- a/Lib9c/Action/DailyReward.cs +++ b/Lib9c/Action/DailyReward.cs @@ -93,6 +93,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (gameConfigState.DailyRuneRewardAmount > 0) { states = states.MintAsset( + context, avatarAddress, RuneHelper.DailyRewardRune * gameConfigState.DailyRuneRewardAmount); } diff --git a/Lib9c/Action/DailyReward6.cs b/Lib9c/Action/DailyReward6.cs index dfd4abf9dd..6324e562e8 100644 --- a/Lib9c/Action/DailyReward6.cs +++ b/Lib9c/Action/DailyReward6.cs @@ -78,6 +78,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (gameConfigState.DailyRuneRewardAmount > 0) { states = states.MintAsset( + context, avatarAddress, RuneHelper.DailyRewardRune * gameConfigState.DailyRuneRewardAmount); } diff --git a/Lib9c/Action/EndPledge.cs b/Lib9c/Action/EndPledge.cs index 5a476c7d50..67f1744128 100644 --- a/Lib9c/Action/EndPledge.cs +++ b/Lib9c/Action/EndPledge.cs @@ -41,7 +41,7 @@ public override IAccountStateDelta Execute(IActionContext context) var balance = states.GetBalance(AgentAddress, Currencies.Mead); if (balance > 0 * Currencies.Mead) { - states = states.TransferAsset(AgentAddress, signer, balance); + states = states.TransferAsset(context, AgentAddress, signer, balance); } return states.SetState(contractAddress, Null.Value); } diff --git a/Lib9c/Action/EventDungeonBattle.cs b/Lib9c/Action/EventDungeonBattle.cs index c3852bcda6..6b59b5299d 100644 --- a/Lib9c/Action/EventDungeonBattle.cs +++ b/Lib9c/Action/EventDungeonBattle.cs @@ -268,6 +268,7 @@ is Bencodex.Types.List serializedEventDungeonInfoList if (cost.Sign > 0) { states = states.TransferAsset( + context, context.Signer, Addresses.EventDungeon, cost); diff --git a/Lib9c/Action/EventDungeonBattleV1.cs b/Lib9c/Action/EventDungeonBattleV1.cs index ee9740c6fc..d0fdc76119 100644 --- a/Lib9c/Action/EventDungeonBattleV1.cs +++ b/Lib9c/Action/EventDungeonBattleV1.cs @@ -278,6 +278,7 @@ is Bencodex.Types.List serializedEventDungeonInfoList if (cost > 0L) { states = states.TransferAsset( + context, context.Signer, Addresses.EventDungeon, cost * currency); diff --git a/Lib9c/Action/EventDungeonBattleV2.cs b/Lib9c/Action/EventDungeonBattleV2.cs index 29938fafdc..55f3320df2 100644 --- a/Lib9c/Action/EventDungeonBattleV2.cs +++ b/Lib9c/Action/EventDungeonBattleV2.cs @@ -279,6 +279,7 @@ is Bencodex.Types.List serializedEventDungeonInfoList if (cost.Sign > 0) { states = states.TransferAsset( + context, context.Signer, Addresses.EventDungeon, cost); diff --git a/Lib9c/Action/EventDungeonBattleV3.cs b/Lib9c/Action/EventDungeonBattleV3.cs index 595c29c5f2..08c7566cd0 100644 --- a/Lib9c/Action/EventDungeonBattleV3.cs +++ b/Lib9c/Action/EventDungeonBattleV3.cs @@ -272,6 +272,7 @@ is Bencodex.Types.List serializedEventDungeonInfoList if (cost.Sign > 0) { states = states.TransferAsset( + context, context.Signer, Addresses.EventDungeon, cost); diff --git a/Lib9c/Action/EventDungeonBattleV4.cs b/Lib9c/Action/EventDungeonBattleV4.cs index 6fd5b40431..589bb09681 100644 --- a/Lib9c/Action/EventDungeonBattleV4.cs +++ b/Lib9c/Action/EventDungeonBattleV4.cs @@ -269,6 +269,7 @@ is Bencodex.Types.List serializedEventDungeonInfoList if (cost.Sign > 0) { states = states.TransferAsset( + context, context.Signer, Addresses.EventDungeon, cost); diff --git a/Lib9c/Action/Grinding.cs b/Lib9c/Action/Grinding.cs index 4483d7f6e2..2b10efbc88 100644 --- a/Lib9c/Action/Grinding.cs +++ b/Lib9c/Action/Grinding.cs @@ -177,7 +177,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states .SetState(AvatarAddress, avatarState.SerializeV2()) .SetState(inventoryAddress, avatarState.inventory.Serialize()) - .MintAsset(context.Signer, crystal); + .MintAsset(context, context.Signer, crystal); } protected override IImmutableDictionary PlainValueInternal => diff --git a/Lib9c/Action/HackAndSlashRandomBuff.cs b/Lib9c/Action/HackAndSlashRandomBuff.cs index 925b488141..e00eb09bc7 100644 --- a/Lib9c/Action/HackAndSlashRandomBuff.cs +++ b/Lib9c/Action/HackAndSlashRandomBuff.cs @@ -116,7 +116,7 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}HackAndSlashRandomBuff Total Executed Time: {Elapsed}", addressesHex, ended - started); return states .SetState(gachaStateAddress, gachaState.Serialize()) - .TransferAsset(context.Signer, Addresses.StageRandomBuff, cost); + .TransferAsset(context, context.Signer, Addresses.StageRandomBuff, cost); } private static bool IsPitySystemNeeded(IEnumerable buffIds, int gachaCount, CrystalRandomBuffSheet sheet) diff --git a/Lib9c/Action/InitializeStates.cs b/Lib9c/Action/InitializeStates.cs index 83480df278..a62e19d2ab 100644 --- a/Lib9c/Action/InitializeStates.cs +++ b/Lib9c/Action/InitializeStates.cs @@ -196,7 +196,7 @@ public override IAccountStateDelta Execute(IActionContext context) } var currency = new GoldCurrencyState(GoldCurrency).Currency; - states = states.MintAsset(GoldCurrencyState.Address, currency * 1000000000); + states = states.MintAsset(ctx, GoldCurrencyState.Address, currency * 1000000000); return states; } diff --git a/Lib9c/Action/ItemEnhancement.cs b/Lib9c/Action/ItemEnhancement.cs index 0dfb60f7eb..ff88a24687 100644 --- a/Lib9c/Action/ItemEnhancement.cs +++ b/Lib9c/Action/ItemEnhancement.cs @@ -286,7 +286,7 @@ public override IAccountStateDelta Execute(IActionContext context) var arenaSheet = states.GetSheet(); var arenaData = arenaSheet.GetRoundByBlockIndex(context.BlockIndex); var feeStoreAddress = Addresses.GetBlacksmithFeeAddress(arenaData.ChampionshipId, arenaData.Round); - states = states.TransferAsset(ctx.Signer, feeStoreAddress, states.GetGoldCurrency() * requiredNcg); + states = states.TransferAsset(ctx, ctx.Signer, feeStoreAddress, states.GetGoldCurrency() * requiredNcg); } // Unequip items @@ -336,7 +336,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (crystal > 0 * CrystalCalculator.CRYSTAL) { - states = states.MintAsset(context.Signer, crystal); + states = states.MintAsset(context, context.Signer, crystal); } } diff --git a/Lib9c/Action/ItemEnhancement0.cs b/Lib9c/Action/ItemEnhancement0.cs index 5bf47e89b3..17f812a2d3 100644 --- a/Lib9c/Action/ItemEnhancement0.cs +++ b/Lib9c/Action/ItemEnhancement0.cs @@ -145,6 +145,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement10.cs b/Lib9c/Action/ItemEnhancement10.cs index 4f798058a1..788271e54a 100644 --- a/Lib9c/Action/ItemEnhancement10.cs +++ b/Lib9c/Action/ItemEnhancement10.cs @@ -291,7 +291,7 @@ public override IAccountStateDelta Execute(IActionContext context) var requiredNcg = row.Cost; if (requiredNcg > 0) { - states = states.TransferAsset(ctx.Signer, GetFeeStoreAddress(), states.GetGoldCurrency() * requiredNcg); + states = states.TransferAsset(ctx, ctx.Signer, GetFeeStoreAddress(), states.GetGoldCurrency() * requiredNcg); } // Unequip items diff --git a/Lib9c/Action/ItemEnhancement2.cs b/Lib9c/Action/ItemEnhancement2.cs index ebe293908e..68d4079225 100644 --- a/Lib9c/Action/ItemEnhancement2.cs +++ b/Lib9c/Action/ItemEnhancement2.cs @@ -143,6 +143,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement3.cs b/Lib9c/Action/ItemEnhancement3.cs index 5399017891..d76a9c8f7e 100644 --- a/Lib9c/Action/ItemEnhancement3.cs +++ b/Lib9c/Action/ItemEnhancement3.cs @@ -143,6 +143,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement4.cs b/Lib9c/Action/ItemEnhancement4.cs index 7d8533fa2e..602947ce46 100644 --- a/Lib9c/Action/ItemEnhancement4.cs +++ b/Lib9c/Action/ItemEnhancement4.cs @@ -141,6 +141,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement5.cs b/Lib9c/Action/ItemEnhancement5.cs index 16c214323b..b5d40f56ac 100644 --- a/Lib9c/Action/ItemEnhancement5.cs +++ b/Lib9c/Action/ItemEnhancement5.cs @@ -141,6 +141,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement6.cs b/Lib9c/Action/ItemEnhancement6.cs index ed3a45ee11..34f5b5ef07 100644 --- a/Lib9c/Action/ItemEnhancement6.cs +++ b/Lib9c/Action/ItemEnhancement6.cs @@ -143,6 +143,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement7.cs b/Lib9c/Action/ItemEnhancement7.cs index ed17d50fa6..f32bbeb2d4 100644 --- a/Lib9c/Action/ItemEnhancement7.cs +++ b/Lib9c/Action/ItemEnhancement7.cs @@ -186,6 +186,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement8.cs b/Lib9c/Action/ItemEnhancement8.cs index 591865abd4..fbe7dda610 100644 --- a/Lib9c/Action/ItemEnhancement8.cs +++ b/Lib9c/Action/ItemEnhancement8.cs @@ -150,6 +150,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (requiredNCG > 0) { states = states.TransferAsset( + ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNCG diff --git a/Lib9c/Action/ItemEnhancement9.cs b/Lib9c/Action/ItemEnhancement9.cs index 82165e10fd..ca6ffece86 100644 --- a/Lib9c/Action/ItemEnhancement9.cs +++ b/Lib9c/Action/ItemEnhancement9.cs @@ -273,7 +273,7 @@ public override IAccountStateDelta Execute(IActionContext context) var requiredNcg = row.Cost; if (requiredNcg > 0) { - states = states.TransferAsset(ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNcg); + states = states.TransferAsset(ctx, ctx.Signer, BlacksmithAddress, states.GetGoldCurrency() * requiredNcg); } // Unequip items diff --git a/Lib9c/Action/JoinArena.cs b/Lib9c/Action/JoinArena.cs index 3ab151dc77..a6bf195a79 100644 --- a/Lib9c/Action/JoinArena.cs +++ b/Lib9c/Action/JoinArena.cs @@ -162,7 +162,7 @@ public override IAccountStateDelta Execute(IActionContext context) } var arenaAdr = ArenaHelper.DeriveArenaAddress(roundData.ChampionshipId, roundData.Round); - states = states.TransferAsset(context.Signer, arenaAdr, fee); + states = states.TransferAsset(context, context.Signer, arenaAdr, fee); } // check medal diff --git a/Lib9c/Action/JoinArena1.cs b/Lib9c/Action/JoinArena1.cs index 628c236fc6..5ce926e389 100644 --- a/Lib9c/Action/JoinArena1.cs +++ b/Lib9c/Action/JoinArena1.cs @@ -145,7 +145,7 @@ public override IAccountStateDelta Execute(IActionContext context) } var arenaAdr = ArenaHelper.DeriveArenaAddress(roundData.ChampionshipId, roundData.Round); - states = states.TransferAsset(context.Signer, arenaAdr, fee); + states = states.TransferAsset(context, context.Signer, arenaAdr, fee); } // check medal diff --git a/Lib9c/Action/JoinArena2.cs b/Lib9c/Action/JoinArena2.cs index cce8f2175d..f38c2bc559 100644 --- a/Lib9c/Action/JoinArena2.cs +++ b/Lib9c/Action/JoinArena2.cs @@ -165,7 +165,7 @@ public override IAccountStateDelta Execute(IActionContext context) } var arenaAdr = ArenaHelper.DeriveArenaAddress(roundData.ChampionshipId, roundData.Round); - states = states.TransferAsset(context.Signer, arenaAdr, fee); + states = states.TransferAsset(context, context.Signer, arenaAdr, fee); } // check medal diff --git a/Lib9c/Action/MigrateMonsterCollection.cs b/Lib9c/Action/MigrateMonsterCollection.cs index 1896999bb1..877aae43e5 100644 --- a/Lib9c/Action/MigrateMonsterCollection.cs +++ b/Lib9c/Action/MigrateMonsterCollection.cs @@ -92,6 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states.SetState(monsterCollectionState.address, Null.Value) .SetState(migratedStakeStateAddress, migratedStakeState.SerializeV2()) .TransferAsset( + context, monsterCollectionState.address, migratedStakeStateAddress, states.GetBalance(monsterCollectionState.address, currency)); diff --git a/Lib9c/Action/MonsterCollect.cs b/Lib9c/Action/MonsterCollect.cs index f53436e302..2d09604dd2 100644 --- a/Lib9c/Action/MonsterCollect.cs +++ b/Lib9c/Action/MonsterCollect.cs @@ -96,7 +96,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Refund holding NCG to user FungibleAssetValue gold = states.GetBalance(monsterCollectionAddress, currency); - states = states.TransferAsset(monsterCollectionAddress, context.Signer, gold); + states = states.TransferAsset(context, monsterCollectionAddress, context.Signer, gold); } if (level == 0) @@ -119,7 +119,7 @@ public override IAccountStateDelta Execute(IActionContext context) requiredGold ); } - states = states.TransferAsset(context.Signer, monsterCollectionAddress, requiredGold); + states = states.TransferAsset(context, context.Signer, monsterCollectionAddress, requiredGold); states = states.SetState(monsterCollectionAddress, monsterCollectionState.Serialize()); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}MonsterCollect Total Executed Time: {Elapsed}", addressesHex, ended - started); diff --git a/Lib9c/Action/MonsterCollect0.cs b/Lib9c/Action/MonsterCollect0.cs index 972657e905..72632152fa 100644 --- a/Lib9c/Action/MonsterCollect0.cs +++ b/Lib9c/Action/MonsterCollect0.cs @@ -102,7 +102,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.Signer, requiredGold); } - states = states.TransferAsset(context.Signer, monsterCollectionAddress, requiredGold); + states = states.TransferAsset(context, context.Signer, monsterCollectionAddress, requiredGold); states = states.SetState(monsterCollectionAddress, monsterCollectionState.Serialize()); return states; } diff --git a/Lib9c/Action/MonsterCollect2.cs b/Lib9c/Action/MonsterCollect2.cs index 015bfade99..e251cfa5ee 100644 --- a/Lib9c/Action/MonsterCollect2.cs +++ b/Lib9c/Action/MonsterCollect2.cs @@ -85,7 +85,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Refund holding NCG to user FungibleAssetValue gold = states.GetBalance(monsterCollectionAddress, currency); - states = states.TransferAsset(monsterCollectionAddress, context.Signer, gold); + states = states.TransferAsset(context, monsterCollectionAddress, context.Signer, gold); } if (level == 0) @@ -106,7 +106,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.Signer, requiredGold); } - states = states.TransferAsset(context.Signer, monsterCollectionAddress, requiredGold); + states = states.TransferAsset(context, context.Signer, monsterCollectionAddress, requiredGold); states = states.SetState(monsterCollectionAddress, monsterCollectionState.Serialize()); return states; } diff --git a/Lib9c/Action/PetEnhancement.cs b/Lib9c/Action/PetEnhancement.cs index e5be53fcf5..ac60cfbc7c 100644 --- a/Lib9c/Action/PetEnhancement.cs +++ b/Lib9c/Action/PetEnhancement.cs @@ -147,7 +147,7 @@ public override IAccountStateDelta Execute(IActionContext context) currentNcg); } - states = states.TransferAsset(context.Signer, feeStoreAddress, ncgCost); + states = states.TransferAsset(context, context.Signer, feeStoreAddress, ncgCost); } if (soulStoneQuantity > 0) @@ -166,6 +166,7 @@ public override IAccountStateDelta Execute(IActionContext context) } states = states.TransferAsset( + context, AvatarAddress, feeStoreAddress, soulStoneCost); diff --git a/Lib9c/Action/PrepareRewardAssets.cs b/Lib9c/Action/PrepareRewardAssets.cs index fbef1f6b20..1ed14c646d 100644 --- a/Lib9c/Action/PrepareRewardAssets.cs +++ b/Lib9c/Action/PrepareRewardAssets.cs @@ -63,7 +63,7 @@ public override IAccountStateDelta Execute(IActionContext context) { throw new CurrencyPermissionException(null, context.Signer, asset.Currency); } - states = states.MintAsset(RewardPoolAddress, asset); + states = states.MintAsset(context, RewardPoolAddress, asset); } return states; diff --git a/Lib9c/Action/Raid.cs b/Lib9c/Action/Raid.cs index 368357a088..59b4ea1c2f 100644 --- a/Lib9c/Action/Raid.cs +++ b/Lib9c/Action/Raid.cs @@ -110,7 +110,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (row.EntranceFee > 0) { FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); } Address raiderListAddress = Addresses.GetRaiderListAddress(raidId); List
raiderList = @@ -144,7 +144,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -280,11 +280,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/Raid1.cs b/Lib9c/Action/Raid1.cs index 0ccd89ea7b..34f1dca013 100644 --- a/Lib9c/Action/Raid1.cs +++ b/Lib9c/Action/Raid1.cs @@ -103,7 +103,7 @@ public override IAccountStateDelta Execute(IActionContext context) { raiderState = new RaiderState(); FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); } if (context.BlockIndex - raiderState.UpdatedBlockIndex < Raid4.RequiredInterval) @@ -126,7 +126,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -200,11 +200,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/Raid2.cs b/Lib9c/Action/Raid2.cs index 8e3ae4f4e7..d6a54b530c 100644 --- a/Lib9c/Action/Raid2.cs +++ b/Lib9c/Action/Raid2.cs @@ -106,7 +106,7 @@ public override IAccountStateDelta Execute(IActionContext context) { raiderState = new RaiderState(); FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); Address raiderListAddress = Addresses.GetRaiderListAddress(raidId); List
raiderList = states.TryGetState(raiderListAddress, out List rawRaiderList) @@ -137,7 +137,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -211,11 +211,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/Raid3.cs b/Lib9c/Action/Raid3.cs index 57a99e2ec4..dbda5f89ac 100644 --- a/Lib9c/Action/Raid3.cs +++ b/Lib9c/Action/Raid3.cs @@ -111,7 +111,7 @@ public override IAccountStateDelta Execute(IActionContext context) { raiderState = new RaiderState(); FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); Address raiderListAddress = Addresses.GetRaiderListAddress(raidId); List
raiderList = states.TryGetState(raiderListAddress, out List rawRaiderList) @@ -142,7 +142,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -278,11 +278,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/Raid4.cs b/Lib9c/Action/Raid4.cs index 19f8905954..567a8d2a3b 100644 --- a/Lib9c/Action/Raid4.cs +++ b/Lib9c/Action/Raid4.cs @@ -112,7 +112,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (row.EntranceFee > 0) { FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); } Address raiderListAddress = Addresses.GetRaiderListAddress(raidId); List
raiderList = @@ -144,7 +144,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -280,11 +280,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/Raid5.cs b/Lib9c/Action/Raid5.cs index 45e59f0c79..088424e8bc 100644 --- a/Lib9c/Action/Raid5.cs +++ b/Lib9c/Action/Raid5.cs @@ -111,7 +111,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (row.EntranceFee > 0) { FungibleAssetValue crystalCost = CrystalCalculator.CalculateEntranceFee(avatarState.level, row.EntranceFee); - states = states.TransferAsset(context.Signer, worldBossAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, worldBossAddress, crystalCost); } Address raiderListAddress = Addresses.GetRaiderListAddress(raidId); List
raiderList = @@ -145,7 +145,7 @@ public override IAccountStateDelta Execute(IActionContext context) throw new ExceedTicketPurchaseLimitException(""); } var goldCurrency = states.GetGoldCurrency(); - states = states.TransferAsset(context.Signer, worldBossAddress, + states = states.TransferAsset(context, context.Signer, worldBossAddress, WorldBossHelper.CalculateTicketPrice(row, raiderState, goldCurrency)); raiderState.PurchaseCount++; } @@ -281,11 +281,11 @@ public override IAccountStateDelta Execute(IActionContext context) { if (battleReward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(context.Signer, battleReward); + states = states.MintAsset(context, context.Signer, battleReward); } else { - states = states.MintAsset(AvatarAddress, battleReward); + states = states.MintAsset(context, AvatarAddress, battleReward); } } diff --git a/Lib9c/Action/RankingBattle0.cs b/Lib9c/Action/RankingBattle0.cs index d80cef9f56..de775be910 100644 --- a/Lib9c/Action/RankingBattle0.cs +++ b/Lib9c/Action/RankingBattle0.cs @@ -133,6 +133,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (agentBalance >= new FungibleAssetValue(agentBalance.Currency, EntranceFee, 0)) { states = states.TransferAsset( + ctx, ctx.Signer, WeeklyArenaAddress, new FungibleAssetValue( diff --git a/Lib9c/Action/RedeemCode.cs b/Lib9c/Action/RedeemCode.cs index 3d10c29865..bb6c724b9b 100644 --- a/Lib9c/Action/RedeemCode.cs +++ b/Lib9c/Action/RedeemCode.cs @@ -113,6 +113,7 @@ public override IAccountStateDelta Execute(IActionContext context) break; case RewardType.Gold: states = states.TransferAsset( + context, GoldCurrencyState.Address, context.Signer, states.GetGoldCurrency() * info.Quantity diff --git a/Lib9c/Action/RedeemCode0.cs b/Lib9c/Action/RedeemCode0.cs index 77be230aee..1bd9411fcf 100644 --- a/Lib9c/Action/RedeemCode0.cs +++ b/Lib9c/Action/RedeemCode0.cs @@ -103,6 +103,7 @@ public override IAccountStateDelta Execute(IActionContext context) break; case RewardType.Gold: states = states.TransferAsset( + context, GoldCurrencyState.Address, context.Signer, states.GetGoldCurrency() * info.Quantity diff --git a/Lib9c/Action/RedeemCode2.cs b/Lib9c/Action/RedeemCode2.cs index 39ac04a3d6..6a0cd57bf5 100644 --- a/Lib9c/Action/RedeemCode2.cs +++ b/Lib9c/Action/RedeemCode2.cs @@ -109,6 +109,7 @@ public override IAccountStateDelta Execute(IActionContext context) break; case RewardType.Gold: states = states.TransferAsset( + context, GoldCurrencyState.Address, context.Signer, states.GetGoldCurrency() * info.Quantity diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index d7c3c30a77..9ac54f7537 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -212,7 +212,7 @@ public static IAccountStateDelta Register(IActionContext context, IRegisterInfo SellerAvatarAddress = assetInfo.AvatarAddress, }; states = states - .TransferAsset(avatarState.address, productAddress, asset) + .TransferAsset(context, avatarState.address, productAddress, asset) .SetState(productAddress, product.Serialize()); productsState.ProductIds.Add(productId); break; diff --git a/Lib9c/Action/RegisterProduct0.cs b/Lib9c/Action/RegisterProduct0.cs index 86d1213fd6..2a83cbdadb 100644 --- a/Lib9c/Action/RegisterProduct0.cs +++ b/Lib9c/Action/RegisterProduct0.cs @@ -212,7 +212,7 @@ public static IAccountStateDelta Register(IActionContext context, IRegisterInfo SellerAvatarAddress = assetInfo.AvatarAddress, }; states = states - .TransferAsset(avatarState.address, productAddress, asset) + .TransferAsset(context, avatarState.address, productAddress, asset) .SetState(productAddress, product.Serialize()); productsState.ProductIds.Add(productId); break; diff --git a/Lib9c/Action/RequestPledge.cs b/Lib9c/Action/RequestPledge.cs index 043a98a26e..484b1d35bc 100644 --- a/Lib9c/Action/RequestPledge.cs +++ b/Lib9c/Action/RequestPledge.cs @@ -45,7 +45,7 @@ public override IAccountStateDelta Execute(IActionContext context) } return states - .TransferAsset(context.Signer, AgentAddress, 1 * Currencies.Mead) + .TransferAsset(context, context.Signer, AgentAddress, 1 * Currencies.Mead) .SetState( contractAddress, List.Empty diff --git a/Lib9c/Action/RewardGold.cs b/Lib9c/Action/RewardGold.cs index 6890138f1b..4f3300ae6e 100644 --- a/Lib9c/Action/RewardGold.cs +++ b/Lib9c/Action/RewardGold.cs @@ -83,6 +83,7 @@ public IAccountStateDelta GenesisGoldDistribution(IActionContext ctx, IAccountSt fav = fav.DivRem(100, out FungibleAssetValue _); } states = states.TransferAsset( + ctx, fund, distribution.Address, fav @@ -291,6 +292,7 @@ public IAccountStateDelta MinerReward(IActionContext ctx, IAccountStateDelta sta if (miningReward >= FungibleAssetValue.Parse(currency, "1.25")) { states = states.TransferAsset( + ctx, GoldCurrencyState.Address, ctx.Miner, miningReward diff --git a/Lib9c/Action/RuneEnhancement.cs b/Lib9c/Action/RuneEnhancement.cs index c5a3a65c26..1b14a3f45d 100644 --- a/Lib9c/Action/RuneEnhancement.cs +++ b/Lib9c/Action/RuneEnhancement.cs @@ -127,19 +127,19 @@ public override IAccountStateDelta Execute(IActionContext context) var ncgCost = cost.NcgQuantity * tryCount * ncgCurrency; if (cost.NcgQuantity > 0) { - states = states.TransferAsset(context.Signer, feeStoreAddress, ncgCost); + states = states.TransferAsset(context, context.Signer, feeStoreAddress, ncgCost); } var crystalCost = cost.CrystalQuantity * tryCount * crystalCurrency; if (cost.CrystalQuantity > 0) { - states = states.TransferAsset(context.Signer, feeStoreAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, feeStoreAddress, crystalCost); } var runeCost = cost.RuneStoneQuantity * tryCount * runeCurrency; if (cost.RuneStoneQuantity > 0) { - states = states.TransferAsset(AvatarAddress, feeStoreAddress, runeCost); + states = states.TransferAsset(context, AvatarAddress, feeStoreAddress, runeCost); } return states; diff --git a/Lib9c/Action/RuneEnhancement0.cs b/Lib9c/Action/RuneEnhancement0.cs index 8ec164c993..7670f8431a 100644 --- a/Lib9c/Action/RuneEnhancement0.cs +++ b/Lib9c/Action/RuneEnhancement0.cs @@ -125,19 +125,19 @@ public override IAccountStateDelta Execute(IActionContext context) var ncgCost = cost.NcgQuantity * tryCount * ncgCurrency; if (cost.NcgQuantity > 0) { - states = states.TransferAsset(context.Signer, feeStoreAddress, ncgCost); + states = states.TransferAsset(context, context.Signer, feeStoreAddress, ncgCost); } var crystalCost = cost.CrystalQuantity * tryCount * crystalCurrency; if (cost.CrystalQuantity > 0) { - states = states.TransferAsset(context.Signer, feeStoreAddress, crystalCost); + states = states.TransferAsset(context, context.Signer, feeStoreAddress, crystalCost); } var runeCost = cost.RuneStoneQuantity * tryCount * runeCurrency; if (cost.RuneStoneQuantity > 0) { - states = states.TransferAsset(AvatarAddress, feeStoreAddress, runeCost); + states = states.TransferAsset(context, AvatarAddress, feeStoreAddress, runeCost); } return states; diff --git a/Lib9c/Action/SecureMiningReward.cs b/Lib9c/Action/SecureMiningReward.cs index 632ca75e99..e3f836fea6 100644 --- a/Lib9c/Action/SecureMiningReward.cs +++ b/Lib9c/Action/SecureMiningReward.cs @@ -76,9 +76,9 @@ public override IAccountStateDelta Execute(IActionContext context) FungibleAssetValue toRecipient = balance.DivRem(100, out _) * EarnRate; FungibleAssetValue toBurn = balance - (toTreasury + toRecipient); - state = state.TransferAsset(minerAddress, Treasury, toTreasury); - state = state.TransferAsset(minerAddress, Recipient, toRecipient); - state = state.TransferAsset(minerAddress, Nil, toBurn); + state = state.TransferAsset(context, minerAddress, Treasury, toTreasury); + state = state.TransferAsset(context, minerAddress, Recipient, toRecipient); + state = state.TransferAsset(context, minerAddress, Nil, toBurn); } return state; diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index a5162b47e2..0b7b5f1b08 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -98,7 +98,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState( stakeStateAddress, stakeState.SerializeV2()) - .TransferAsset(context.Signer, stakeStateAddress, targetStakeBalance); + .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance); } if (stakeState.IsClaimable(context.BlockIndex)) @@ -119,8 +119,9 @@ public override IAccountStateDelta Execute(IActionContext context) { if (stakeState.IsCancellable(context.BlockIndex)) { - return states.SetState(stakeState.address, Null.Value) - .TransferAsset(stakeState.address, context.Signer, stakedBalance); + return states + .SetState(stakeState.address, Null.Value) + .TransferAsset(context, stakeState.address, context.Signer, stakedBalance); } } @@ -128,8 +129,9 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}Stake Total Executed Time: {Elapsed}", addressesHex, ended - started); // Stake with more or less amount. - return states.TransferAsset(stakeState.address, context.Signer, stakedBalance) - .TransferAsset(context.Signer, stakeState.address, targetStakeBalance) + return states + .TransferAsset(context, stakeState.address, context.Signer, stakedBalance) + .TransferAsset(context, context.Signer, stakeState.address, targetStakeBalance) .SetState( stakeState.address, new StakeState(stakeState.address, context.BlockIndex).SerializeV2()); diff --git a/Lib9c/Action/Stake0.cs b/Lib9c/Action/Stake0.cs index d0ae7ca2c5..a0c3b7d3cc 100644 --- a/Lib9c/Action/Stake0.cs +++ b/Lib9c/Action/Stake0.cs @@ -103,7 +103,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState( stakeStateAddress, stakeState.SerializeV2()) - .TransferAsset(context.Signer, stakeStateAddress, targetStakeBalance); + .TransferAsset(context, context.Signer, stakeStateAddress, targetStakeBalance); } if (stakeState.IsClaimable(context.BlockIndex)) @@ -124,14 +124,16 @@ public override IAccountStateDelta Execute(IActionContext context) { if (stakeState.IsCancellable(context.BlockIndex)) { - return states.SetState(stakeState.address, Null.Value) - .TransferAsset(stakeState.address, context.Signer, stakedBalance); + return states + .SetState(stakeState.address, Null.Value) + .TransferAsset(context, stakeState.address, context.Signer, stakedBalance); } } // Stake with more or less amount. - return states.TransferAsset(stakeState.address, context.Signer, stakedBalance) - .TransferAsset(context.Signer, stakeState.address, targetStakeBalance) + return states + .TransferAsset(context, stakeState.address, context.Signer, stakedBalance) + .TransferAsset(context, context.Signer, stakeState.address, targetStakeBalance) .SetState( stakeState.address, new StakeState(stakeState.address, context.BlockIndex).SerializeV2()); diff --git a/Lib9c/Action/TransferAsset.cs b/Lib9c/Action/TransferAsset.cs index 44c1c67dc8..d1bf8e6569 100644 --- a/Lib9c/Action/TransferAsset.cs +++ b/Lib9c/Action/TransferAsset.cs @@ -119,7 +119,7 @@ public override IAccountStateDelta Execute(IActionContext context) TransferAsset3.CheckCrystalSender(currency, context.BlockIndex, Sender); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}TransferAsset4 Total Executed Time: {Elapsed}", addressesHex, ended - started); - return state.TransferAsset(Sender, Recipient, Amount); + return state.TransferAsset(context, Sender, Recipient, Amount); } public override void LoadPlainValue(IValue plainValue) diff --git a/Lib9c/Action/TransferAsset0.cs b/Lib9c/Action/TransferAsset0.cs index 17113cc093..a00d8dfdcf 100644 --- a/Lib9c/Action/TransferAsset0.cs +++ b/Lib9c/Action/TransferAsset0.cs @@ -108,7 +108,7 @@ public override IAccountStateDelta Execute(IActionContext context) ); } - return state.TransferAsset(Sender, Recipient, Amount); + return state.TransferAsset(context, Sender, Recipient, Amount); } public override void LoadPlainValue(IValue plainValue) diff --git a/Lib9c/Action/TransferAsset2.cs b/Lib9c/Action/TransferAsset2.cs index 55138f9c7c..bd51e27d1d 100644 --- a/Lib9c/Action/TransferAsset2.cs +++ b/Lib9c/Action/TransferAsset2.cs @@ -133,7 +133,7 @@ public override IAccountStateDelta Execute(IActionContext context) var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}TransferAsset2 Total Executed Time: {Elapsed}", addressesHex, ended - started); - return state.TransferAsset(Sender, Recipient, Amount); + return state.TransferAsset(context, Sender, Recipient, Amount); } public override void LoadPlainValue(IValue plainValue) diff --git a/Lib9c/Action/TransferAsset3.cs b/Lib9c/Action/TransferAsset3.cs index d225043498..d16939c6e1 100644 --- a/Lib9c/Action/TransferAsset3.cs +++ b/Lib9c/Action/TransferAsset3.cs @@ -152,7 +152,7 @@ public override IAccountStateDelta Execute(IActionContext context) CheckCrystalSender(currency, context.BlockIndex, Sender); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}TransferAsset3 Total Executed Time: {Elapsed}", addressesHex, ended - started); - return state.TransferAsset(Sender, Recipient, Amount); + return state.TransferAsset(context, Sender, Recipient, Amount); } public override void LoadPlainValue(IValue plainValue) diff --git a/Lib9c/Action/TransferAssets.cs b/Lib9c/Action/TransferAssets.cs index 3f5be50239..0fb592a639 100644 --- a/Lib9c/Action/TransferAssets.cs +++ b/Lib9c/Action/TransferAssets.cs @@ -96,7 +96,7 @@ public override IAccountStateDelta Execute(IActionContext context) var started = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}{ActionName} exec started", addressesHex, TypeIdentifier); - state = Recipients.Aggregate(state, (current, t) => Transfer(current, context.Signer, t.recipient, t.amount, context.BlockIndex)); + state = Recipients.Aggregate(state, (current, t) => Transfer(context, current, context.Signer, t.recipient, t.amount, context.BlockIndex)); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}{ActionName} Total Executed Time: {Elapsed}", addressesHex, TypeIdentifier, ended - started); @@ -135,7 +135,8 @@ private void CheckMemoLength(string memo) } } - private IAccountStateDelta Transfer(IAccountStateDelta state, Address signer, Address recipient, FungibleAssetValue amount, long blockIndex) + private IAccountStateDelta Transfer( + IActionContext context, IAccountStateDelta state, Address signer, Address recipient, FungibleAssetValue amount, long blockIndex) { if (Sender != signer) { @@ -159,7 +160,7 @@ private IAccountStateDelta Transfer(IAccountStateDelta state, Address signer, Ad } TransferAsset3.CheckCrystalSender(currency, blockIndex, Sender); - return state.TransferAsset(Sender, recipient, amount); + return state.TransferAsset(context, Sender, recipient, amount); } } } diff --git a/Lib9c/Action/TransferAssets0.cs b/Lib9c/Action/TransferAssets0.cs index 0eb108b9cf..373e19a5b8 100644 --- a/Lib9c/Action/TransferAssets0.cs +++ b/Lib9c/Action/TransferAssets0.cs @@ -102,7 +102,7 @@ public override IAccountStateDelta Execute(IActionContext context) ? new ActivatedAccountsState(asDict) : new ActivatedAccountsState(); - state = Recipients.Aggregate(state, (current, t) => Transfer(current, context.Signer, t.recipient, t.amount, activatedAccountsState, context.BlockIndex)); + state = Recipients.Aggregate(state, (current, t) => Transfer(context, current, context.Signer, t.recipient, t.amount, activatedAccountsState, context.BlockIndex)); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}transfer_assets Total Executed Time: {Elapsed}", addressesHex, ended - started); @@ -141,7 +141,8 @@ private void CheckMemoLength(string memo) } } - private IAccountStateDelta Transfer(IAccountStateDelta state, Address signer, Address recipient, FungibleAssetValue amount, ActivatedAccountsState activatedAccountsState, long blockIndex) + private IAccountStateDelta Transfer( + IActionContext context, IAccountStateDelta state, Address signer, Address recipient, FungibleAssetValue amount, ActivatedAccountsState activatedAccountsState, long blockIndex) { if (Sender != signer) { @@ -184,7 +185,7 @@ private IAccountStateDelta Transfer(IAccountStateDelta state, Address signer, Ad } TransferAsset3.CheckCrystalSender(currency, blockIndex, Sender); - return state.TransferAsset(Sender, recipient, amount); + return state.TransferAsset(context, Sender, recipient, amount); } } } diff --git a/Lib9c/Action/UnlockEquipmentRecipe.cs b/Lib9c/Action/UnlockEquipmentRecipe.cs index 95ad860b9a..5ba7dd71a6 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe.cs @@ -103,7 +103,7 @@ public override IAccountStateDelta Execute(IActionContext context) (current, address) => current.Add(address.Serialize()))); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}UnlockEquipmentRecipe Total Executed Time: {Elapsed}", addressesHex, ended - started); - return states.TransferAsset(context.Signer, Addresses.UnlockEquipmentRecipe, cost); + return states.TransferAsset(context, context.Signer, Addresses.UnlockEquipmentRecipe, cost); } public static List UnlockedIds( diff --git a/Lib9c/Action/UnlockEquipmentRecipe1.cs b/Lib9c/Action/UnlockEquipmentRecipe1.cs index 54197cc651..81b4fc6dd3 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe1.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe1.cs @@ -106,7 +106,7 @@ public override IAccountStateDelta Execute(IActionContext context) (current, address) => current.Add(address.Serialize()))); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}UnlockEquipmentRecipe Total Executed Time: {Elapsed}", addressesHex, ended - started); - return states.TransferAsset(context.Signer, Addresses.UnlockEquipmentRecipe, cost); + return states.TransferAsset(context, context.Signer, Addresses.UnlockEquipmentRecipe, cost); } public static List UnlockedIds( diff --git a/Lib9c/Action/UnlockRuneSlot.cs b/Lib9c/Action/UnlockRuneSlot.cs index 327e2d147d..a42d794a17 100644 --- a/Lib9c/Action/UnlockRuneSlot.cs +++ b/Lib9c/Action/UnlockRuneSlot.cs @@ -99,7 +99,7 @@ public override IAccountStateDelta Execute(IActionContext context) raidSlotState.Unlock(SlotIndex); return states - .TransferAsset(context.Signer, feeStoreAddress, cost * ncgCurrency) + .TransferAsset(context, context.Signer, feeStoreAddress, cost * ncgCurrency) .SetState(adventureSlotStateAddress, adventureSlotState.Serialize()) .SetState(arenaSlotStateAddress, arenaSlotState.Serialize()) .SetState(raidSlotStateAddress, raidSlotState.Serialize()); diff --git a/Lib9c/Action/UnlockWorld.cs b/Lib9c/Action/UnlockWorld.cs index a036a19f6e..31debc9106 100644 --- a/Lib9c/Action/UnlockWorld.cs +++ b/Lib9c/Action/UnlockWorld.cs @@ -137,7 +137,7 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Debug("{AddressesHex}UnlockWorld Total Executed Time: {Elapsed}", addressesHex, ended - started); return states .SetState(unlockedWorldIdsAddress, new List(unlockedIds.Select(i => i.Serialize()))) - .TransferAsset(context.Signer, Addresses.UnlockWorld, cost); + .TransferAsset(context, context.Signer, Addresses.UnlockWorld, cost); } protected override IImmutableDictionary PlainValueInternal diff --git a/Lib9c/Action/UnlockWorld1.cs b/Lib9c/Action/UnlockWorld1.cs index 743ce17db3..17659d92f8 100644 --- a/Lib9c/Action/UnlockWorld1.cs +++ b/Lib9c/Action/UnlockWorld1.cs @@ -129,7 +129,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states .SetState(unlockedWorldIdsAddress, new List(unlockedIds.Select(i => i.Serialize()))) - .TransferAsset(context.Signer, Addresses.UnlockWorld, cost); + .TransferAsset(context, context.Signer, Addresses.UnlockWorld, cost); } protected override IImmutableDictionary PlainValueInternal From 68b9b733f065cf1d534b0108b1311fa421a1f9a4 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 22 Jun 2023 18:24:38 +0900 Subject: [PATCH 18/68] Pass dummy context for rest of the code --- .../Action/AccountStateDeltaExtensionsTest.cs | 11 ++-- .Lib9c.Tests/Action/ActionContext.cs | 3 ++ .Lib9c.Tests/Action/ActionEvaluationTest.cs | 3 +- .Lib9c.Tests/Action/BattleArena10Test.cs | 45 ++++++++++++++--- .Lib9c.Tests/Action/BattleArena11Test.cs | 45 ++++++++++++++--- .Lib9c.Tests/Action/BattleArena12Test.cs | 45 ++++++++++++++--- .Lib9c.Tests/Action/BattleArena1Test.cs | 21 ++++---- .Lib9c.Tests/Action/BattleArena2Test.cs | 38 ++++++++------ .Lib9c.Tests/Action/BattleArena3Test.cs | 38 ++++++++------ .Lib9c.Tests/Action/BattleArena4Test.cs | 50 +++++++++++-------- .Lib9c.Tests/Action/BattleArena5Test.cs | 30 +++++++++-- .Lib9c.Tests/Action/BattleArena6Test.cs | 35 +++++++++++-- .Lib9c.Tests/Action/BattleArena7Test.cs | 35 +++++++++++-- .Lib9c.Tests/Action/BattleArena8Test.cs | 45 ++++++++++++++--- .Lib9c.Tests/Action/BattleArena9Test.cs | 45 ++++++++++++++--- .Lib9c.Tests/Action/Buy10Test.cs | 6 ++- .Lib9c.Tests/Action/Buy11Test.cs | 6 ++- .Lib9c.Tests/Action/Buy2Test.cs | 3 +- .Lib9c.Tests/Action/Buy3Test.cs | 6 ++- .Lib9c.Tests/Action/Buy4Test.cs | 6 ++- .Lib9c.Tests/Action/Buy5Test.cs | 6 ++- .Lib9c.Tests/Action/Buy6Test.cs | 6 ++- .Lib9c.Tests/Action/Buy7Test.cs | 6 ++- .Lib9c.Tests/Action/Buy8Test.cs | 6 ++- .Lib9c.Tests/Action/Buy9Test.cs | 6 ++- .Lib9c.Tests/Action/BuyMultipleTest.cs | 6 ++- .Lib9c.Tests/Action/BuyProduct0Test.cs | 3 +- .Lib9c.Tests/Action/BuyProductTest.cs | 3 +- .Lib9c.Tests/Action/BuyTest.cs | 6 ++- .../Action/CancelMonsterCollectTest.cs | 3 +- .../Action/CancelProductRegistrationTest.cs | 3 +- .../ClaimMonsterCollectionReward0Test.cs | 3 +- .Lib9c.Tests/Action/ClaimStakeReward1Test.cs | 3 +- .Lib9c.Tests/Action/ClaimStakeReward2Test.cs | 3 +- .Lib9c.Tests/Action/ClaimStakeReward3Test.cs | 3 +- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 3 +- .../Action/CombinationEquipment0Test.cs | 3 +- .../Action/CombinationEquipment10Test.cs | 6 ++- .../Action/CombinationEquipment11Test.cs | 6 ++- .../Action/CombinationEquipment12Test.cs | 4 +- .../Action/CombinationEquipment13Test.cs | 7 ++- .../Action/CombinationEquipment14Test.cs | 7 ++- .../Action/CombinationEquipment15Test.cs | 7 ++- .../Action/CombinationEquipment2Test.cs | 3 +- .../Action/CombinationEquipment3Test.cs | 3 +- .../Action/CombinationEquipment4Test.cs | 3 +- .../Action/CombinationEquipment5Test.cs | 3 +- .../Action/CombinationEquipment6Test.cs | 3 +- .../Action/CombinationEquipment7Test.cs | 3 +- .../Action/CombinationEquipment8Test.cs | 3 +- .../Action/CombinationEquipment9Test.cs | 3 +- .../Action/CombinationEquipmentTest.cs | 7 ++- .Lib9c.Tests/Action/CreateAvatar0Test.cs | 3 +- .Lib9c.Tests/Action/CreateAvatar2Test.cs | 3 +- .Lib9c.Tests/Action/CreateAvatar3Test.cs | 3 +- .Lib9c.Tests/Action/CreateAvatar6Test.cs | 3 +- .Lib9c.Tests/Action/CreatePledgeTest.cs | 3 +- .Lib9c.Tests/Action/EndPledgeTest.cs | 3 +- .../Action/EventDungeonBattleV1Test.cs | 6 ++- .../Action/EventDungeonBattleV2Test.cs | 6 ++- .../Action/EventDungeonBattleV3Test.cs | 6 ++- .../Action/EventDungeonBattleV4Test.cs | 9 ++-- .../Action/EventDungeonBattleV5Test.cs | 9 ++-- .Lib9c.Tests/Action/GrindingTest.cs | 5 +- .Lib9c.Tests/Action/HackAndSlash18Test.cs | 3 +- .Lib9c.Tests/Action/HackAndSlash19Test.cs | 3 +- .Lib9c.Tests/Action/HackAndSlash20Test.cs | 9 ++-- .Lib9c.Tests/Action/HackAndSlash21Test.cs | 9 ++-- .../Action/HackAndSlashRandomBuffTest.cs | 6 ++- .Lib9c.Tests/Action/HackAndSlashSweep6Test.cs | 3 +- .Lib9c.Tests/Action/HackAndSlashSweep7Test.cs | 3 +- .Lib9c.Tests/Action/HackAndSlashSweep8Test.cs | 3 +- .Lib9c.Tests/Action/HackAndSlashSweep9Test.cs | 8 +-- .Lib9c.Tests/Action/ItemEnhancement0Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement2Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement3Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement4Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement5Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement6Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement7Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement8Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 5 +- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 10 ++-- .Lib9c.Tests/Action/JoinArena1Test.cs | 6 ++- .Lib9c.Tests/Action/JoinArena2Test.cs | 6 ++- .Lib9c.Tests/Action/JoinArena3Test.cs | 11 ++-- .../Action/MigrateMonsterCollectionTest.cs | 6 ++- .../Action/MimisbrunnrBattle12Test.cs | 3 +- .../Action/MimisbrunnrBattle13Test.cs | 3 +- .Lib9c.Tests/Action/MonsterCollect0Test.cs | 3 +- .Lib9c.Tests/Action/MonsterCollect2Test.cs | 5 +- .Lib9c.Tests/Action/MonsterCollectTest.cs | 5 +- .Lib9c.Tests/Action/PetEnhancement0Test.cs | 6 ++- .Lib9c.Tests/Action/Raid1Test.cs | 5 +- .Lib9c.Tests/Action/Raid2Test.cs | 5 +- .Lib9c.Tests/Action/Raid3Test.cs | 5 +- .Lib9c.Tests/Action/Raid4Test.cs | 7 +-- .Lib9c.Tests/Action/Raid5Test.cs | 7 +-- .Lib9c.Tests/Action/Raid6Test.cs | 7 +-- .Lib9c.Tests/Action/RankingBattle0Test.cs | 2 + .Lib9c.Tests/Action/RawState.cs | 6 ++- .Lib9c.Tests/Action/RedeemCode0Test.cs | 3 +- .Lib9c.Tests/Action/RedeemCodeTest.cs | 3 +- .Lib9c.Tests/Action/RegisterProduct0Test.cs | 3 +- .Lib9c.Tests/Action/RegisterProductTest.cs | 3 +- .Lib9c.Tests/Action/RequestPledgeTest.cs | 3 +- .Lib9c.Tests/Action/RewardGoldTest.cs | 12 +++-- .Lib9c.Tests/Action/RuneEnhancement0Test.cs | 20 ++++---- .Lib9c.Tests/Action/RuneEnhancementTest.cs | 20 ++++---- .../Action/Scenario/ArenaScenarioTest.cs | 3 +- .../Action/Scenario/MarketScenarioTest.cs | 18 ++++--- .../Action/Scenario/MeadScenarioTest.cs | 19 +++---- .../Pet/DiscountMaterialCostCrystalTest.cs | 3 +- .../Action/Scenario/RuneScenarioTest.cs | 3 +- .../StakeAndClaimStakeReward2ScenarioTest.cs | 15 ++++-- .../StakeAndClaimStakeReward3ScenarioTest.cs | 15 ++++-- .../StakeAndClaimStakeRewardScenarioTest.cs | 15 ++++-- .../Snapshot/TransferAsset0SnapshotTest.cs | 6 ++- .Lib9c.Tests/Action/Stake0Test.cs | 6 ++- .Lib9c.Tests/Action/StakeTest.cs | 6 ++- .Lib9c.Tests/Action/State.cs | 6 ++- .Lib9c.Tests/Action/TransferAssetTest.cs | 3 +- .../Action/UnlockEquipmentRecipe1Test.cs | 3 +- .../Action/UnlockEquipmentRecipeTest.cs | 3 +- .Lib9c.Tests/Action/UnlockRuneSlotTest.cs | 6 ++- .Lib9c.Tests/Action/UnlockWorld1Test.cs | 3 +- .Lib9c.Tests/Action/UnlockWorldTest.cs | 3 +- .Lib9c.Tests/TestHelper/BlockChainHelper.cs | 5 +- .Lib9c.Tests/Util/CurrencyUtil.cs | 4 +- .Lib9c.Tests/Util/InitializeUtil.cs | 4 +- Lib9c.DevExtensions/Action/CreateTestbed.cs | 4 +- Lib9c.DevExtensions/Action/FaucetCurrency.cs | 4 +- Lib9c.DevExtensions/Action/FaucetRune.cs | 2 +- Lib9c.DevExtensions/Action/ManipulateState.cs | 9 ++-- Lib9c.MessagePack/AccountStateDelta.cs | 5 +- Lib9c/Action/AccountStateDeltaExtensions.cs | 17 ++++--- Lib9c/Action/Buy0.cs | 1 + Lib9c/Action/Buy10.cs | 1 + Lib9c/Action/Buy11.cs | 1 + Lib9c/Action/Buy2.cs | 1 + Lib9c/Action/Buy3.cs | 1 + Lib9c/Action/Buy4.cs | 1 + Lib9c/Action/Buy5.cs | 1 + Lib9c/Action/Buy6.cs | 1 + Lib9c/Action/Buy7.cs | 1 + Lib9c/Action/Buy8.cs | 1 + Lib9c/Action/Buy9.cs | 1 + Lib9c/Action/BuyMultiple.cs | 1 + Lib9c/Action/CancelMonsterCollect.cs | 2 +- Lib9c/Action/ClaimWordBossKillReward.cs | 1 + Lib9c/Action/CombinationEquipment0.cs | 2 +- Lib9c/Action/CombinationEquipment10.cs | 2 +- Lib9c/Action/CombinationEquipment11.cs | 2 +- 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/CreateAvatar.cs | 2 +- Lib9c/Action/CreateAvatar0.cs | 2 +- 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/DailyReward.cs | 2 +- Lib9c/Action/DailyReward6.cs | 2 +- Lib9c/Action/Grinding.cs | 2 +- Lib9c/Action/ItemEnhancement0.cs | 2 +- Lib9c/Action/ItemEnhancement10.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/MonsterCollect.cs | 8 +-- Lib9c/Action/MonsterCollect0.cs | 2 +- Lib9c/Action/MonsterCollect2.cs | 8 +-- Lib9c/Action/PrepareRewardAssets.cs | 2 +- Lib9c/Action/Raid.cs | 1 + Lib9c/Action/Raid1.cs | 1 + Lib9c/Action/Raid2.cs | 1 + Lib9c/Action/Raid3.cs | 1 + Lib9c/Action/Raid4.cs | 1 + Lib9c/Action/Raid5.cs | 1 + Lib9c/Action/RankingBattle0.cs | 2 +- Lib9c/Action/RankingBattle2.cs | 2 +- Lib9c/Action/RankingBattle3.cs | 2 +- Lib9c/Action/RankingBattle4.cs | 2 +- Lib9c/Action/RedeemCode.cs | 4 +- Lib9c/Action/RedeemCode0.cs | 4 +- Lib9c/Action/RedeemCode2.cs | 4 +- Lib9c/Action/RewardGold.cs | 6 +-- Lib9c/Action/SecureMiningReward.cs | 1 + Lib9c/Action/Stake.cs | 1 + Lib9c/Action/Stake0.cs | 1 + Lib9c/Action/TransferAsset.cs | 2 +- Lib9c/Action/TransferAsset0.cs | 2 +- Lib9c/Action/TransferAsset2.cs | 2 +- Lib9c/Action/TransferAsset3.cs | 2 +- Lib9c/Action/TransferAssets.cs | 2 +- Lib9c/Action/TransferAssets0.cs | 2 +- Lib9c/Action/UnlockEquipmentRecipe.cs | 2 +- Lib9c/Action/UnlockEquipmentRecipe1.cs | 2 +- Lib9c/Action/UnlockWorld.cs | 2 +- Lib9c/Action/UnlockWorld1.cs | 2 +- 213 files changed, 904 insertions(+), 425 deletions(-) diff --git a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs index 63d4bfa27c..32fe6157f0 100644 --- a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs @@ -45,6 +45,7 @@ public AccountStateDeltaExtensionsTest() [InlineData(2, 2, 200, null)] public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrystal, Type exc) { + var context = new ActionContext(); IAccountStateDelta states = new State(); var rewardInfoAddress = new PrivateKey().ToAddress(); var rewardRecord = new WorldBossKillRewardRecord(); @@ -76,7 +77,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys if (exc is null) { - var nextState = states.SetWorldBossKillReward(rewardInfoAddress, rewardRecord, 0, bossState, runeWeightSheet, killRewardSheet, runeSheet, random, avatarAddress, _agentAddress); + var nextState = states.SetWorldBossKillReward(context, rewardInfoAddress, rewardRecord, 0, bossState, runeWeightSheet, killRewardSheet, runeSheet, random, avatarAddress, _agentAddress); Assert.Equal(expectedRune * runeCurrency, nextState.GetBalance(avatarAddress, runeCurrency)); Assert.Equal(expectedCrystal * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); var nextRewardInfo = new WorldBossKillRewardRecord((List)nextState.GetState(rewardInfoAddress)); @@ -87,6 +88,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys Assert.Throws( exc, () => states.SetWorldBossKillReward( + context, rewardInfoAddress, rewardRecord, 0, @@ -166,18 +168,19 @@ public void Mead(int agentBalance) var agentContractAddress = _agentAddress.GetPledgeAddress(); var mead = Currencies.Mead; var price = RequestPledge.DefaultRefillMead * mead; + ActionContext context = new ActionContext(); IAccountStateDelta states = new State() .SetState( agentContractAddress, List.Empty.Add(patron.Serialize()).Add(true.Serialize())) - .MintAsset(patron, price); + .MintAsset(context, patron, price); if (agentBalance > 0) { - states = states.MintAsset(_agentAddress, agentBalance * mead); + states = states.MintAsset(context, _agentAddress, agentBalance * mead); } - states = states.Mead(_agentAddress, 4); + states = states.Mead(context, _agentAddress, 4); Assert.Equal(agentBalance * mead, states.GetBalance(patron, mead)); Assert.Equal(price, states.GetBalance(_agentAddress, mead)); } diff --git a/.Lib9c.Tests/Action/ActionContext.cs b/.Lib9c.Tests/Action/ActionContext.cs index 1867ef3629..2d327a660c 100644 --- a/.Lib9c.Tests/Action/ActionContext.cs +++ b/.Lib9c.Tests/Action/ActionContext.cs @@ -24,6 +24,8 @@ public class ActionContext : IActionContext public long BlockIndex { get; set; } + public int BlockProtocolVersion { get; set; } + public bool Rehearsal { get; set; } public IAccountStateDelta PreviousStates { get; set; } @@ -51,6 +53,7 @@ public IActionContext GetUnconsumedContext() Miner = Miner, BlockHash = BlockHash, BlockIndex = BlockIndex, + BlockProtocolVersion = BlockProtocolVersion, Rehearsal = Rehearsal, PreviousStates = PreviousStates, Random = Random, diff --git a/.Lib9c.Tests/Action/ActionEvaluationTest.cs b/.Lib9c.Tests/Action/ActionEvaluationTest.cs index 2a8f6ae1b1..b21f2a16dc 100644 --- a/.Lib9c.Tests/Action/ActionEvaluationTest.cs +++ b/.Lib9c.Tests/Action/ActionEvaluationTest.cs @@ -26,6 +26,7 @@ public class ActionEvaluationTest public ActionEvaluationTest() { + var context = new ActionContext(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 _currency = Currency.Legacy("NCG", 2, null); @@ -35,7 +36,7 @@ public ActionEvaluationTest() _states = new State() .SetState(_signer, (Text)"ANYTHING") .SetState(default, Dictionary.Empty.Add("key", "value")) - .MintAsset(_signer, _currency * 10000); + .MintAsset(context, _signer, _currency * 10000); var resolver = MessagePack.Resolvers.CompositeResolver.Create( NineChroniclesResolver.Instance, StandardResolver.Instance diff --git a/.Lib9c.Tests/Action/BattleArena10Test.cs b/.Lib9c.Tests/Action/BattleArena10Test.cs index 3153d7fd4f..33430f903d 100644 --- a/.Lib9c.Tests/Action/BattleArena10Test.cs +++ b/.Lib9c.Tests/Action/BattleArena10Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena10 { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena10 { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -846,6 +867,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 int arenaInterval = 5; int randomSeed = 3; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -859,6 +881,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -867,6 +890,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -883,7 +907,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 } var ncgCurrency = previousStates.GetGoldCurrency(); - previousStates = previousStates.MintAsset(_agent1Address, 99999 * ncgCurrency); + previousStates = previousStates.MintAsset(context, _agent1Address, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { @@ -960,6 +984,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -978,6 +1003,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -986,6 +1012,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -1013,7 +1040,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena10 { @@ -1077,6 +1104,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -1090,6 +1118,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -1098,6 +1127,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -1123,7 +1153,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1255,6 +1285,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1264,7 +1295,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena11Test.cs b/.Lib9c.Tests/Action/BattleArena11Test.cs index b5eb5db560..9fa9e9d1af 100644 --- a/.Lib9c.Tests/Action/BattleArena11Test.cs +++ b/.Lib9c.Tests/Action/BattleArena11Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena11 { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena11 { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -846,6 +867,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 int arenaInterval = 5; int randomSeed = 3; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -859,6 +881,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -867,6 +890,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -883,7 +907,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 } var ncgCurrency = previousStates.GetGoldCurrency(); - previousStates = previousStates.MintAsset(_agent1Address, 99999 * ncgCurrency); + previousStates = previousStates.MintAsset(context, _agent1Address, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { @@ -958,6 +982,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 [Fact] public void Execute_ValidateDuplicateTicketPurchaseException() { + var context = new ActionContext(); const int championshipId = 1; const int round = 1; var previousStates = _initialStates; @@ -978,6 +1003,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -986,6 +1012,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -1013,7 +1040,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena11 { @@ -1077,6 +1104,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -1090,6 +1118,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -1098,6 +1127,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -1123,7 +1153,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1255,6 +1285,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1264,7 +1295,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena12Test.cs b/.Lib9c.Tests/Action/BattleArena12Test.cs index 4ff948fad8..767f8f3dcc 100644 --- a/.Lib9c.Tests/Action/BattleArena12Test.cs +++ b/.Lib9c.Tests/Action/BattleArena12Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -846,6 +867,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 int arenaInterval = 5; int randomSeed = 3; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -859,6 +881,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -867,6 +890,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -883,7 +907,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 } var ncgCurrency = previousStates.GetGoldCurrency(); - previousStates = previousStates.MintAsset(_agent1Address, 99999 * ncgCurrency); + previousStates = previousStates.MintAsset(context, _agent1Address, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { @@ -960,6 +984,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -978,6 +1003,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -986,6 +1012,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -1013,7 +1040,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena { @@ -1077,6 +1104,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -1090,6 +1118,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -1098,6 +1127,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -1123,7 +1153,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1255,6 +1285,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1264,7 +1295,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena1Test.cs b/.Lib9c.Tests/Action/BattleArena1Test.cs index c9778bab69..70798c7cb4 100644 --- a/.Lib9c.Tests/Action/BattleArena1Test.cs +++ b/.Lib9c.Tests/Action/BattleArena1Test.cs @@ -191,10 +191,10 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; - _state = _state.MintAsset(signer, preCurrency); + _state = _state.MintAsset(context, signer, preCurrency); var action = new JoinArena1() { @@ -225,6 +225,7 @@ public IAccountStateDelta JoinArena(Address signer, Address avatarAddress, long [InlineData(1, 1, 2, 5, 2, 1)] public void Execute(long nextBlockIndex, int championshipId, int round, int ticket, int arenaInterval, int randomSeed) { + var context = new ActionContext(); var arenaSheet = _state.GetSheet(); if (!arenaSheet.TryGetValue(championshipId, out var row)) { @@ -239,8 +240,8 @@ public void Execute(long nextBlockIndex, int championshipId, int round, int tick } var random = new TestRandom(randomSeed); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -256,7 +257,7 @@ public void Execute(long nextBlockIndex, int championshipId, int round, int tick if (buyTicket > 0) { var currency = buyTicket * _ncg * roundData.TicketPrice; - _state = _state.MintAsset(_agent1Address, currency); + _state = _state.MintAsset(context, _agent1Address, currency); } var action = new BattleArena1() @@ -508,6 +509,7 @@ public void Execute_ArenaParticipantsNotFoundException() [InlineData(false)] public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { + var context = new ActionContext(); var championshipId = 1; var round = 1; var arenaSheet = _state.GetSheet(); @@ -525,8 +527,8 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); _state = excludeMe - ? JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) - : JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + ? JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) + : JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); var action = new BattleArena1() { @@ -553,6 +555,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) [InlineData(false)] public void Execute_ValidateScoreDifferenceException(bool isSigner) { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -569,8 +572,8 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaScoreAdr = ArenaScore.DeriveAddress(isSigner ? _avatar1Address : _avatar2Address, roundData.ChampionshipId, roundData.Round); _state.TryGetArenaScore(arenaScoreAdr, out var arenaScore); diff --git a/.Lib9c.Tests/Action/BattleArena2Test.cs b/.Lib9c.Tests/Action/BattleArena2Test.cs index 998c2de9e2..4012097862 100644 --- a/.Lib9c.Tests/Action/BattleArena2Test.cs +++ b/.Lib9c.Tests/Action/BattleArena2Test.cs @@ -195,10 +195,10 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; - _state = _state.MintAsset(signer, preCurrency); + _state = _state.MintAsset(context, signer, preCurrency); var action = new JoinArena1() { @@ -237,6 +237,7 @@ public void Execute( int arenaInterval, int randomSeed) { + var context = new ActionContext(); var arenaSheet = _state.GetSheet(); if (!arenaSheet.TryGetValue(championshipId, out var row)) { @@ -251,8 +252,8 @@ public void Execute( } var random = new TestRandom(randomSeed); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -267,7 +268,7 @@ public void Execute( for (var i = 0; i < ticket; i++) { var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } @@ -537,6 +538,7 @@ public void Execute_ArenaParticipantsNotFoundException() [InlineData(false)] public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { + var context = new ActionContext(); var championshipId = 1; var round = 1; var arenaSheet = _state.GetSheet(); @@ -554,8 +556,8 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); _state = excludeMe - ? JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) - : JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + ? JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) + : JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); var action = new BattleArena2() { @@ -582,6 +584,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) [InlineData(false)] public void Execute_ValidateScoreDifferenceException(bool isSigner) { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -598,8 +601,8 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaScoreAdr = ArenaScore.DeriveAddress(isSigner ? _avatar1Address : _avatar2Address, roundData.ChampionshipId, roundData.Round); _state.TryGetArenaScore(arenaScoreAdr, out var arenaScore); @@ -630,6 +633,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) [Fact] public void Execute_InsufficientBalanceException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -646,8 +650,8 @@ public void Execute_InsufficientBalanceException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -682,6 +686,7 @@ public void Execute_InsufficientBalanceException() [Fact] public void Execute_ExceedPlayCountException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -698,8 +703,8 @@ public void Execute_ExceedPlayCountException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -731,6 +736,7 @@ public void Execute_ExceedPlayCountException() [Fact] public void Execute_ExceedTicketPurchaseLimitException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -747,8 +753,8 @@ public void Execute_ExceedTicketPurchaseLimitException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -765,7 +771,7 @@ public void Execute_ExceedTicketPurchaseLimitException() _state = _state.SetState(arenaInfoAdr, beforeInfo.Serialize()); var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); var action = new BattleArena2() { diff --git a/.Lib9c.Tests/Action/BattleArena3Test.cs b/.Lib9c.Tests/Action/BattleArena3Test.cs index 6c42e542d5..b362516be8 100644 --- a/.Lib9c.Tests/Action/BattleArena3Test.cs +++ b/.Lib9c.Tests/Action/BattleArena3Test.cs @@ -195,10 +195,10 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; - _state = _state.MintAsset(signer, preCurrency); + _state = _state.MintAsset(context, signer, preCurrency); var action = new JoinArena1() { @@ -237,6 +237,7 @@ public void Execute( int arenaInterval, int randomSeed) { + var context = new ActionContext(); var arenaSheet = _state.GetSheet(); if (!arenaSheet.TryGetValue(championshipId, out var row)) { @@ -251,8 +252,8 @@ public void Execute( } var random = new TestRandom(randomSeed); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -267,7 +268,7 @@ public void Execute( for (var i = 0; i < ticket; i++) { var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } @@ -537,6 +538,7 @@ public void Execute_ArenaParticipantsNotFoundException() [InlineData(false)] public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { + var context = new ActionContext(); var championshipId = 1; var round = 1; var arenaSheet = _state.GetSheet(); @@ -554,8 +556,8 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); _state = excludeMe - ? JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) - : JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + ? JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) + : JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); var action = new BattleArena3() { @@ -582,6 +584,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) [InlineData(false)] public void Execute_ValidateScoreDifferenceException(bool isSigner) { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -598,8 +601,8 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaScoreAdr = ArenaScore.DeriveAddress(isSigner ? _avatar1Address : _avatar2Address, roundData.ChampionshipId, roundData.Round); _state.TryGetArenaScore(arenaScoreAdr, out var arenaScore); @@ -630,6 +633,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) [Fact] public void Execute_InsufficientBalanceException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -646,8 +650,8 @@ public void Execute_InsufficientBalanceException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -682,6 +686,7 @@ public void Execute_InsufficientBalanceException() [Fact] public void Execute_ExceedPlayCountException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -698,8 +703,8 @@ public void Execute_ExceedPlayCountException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -731,6 +736,7 @@ public void Execute_ExceedPlayCountException() [Fact] public void Execute_ExceedTicketPurchaseLimitException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; var arenaSheet = _state.GetSheet(); @@ -747,8 +753,8 @@ public void Execute_ExceedTicketPurchaseLimitException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -765,7 +771,7 @@ public void Execute_ExceedTicketPurchaseLimitException() _state = _state.SetState(arenaInfoAdr, beforeInfo.Serialize()); var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); var action = new BattleArena3() { diff --git a/.Lib9c.Tests/Action/BattleArena4Test.cs b/.Lib9c.Tests/Action/BattleArena4Test.cs index 4b19932cc5..e7188ab8d6 100644 --- a/.Lib9c.Tests/Action/BattleArena4Test.cs +++ b/.Lib9c.Tests/Action/BattleArena4Test.cs @@ -195,10 +195,10 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith return (equipments, costumes); } - public IAccountStateDelta JoinArena(Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) + public IAccountStateDelta JoinArena(IActionContext context, Address signer, Address avatarAddress, long blockIndex, int championshipId, int round, IRandom random) { var preCurrency = 1000 * _crystal; - _state = _state.MintAsset(signer, preCurrency); + _state = _state.MintAsset(context, signer, preCurrency); var action = new JoinArena1() { @@ -237,6 +237,7 @@ public void Execute( int arenaInterval, int randomSeed) { + var context = new ActionContext(); Assert.True(_state.GetSheet().TryGetValue( championshipId, out var row)); @@ -248,8 +249,8 @@ public void Execute( } var random = new TestRandom(randomSeed); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -264,7 +265,7 @@ public void Execute( for (var i = 0; i < ticket; i++) { var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } @@ -537,6 +538,7 @@ public void Execute_ArenaParticipantsNotFoundException() [InlineData(false)] public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { + var context = new ActionContext(); var championshipId = 1; var round = 1; @@ -552,8 +554,8 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); _state = excludeMe - ? JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) - : JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + ? JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random) + : JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); var action = new BattleArena4() { @@ -580,6 +582,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) [InlineData(false)] public void Execute_ValidateScoreDifferenceException(bool isSigner) { + var context = new ActionContext(); var championshipId = 1; var round = 2; @@ -594,8 +597,8 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaScoreAdr = ArenaScore.DeriveAddress(isSigner ? _avatar1Address : _avatar2Address, roundData.ChampionshipId, roundData.Round); _state.TryGetArenaScore(arenaScoreAdr, out var arenaScore); @@ -626,6 +629,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) [Fact] public void Execute_InsufficientBalanceException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; @@ -640,8 +644,8 @@ public void Execute_InsufficientBalanceException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -676,6 +680,7 @@ public void Execute_InsufficientBalanceException() [Fact] public void Execute_ExceedPlayCountException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; @@ -690,8 +695,8 @@ public void Execute_ExceedPlayCountException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -723,6 +728,7 @@ public void Execute_ExceedPlayCountException() [Fact] public void Execute_ExceedTicketPurchaseLimitException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; @@ -737,8 +743,8 @@ public void Execute_ExceedTicketPurchaseLimitException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -755,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitException() _state = _state.SetState(arenaInfoAdr, beforeInfo.Serialize()); var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); var action = new BattleArena4() { @@ -781,6 +787,7 @@ public void Execute_ExceedTicketPurchaseLimitException() [Fact] public void Execute_CoolDownBlockException() { + var context = new ActionContext(); var championshipId = 1; var round = 2; @@ -795,8 +802,8 @@ public void Execute_CoolDownBlockException() } var random = new TestRandom(); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) @@ -810,7 +817,7 @@ public void Execute_CoolDownBlockException() for (var i = 0; i < max; i++) { var price = ArenaHelper.GetTicketPrice(roundData, beforeInfo, _state.GetGoldCurrency()); - _state = _state.MintAsset(_agent1Address, price); + _state = _state.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } @@ -847,6 +854,7 @@ public void Execute_CoolDownBlockException() [Fact] public void Execute_v100291() { + var context = new ActionContext(); var keys = new List { nameof(SkillActionBuffSheet), @@ -870,8 +878,8 @@ public void Execute_v100291() Assert.True(row.TryGetRound(1, out var roundData)); var random = new TestRandom(1); - _state = JoinArena(_agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); - _state = JoinArena(_agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent1Address, _avatar1Address, roundData.StartBlockIndex, championshipId, round, random); + _state = JoinArena(context, _agent2Address, _avatar2Address, roundData.StartBlockIndex, championshipId, round, random); var arenaInfoAdr = ArenaInformation.DeriveAddress(_avatar1Address, championshipId, round); if (!_state.TryGetArenaInformation(arenaInfoAdr, out var beforeInfo)) diff --git a/.Lib9c.Tests/Action/BattleArena5Test.cs b/.Lib9c.Tests/Action/BattleArena5Test.cs index 5ca14a332d..1bab467303 100644 --- a/.Lib9c.Tests/Action/BattleArena5Test.cs +++ b/.Lib9c.Tests/Action/BattleArena5Test.cs @@ -335,6 +335,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -349,6 +350,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -357,6 +359,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -393,6 +396,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -406,6 +410,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -414,6 +419,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -457,6 +463,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -470,6 +477,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -478,6 +486,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -522,6 +531,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -535,6 +545,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -543,6 +554,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -584,6 +596,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -597,6 +610,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -605,6 +619,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -632,7 +647,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena5 { @@ -660,6 +675,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -673,6 +689,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -681,6 +698,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -705,7 +723,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } @@ -780,6 +798,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -793,6 +812,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -801,6 +821,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -826,7 +847,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(ArenaHelper.GetMaxPurchasedTicketCount(roundData)); } } @@ -955,6 +976,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -964,7 +986,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena6Test.cs b/.Lib9c.Tests/Action/BattleArena6Test.cs index 88484d1db1..2b06ecc562 100644 --- a/.Lib9c.Tests/Action/BattleArena6Test.cs +++ b/.Lib9c.Tests/Action/BattleArena6Test.cs @@ -337,6 +337,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -351,6 +352,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -359,6 +361,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -395,6 +398,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -408,6 +412,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -416,6 +421,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -459,6 +465,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -472,6 +479,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -480,6 +488,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -524,6 +533,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -537,6 +547,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -545,6 +556,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -586,6 +598,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -599,6 +612,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -607,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -634,7 +649,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena6 { @@ -662,6 +677,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -675,6 +691,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -683,6 +700,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -715,7 +733,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena6 { @@ -743,6 +761,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -756,6 +775,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -764,6 +784,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -788,7 +809,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -863,6 +884,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -876,6 +898,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -884,6 +907,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -909,7 +933,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1038,6 +1062,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1047,7 +1072,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena7Test.cs b/.Lib9c.Tests/Action/BattleArena7Test.cs index f3d7f911dc..484d84f6ad 100644 --- a/.Lib9c.Tests/Action/BattleArena7Test.cs +++ b/.Lib9c.Tests/Action/BattleArena7Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena7 { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena7 { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -875,6 +896,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -888,6 +910,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -896,6 +919,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -921,7 +945,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1051,6 +1075,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1060,7 +1085,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena8Test.cs b/.Lib9c.Tests/Action/BattleArena8Test.cs index 079baf06f9..8160f19e74 100644 --- a/.Lib9c.Tests/Action/BattleArena8Test.cs +++ b/.Lib9c.Tests/Action/BattleArena8Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena8 { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena8 { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -846,6 +867,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 int arenaInterval = 5; int randomSeed = 3; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -859,6 +881,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -867,6 +890,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -883,7 +907,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 } var ncgCurrency = previousStates.GetGoldCurrency(); - previousStates = previousStates.MintAsset(_agent1Address, 99999 * ncgCurrency); + previousStates = previousStates.MintAsset(context, _agent1Address, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { @@ -960,6 +984,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -978,6 +1003,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -986,6 +1012,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -1013,7 +1040,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena8 { @@ -1077,6 +1104,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -1090,6 +1118,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -1098,6 +1127,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -1123,7 +1153,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1255,6 +1285,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1264,7 +1295,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/BattleArena9Test.cs b/.Lib9c.Tests/Action/BattleArena9Test.cs index 40b0e7565d..fbe60e4588 100644 --- a/.Lib9c.Tests/Action/BattleArena9Test.cs +++ b/.Lib9c.Tests/Action/BattleArena9Test.cs @@ -342,6 +342,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -356,6 +357,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) var random = new TestRandom(); previousStates = excludeMe ? JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -364,6 +366,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) round, random) : JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -401,6 +404,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -414,6 +418,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -422,6 +427,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -466,6 +472,7 @@ public void Execute_InsufficientBalanceException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -479,6 +486,7 @@ public void Execute_InsufficientBalanceException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -487,6 +495,7 @@ public void Execute_InsufficientBalanceException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -532,6 +541,7 @@ public void Execute_ExceedPlayCountException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -545,6 +555,7 @@ public void Execute_ExceedPlayCountException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -553,6 +564,7 @@ public void Execute_ExceedPlayCountException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -595,6 +607,7 @@ public void Execute_ExceedTicketPurchaseLimitException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -608,6 +621,7 @@ public void Execute_ExceedTicketPurchaseLimitException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -616,6 +630,7 @@ public void Execute_ExceedTicketPurchaseLimitException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -643,7 +658,7 @@ public void Execute_ExceedTicketPurchaseLimitException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena9 { @@ -672,6 +687,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -685,6 +701,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -693,6 +710,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -725,7 +743,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena9 { @@ -754,6 +772,7 @@ public void Execute_CoolDownBlockException() { const int championshipId = 1; const int round = 2; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -767,6 +786,7 @@ public void Execute_CoolDownBlockException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -775,6 +795,7 @@ public void Execute_CoolDownBlockException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -799,7 +820,7 @@ public void Execute_CoolDownBlockException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } @@ -846,6 +867,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 int arenaInterval = 5; int randomSeed = 3; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -859,6 +881,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -867,6 +890,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -883,7 +907,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 } var ncgCurrency = previousStates.GetGoldCurrency(); - previousStates = previousStates.MintAsset(_agent1Address, 99999 * ncgCurrency); + previousStates = previousStates.MintAsset(context, _agent1Address, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { @@ -960,6 +984,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() { const int championshipId = 1; const int round = 1; + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(previousStates.GetSheet().TryGetValue( championshipId, @@ -978,6 +1003,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() var random = new TestRandom(); previousStates = JoinArena( + context, previousStates, _agent1Address, _avatar1Address, @@ -986,6 +1012,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() round, random); previousStates = JoinArena( + context, previousStates, _agent2Address, _avatar2Address, @@ -1013,7 +1040,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(_agent1Address, price); + previousStates = previousStates.MintAsset(context, _agent1Address, price); var action = new BattleArena9 { @@ -1077,6 +1104,7 @@ private void Execute( Address enemyAgentAddress, Address enemyAvatarAddress) { + var context = new ActionContext(); var previousStates = _initialStates; Assert.True(_initialStates.GetSheet().TryGetValue( championshipId, @@ -1090,6 +1118,7 @@ private void Execute( var random = new TestRandom(randomSeed); previousStates = JoinArena( + context, previousStates, myAgentAddress, myAvatarAddress, @@ -1098,6 +1127,7 @@ private void Execute( round, random); previousStates = JoinArena( + context, previousStates, enemyAgentAddress, enemyAvatarAddress, @@ -1123,7 +1153,7 @@ private void Execute( roundData, beforeInfo, previousStates.GetGoldCurrency()); - previousStates = previousStates.MintAsset(myAgentAddress, price); + previousStates = previousStates.MintAsset(context, myAgentAddress, price); beforeInfo.BuyTicket(roundData.MaxPurchaseCount); } } @@ -1255,6 +1285,7 @@ private void Execute( } private IAccountStateDelta JoinArena( + IActionContext context, IAccountStateDelta states, Address signer, Address avatarAddress, @@ -1264,7 +1295,7 @@ private IAccountStateDelta JoinArena( IRandom random) { var preCurrency = 1000 * _crystal; - states = states.MintAsset(signer, preCurrency); + states = states.MintAsset(context, signer, preCurrency); var action = new JoinArena1 { diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 7754e753e6..6836652219 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -44,6 +44,7 @@ public Buy10Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -105,7 +106,7 @@ public Buy10Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -467,6 +468,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty [MemberData(nameof(ErrorCodeMemberData))] public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) { + var context = new ActionContext(); var agentAddress = errorCodeMember.BuyerExist ? _buyerAgentAddress : default; var orderPrice = new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0); var sellerAvatarAddress = errorCodeMember.EqualSellerAvatar ? _sellerAvatarAddress : default; @@ -552,7 +554,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) if (errorCodeMember.NotEnoughBalance) { var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); } PurchaseInfo purchaseInfo = new PurchaseInfo( diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index b17c4ce791..1525320e82 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -46,6 +46,7 @@ public Buy11Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -107,7 +108,7 @@ public Buy11Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); var arenaSheetAddress = Addresses.GetSheetAddress(); _arenaSheetState = _initialState.GetState(arenaSheetAddress); @@ -473,6 +474,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty [MemberData(nameof(ErrorCodeMemberData))] public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) { + var context = new ActionContext(); var agentAddress = errorCodeMember.BuyerExist ? _buyerAgentAddress : default; var orderPrice = new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0); var sellerAvatarAddress = errorCodeMember.EqualSellerAvatar ? _sellerAvatarAddress : default; @@ -558,7 +560,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) if (errorCodeMember.NotEnoughBalance) { var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); } PurchaseInfo purchaseInfo = new PurchaseInfo( diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index 9daa7195c1..7d419b3afc 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -35,6 +35,7 @@ public Buy2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -124,7 +125,7 @@ public Buy2Test(ITestOutputHelper outputHelper) .SetState(_sellerAvatarAddress, sellerAvatarState.Serialize()) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } [Fact] diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index a8a8fb1467..eb269ea0d3 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -35,6 +35,7 @@ public Buy3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -131,7 +132,7 @@ public Buy3Test(ITestOutputHelper outputHelper) .SetState(_sellerAvatarAddress, sellerAvatarState.Serialize()) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(_buyerAgentAddress, shopState.Products + .MintAsset(context, _buyerAgentAddress, shopState.Products .Select(pair => pair.Value.Price) .Aggregate((totalPrice, next) => totalPrice + next)); } @@ -296,8 +297,9 @@ public void ExecuteThrowInsufficientBalanceException() var (productId, shopItem) = shopState.Products.FirstOrDefault(); Assert.NotNull(shopItem); + var context = new ActionContext(); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); var action = new Buy3 { diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index 01058ea5ef..2373548a4e 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -37,6 +37,7 @@ public Buy4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -150,7 +151,7 @@ public Buy4Test(ITestOutputHelper outputHelper) .SetState(_sellerAvatarAddress, sellerAvatarState.Serialize()) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(_buyerAgentAddress, shopState.Products + .MintAsset(context, _buyerAgentAddress, shopState.Products .Select(pair => pair.Value.Price) .Aggregate((totalPrice, next) => totalPrice + next)); } @@ -314,6 +315,7 @@ public void ExecuteThrowItemDoesNotExistException() [Fact] public void ExecuteThrowInsufficientBalanceException() { + var context = new ActionContext(); var shopState = _initialState.GetShopState(); Assert.NotEmpty(shopState.Products); @@ -321,7 +323,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.NotNull(shopItem); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); var action = new Buy4 { diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index f99f20d582..956bdff14b 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -38,6 +38,7 @@ public Buy5Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -99,7 +100,7 @@ public Buy5Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -441,6 +442,7 @@ public void Execute_ErrorCode_ItemDoesNotExist() [Fact] public void Execute_ErrorCode_InsufficientBalance() { + var context = new ActionContext(); Address shardedShopAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, @@ -459,7 +461,7 @@ public void Execute_ErrorCode_InsufficientBalance() shopState.Register(shopItem); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance) + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance) .SetState(shardedShopAddress, shopState.Serialize()); PurchaseInfo0 purchaseInfo0 = new PurchaseInfo0( diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index b9bb35b975..ab9a372098 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -39,6 +39,7 @@ public Buy6Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -100,7 +101,7 @@ public Buy6Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -568,6 +569,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_Material(ItemSubType itemSubType) [Fact] public void Execute_ErrorCode_InsufficientBalance() { + var context = new ActionContext(); Address shardedShopAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, @@ -586,7 +588,7 @@ public void Execute_ErrorCode_InsufficientBalance() shopState.Register(shopItem); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance) + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance) .SetState(shardedShopAddress, shopState.Serialize()); PurchaseInfo0 purchaseInfo0 = new PurchaseInfo0( diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index 7c98dfdf19..26ae35a716 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -39,6 +39,7 @@ public Buy7Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -100,7 +101,7 @@ public Buy7Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -639,6 +640,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_20210604(ItemSubType itemSubType, [Fact] public void Execute_ErrorCode_InsufficientBalance() { + var context = new ActionContext(); Address shardedShopAddress = ShardedShopState.DeriveAddress(ItemSubType.Weapon, _productId); var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, @@ -657,7 +659,7 @@ public void Execute_ErrorCode_InsufficientBalance() shopState.Register(shopItem); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance) + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance) .SetState(shardedShopAddress, shopState.Serialize()); PurchaseInfo0 purchaseInfo0 = new PurchaseInfo0( diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index da1a8cbaa5..d7758d41cc 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -41,6 +41,7 @@ public Buy8Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -102,7 +103,7 @@ public Buy8Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -441,6 +442,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty [MemberData(nameof(ErrorCodeMemberData))] public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) { + var context = new ActionContext(); var agentAddress = errorCodeMember.BuyerExist ? _buyerAgentAddress : default; var orderPrice = new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0); var sellerAvatarAddress = errorCodeMember.EqualSellerAvatar ? _sellerAvatarAddress : default; @@ -509,7 +511,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) if (errorCodeMember.NotEnoughBalance) { var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); } PurchaseInfo purchaseInfo = new PurchaseInfo( diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index d50f6b552c..83a7f6371a 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -41,6 +41,7 @@ public Buy9Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -102,7 +103,7 @@ public Buy9Test(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -539,6 +540,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty [MemberData(nameof(ErrorCodeMemberData))] public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) { + var context = new ActionContext(); var agentAddress = errorCodeMember.BuyerExist ? _buyerAgentAddress : default; var orderPrice = new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0); var sellerAvatarAddress = errorCodeMember.EqualSellerAvatar ? _sellerAvatarAddress : default; @@ -608,7 +610,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) if (errorCodeMember.NotEnoughBalance) { var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); } PurchaseInfo purchaseInfo = new PurchaseInfo( diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index a049777899..6927686480 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -36,6 +36,7 @@ public BuyMultipleTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -80,7 +81,7 @@ public BuyMultipleTest(ITestOutputHelper outputHelper) .SetState(Addresses.Shop, shopState.Serialize()) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -519,6 +520,7 @@ public void ExecuteInsufficientBalanceError() 100, costume)); + var context = new ActionContext(); _initialState = _initialState .SetState(Addresses.Shop, shopState.Serialize()); shopState = _initialState.GetShopState(); @@ -533,7 +535,7 @@ public void ExecuteInsufficientBalanceError() Assert.NotEmpty(products); var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); var action = new BuyMultiple { diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index 5f124bb946..a1bdf61d5e 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -45,6 +45,7 @@ public BuyProduct0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -118,7 +119,7 @@ public BuyProduct0Test(ITestOutputHelper outputHelper) .SetState(_sellerAvatarAddress2, sellerAvatarState2.Serialize()) .SetState(BuyerAgentAddress, buyerAgentState.Serialize()) .SetState(BuyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(BuyerAgentAddress, _goldCurrencyState.Currency * 1); + .MintAsset(context, BuyerAgentAddress, _goldCurrencyState.Currency * 1); } public static IEnumerable Execute_MemberData() diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index 44f13f37b4..18e6ac5845 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -45,6 +45,7 @@ public BuyProductTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -118,7 +119,7 @@ public BuyProductTest(ITestOutputHelper outputHelper) .SetState(_sellerAvatarAddress2, sellerAvatarState2.Serialize()) .SetState(BuyerAgentAddress, buyerAgentState.Serialize()) .SetState(BuyerAvatarAddress, _buyerAvatarState.Serialize()) - .MintAsset(BuyerAgentAddress, _goldCurrencyState.Currency * 1); + .MintAsset(context, BuyerAgentAddress, _goldCurrencyState.Currency * 1); } public static IEnumerable Execute_MemberData() diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index e19271dc21..353acfad03 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -44,6 +44,7 @@ public BuyTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -105,7 +106,7 @@ public BuyTest(ITestOutputHelper outputHelper) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); + .MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100); } public static IEnumerable GetExecuteMemberData() @@ -501,6 +502,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty [MemberData(nameof(ErrorCodeMemberData))] public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) { + var context = new ActionContext(); var agentAddress = errorCodeMember.BuyerExist ? _buyerAgentAddress : default; var orderPrice = new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0); var sellerAvatarAddress = errorCodeMember.EqualSellerAvatar ? _sellerAvatarAddress : default; @@ -586,7 +588,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) if (errorCodeMember.NotEnoughBalance) { var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency); - _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance); + _initialState = _initialState.BurnAsset(context, _buyerAgentAddress, balance); } PurchaseInfo purchaseInfo = new PurchaseInfo( diff --git a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs index d46a884eaa..5fe1816736 100644 --- a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs @@ -50,6 +50,7 @@ public CancelMonsterCollectTest() [InlineData(4, 3, MonsterCollectionState0.RewardInterval * 4)] public void Execute(int prevLevel, int collectionLevel, long blockIndex) { + var context = new ActionContext(); Address collectionAddress = MonsterCollectionState0.DeriveAddress(_signer, 0); List rewardInfos = _tableSheets.MonsterCollectionRewardSheet[prevLevel].Rewards; MonsterCollectionState0 monsterCollectionState = new MonsterCollectionState0(collectionAddress, prevLevel, 0, _tableSheets.MonsterCollectionRewardSheet); @@ -67,7 +68,7 @@ public void Execute(int prevLevel, int collectionLevel, long blockIndex) _state = _state .SetState(collectionAddress, monsterCollectionState.Serialize()) - .MintAsset(collectionAddress, balance); + .MintAsset(context, collectionAddress, balance); CancelMonsterCollect action = new CancelMonsterCollect { diff --git a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs index b6b41fef24..704f9deca3 100644 --- a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs +++ b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs @@ -128,7 +128,8 @@ bool invalidAgentAddress [Fact] public void Execute_Throw_ProductNotFoundException() { - var prevState = _initialState.MintAsset(_avatarAddress, 1 * RuneHelper.StakeRune); + var context = new ActionContext(); + var prevState = _initialState.MintAsset(context, _avatarAddress, 1 * RuneHelper.StakeRune); var registerProduct = new RegisterProduct { AvatarAddress = _avatarAddress, diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs index 374e491fbe..a45b46d9a7 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs @@ -70,6 +70,7 @@ public ClaimMonsterCollectionReward0Test() [InlineData(4, 3, 6)] public void Execute(int rewardLevel, int prevRewardLevel, int collectionLevel) { + var context = new ActionContext(); Address collectionAddress = MonsterCollectionState0.DeriveAddress(_signer, 0); List rewards = _tableSheets.MonsterCollectionRewardSheet[1].Rewards; MonsterCollectionState0 monsterCollectionState = new MonsterCollectionState0(collectionAddress, 1, 0, _tableSheets.MonsterCollectionRewardSheet); @@ -130,7 +131,7 @@ public void Execute(int rewardLevel, int prevRewardLevel, int collectionLevel) collectionRound += 1; _state = _state - .MintAsset(collectionAddress, balance); + .MintAsset(context, collectionAddress, balance); } Assert.Equal(prevRewardLevel, monsterCollectionState.RewardLevel); diff --git a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs index 4088ed239d..9bbbbd83d9 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs @@ -30,6 +30,7 @@ public ClaimStakeReward1Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); @@ -78,7 +79,7 @@ public ClaimStakeReward1Test(ITestOutputHelper outputHelper) avatarState.questList.Serialize()) .SetState(GoldCurrencyState.Address, _goldCurrencyState.Serialize()) .SetState(stakeStateAddress, new StakeState(stakeStateAddress, 0).Serialize()) - .MintAsset(stakeStateAddress, _currency * 100); + .MintAsset(context, stakeStateAddress, _currency * 100); } [Fact] diff --git a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs index b0e1065f32..e2ffa91f3b 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs @@ -31,6 +31,7 @@ public ClaimStakeReward2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); @@ -96,7 +97,7 @@ public ClaimStakeReward2Test(ITestOutputHelper outputHelper) avatarStateForBackwardCompatibility.Serialize()) .SetState(GoldCurrencyState.Address, _goldCurrencyState.Serialize()) .SetState(stakeStateAddress, new StakeState(stakeStateAddress, 0).Serialize()) - .MintAsset(stakeStateAddress, _currency * 100); + .MintAsset(context, stakeStateAddress, _currency * 100); } [Fact] diff --git a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs index 48b90c253f..83584ed401 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs @@ -198,6 +198,7 @@ private void Execute( int expectedApStone, int expectedRune) { + var context = new ActionContext(); var stakeStateAddr = StakeState.DeriveAddress(agentAddr); var initialStakeState = new StakeState(stakeStateAddr, startedBlockIndex); if (!(previousRewardReceiveIndex is null)) @@ -207,7 +208,7 @@ private void Execute( prevState = prevState .SetState(stakeStateAddr, initialStakeState.Serialize()) - .MintAsset(stakeStateAddr, _ncg * stakeAmount); + .MintAsset(context, stakeStateAddr, _ncg * stakeAmount); var action = new ClaimStakeReward3(avatarAddr); var states = action.Execute(new ActionContext diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index e592120fd8..2403af0775 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -223,6 +223,7 @@ private void Execute( string expectedCurrencyTicker, long expectedCurrencyAmount) { + var context = new ActionContext(); var stakeStateAddr = StakeState.DeriveAddress(agentAddr); var initialStakeState = new StakeState(stakeStateAddr, startedBlockIndex); if (!(previousRewardReceiveIndex is null)) @@ -232,7 +233,7 @@ private void Execute( prevState = prevState .SetState(stakeStateAddr, initialStakeState.Serialize()) - .MintAsset(stakeStateAddr, _ncg * stakeAmount); + .MintAsset(context, stakeStateAddr, _ncg * stakeAmount); var action = new ClaimStakeReward(avatarAddr); var states = action.Execute(new ActionContext diff --git a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs index bfa712b9f6..abc7a2cea8 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs @@ -56,6 +56,7 @@ public CombinationEquipment0Test() var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -66,7 +67,7 @@ public CombinationEquipment0Test() GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in _sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs index 09f4450359..1f80bd487f 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs @@ -221,6 +221,7 @@ public void MadeWithMimisbrunnrRecipe( } } + var context = new ActionContext(); var previousState = _initialState .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) .SetState( @@ -229,7 +230,7 @@ public void MadeWithMimisbrunnrRecipe( .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize()) .SetState(_avatarAddress, avatarState.SerializeV2()); - previousState = previousState.MintAsset(_agentAddress, 10_000 * currency); + previousState = previousState.MintAsset(context, _agentAddress, 10_000 * currency); var action = new CombinationEquipment10 { @@ -304,6 +305,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } } + var context = new ActionContext(); IAccountStateDelta previousState; if (backward) { @@ -320,7 +322,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) .SetState(_avatarAddress, avatarState.SerializeV2()); } - previousState = previousState.MintAsset(_agentAddress, mintNCG * currency); + previousState = previousState.MintAsset(context, _agentAddress, mintNCG * currency); var goldCurrencyState = previousState.GetGoldCurrency(); var previousNCG = previousState.GetBalance(_agentAddress, goldCurrencyState); Assert.Equal(mintNCG * currency, previousNCG); diff --git a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs index 60946ff85a..45126abd86 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs @@ -228,6 +228,7 @@ public void MadeWithMimisbrunnrRecipe( } } + var context = new ActionContext(); var previousState = _initialState .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) .SetState( @@ -236,7 +237,7 @@ public void MadeWithMimisbrunnrRecipe( .SetState(_avatarAddress.Derive(LegacyQuestListKey), avatarState.questList.Serialize()) .SetState(_avatarAddress, avatarState.SerializeV2()); - previousState = previousState.MintAsset(_agentAddress, 10_000 * currency); + previousState = previousState.MintAsset(context, _agentAddress, 10_000 * currency); var action = new CombinationEquipment11 { @@ -311,6 +312,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } } + var context = new ActionContext(); IAccountStateDelta previousState; if (backward) { @@ -327,7 +329,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) .SetState(_avatarAddress, avatarState.SerializeV2()); } - previousState = previousState.MintAsset(_agentAddress, mintNCG * currency); + previousState = previousState.MintAsset(context, _agentAddress, mintNCG * currency); var goldCurrencyState = previousState.GetGoldCurrency(); var previousNCG = previousState.GetBalance(_agentAddress, goldCurrencyState); Assert.Equal(mintNCG * currency, previousNCG); diff --git a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs index 12e8d83298..e33b433d63 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs @@ -151,6 +151,7 @@ public void Execute( bool previousCostStateExist ) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; if (unlockIdsExist) { @@ -198,6 +199,7 @@ bool previousCostStateExist if (ncgBalanceExist) { state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); } @@ -269,7 +271,7 @@ bool previousCostStateExist } expectedCrystal = crystalBalance; - state = state.MintAsset(_agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); + state = state.MintAsset(context, _agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); } var dailyCostAddress = diff --git a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs index a32f91301f..33b2121828 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs @@ -146,6 +146,7 @@ public void Execute( bool previousCostStateExist ) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; if (unlockIdsExist) { @@ -193,6 +194,7 @@ bool previousCostStateExist if (ncgBalanceExist) { state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); } @@ -264,7 +266,7 @@ bool previousCostStateExist } expectedCrystal = crystalBalance; - state = state.MintAsset(_agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); + state = state.MintAsset(context, _agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); } var dailyCostAddress = @@ -381,6 +383,7 @@ public void ExecuteBySuperCraft( bool useBasicRecipe, int recipeId) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) @@ -410,6 +413,7 @@ public void ExecuteBySuperCraft( } state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); @@ -439,6 +443,7 @@ public void ExecuteBySuperCraft( var costCrystal = CrystalCalculator.CRYSTAL * hammerPointSheet[recipeId].CRYSTAL; state = state.MintAsset( + context, _agentAddress, costCrystal); } diff --git a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs index 7b574a2f05..c7d747dfeb 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs @@ -147,6 +147,7 @@ public void Execute( bool previousCostStateExist ) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; if (unlockIdsExist) { @@ -194,6 +195,7 @@ bool previousCostStateExist if (ncgBalanceExist) { state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); } @@ -265,7 +267,7 @@ bool previousCostStateExist } expectedCrystal = crystalBalance; - state = state.MintAsset(_agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); + state = state.MintAsset(context, _agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); } var dailyCostAddress = @@ -383,6 +385,7 @@ public void ExecuteBySuperCraft( bool useBasicRecipe, int recipeId) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) @@ -412,6 +415,7 @@ public void ExecuteBySuperCraft( } state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); @@ -441,6 +445,7 @@ public void ExecuteBySuperCraft( var costCrystal = CrystalCalculator.CRYSTAL * hammerPointSheet[recipeId].CRYSTAL; state = state.MintAsset( + context, _agentAddress, costCrystal); } diff --git a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs index 9f8f06ebcb..0b83fd83ae 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs @@ -147,6 +147,7 @@ public void Execute( bool previousCostStateExist ) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; if (unlockIdsExist) { @@ -194,6 +195,7 @@ bool previousCostStateExist if (ncgBalanceExist) { state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); } @@ -265,7 +267,7 @@ bool previousCostStateExist } expectedCrystal = crystalBalance; - state = state.MintAsset(_agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); + state = state.MintAsset(context, _agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); } var dailyCostAddress = @@ -383,6 +385,7 @@ public void ExecuteBySuperCraft( bool useBasicRecipe, int recipeId) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) @@ -412,6 +415,7 @@ public void ExecuteBySuperCraft( } state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); @@ -441,6 +445,7 @@ public void ExecuteBySuperCraft( var costCrystal = CrystalCalculator.CRYSTAL * hammerPointSheet[recipeId].CRYSTAL; state = state.MintAsset( + context, _agentAddress, costCrystal); } diff --git a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs index bac25b4c7a..c1f47d91f3 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs @@ -56,6 +56,7 @@ public CombinationEquipment2Test() var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -66,7 +67,7 @@ public CombinationEquipment2Test() GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in _sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs index 4577dd02f4..ea6fb31ac2 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs @@ -61,6 +61,7 @@ public CombinationEquipment3Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -71,7 +72,7 @@ public CombinationEquipment3Test(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(_agentAddress, gold.Currency * 300); + .MintAsset(context, _agentAddress, gold.Currency * 300); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs index c7eca46476..74bbbf22b1 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs @@ -61,6 +61,7 @@ public CombinationEquipment4Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -71,7 +72,7 @@ public CombinationEquipment4Test(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(_agentAddress, gold.Currency * 300); + .MintAsset(context, _agentAddress, gold.Currency * 300); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs index 120afca18a..72a438d6d9 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs @@ -61,6 +61,7 @@ public CombinationEquipment5Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -71,7 +72,7 @@ public CombinationEquipment5Test(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(_agentAddress, gold.Currency * 300); + .MintAsset(context, _agentAddress, gold.Currency * 300); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs index b0b596661a..d183ac7606 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs @@ -63,6 +63,7 @@ public CombinationEquipment6Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -73,7 +74,7 @@ public CombinationEquipment6Test(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(_agentAddress, gold.Currency * 300); + .MintAsset(context, _agentAddress, gold.Currency * 300); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs index bab2e92254..55110d3472 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs @@ -63,6 +63,7 @@ public CombinationEquipment7Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -73,7 +74,7 @@ public CombinationEquipment7Test(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.CombinationEquipmentAction ).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(_agentAddress, gold.Currency * 300); + .MintAsset(context, _agentAddress, gold.Currency * 300); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs index 37aaac77e5..161b20db56 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs @@ -214,6 +214,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } } + var context = new ActionContext(); IAccountStateDelta previousState; if (backward) { @@ -230,7 +231,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) .SetState(_avatarAddress, avatarState.SerializeV2()); } - previousState = previousState.MintAsset(_agentAddress, mintNCG * currency); + previousState = previousState.MintAsset(context, _agentAddress, mintNCG * currency); var goldCurrencyState = previousState.GetGoldCurrency(); var previousNCG = previousState.GetBalance(_agentAddress, goldCurrencyState); Assert.Equal(mintNCG * currency, previousNCG); diff --git a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs index 0819faa240..88f52f5247 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs @@ -214,6 +214,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) } } + var context = new ActionContext(); IAccountStateDelta previousState; if (backward) { @@ -230,7 +231,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) .SetState(_avatarAddress, avatarState.SerializeV2()); } - previousState = previousState.MintAsset(_agentAddress, mintNCG * currency); + previousState = previousState.MintAsset(context, _agentAddress, mintNCG * currency); var goldCurrencyState = previousState.GetGoldCurrency(); var previousNCG = previousState.GetBalance(_agentAddress, goldCurrencyState); Assert.Equal(mintNCG * currency, previousNCG); diff --git a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs index 3986d40f7a..9e29f33a05 100644 --- a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs +++ b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs @@ -149,6 +149,7 @@ public void Execute( bool previousCostStateExist ) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; if (unlockIdsExist) { @@ -196,6 +197,7 @@ bool previousCostStateExist if (ncgBalanceExist) { state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); } @@ -267,7 +269,7 @@ bool previousCostStateExist } expectedCrystal = crystalBalance; - state = state.MintAsset(_agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); + state = state.MintAsset(context, _agentAddress, expectedCrystal * CrystalCalculator.CRYSTAL); } var dailyCostAddress = @@ -385,6 +387,7 @@ public void ExecuteWithCheckingHammerPointState( int subRecipeIndex, int recipeId) { + var context = new ActionContext(); IAccountStateDelta state = _initialState; var unlockIds = List.Empty.Add(1.Serialize()); for (int i = 2; i < recipeId + 1; i++) @@ -414,6 +417,7 @@ public void ExecuteWithCheckingHammerPointState( } state = state.MintAsset( + context, _agentAddress, subRow.RequiredGold * state.GetGoldCurrency()); @@ -443,6 +447,7 @@ public void ExecuteWithCheckingHammerPointState( var costCrystal = CrystalCalculator.CRYSTAL * hammerPointSheet[recipeId].CRYSTAL; state = state.MintAsset( + context, _agentAddress, costCrystal); } diff --git a/.Lib9c.Tests/Action/CreateAvatar0Test.cs b/.Lib9c.Tests/Action/CreateAvatar0Test.cs index 06ecf08c9f..bdd8ddb722 100644 --- a/.Lib9c.Tests/Action/CreateAvatar0Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar0Test.cs @@ -52,6 +52,7 @@ public void Execute() } var sheets = TableSheetsImporter.ImportSheets(); + var context = new ActionContext(); var state = new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( @@ -63,7 +64,7 @@ public void Execute() new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() ) .SetState(Addresses.Ranking, ranking.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CreateAvatar2Test.cs b/.Lib9c.Tests/Action/CreateAvatar2Test.cs index f457138ba3..fcd6c14fa9 100644 --- a/.Lib9c.Tests/Action/CreateAvatar2Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar2Test.cs @@ -49,6 +49,7 @@ public void Execute() } var sheets = TableSheetsImporter.ImportSheets(); + var context = new ActionContext(); var state = new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( @@ -60,7 +61,7 @@ public void Execute() new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() ) .SetState(Addresses.Ranking, ranking.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CreateAvatar3Test.cs b/.Lib9c.Tests/Action/CreateAvatar3Test.cs index 49da0cb072..90ed01cc47 100644 --- a/.Lib9c.Tests/Action/CreateAvatar3Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar3Test.cs @@ -50,6 +50,7 @@ public void Execute() } var sheets = TableSheetsImporter.ImportSheets(); + var context = new ActionContext(); var state = new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( @@ -61,7 +62,7 @@ public void Execute() new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() ) .SetState(Addresses.Ranking, ranking.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CreateAvatar6Test.cs b/.Lib9c.Tests/Action/CreateAvatar6Test.cs index bdcbd4ef6f..09e26ae24e 100644 --- a/.Lib9c.Tests/Action/CreateAvatar6Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar6Test.cs @@ -50,6 +50,7 @@ public void Execute() } var sheets = TableSheetsImporter.ImportSheets(); + var context = new ActionContext(); var state = new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( @@ -61,7 +62,7 @@ public void Execute() new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() ) .SetState(Addresses.Ranking, ranking.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CreatePledgeTest.cs b/.Lib9c.Tests/Action/CreatePledgeTest.cs index 6cfbedf977..af3a91c998 100644 --- a/.Lib9c.Tests/Action/CreatePledgeTest.cs +++ b/.Lib9c.Tests/Action/CreatePledgeTest.cs @@ -34,9 +34,10 @@ public void Execute(bool admin, Type exc) var mead = Currencies.Mead; var agentAddress = new PrivateKey().ToAddress(); var pledgeAddress = agentAddress.GetPledgeAddress(); + var context = new ActionContext(); IAccountStateDelta states = new State() .SetState(Addresses.Admin, adminState.Serialize()) - .MintAsset(patronAddress, 4 * 500 * mead); + .MintAsset(context, patronAddress, 4 * 500 * mead); var agentAddresses = new List<(Address, Address)> { diff --git a/.Lib9c.Tests/Action/EndPledgeTest.cs b/.Lib9c.Tests/Action/EndPledgeTest.cs index 2741f136ef..36fefd4e7e 100644 --- a/.Lib9c.Tests/Action/EndPledgeTest.cs +++ b/.Lib9c.Tests/Action/EndPledgeTest.cs @@ -19,12 +19,13 @@ public void Execute(int balance) { var patron = new PrivateKey().ToAddress(); var agent = new PrivateKey().ToAddress(); + var context = new ActionContext(); IAccountStateDelta states = new State() .SetState(agent.GetPledgeAddress(), List.Empty.Add(patron.Serialize()).Add(true.Serialize())); var mead = Currencies.Mead; if (balance > 0) { - states = states.MintAsset(agent, mead * balance); + states = states.MintAsset(context, agent, mead * balance); } var action = new EndPledge diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs index 6e86a42715..c6753e88fb 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs @@ -129,6 +129,7 @@ public void Execute_Success_With_Ticket_Purchase( int dungeonTicketAdditionalPrice, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var scheduleSheet = _tableSheets.EventScheduleSheet; Assert.True(scheduleSheet.TryGetValue(eventScheduleId, out var scheduleRow)); @@ -162,7 +163,7 @@ public void Execute_Success_With_Ticket_Purchase( Assert.True(previousStates.GetSheet() .TryGetValue(eventScheduleId, out var newScheduleRow)); var ncgHas = newScheduleRow.GetDungeonTicketCostV1(numberOfTicketPurchases); - previousStates = previousStates.MintAsset(_agentAddress, ncgHas * _ncgCurrency); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas * _ncgCurrency); var nextStates = Execute( previousStates, @@ -290,6 +291,7 @@ public void Execute_Throw_InsufficientBalanceException( int eventDungeonStageId, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var eventDungeonInfoAddr = EventDungeonInfo.DeriveAddress(_avatarAddress, eventDungeonId); @@ -302,7 +304,7 @@ public void Execute_Throw_InsufficientBalanceException( Assert.True(_tableSheets.EventScheduleSheet .TryGetValue(eventScheduleId, out var scheduleRow)); var ncgHas = scheduleRow.GetDungeonTicketCostV1(numberOfTicketPurchases) - 1; - previousStates = previousStates.MintAsset(_agentAddress, ncgHas * _ncgCurrency); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas * _ncgCurrency); Assert.Throws(() => Execute( diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs index cf31df14a3..0ef33428a9 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs @@ -130,6 +130,7 @@ public void Execute_Success_With_Ticket_Purchase( int dungeonTicketAdditionalPrice, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var scheduleSheet = _tableSheets.EventScheduleSheet; Assert.True(scheduleSheet.TryGetValue(eventScheduleId, out var scheduleRow)); @@ -165,7 +166,7 @@ public void Execute_Success_With_Ticket_Purchase( var ncgHas = newScheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency); - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); var nextStates = Execute( previousStates, @@ -301,6 +302,7 @@ public void Execute_Throw_InsufficientBalanceException( int eventDungeonStageId, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var eventDungeonInfoAddr = EventDungeonInfo.DeriveAddress(_avatarAddress, eventDungeonId); @@ -315,7 +317,7 @@ public void Execute_Throw_InsufficientBalanceException( var ncgHas = scheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency) - 1 * _ncgCurrency; - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); Assert.Throws(() => Execute( diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs index 98dcf1a807..2bb3b49f87 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs @@ -129,6 +129,7 @@ public void Execute_Success_With_Ticket_Purchase( int dungeonTicketAdditionalPrice, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var scheduleSheet = _tableSheets.EventScheduleSheet; Assert.True(scheduleSheet.TryGetValue(eventScheduleId, out var scheduleRow)); @@ -164,7 +165,7 @@ public void Execute_Success_With_Ticket_Purchase( var ncgHas = newScheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency); - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); var nextStates = Execute( previousStates, @@ -300,6 +301,7 @@ public void Execute_Throw_InsufficientBalanceException( int eventDungeonStageId, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var eventDungeonInfoAddr = EventDungeonInfo.DeriveAddress(_avatarAddress, eventDungeonId); @@ -314,7 +316,7 @@ public void Execute_Throw_InsufficientBalanceException( var ncgHas = scheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency) - 1 * _ncgCurrency; - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); Assert.Throws(() => Execute( diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs index cdd034d7cc..beb6de5b48 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs @@ -130,6 +130,7 @@ public void Execute_Success_With_Ticket_Purchase( int dungeonTicketAdditionalPrice, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var scheduleSheet = _tableSheets.EventScheduleSheet; Assert.True(scheduleSheet.TryGetValue(eventScheduleId, out var scheduleRow)); @@ -165,7 +166,7 @@ public void Execute_Success_With_Ticket_Purchase( var ncgHas = newScheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency); - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); var nextStates = Execute( previousStates, @@ -301,6 +302,7 @@ public void Execute_Throw_InsufficientBalanceException( int eventDungeonStageId, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var eventDungeonInfoAddr = EventDungeonInfo.DeriveAddress(_avatarAddress, eventDungeonId); @@ -315,7 +317,7 @@ public void Execute_Throw_InsufficientBalanceException( var ncgHas = scheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency) - 1 * _ncgCurrency; - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); Assert.Throws(() => Execute( @@ -353,7 +355,8 @@ public void Execute_DuplicatedException(int slotIndex, int runeId, int slotIndex Assert.True(_tableSheets.EventScheduleSheet .TryGetValue(1001, out var scheduleRow)); - _initialStates = _initialStates.MintAsset(_agentAddress, 99999 * _ncgCurrency); + var context = new ActionContext(); + _initialStates = _initialStates.MintAsset(context, _agentAddress, 99999 * _ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs index 5300be93e8..f863d3e9f2 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs @@ -131,6 +131,7 @@ public void Execute_Success_With_Ticket_Purchase( int dungeonTicketAdditionalPrice, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var scheduleSheet = _tableSheets.EventScheduleSheet; Assert.True(scheduleSheet.TryGetValue(eventScheduleId, out var scheduleRow)); @@ -166,7 +167,7 @@ public void Execute_Success_With_Ticket_Purchase( var ncgHas = newScheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency); - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); var nextStates = Execute( previousStates, @@ -302,6 +303,7 @@ public void Execute_Throw_InsufficientBalanceException( int eventDungeonStageId, int numberOfTicketPurchases) { + var context = new ActionContext(); var previousStates = _initialStates; var eventDungeonInfoAddr = EventDungeonInfo.DeriveAddress(_avatarAddress, eventDungeonId); @@ -316,7 +318,7 @@ public void Execute_Throw_InsufficientBalanceException( var ncgHas = scheduleRow.GetDungeonTicketCost( numberOfTicketPurchases, _ncgCurrency) - 1 * _ncgCurrency; - previousStates = previousStates.MintAsset(_agentAddress, ncgHas); + previousStates = previousStates.MintAsset(context, _agentAddress, ncgHas); Assert.Throws(() => Execute( @@ -354,7 +356,8 @@ public void Execute_DuplicatedException(int slotIndex, int runeId, int slotIndex Assert.True(_tableSheets.EventScheduleSheet .TryGetValue(1001, out var scheduleRow)); - _initialStates = _initialStates.MintAsset(_agentAddress, 99999 * _ncgCurrency); + var context = new ActionContext(); + _initialStates = _initialStates.MintAsset(context, _agentAddress, 99999 * _ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index 49cea4bc2e..67c9921b15 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -122,6 +122,7 @@ public void Execute( Type exc ) { + var context = new ActionContext(); var state = _initialState; if (agentExist) { @@ -175,7 +176,7 @@ Type exc { state = state .SetState(stakeStateAddress, stakeState.SerializeV2()) - .MintAsset(stakeStateAddress, requiredGold * _ncgCurrency); + .MintAsset(context, stakeStateAddress, requiredGold * _ncgCurrency); } if (monsterCollect) @@ -187,7 +188,7 @@ Type exc new MonsterCollectionState(mcAddress, monsterCollectLevel, 1) .Serialize() ) - .MintAsset(mcAddress, requiredGold * _ncgCurrency); + .MintAsset(context, mcAddress, requiredGold * _ncgCurrency); } } diff --git a/.Lib9c.Tests/Action/HackAndSlash18Test.cs b/.Lib9c.Tests/Action/HackAndSlash18Test.cs index 7acd6fa1f4..61e2d73bc1 100644 --- a/.Lib9c.Tests/Action/HackAndSlash18Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash18Test.cs @@ -1372,6 +1372,7 @@ public void CheckUsedApByStaking(int level, int playCount) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1387,7 +1388,7 @@ public void CheckUsedApByStaking(int level, int playCount) .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var expectedAp = previousAvatarState.actionPoint - _tableSheets.StakeActionPointCoefficientSheet.GetActionPointByStaking( diff --git a/.Lib9c.Tests/Action/HackAndSlash19Test.cs b/.Lib9c.Tests/Action/HackAndSlash19Test.cs index 4b81bbb325..b227f36e49 100644 --- a/.Lib9c.Tests/Action/HackAndSlash19Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash19Test.cs @@ -1295,6 +1295,7 @@ public void CheckUsedApByStaking(int level, int playCount) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1310,7 +1311,7 @@ public void CheckUsedApByStaking(int level, int playCount) .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var expectedAp = previousAvatarState.actionPoint - _tableSheets.StakeActionPointCoefficientSheet.GetActionPointByStaking( diff --git a/.Lib9c.Tests/Action/HackAndSlash20Test.cs b/.Lib9c.Tests/Action/HackAndSlash20Test.cs index 0d975abc90..f60fca29cd 100644 --- a/.Lib9c.Tests/Action/HackAndSlash20Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash20Test.cs @@ -1385,6 +1385,7 @@ public void CheckUsedApByStaking(int level, int playCount) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1400,7 +1401,7 @@ public void CheckUsedApByStaking(int level, int playCount) .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var expectedAp = previousAvatarState.actionPoint - _tableSheets.StakeActionPointCoefficientSheet.GetActionPointByStaking( @@ -1463,6 +1464,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1478,7 +1480,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var itemCount = previousAvatarState.inventory.Items .FirstOrDefault(i => i.item.Id == itemId)?.count ?? 0; @@ -1739,6 +1741,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousAvatarState.Update(mail); } + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) @@ -1751,7 +1754,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 ); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/HackAndSlash21Test.cs b/.Lib9c.Tests/Action/HackAndSlash21Test.cs index 64a5fd79df..1ca21a15eb 100644 --- a/.Lib9c.Tests/Action/HackAndSlash21Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash21Test.cs @@ -1386,6 +1386,7 @@ public void CheckUsedApByStaking(int level, int playCount) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1401,7 +1402,7 @@ public void CheckUsedApByStaking(int level, int playCount) .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var expectedAp = previousAvatarState.actionPoint - _tableSheets.StakeActionPointCoefficientSheet.GetActionPointByStaking( @@ -1464,6 +1465,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == level)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState( @@ -1479,7 +1481,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR .SetState( _avatarAddress.Derive("world_ids"), List.Empty.Add(worldId.Serialize())) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var itemCount = previousAvatarState.inventory.Items .FirstOrDefault(i => i.item.Id == itemId)?.count ?? 0; @@ -1740,6 +1742,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousAvatarState.Update(mail); } + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, previousAvatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) @@ -1752,7 +1755,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 ); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs index dc4b06740b..fc81346794 100644 --- a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs @@ -103,7 +103,8 @@ public HackAndSlashRandomBuffTest() [InlineData(20, false, 1, 10_000, typeof(NotEnoughFungibleAssetValueException))] public void Execute(int stageId, bool advancedGacha, int balance, int gatheredStar, Type excType) { - var states = _initialState.MintAsset(_agentAddress, balance * _currency); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _agentAddress, balance * _currency); var gameConfigState = _initialState.GetGameConfigState(); var avatarState = new AvatarState( _avatarAddress, @@ -174,7 +175,8 @@ public void Execute(int stageId, bool advancedGacha, int balance, int gatheredSt [InlineData(true, CrystalRandomBuffSheet.Row.BuffRank.S)] public void ContainMinimumBuffRank(bool advancedGacha, CrystalRandomBuffSheet.Row.BuffRank minimumRank) { - var states = _initialState.MintAsset(_agentAddress, 100_000_000 * _currency); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _agentAddress, 100_000_000 * _currency); var gameConfigState = _initialState.GetGameConfigState(); var avatarState = new AvatarState( _avatarAddress, diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs index 53b5c0976a..a305636242 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs @@ -825,10 +825,11 @@ public void ExecuteWithStake(int stakingLevel) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == stakingLevel)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(stakeStateAddress, stakeState.Serialize()) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var stageSheet = _initialState.GetSheet(); if (stageSheet.TryGetValue(stageId, out var stageRow)) { diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs index 8611478ad2..e1fe6d158b 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs @@ -828,10 +828,11 @@ public void ExecuteWithStake(int stakingLevel) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == stakingLevel)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(stakeStateAddress, stakeState.Serialize()) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var stageSheet = _initialState.GetSheet(); if (stageSheet.TryGetValue(stageId, out var stageRow)) { diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs index 5bc88ae728..72e82421f0 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs @@ -839,10 +839,11 @@ public void ExecuteWithStake(int stakingLevel) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == stakingLevel)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(stakeStateAddress, stakeState.Serialize()) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var stageSheet = _initialState.GetSheet(); if (stageSheet.TryGetValue(stageId, out var stageRow)) { diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs index 58465859ec..f36953dc09 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs @@ -840,10 +840,11 @@ public void ExecuteWithStake(int stakingLevel) var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == stakingLevel)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(stakeStateAddress, stakeState.Serialize()) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var stageSheet = _initialState.GetSheet(); if (stageSheet.TryGetValue(stageId, out var stageRow)) { @@ -917,10 +918,11 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 var stakeState = new StakeState(stakeStateAddress, 1); var requiredGold = _tableSheets.StakeRegularRewardSheet.OrderedRows .FirstOrDefault(r => r.Level == stakingLevel)?.RequiredGold ?? 0; + var context = new ActionContext(); var state = _initialState .SetState(_avatarAddress, avatarState.Serialize()) .SetState(stakeStateAddress, stakeState.Serialize()) - .MintAsset(stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); + .MintAsset(context, stakeStateAddress, requiredGold * _initialState.GetGoldCurrency()); var stageSheet = _initialState.GetSheet(); if (stageSheet.TryGetValue(stageId, out var stageRow)) { @@ -936,7 +938,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 playCount); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs index 687f86738c..307271f269 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs @@ -57,13 +57,14 @@ public ItemEnhancement0Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 47c1347bd2..22fd1abd5d 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -62,13 +62,14 @@ public ItemEnhancement10Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs index 19677be0c1..66a2493ee7 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs @@ -56,13 +56,14 @@ public ItemEnhancement2Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs index e4c04fa4de..dbb353b425 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs @@ -56,13 +56,14 @@ public ItemEnhancement3Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs index 9075d2bbce..c06f309a2a 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs @@ -57,13 +57,14 @@ public ItemEnhancement4Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs index f80f1628a5..652e061764 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs @@ -57,13 +57,14 @@ public ItemEnhancement5Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs index 9ab5ccafdb..27a4ea2e75 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs @@ -57,13 +57,14 @@ public ItemEnhancement6Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs index 9931124c9c..29de65c85d 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs @@ -59,13 +59,14 @@ public ItemEnhancement7Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs index 8472aaa053..338b3c53d4 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs @@ -59,13 +59,14 @@ public ItemEnhancement8Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index fde12965d6..519dfd2217 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -60,13 +60,14 @@ public ItemEnhancement9Test() _slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 65574ab111..52ef5cfd92 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -56,13 +56,14 @@ public ItemEnhancementTest() var gold = new GoldCurrencyState(_currency); var slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); + var context = new ActionContext(); _initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(slotAddress, new CombinationSlotState(slotAddress, 0).Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000) - .TransferAsset(Addresses.GoldCurrency, _agentAddress, gold.Currency * 1000); + .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)); @@ -96,6 +97,7 @@ public void Execute( bool stake ) { + var context = new ActionContext(); var row = _tableSheets.EquipmentItemSheet.Values.First(r => r.Grade == 1); var equipment = (Equipment)ItemFactory.CreateItemUsable(row, default, 0, level); var materialId = Guid.NewGuid(); @@ -152,7 +154,7 @@ bool stake var stakeState = new StakeState(stakeStateAddress, 1); _initialState = _initialState .SetState(stakeStateAddress, stakeState.SerializeV2()) - .MintAsset(stakeStateAddress, requiredGold * _currency); + .MintAsset(context, stakeStateAddress, requiredGold * _currency); } else { @@ -161,7 +163,7 @@ bool stake mcAddress, new MonsterCollectionState(mcAddress, monsterCollectLevel, 0).Serialize() ) - .MintAsset(mcAddress, requiredGold * _currency); + .MintAsset(context, mcAddress, requiredGold * _currency); } } diff --git a/.Lib9c.Tests/Action/JoinArena1Test.cs b/.Lib9c.Tests/Action/JoinArena1Test.cs index b5cbdad8a5..1a8db86049 100644 --- a/.Lib9c.Tests/Action/JoinArena1Test.cs +++ b/.Lib9c.Tests/Action/JoinArena1Test.cs @@ -203,7 +203,8 @@ public void Execute(long blockIndex, int championshipId, int round, string balan avatarState = GetAvatarState(avatarState, out var equipments, out var costumes); avatarState = AddMedal(avatarState, row, 80); - var state = _state.MintAsset(_signer, FungibleAssetValue.Parse(_currency, balance)); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, FungibleAssetValue.Parse(_currency, balance)); var action = new JoinArena1() { @@ -332,7 +333,8 @@ public void Execute_NotEnoughMedalException(int round) var avatarState = _state.GetAvatarStateV2(_avatarAddress); GetAvatarState(avatarState, out var equipments, out var costumes); var preCurrency = 99800100000 * _currency; - var state = _state.MintAsset(_signer, preCurrency); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, preCurrency); var action = new JoinArena1() { diff --git a/.Lib9c.Tests/Action/JoinArena2Test.cs b/.Lib9c.Tests/Action/JoinArena2Test.cs index fd7f5226f1..402544ec27 100644 --- a/.Lib9c.Tests/Action/JoinArena2Test.cs +++ b/.Lib9c.Tests/Action/JoinArena2Test.cs @@ -203,7 +203,8 @@ public void Execute(long blockIndex, int championshipId, int round, string balan avatarState = GetAvatarState(avatarState, out var equipments, out var costumes); avatarState = AddMedal(avatarState, row, 80); - var state = _state.MintAsset(_signer, FungibleAssetValue.Parse(_currency, balance)); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, FungibleAssetValue.Parse(_currency, balance)); var action = new JoinArena2() { @@ -335,7 +336,8 @@ public void Execute_NotEnoughMedalException(int round) var avatarState = _state.GetAvatarStateV2(_avatarAddress); GetAvatarState(avatarState, out var equipments, out var costumes); var preCurrency = 99800100000 * _currency; - var state = _state.MintAsset(_signer, preCurrency); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, preCurrency); var action = new JoinArena2() { diff --git a/.Lib9c.Tests/Action/JoinArena3Test.cs b/.Lib9c.Tests/Action/JoinArena3Test.cs index 7c2e7abfed..645b7e4a4d 100644 --- a/.Lib9c.Tests/Action/JoinArena3Test.cs +++ b/.Lib9c.Tests/Action/JoinArena3Test.cs @@ -206,7 +206,8 @@ public void Execute(long blockIndex, int championshipId, int round, string balan avatarState = GetAvatarState(avatarState, out var equipments, out var costumes); avatarState = AddMedal(avatarState, row, 80); - var state = _state.MintAsset(_signer, FungibleAssetValue.Parse(_currency, balance)); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, FungibleAssetValue.Parse(_currency, balance)); var action = new JoinArena() { @@ -338,7 +339,8 @@ public void Execute_NotEnoughMedalException(int round) var avatarState = _state.GetAvatarStateV2(_avatarAddress); GetAvatarState(avatarState, out var equipments, out var costumes); var preCurrency = 99800100000 * _currency; - var state = _state.MintAsset(_signer, preCurrency); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, preCurrency); var action = new JoinArena() { @@ -528,9 +530,10 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 avatarState = GetAvatarState(avatarState, out var equipments, out var costumes); avatarState = AddMedal(avatarState, row, 80); - var state = _state.MintAsset(_signer, FungibleAssetValue.Parse(_currency, balance)); + var context = new ActionContext(); + var state = _state.MintAsset(context, _signer, FungibleAssetValue.Parse(_currency, balance)); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_signer, 99999 * ncgCurrency); + state = state.MintAsset(context, _signer, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs index c25da2a51c..60ecabe9e1 100644 --- a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs +++ b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs @@ -94,9 +94,10 @@ public void Execute_After_V100220ObsoleteIndex() var monsterCollectionState = new MonsterCollectionState( monsterCollectionAddress, 1, ActionObsoleteConfig.V100220ObsoleteIndex - MonsterCollectionState.RewardInterval); var currency = _state.GetGoldCurrency(); + var context = new ActionContext(); var states = _state .SetState(monsterCollectionAddress, monsterCollectionState.Serialize()) - .MintAsset(monsterCollectionAddress, currency * 100); + .MintAsset(context, monsterCollectionAddress, currency * 100); MigrateMonsterCollection action = new MigrateMonsterCollection(_avatarAddress); states = action.Execute(new ActionContext { @@ -124,9 +125,10 @@ public void Execute(int collectionLevel, long claimBlockIndex, long receivedBloc var monsterCollectionState = new MonsterCollectionState(collectionAddress, collectionLevel, 0); Currency currency = _state.GetGoldCurrency(); + var context = new ActionContext(); var states = _state .SetState(collectionAddress, monsterCollectionState.Serialize()) - .MintAsset(monsterCollectionState.address, stakedAmount * currency); + .MintAsset(context, monsterCollectionState.address, stakedAmount * currency); Assert.Equal(0, states.GetAgentState(_signer).MonsterCollectionRound); Assert.Equal(0 * currency, states.GetBalance(_signer, currency)); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs index 556dc61989..5872b80b7e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs @@ -809,6 +809,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousAvatarState.Update(mail); } + var context = new ActionContext(); var state = _initialState; state = _initialState .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) @@ -817,7 +818,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 .SetState(_avatarAddress, previousAvatarState.SerializeV2()); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs index 3f53e0a53d..8a4a0847b2 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs @@ -810,6 +810,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousAvatarState.Update(mail); } + var context = new ActionContext(); var state = _initialState; state = _initialState .SetState(_avatarAddress.Derive(LegacyInventoryKey), previousAvatarState.inventory.Serialize()) @@ -818,7 +819,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 .SetState(_avatarAddress, previousAvatarState.SerializeV2()); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/MonsterCollect0Test.cs b/.Lib9c.Tests/Action/MonsterCollect0Test.cs index e6bc06e134..20f8dea707 100644 --- a/.Lib9c.Tests/Action/MonsterCollect0Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect0Test.cs @@ -60,6 +60,7 @@ public void Execute(bool exist, int level, int monsterCollectionRound, int prevL prevAgentState.IncreaseCollectionRound(); } + var context = new ActionContext(); _initialState = _initialState.SetState(_signer, prevAgentState.Serialize()); Currency currency = _initialState.GetGoldCurrency(); @@ -69,7 +70,7 @@ public void Execute(bool exist, int level, int monsterCollectionRound, int prevL if (i > prevLevel) { MonsterCollectionSheet.Row row = _tableSheets.MonsterCollectionSheet[i]; - _initialState = _initialState.MintAsset(_signer, row.RequiredGold * currency); + _initialState = _initialState.MintAsset(context, _signer, row.RequiredGold * currency); } } diff --git a/.Lib9c.Tests/Action/MonsterCollect2Test.cs b/.Lib9c.Tests/Action/MonsterCollect2Test.cs index 35773c0a45..707f8d4ed9 100644 --- a/.Lib9c.Tests/Action/MonsterCollect2Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect2Test.cs @@ -60,6 +60,7 @@ public void Execute(int? prevLevel, int level, long blockIndex, Type exc, int? e Currency currency = _initialState.GetGoldCurrency(); FungibleAssetValue balance = currency * 10000000; FungibleAssetValue staked = currency * 0; + var context = new ActionContext(); if (prevLevel is { } prevLevelNotNull) { List rewards = _tableSheets.MonsterCollectionRewardSheet[prevLevelNotNull].Rewards; @@ -74,13 +75,13 @@ public void Execute(int? prevLevel, int level, long blockIndex, Type exc, int? e { MonsterCollectionSheet.Row row = _tableSheets.MonsterCollectionSheet[i + 1]; staked += row.RequiredGold * currency; - _initialState = _initialState.MintAsset(monsterCollectionAddress, row.RequiredGold * currency); + _initialState = _initialState.MintAsset(context, monsterCollectionAddress, row.RequiredGold * currency); } } balance -= staked; - _initialState = _initialState.MintAsset(_signer, balance); + _initialState = _initialState.MintAsset(context, _signer, balance); var action = new MonsterCollect2 { level = level, diff --git a/.Lib9c.Tests/Action/MonsterCollectTest.cs b/.Lib9c.Tests/Action/MonsterCollectTest.cs index a7e767a200..9239b56ba9 100644 --- a/.Lib9c.Tests/Action/MonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/MonsterCollectTest.cs @@ -61,6 +61,7 @@ public void Execute(int balance, int? prevLevel, int level, long blockIndex, Typ Currency currency = _initialState.GetGoldCurrency(); FungibleAssetValue balanceFav = currency * balance; FungibleAssetValue staked = currency * 0; + var context = new ActionContext(); if (prevLevel is { } prevLevelNotNull) { List rewards = _tableSheets.MonsterCollectionRewardSheet[prevLevelNotNull].Rewards; @@ -75,13 +76,13 @@ public void Execute(int balance, int? prevLevel, int level, long blockIndex, Typ { MonsterCollectionSheet.Row row = _tableSheets.MonsterCollectionSheet[i + 1]; staked += row.RequiredGold * currency; - _initialState = _initialState.MintAsset(monsterCollectionAddress, row.RequiredGold * currency); + _initialState = _initialState.MintAsset(context, monsterCollectionAddress, row.RequiredGold * currency); } } balanceFav -= staked; - _initialState = _initialState.MintAsset(_signer, balanceFav); + _initialState = _initialState.MintAsset(context, _signer, balanceFav); var action = new MonsterCollect { level = level, diff --git a/.Lib9c.Tests/Action/PetEnhancement0Test.cs b/.Lib9c.Tests/Action/PetEnhancement0Test.cs index bdb2b1027b..9baa0a0ac4 100644 --- a/.Lib9c.Tests/Action/PetEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/PetEnhancement0Test.cs @@ -4,6 +4,7 @@ namespace Lib9c.Tests.Action using Bencodex.Types; using Lib9c.Tests.Util; using Libplanet; + using Libplanet.Action; using Libplanet.Assets; using Libplanet.Crypto; using Libplanet.State; @@ -285,6 +286,7 @@ private static IAccountStateDelta Execute( bool removePetCostRow = false, bool removePetCostRowWithTargetPetLevel = false) { + var context = new ActionContext(); var petAddress = PetState.DeriveAddress(avatarAddr, petId); if (currentPetLevel > 0) { @@ -314,8 +316,8 @@ private static IAccountStateDelta Execute( targetPetLevel); prevStates = prevStates - .MintAsset(agentAddr, ncgCost * ncgCurrency) - .MintAsset(avatarAddr, soulStoneCost * soulStoneCurrency); + .MintAsset(context, agentAddr, ncgCost * ncgCurrency) + .MintAsset(context, avatarAddr, soulStoneCost * soulStoneCurrency); } if (removePetRow) diff --git a/.Lib9c.Tests/Action/Raid1Test.cs b/.Lib9c.Tests/Action/Raid1Test.cs index 5c1f6a0235..3c4eb54288 100644 --- a/.Lib9c.Tests/Action/Raid1Test.cs +++ b/.Lib9c.Tests/Action/Raid1Test.cs @@ -113,6 +113,7 @@ long executeOffset var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -150,7 +151,7 @@ long executeOffset if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -184,7 +185,7 @@ long executeOffset if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state diff --git a/.Lib9c.Tests/Action/Raid2Test.cs b/.Lib9c.Tests/Action/Raid2Test.cs index 457fcee3ab..121cc71607 100644 --- a/.Lib9c.Tests/Action/Raid2Test.cs +++ b/.Lib9c.Tests/Action/Raid2Test.cs @@ -116,6 +116,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -153,7 +154,7 @@ bool raiderListExist if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -196,7 +197,7 @@ bool raiderListExist if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state diff --git a/.Lib9c.Tests/Action/Raid3Test.cs b/.Lib9c.Tests/Action/Raid3Test.cs index 8f99e8dd9f..1886b93d39 100644 --- a/.Lib9c.Tests/Action/Raid3Test.cs +++ b/.Lib9c.Tests/Action/Raid3Test.cs @@ -117,6 +117,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -154,7 +155,7 @@ bool raiderListExist if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -197,7 +198,7 @@ bool raiderListExist if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state diff --git a/.Lib9c.Tests/Action/Raid4Test.cs b/.Lib9c.Tests/Action/Raid4Test.cs index 34899ccc5c..5775e72426 100644 --- a/.Lib9c.Tests/Action/Raid4Test.cs +++ b/.Lib9c.Tests/Action/Raid4Test.cs @@ -136,6 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -174,7 +175,7 @@ int runeId2 if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -217,7 +218,7 @@ int runeId2 if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state @@ -388,7 +389,7 @@ Dictionary rewardMap if (exc == typeof(DuplicatedRuneIdException) || exc == typeof(DuplicatedRuneSlotIndexException)) { var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/Raid5Test.cs b/.Lib9c.Tests/Action/Raid5Test.cs index 39d9ef319d..cea946b201 100644 --- a/.Lib9c.Tests/Action/Raid5Test.cs +++ b/.Lib9c.Tests/Action/Raid5Test.cs @@ -136,6 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -174,7 +175,7 @@ int runeId2 if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -217,7 +218,7 @@ int runeId2 if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state @@ -388,7 +389,7 @@ Dictionary rewardMap if (exc == typeof(DuplicatedRuneIdException) || exc == typeof(DuplicatedRuneSlotIndexException)) { var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/Raid6Test.cs b/.Lib9c.Tests/Action/Raid6Test.cs index a75573d3f2..13b731e761 100644 --- a/.Lib9c.Tests/Action/Raid6Test.cs +++ b/.Lib9c.Tests/Action/Raid6Test.cs @@ -136,6 +136,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; + var context = new ActionContext(); IAccountStateDelta state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -174,7 +175,7 @@ int runeId2 if (crystalExist) { var price = _tableSheets.WorldBossListSheet[raidId].EntranceFee; - state = state.MintAsset(_agentAddress, price * crystal); + state = state.MintAsset(context, _agentAddress, price * crystal); } if (raiderStateExist) @@ -217,7 +218,7 @@ int runeId2 if (ncgExist) { var row = _tableSheets.WorldBossListSheet.FindRowByBlockIndex(blockIndex); - state = state.MintAsset(_agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); + state = state.MintAsset(context, _agentAddress, (row.TicketPrice + row.AdditionalTicketPrice * purchaseCount) * _goldCurrency); } state = state @@ -388,7 +389,7 @@ Dictionary rewardMap if (exc == typeof(DuplicatedRuneIdException) || exc == typeof(DuplicatedRuneSlotIndexException)) { var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(_agentAddress, 99999 * ncgCurrency); + state = state.MintAsset(context, _agentAddress, 99999 * ncgCurrency); var unlockRuneSlot = new UnlockRuneSlot() { diff --git a/.Lib9c.Tests/Action/RankingBattle0Test.cs b/.Lib9c.Tests/Action/RankingBattle0Test.cs index 9832fc8d06..9e7177e078 100644 --- a/.Lib9c.Tests/Action/RankingBattle0Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle0Test.cs @@ -381,6 +381,7 @@ public void ExecuteThrowNotEnoughFungibleAssetValueException() var arenaInfo = previousWeeklyArenaState.GetArenaInfo(_avatar1Address); previousWeeklyArenaState.Update(new ArenaInfo(arenaInfo)); + var context = new ActionContext(); var previousState = _initialState.SetState( _weeklyArenaAddress, previousWeeklyArenaState.Serialize()); @@ -396,6 +397,7 @@ public void ExecuteThrowNotEnoughFungibleAssetValueException() if (previousAgentGoldState.Sign > 0) { previousState = _initialState.TransferAsset( + context, _agent1Address, Addresses.GoldCurrency, previousAgentGoldState); diff --git a/.Lib9c.Tests/Action/RawState.cs b/.Lib9c.Tests/Action/RawState.cs index 4a846af573..15c6ae490f 100644 --- a/.Lib9c.Tests/Action/RawState.cs +++ b/.Lib9c.Tests/Action/RawState.cs @@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action using System.Linq; using Bencodex.Types; using Libplanet; + using Libplanet.Action; using Libplanet.Assets; using Libplanet.Consensus; using Libplanet.State; @@ -77,7 +78,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) return currency * 0; } - public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) + public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { var currency = value.Currency; var rawStates = _rawStates.SetItem( @@ -94,6 +95,7 @@ public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) } public IAccountStateDelta TransferAsset( + IActionContext context, Address sender, Address recipient, FungibleAssetValue value, @@ -125,7 +127,7 @@ public IAccountStateDelta TransferAsset( return new RawState(newRawStates); } - public IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value) + public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { var currency = value.Currency; var rawStates = _rawStates.SetItem( diff --git a/.Lib9c.Tests/Action/RedeemCode0Test.cs b/.Lib9c.Tests/Action/RedeemCode0Test.cs index 44aab5eb0f..2602d76200 100644 --- a/.Lib9c.Tests/Action/RedeemCode0Test.cs +++ b/.Lib9c.Tests/Action/RedeemCode0Test.cs @@ -67,12 +67,13 @@ public void Execute() var goldState = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); var initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(RedeemCodeState.Address, prevRedeemCodesState.Serialize()) .SetState(GoldCurrencyState.Address, goldState.Serialize()) - .MintAsset(GoldCurrencyState.Address, goldState.Currency * 100000000); + .MintAsset(context, GoldCurrencyState.Address, goldState.Currency * 100000000); foreach (var (key, value) in _sheets) { diff --git a/.Lib9c.Tests/Action/RedeemCodeTest.cs b/.Lib9c.Tests/Action/RedeemCodeTest.cs index e97bd0a9c1..610edddfc5 100644 --- a/.Lib9c.Tests/Action/RedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/RedeemCodeTest.cs @@ -70,11 +70,12 @@ public void Execute(bool backward) var goldState = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + var context = new ActionContext(); var initialState = new State() .SetState(_agentAddress, agentState.Serialize()) .SetState(RedeemCodeState.Address, prevRedeemCodesState.Serialize()) .SetState(GoldCurrencyState.Address, goldState.Serialize()) - .MintAsset(GoldCurrencyState.Address, goldState.Currency * 100000000); + .MintAsset(context, GoldCurrencyState.Address, goldState.Currency * 100000000); if (backward) { diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index 0485a63426..dbac77b50c 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -206,9 +206,10 @@ public void Execute() _avatarState.inventory.AddItem(equipment); Assert.Equal(2, _avatarState.inventory.Items.Count); var asset = 3 * RuneHelper.DailyRewardRune; + var context = new ActionContext(); _initialState = _initialState .SetState(AvatarAddress, _avatarState.Serialize()) - .MintAsset(AvatarAddress, asset); + .MintAsset(context, AvatarAddress, asset); var action = new RegisterProduct0 { AvatarAddress = AvatarAddress, diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 8330bc51e7..11e01340f4 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -206,9 +206,10 @@ public void Execute() _avatarState.inventory.AddItem(equipment); Assert.Equal(2, _avatarState.inventory.Items.Count); var asset = 3 * RuneHelper.DailyRewardRune; + var context = new ActionContext(); _initialState = _initialState .SetState(AvatarAddress, _avatarState.Serialize()) - .MintAsset(AvatarAddress, asset); + .MintAsset(context, AvatarAddress, asset); var action = new RegisterProduct { AvatarAddress = AvatarAddress, diff --git a/.Lib9c.Tests/Action/RequestPledgeTest.cs b/.Lib9c.Tests/Action/RequestPledgeTest.cs index 61cf57d85a..01cdf957c1 100644 --- a/.Lib9c.Tests/Action/RequestPledgeTest.cs +++ b/.Lib9c.Tests/Action/RequestPledgeTest.cs @@ -20,7 +20,8 @@ public void Execute(int contractedMead) { Currency mead = Currencies.Mead; Address patron = new PrivateKey().ToAddress(); - IAccountStateDelta states = new State().MintAsset(patron, 2 * mead); + var context = new ActionContext(); + IAccountStateDelta states = new State().MintAsset(context, patron, 2 * mead); var address = new PrivateKey().ToAddress(); var action = new RequestPledge { diff --git a/.Lib9c.Tests/Action/RewardGoldTest.cs b/.Lib9c.Tests/Action/RewardGoldTest.cs index af7c59cab2..85f564d0cd 100644 --- a/.Lib9c.Tests/Action/RewardGoldTest.cs +++ b/.Lib9c.Tests/Action/RewardGoldTest.cs @@ -76,10 +76,11 @@ public RewardGoldTest() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 + IActionContext context = new ActionContext(); _baseState = (State)new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState(Addresses.GoldDistribution, GoldDistributionTest.Fixture.Select(v => v.Serialize()).Serialize()) - .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); + .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); } [Theory] @@ -571,15 +572,16 @@ public void TransferMead(int patronMead, int balance) var agentAddress = new PrivateKey().ToAddress(); var patronAddress = new PrivateKey().ToAddress(); var contractAddress = agentAddress.GetPledgeAddress(); + IActionContext context = new ActionContext(); IAccountStateDelta states = new State() - .MintAsset(patronAddress, patronMead * Currencies.Mead) - .TransferAsset(patronAddress, agentAddress, 1 * Currencies.Mead) + .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())) - .BurnAsset(agentAddress, 1 * Currencies.Mead); + .BurnAsset(context, agentAddress, 1 * Currencies.Mead); Assert.Equal(balance * Currencies.Mead, states.GetBalance(patronAddress, Currencies.Mead)); Assert.Equal(0 * Currencies.Mead, states.GetBalance(agentAddress, Currencies.Mead)); - var nextState = RewardGold.TransferMead(states); + var nextState = RewardGold.TransferMead(context, states); // transfer mead from patron to agent Assert.Equal(0 * Currencies.Mead, nextState.GetBalance(patronAddress, Currencies.Mead)); Assert.Equal(balance * Currencies.Mead, nextState.GetBalance(agentAddress, Currencies.Mead)); diff --git a/.Lib9c.Tests/Action/RuneEnhancement0Test.cs b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs index 00e04bcbb7..42b9c7c6f9 100644 --- a/.Lib9c.Tests/Action/RuneEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs @@ -39,6 +39,7 @@ public void Execute(int seed) .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); + var context = new ActionContext(); var state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -94,9 +95,9 @@ public void Execute(int seed) throw new RuneNotFoundException($"[{nameof(Execute)}] "); } - state = state.MintAsset(agentAddress, ncgBal); - state = state.MintAsset(agentAddress, crystalBal); - state = state.MintAsset(avatarState.address, runeBal); + state = state.MintAsset(context, agentAddress, ncgBal); + state = state.MintAsset(context, agentAddress, crystalBal); + state = state.MintAsset(context, avatarState.address, runeBal); var action = new RuneEnhancement0() { @@ -143,9 +144,9 @@ public void Execute(int seed) var costCrystal = tryCount * cost.CrystalQuantity * crystalCurrency; var costRune = tryCount * cost.RuneStoneQuantity * runeCurrency; - nextState = nextState.MintAsset(agentAddress, costNcg); - nextState = nextState.MintAsset(agentAddress, costCrystal); - nextState = nextState.MintAsset(avatarState.address, costRune); + nextState = nextState.MintAsset(context, agentAddress, costNcg); + nextState = nextState.MintAsset(context, agentAddress, costCrystal); + nextState = nextState.MintAsset(context, avatarState.address, costRune); var finalNcgBal = nextState.GetBalance(agentAddress, ncgCurrency); var finalCrystalBal = nextState.GetBalance(agentAddress, crystalCurrency); @@ -290,6 +291,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); + var context = new ActionContext(); var state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -337,17 +339,17 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, if (ncg) { - state = state.MintAsset(agentAddress, cost.NcgQuantity * ncgCurrency); + state = state.MintAsset(context, agentAddress, cost.NcgQuantity * ncgCurrency); } if (crystal) { - state = state.MintAsset(agentAddress, cost.CrystalQuantity * crystalCurrency); + state = state.MintAsset(context, agentAddress, cost.CrystalQuantity * crystalCurrency); } if (rune) { - state = state.MintAsset(avatarState.address, cost.RuneStoneQuantity * runeCurrency); + state = state.MintAsset(context, avatarState.address, cost.RuneStoneQuantity * runeCurrency); } var action = new RuneEnhancement0() diff --git a/.Lib9c.Tests/Action/RuneEnhancementTest.cs b/.Lib9c.Tests/Action/RuneEnhancementTest.cs index da4457ab22..0a1c7d939f 100644 --- a/.Lib9c.Tests/Action/RuneEnhancementTest.cs +++ b/.Lib9c.Tests/Action/RuneEnhancementTest.cs @@ -54,6 +54,7 @@ public void Execute(int seed) rankingMapAddress ); agentState.avatarAddresses.Add(0, avatarAddress); + var context = new ActionContext(); var state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) @@ -104,9 +105,9 @@ public void Execute(int seed) throw new RuneNotFoundException($"[{nameof(Execute)}] "); } - state = state.MintAsset(agentAddress, ncgBal); - state = state.MintAsset(agentAddress, crystalBal); - state = state.MintAsset(avatarState.address, runeBal); + state = state.MintAsset(context, agentAddress, ncgBal); + state = state.MintAsset(context, agentAddress, crystalBal); + state = state.MintAsset(context, avatarState.address, runeBal); var action = new RuneEnhancement() { @@ -153,9 +154,9 @@ public void Execute(int seed) var costCrystal = tryCount * cost.CrystalQuantity * crystalCurrency; var costRune = tryCount * cost.RuneStoneQuantity * runeCurrency; - nextState = nextState.MintAsset(agentAddress, costNcg); - nextState = nextState.MintAsset(agentAddress, costCrystal); - nextState = nextState.MintAsset(avatarState.address, costRune); + nextState = nextState.MintAsset(context, agentAddress, costNcg); + nextState = nextState.MintAsset(context, agentAddress, costCrystal); + nextState = nextState.MintAsset(context, avatarState.address, costRune); var finalNcgBal = nextState.GetBalance(agentAddress, ncgCurrency); var finalCrystalBal = nextState.GetBalance(agentAddress, crystalCurrency); @@ -332,6 +333,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, rankingMapAddress ); agentState.avatarAddresses.Add(0, avatarAddress); + var context = new ActionContext(); var state = new State() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) @@ -374,17 +376,17 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, if (ncg) { - state = state.MintAsset(agentAddress, cost.NcgQuantity * ncgCurrency); + state = state.MintAsset(context, agentAddress, cost.NcgQuantity * ncgCurrency); } if (crystal) { - state = state.MintAsset(agentAddress, cost.CrystalQuantity * crystalCurrency); + state = state.MintAsset(context, agentAddress, cost.CrystalQuantity * crystalCurrency); } if (rune) { - state = state.MintAsset(avatarState.address, cost.RuneStoneQuantity * runeCurrency); + state = state.MintAsset(context, avatarState.address, cost.RuneStoneQuantity * runeCurrency); } var action = new RuneEnhancement() diff --git a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs index 5e3a31be6d..e0f65f3b4b 100644 --- a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs @@ -94,13 +94,14 @@ public ArenaScenarioTest(ITestOutputHelper outputHelper) } public IAccountStateDelta JoinArena( + IActionContext context, IRandom random, Address signer, Address avatarAddress, ArenaSheet.RoundData roundData) { var preCurrency = roundData.EntranceFee * _crystal; - _state = _state.MintAsset(signer, preCurrency); + _state = _state.MintAsset(context, signer, preCurrency); var action = new JoinArena() { diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index 593bee8363..8dc45a8d39 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -119,6 +119,7 @@ public MarketScenarioTest(ITestOutputHelper outputHelper) [Fact] public void Register_And_Buy() { + var context = new ActionContext(); var materialRow = _tableSheets.MaterialItemSheet.Values.First(); var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var tradableMaterial = ItemFactory.CreateTradableMaterial(materialRow); @@ -129,9 +130,9 @@ public void Register_And_Buy() _initialState = _initialState .SetState(_sellerAvatarAddress, _sellerAvatarState.Serialize()) .SetState(_sellerAvatarAddress2, _sellerAvatarState2.Serialize()) - .MintAsset(_buyerAgentAddress, 4 * _currency) - .MintAsset(_sellerAvatarAddress, 1 * RuneHelper.StakeRune) - .MintAsset(_sellerAvatarAddress2, 1 * RuneHelper.DailyRewardRune); + .MintAsset(context, _buyerAgentAddress, 4 * _currency) + .MintAsset(context, _sellerAvatarAddress, 1 * RuneHelper.StakeRune) + .MintAsset(context, _sellerAvatarAddress2, 1 * RuneHelper.DailyRewardRune); var random = new TestRandom(); var productInfoList = new List(); @@ -346,6 +347,7 @@ public void Register_And_Buy() [Fact] public void Register_And_Cancel() { + var context = new ActionContext(); var materialRow = _tableSheets.MaterialItemSheet.Values.First(); var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var tradableMaterial = ItemFactory.CreateTradableMaterial(materialRow); @@ -356,7 +358,7 @@ public void Register_And_Cancel() Assert.Equal(2, _sellerAvatarState.inventory.Items.Count); _initialState = _initialState .SetState(_sellerAvatarAddress, _sellerAvatarState.Serialize()) - .MintAsset(_sellerAvatarAddress, 1 * RuneHelper.StakeRune); + .MintAsset(context, _sellerAvatarAddress, 1 * RuneHelper.StakeRune); var action = new RegisterProduct { AvatarAddress = _sellerAvatarAddress, @@ -517,6 +519,7 @@ public void Register_And_Cancel() [Fact] public void Register_And_ReRegister() { + var context = new ActionContext(); var materialRow = _tableSheets.MaterialItemSheet.Values.First(); var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var tradableMaterial = ItemFactory.CreateTradableMaterial(materialRow); @@ -526,7 +529,7 @@ public void Register_And_ReRegister() _sellerAvatarState.inventory.AddItem(equipment); Assert.Equal(2, _sellerAvatarState.inventory.Items.Count); _initialState = _initialState - .MintAsset(_sellerAvatarAddress, 2 * RuneHelper.StakeRune) + .MintAsset(context, _sellerAvatarAddress, 2 * RuneHelper.StakeRune) .SetState(_sellerAvatarAddress, _sellerAvatarState.Serialize()); var action = new RegisterProduct { @@ -842,6 +845,7 @@ public void ReRegister_Order() [Fact] public void HardFork() { + var context = new ActionContext(); var materialRow = _tableSheets.MaterialItemSheet.Values.First(); var equipmentRow = _tableSheets.EquipmentItemSheet.Values.First(); var tradableMaterial = ItemFactory.CreateTradableMaterial(materialRow); @@ -852,8 +856,8 @@ public void HardFork() Assert.Equal(2, _sellerAvatarState.inventory.Items.Count); _initialState = _initialState .SetState(_sellerAvatarAddress, _sellerAvatarState.Serialize()) - .MintAsset(_buyerAgentAddress, 3 * _currency) - .MintAsset(_sellerAvatarAddress, 1 * RuneHelper.StakeRune); + .MintAsset(context, _buyerAgentAddress, 3 * _currency) + .MintAsset(context, _sellerAvatarAddress, 1 * RuneHelper.StakeRune); var action = new RegisterProduct0 { AvatarAddress = _sellerAvatarAddress, diff --git a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs index 51bcc5eed5..ded4fdff71 100644 --- a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs @@ -20,7 +20,8 @@ public void Contract() { Currency mead = Currencies.Mead; var patron = new PrivateKey().ToAddress(); - IAccountStateDelta states = new State().MintAsset(patron, 10 * mead); + IActionContext context = new ActionContext(); + IAccountStateDelta states = new State().MintAsset(context, patron, 10 * mead); var agentAddress = new PrivateKey().ToAddress(); var requestPledge = new RequestPledge @@ -28,7 +29,7 @@ public void Contract() AgentAddress = agentAddress, RefillMead = RequestPledge.DefaultRefillMead, }; - var states2 = Execute(states, requestPledge, patron); + var states2 = Execute(context, states, requestPledge, patron); Assert.Equal(8 * mead, states2.GetBalance(patron, mead)); Assert.Equal(1 * mead, states2.GetBalance(agentAddress, mead)); @@ -36,7 +37,7 @@ public void Contract() { PatronAddress = patron, }; - var states3 = Execute(states2, approvePledge, agentAddress); + var states3 = Execute(context, states2, approvePledge, agentAddress); Assert.Equal(4 * mead, states3.GetBalance(patron, mead)); Assert.Equal(4 * mead, states3.GetBalance(agentAddress, mead)); @@ -45,16 +46,16 @@ public void Contract() { AgentAddress = agentAddress, }; - var states4 = Execute(states3, endPledge, patron); + var states4 = Execute(context, states3, endPledge, patron); Assert.Equal(7 * mead, states4.GetBalance(patron, mead)); Assert.Equal(0 * mead, states4.GetBalance(agentAddress, mead)); // re-contract with Bencodex.Null - var states5 = Execute(states4, requestPledge, patron); + var states5 = Execute(context, states4, requestPledge, patron); Assert.Equal(5 * mead, states5.GetBalance(patron, mead)); Assert.Equal(1 * mead, states5.GetBalance(agentAddress, mead)); - var states6 = Execute(states5, approvePledge, agentAddress); + var states6 = Execute(context, states5, approvePledge, agentAddress); Assert.Equal(1 * mead, states6.GetBalance(patron, mead)); Assert.Equal(4 * mead, states6.GetBalance(agentAddress, mead)); } @@ -105,16 +106,16 @@ bool IsTarget(Type type) } } - private IAccountStateDelta Execute(IAccountStateDelta state, IAction action, Address signer) + private IAccountStateDelta Execute(IActionContext context, IAccountStateDelta state, IAction action, Address signer) { Assert.True(state.GetBalance(signer, Currencies.Mead) > 0 * Currencies.Mead); - var nextState = state.BurnAsset(signer, 1 * Currencies.Mead); + var nextState = state.BurnAsset(context, signer, 1 * Currencies.Mead); var executedState = action.Execute(new ActionContext { Signer = signer, PreviousStates = nextState, }); - return RewardGold.TransferMead(executedState); + return RewardGold.TransferMead(context, executedState); } } } diff --git a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs index 30b12b9bfd..12d251ad53 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs @@ -72,6 +72,7 @@ public void CraftEquipmentTest( stageList = stageList.Add(i.Serialize()); } + var context = new ActionContext(); var stateV2 = _initialStateV2.SetState( _avatarAddr.Derive("recipe_ids"), stageList @@ -104,7 +105,7 @@ public void CraftEquipmentTest( // Prepare stateV2 = CraftUtil.PrepareCombinationSlot(stateV2, _avatarAddr, 0); - stateV2 = CurrencyUtil.AddCurrency(stateV2, _agentAddr, crystal, expectedCrystal); + stateV2 = CurrencyUtil.AddCurrency(context, stateV2, _agentAddr, crystal, expectedCrystal); stateV2 = CraftUtil.UnlockStage( stateV2, _tableSheets, diff --git a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs index b57f77b82a..09bf0a772c 100644 --- a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs @@ -39,6 +39,7 @@ public void Craft_And_Equip() rankingMapAddress ); + var context = new ActionContext(); IAccountStateDelta initialState = new Tests.Action.State() .SetState(agentAddress, agentState.Serialize()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -64,7 +65,7 @@ public void Craft_And_Equip() var runeId = 30001; var runeRow = tableSheets.RuneSheet[runeId]; var rune = RuneHelper.ToCurrency(runeRow); - initialState = initialState.MintAsset(avatarAddress, rune * 1); + initialState = initialState.MintAsset(context, avatarAddress, rune * 1); var runeAddress = RuneState.DeriveAddress(avatarAddress, runeId); Assert.Null(initialState.GetState(runeAddress)); diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs index f7bafe1674..abf89c1ed0 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs @@ -631,7 +631,8 @@ public static IEnumerable StakeLessAfterLockupTestcases() [MemberData(nameof(StakeAndClaimStakeRewardTestCases))] public void StakeAndClaimStakeReward(long stakeAmount, (int ItemId, int Amount)[] expectedItems, long receiveBlockIndex) { - var states = _initialState.MintAsset(_signerAddress, _currency * stakeAmount); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _signerAddress, _currency * stakeAmount); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -681,7 +682,8 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta Assert.True(newStakeBlockIndex < StakeState.LockupInterval); Assert.True(stakeAmount < newStakeAmount); - var states = _initialState.MintAsset(_signerAddress, _currency * initialBalance); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -754,7 +756,8 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta Assert.True(initialBalance >= stakeAmount); Assert.True(newStakeAmount < stakeAmount); - var states = _initialState.MintAsset(_signerAddress, _currency * initialBalance); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -811,7 +814,8 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new // Validate testcases Assert.True(stakeAmount > newStakeAmount); - var states = _initialState.MintAsset(_signerAddress, _currency * initialBalance); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _signerAddress, _currency * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -903,7 +907,8 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new [Fact] public void StakeAndClaimStakeRewardBeforeRewardInterval() { - var states = _initialState.MintAsset(_signerAddress, _currency * 500); + var context = new ActionContext(); + var states = _initialState.MintAsset(context, _signerAddress, _currency * 500); IAction action = new Stake(500); states = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs index 50e0204d8e..bcadbae5d8 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs @@ -601,7 +601,8 @@ public void StakeAndClaimStakeReward( long receiveBlockIndex, int expectedRune) { - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * stakeAmount); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * stakeAmount); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -653,7 +654,8 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta // Validate testcases Assert.True(stakeAmount < newStakeAmount); - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -726,7 +728,8 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta Assert.True(initialBalance >= stakeAmount); Assert.True(newStakeAmount < stakeAmount); - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -787,7 +790,8 @@ public void StakeLessAfterLockup( // Validate testcases Assert.True(stakeAmount > newStakeAmount); - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -879,7 +883,8 @@ public void StakeLessAfterLockup( [Fact] public void StakeAndClaimStakeRewardBeforeRewardInterval() { - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * 500); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * 500); IAction action = new Stake(500); states = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs index c1fac650d3..d72ae993c3 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs @@ -684,7 +684,8 @@ public void StakeAndClaimStakeReward( string expectedCurrencyTicker, long expectedCurrencyAmount) { - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * stakeAmount); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * stakeAmount); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -750,8 +751,9 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta // Validate testcases Assert.True(stakeAmount < newStakeAmount); + var context = new ActionContext(); var states = - _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -824,8 +826,9 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta Assert.True(initialBalance >= stakeAmount); Assert.True(newStakeAmount < stakeAmount); + var context = new ActionContext(); var states = - _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -887,8 +890,9 @@ public void StakeLessAfterLockup( // Validate testcases Assert.True(stakeAmount > newStakeAmount); + var context = new ActionContext(); var states = - _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * initialBalance); + _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * initialBalance); IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext @@ -984,7 +988,8 @@ public void StakeLessAfterLockup( [Fact] public void StakeAndClaimStakeRewardBeforeRewardInterval() { - var states = _initialStatesWithAvatarStateV2.MintAsset(_agentAddr, _ncg * 500); + var context = new ActionContext(); + var states = _initialStatesWithAvatarStateV2.MintAsset(context, _agentAddr, _ncg * 500); IAction action = new Stake(500); states = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index b3ab28a7b3..97ed7a2978 100644 --- a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs +++ b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs @@ -38,7 +38,8 @@ public Task TransferCrystal() var senderAddress = senderPrivateKey.ToAddress(); var recipientAddress = recipientPrivateKey.ToAddress(); var crystal = CrystalCalculator.CRYSTAL; - var state = new State().MintAsset(senderAddress, crystal * 100); + var context = new ActionContext(); + var state = new State().MintAsset(context, senderAddress, crystal * 100); var actionContext = new ActionContext { Signer = senderAddress, @@ -66,7 +67,8 @@ public Task TransferWithMemo() var senderAddress = senderPrivateKey.ToAddress(); var recipientAddress = recipientPrivateKey.ToAddress(); var crystal = CrystalCalculator.CRYSTAL; - var state = new State().MintAsset(senderAddress, crystal * 100); + var context = new ActionContext(); + var state = new State().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 fcb06439e9..c1140811eb 100644 --- a/.Lib9c.Tests/Action/Stake0Test.cs +++ b/.Lib9c.Tests/Action/Stake0Test.cs @@ -28,6 +28,7 @@ public Stake0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); + var context = new ActionContext(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); @@ -48,7 +49,7 @@ public Stake0Test(ITestOutputHelper outputHelper) _signerAddress = new PrivateKey().ToAddress(); _initialState = _initialState .SetState(GoldCurrencyState.Address, _goldCurrencyState.Serialize()) - .MintAsset(_signerAddress, _currency * 100); + .MintAsset(context, _signerAddress, _currency * 100); } [Fact] @@ -92,9 +93,10 @@ public void Execute_Throws_WhenThereIsMonsterCollection() public void Execute_Throws_WhenClaimableExisting() { Address stakeStateAddress = StakeState.DeriveAddress(_signerAddress); + var context = new ActionContext(); var states = _initialState .SetState(stakeStateAddress, new StakeState(stakeStateAddress, 0).Serialize()) - .MintAsset(stakeStateAddress, _currency * 50); + .MintAsset(context, stakeStateAddress, _currency * 50); var action = new Stake0(100); Assert.Throws(() => action.Execute(new ActionContext diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index c4e4cac4fc..49b860f71e 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -46,9 +46,10 @@ public StakeTest(ITestOutputHelper outputHelper) _goldCurrencyState = new GoldCurrencyState(_currency); _signerAddress = new PrivateKey().ToAddress(); + var context = new ActionContext(); _initialState = _initialState .SetState(GoldCurrencyState.Address, _goldCurrencyState.Serialize()) - .MintAsset(_signerAddress, _currency * 100); + .MintAsset(context, _signerAddress, _currency * 100); } [Fact] @@ -92,9 +93,10 @@ public void Execute_Throws_WhenThereIsMonsterCollection() public void Execute_Throws_WhenClaimableExisting() { Address stakeStateAddress = StakeState.DeriveAddress(_signerAddress); + var context = new ActionContext(); var states = _initialState .SetState(stakeStateAddress, new StakeState(stakeStateAddress, 0).Serialize()) - .MintAsset(stakeStateAddress, _currency * 50); + .MintAsset(context, stakeStateAddress, _currency * 50); var action = new Stake(100); Assert.Throws(() => action.Execute(new ActionContext diff --git a/.Lib9c.Tests/Action/State.cs b/.Lib9c.Tests/Action/State.cs index 6903283cbd..b090bdede1 100644 --- a/.Lib9c.Tests/Action/State.cs +++ b/.Lib9c.Tests/Action/State.cs @@ -6,6 +6,7 @@ namespace Lib9c.Tests.Action using System.Linq; using Bencodex.Types; using Libplanet; + using Libplanet.Action; using Libplanet.Assets; using Libplanet.Consensus; using Libplanet.State; @@ -81,7 +82,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) return currency * 0; } - public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) + public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { var totalSupplies = value.Currency.TotalSupplyTrackable @@ -98,7 +99,7 @@ public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) ); } - public IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value) + public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { var totalSupplies = value.Currency.TotalSupplyTrackable @@ -115,6 +116,7 @@ public IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value) } public IAccountStateDelta TransferAsset( + IActionContext context, Address sender, Address recipient, FungibleAssetValue value, diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index 749fe4dd26..fb40f51d3d 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -219,9 +219,10 @@ public void Rehearsal() amount: _currency * 100 ); + var context = new ActionContext(); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State().MintAsset(_sender, Currencies.Mead * 1), + PreviousStates = new State().MintAsset(context, _sender, Currencies.Mead * 1), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs index e19efbf90e..7c37ee739d 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs @@ -93,7 +93,8 @@ public void Execute( Type exc ) { - var state = _initialState.MintAsset(_agentAddress, balance * _currency); + var context = new ActionContext(); + var state = _initialState.MintAsset(context, _agentAddress, balance * _currency); List recipeIds = ids.ToList(); Address unlockedRecipeIdsAddress = _avatarAddress.Derive("recipe_ids"); if (stateExist) diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs index 9e0bcd4162..a59c79ef9b 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs @@ -93,7 +93,8 @@ public void Execute( Type exc ) { - var state = _initialState.MintAsset(_agentAddress, balance * _currency); + var context = new ActionContext(); + var state = _initialState.MintAsset(context, _agentAddress, balance * _currency); List recipeIds = ids.ToList(); Address unlockedRecipeIdsAddress = _avatarAddress.Derive("recipe_ids"); if (stateExist) diff --git a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs index fc24033fcc..b7076d9a13 100644 --- a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs +++ b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs @@ -61,13 +61,14 @@ public IAccountStateDelta Init(out Address agentAddress, out Address avatarAddre [InlineData(4)] public void Execute(int slotIndex) { + var context = new ActionContext(); var state = Init(out var agentAddress, out var avatarAddress, out var blockIndex); var gameConfig = state.GetGameConfigState(); var cost = slotIndex == 1 ? gameConfig.RuneStatSlotUnlockCost : gameConfig.RuneSkillSlotUnlockCost; var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(agentAddress, cost * ncgCurrency); + state = state.MintAsset(context, agentAddress, cost * ncgCurrency); var action = new UnlockRuneSlot() { AvatarAddress = avatarAddress, @@ -205,10 +206,11 @@ public void Execute_MismatchRuneSlotTypeException() [Fact] public void Execute_SlotIsAlreadyUnlockedException() { + var context = new ActionContext(); var state = Init(out var agentAddress, out var avatarAddress, out var blockIndex); var gameConfig = state.GetGameConfigState(); var ncgCurrency = state.GetGoldCurrency(); - state = state.MintAsset(agentAddress, gameConfig.RuneStatSlotUnlockCost * ncgCurrency); + state = state.MintAsset(context, agentAddress, gameConfig.RuneStatSlotUnlockCost * ncgCurrency); var action = new UnlockRuneSlot() { AvatarAddress = avatarAddress, diff --git a/.Lib9c.Tests/Action/UnlockWorld1Test.cs b/.Lib9c.Tests/Action/UnlockWorld1Test.cs index 75fa6ff4fb..ef3f683cd9 100644 --- a/.Lib9c.Tests/Action/UnlockWorld1Test.cs +++ b/.Lib9c.Tests/Action/UnlockWorld1Test.cs @@ -86,7 +86,8 @@ public void Execute( Type exc ) { - var state = _initialState.MintAsset(_agentAddress, balance * _currency); + var context = new ActionContext(); + var state = _initialState.MintAsset(context, _agentAddress, balance * _currency); var worldIds = ids.ToList(); if (stateExist) diff --git a/.Lib9c.Tests/Action/UnlockWorldTest.cs b/.Lib9c.Tests/Action/UnlockWorldTest.cs index 66378a8932..9bdef08cc0 100644 --- a/.Lib9c.Tests/Action/UnlockWorldTest.cs +++ b/.Lib9c.Tests/Action/UnlockWorldTest.cs @@ -88,7 +88,8 @@ public void Execute( Type exc ) { - var state = _initialState.MintAsset(_agentAddress, balance * _currency); + var context = new ActionContext(); + var state = _initialState.MintAsset(context, _agentAddress, balance * _currency); var worldIds = ids.ToList(); if (stateExist) diff --git a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs index 8d8f6fa6b2..351da86652 100644 --- a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs +++ b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs @@ -98,6 +98,7 @@ public static MakeInitialStateResult MakeInitialState() var sheets = TableSheetsImporter.ImportSheets(); var weeklyArenaAddress = WeeklyArenaState.DeriveAddress(0); + var context = new ActionContext(); var initialState = new Tests.Action.State() .SetState(GoldCurrencyState.Address, goldCurrencyState.Serialize()) .SetState( @@ -146,8 +147,8 @@ public static MakeInitialStateResult MakeInitialState() .SetState(agentAddress, agentState.Serialize()) .SetState(avatarAddress, avatarState.Serialize()) .SetState(Addresses.Shop, new ShopState().Serialize()) - .MintAsset(GoldCurrencyState.Address, initCurrencyGold) - .TransferAsset(Addresses.GoldCurrency, agentAddress, agentCurrencyGold); + .MintAsset(context, GoldCurrencyState.Address, initCurrencyGold) + .TransferAsset(context, Addresses.GoldCurrency, agentAddress, agentCurrencyGold); var action = new CreateTestbed { diff --git a/.Lib9c.Tests/Util/CurrencyUtil.cs b/.Lib9c.Tests/Util/CurrencyUtil.cs index 5ae5c91c90..1ef3663263 100644 --- a/.Lib9c.Tests/Util/CurrencyUtil.cs +++ b/.Lib9c.Tests/Util/CurrencyUtil.cs @@ -1,19 +1,21 @@ namespace Lib9c.Tests.Util { using Libplanet; + using Libplanet.Action; using Libplanet.Assets; using Libplanet.State; public static class CurrencyUtil { public static IAccountStateDelta AddCurrency( + IActionContext context, IAccountStateDelta state, Address agentAddress, Currency currency, FungibleAssetValue amount ) { - return state.MintAsset(agentAddress, amount); + return state.MintAsset(context, agentAddress, amount); } } } diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index 9dd8055428..3337742b1c 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -2,6 +2,7 @@ namespace Lib9c.Tests.Util { using System.Collections.Immutable; using System.IO; + using Lib9c.Tests.Action; using Libplanet; using Libplanet.Assets; using Libplanet.Crypto; @@ -29,6 +30,7 @@ IAccountStateDelta initialStatesWithAvatarStateV2 ) { adminAddr ??= new PrivateKey().ToAddress(); + var context = new ActionContext(); var states = new State().SetState( Addresses.Admin, new AdminState(adminAddr.Value, long.MaxValue).Serialize()); @@ -54,7 +56,7 @@ IAccountStateDelta initialStatesWithAvatarStateV2 var goldCurrencyState = new GoldCurrencyState(goldCurrency); states = states .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) - .MintAsset(goldCurrencyState.address, goldCurrency * 1_000_000_000); + .MintAsset(context, goldCurrencyState.address, goldCurrency * 1_000_000_000); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); states = states.SetState(gameConfigState.address, gameConfigState.Serialize()); diff --git a/Lib9c.DevExtensions/Action/CreateTestbed.cs b/Lib9c.DevExtensions/Action/CreateTestbed.cs index 6a26bac59a..53eca6c9eb 100644 --- a/Lib9c.DevExtensions/Action/CreateTestbed.cs +++ b/Lib9c.DevExtensions/Action/CreateTestbed.cs @@ -121,8 +121,8 @@ public override IAccountStateDelta Execute(IActionContext context) states = states.SetState(avatarAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, agentAddress, - GoldCurrencyState.Address) + .MarkBalanceChanged( + context, GoldCurrencyMock, agentAddress, GoldCurrencyState.Address) .SetState(orderReceiptAddress, MarkChanged) .SetState(itemAddress, MarkChanged) .SetState(orderAddress, MarkChanged) diff --git a/Lib9c.DevExtensions/Action/FaucetCurrency.cs b/Lib9c.DevExtensions/Action/FaucetCurrency.cs index fa5f25e15f..8a44ce2293 100644 --- a/Lib9c.DevExtensions/Action/FaucetCurrency.cs +++ b/Lib9c.DevExtensions/Action/FaucetCurrency.cs @@ -31,7 +31,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (FaucetNcg > 0) { var ncg = states.GetGoldCurrency(); - states = states.TransferAsset(GoldCurrencyState.Address, AgentAddress, ncg * FaucetNcg); + states = states.TransferAsset(context, GoldCurrencyState.Address, AgentAddress, ncg * FaucetNcg); } if (FaucetCrystal > 0) @@ -39,7 +39,7 @@ public override IAccountStateDelta Execute(IActionContext context) #pragma warning disable CS0618 var crystal = Currency.Legacy("CRYSTAL", 18, null); #pragma warning restore CS0618 - states = states.MintAsset(AgentAddress, crystal * FaucetCrystal); + states = states.MintAsset(context, AgentAddress, crystal * FaucetCrystal); } return states; diff --git a/Lib9c.DevExtensions/Action/FaucetRune.cs b/Lib9c.DevExtensions/Action/FaucetRune.cs index e3018420b3..63fce9eb39 100644 --- a/Lib9c.DevExtensions/Action/FaucetRune.cs +++ b/Lib9c.DevExtensions/Action/FaucetRune.cs @@ -37,7 +37,7 @@ public override IAccountStateDelta Execute(IActionContext context) { foreach (var rune in FaucetRuneInfos) { - states = states.MintAsset(AvatarAddress, RuneHelper.ToFungibleAssetValue( + states = states.MintAsset(context, AvatarAddress, RuneHelper.ToFungibleAssetValue( runeSheet.OrderedList.First(r => r.Id == rune.RuneId), rune.Amount )); diff --git a/Lib9c.DevExtensions/Action/ManipulateState.cs b/Lib9c.DevExtensions/Action/ManipulateState.cs index 563e112d7c..a557cb6424 100644 --- a/Lib9c.DevExtensions/Action/ManipulateState.cs +++ b/Lib9c.DevExtensions/Action/ManipulateState.cs @@ -52,10 +52,11 @@ public override IAccountStateDelta Execute(IActionContext context) return context.PreviousStates; } - return Execute(context.PreviousStates, StateList, BalanceList); + return Execute(context, context.PreviousStates, StateList, BalanceList); } public static IAccountStateDelta Execute( + IActionContext context, IAccountStateDelta prevStates, List<(Address addr, IValue value)> stateList, List<(Address addr, FungibleAssetValue fav)> balanceList) @@ -82,6 +83,7 @@ public static IAccountStateDelta Execute( if (currentFav > fav) { states = states.TransferAsset( + context, addr, GoldCurrencyState.Address, currentFav - fav); @@ -89,6 +91,7 @@ public static IAccountStateDelta Execute( else { states = states.TransferAsset( + context, GoldCurrencyState.Address, addr, fav - currentFav); @@ -101,8 +104,8 @@ public static IAccountStateDelta Execute( } states = currentFav > fav - ? states.BurnAsset(addr, currentFav - fav) - : states.MintAsset(addr, fav - currentFav); + ? states.BurnAsset(context, addr, currentFav - fav) + : states.MintAsset(context, addr, fav - currentFav); } return states; diff --git a/Lib9c.MessagePack/AccountStateDelta.cs b/Lib9c.MessagePack/AccountStateDelta.cs index 41d6fa2c1d..93875f420d 100644 --- a/Lib9c.MessagePack/AccountStateDelta.cs +++ b/Lib9c.MessagePack/AccountStateDelta.cs @@ -123,7 +123,7 @@ public FungibleAssetValue GetTotalSupply(Currency currency) return currency * 0; } - public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) + public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException // 던지는 처리를 해야하는데 여기서 트랜잭션 서명자를 무슨 수로 가져올지 잘 모르겠음. @@ -169,6 +169,7 @@ public IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value) } public IAccountStateDelta TransferAsset( + IActionContext context, Address sender, Address recipient, FungibleAssetValue value, @@ -198,7 +199,7 @@ public IAccountStateDelta TransferAsset( return new AccountStateDelta(_states, balances, _totalSupplies); } - public IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value) + public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { // FIXME: 트랜잭션 서명자를 알아내 currency.AllowsToMint() 확인해서 CurrencyPermissionException // 던지는 처리를 해야하는데 여기서 트랜잭션 서명자를 무슨 수로 가져올지 잘 모르겠음. diff --git a/Lib9c/Action/AccountStateDeltaExtensions.cs b/Lib9c/Action/AccountStateDeltaExtensions.cs index 91bbe1a5dc..ccd32472ac 100644 --- a/Lib9c/Action/AccountStateDeltaExtensions.cs +++ b/Lib9c/Action/AccountStateDeltaExtensions.cs @@ -22,13 +22,14 @@ public static class AccountStateDeltaExtensions { public static IAccountStateDelta MarkBalanceChanged( this IAccountStateDelta states, + IActionContext context, Currency currency, params Address[] accounts ) { if (accounts.Length == 1) { - return states.MintAsset(accounts[0], currency * 1); + return states.MintAsset(context, accounts[0], currency * 1); } else if (accounts.Length < 1) { @@ -37,7 +38,7 @@ params Address[] accounts for (int i = 1; i < accounts.Length; i++) { - states = states.TransferAsset(accounts[i - 1], accounts[i], currency * 1, true); + states = states.TransferAsset(context, accounts[i - 1], accounts[i], currency * 1, true); } return states; @@ -46,6 +47,7 @@ params Address[] accounts public static IAccountStateDelta SetWorldBossKillReward( this IAccountStateDelta states, + IActionContext context, Address rewardInfoAddress, WorldBossKillRewardRecord rewardRecord, int rank, @@ -82,11 +84,11 @@ public static IAccountStateDelta SetWorldBossKillReward( { if (reward.Currency.Equals(CrystalCalculator.CRYSTAL)) { - states = states.MintAsset(agentAddress, reward); + states = states.MintAsset(context, agentAddress, reward); } else { - states = states.MintAsset(avatarAddress, reward); + states = states.MintAsset(context, avatarAddress, reward); } } } @@ -114,7 +116,8 @@ public static IAccountStateDelta SetCouponWallet( } #nullable disable - public static IAccountStateDelta Mead(this IAccountStateDelta states, Address signer, BigInteger rawValue) + public static IAccountStateDelta Mead( + this IAccountStateDelta states, IActionContext context, Address signer, BigInteger rawValue) { while (true) { @@ -129,11 +132,11 @@ public static IAccountStateDelta Mead(this IAccountStateDelta states, Address si var patron = contract[0].ToAddress(); try { - states = states.TransferAsset(patron, signer, requiredMead); + states = states.TransferAsset(context, patron, signer, requiredMead); } catch (InsufficientBalanceException) { - states = states.Mead(patron, rawValue); + states = states.Mead(context, patron, rawValue); continue; } } diff --git a/Lib9c/Action/Buy0.cs b/Lib9c/Action/Buy0.cs index d0cb49f15d..5bada46594 100644 --- a/Lib9c/Action/Buy0.cs +++ b/Lib9c/Action/Buy0.cs @@ -63,6 +63,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(ctx.Signer, MarkChanged) .SetState(sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, sellerAgentAddress, diff --git a/Lib9c/Action/Buy10.cs b/Lib9c/Action/Buy10.cs index c1fe84dd0b..13ae1b8b3d 100644 --- a/Lib9c/Action/Buy10.cs +++ b/Lib9c/Action/Buy10.cs @@ -88,6 +88,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(orderReceiptAddress, MarkChanged) .SetState(digestListAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.SellerAgentAddress, diff --git a/Lib9c/Action/Buy11.cs b/Lib9c/Action/Buy11.cs index d58a318600..64b9c90635 100644 --- a/Lib9c/Action/Buy11.cs +++ b/Lib9c/Action/Buy11.cs @@ -93,6 +93,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(orderReceiptAddress, MarkChanged) .SetState(digestListAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.SellerAgentAddress, diff --git a/Lib9c/Action/Buy2.cs b/Lib9c/Action/Buy2.cs index 288c1271df..a77a9596a0 100644 --- a/Lib9c/Action/Buy2.cs +++ b/Lib9c/Action/Buy2.cs @@ -65,6 +65,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(ctx.Signer, MarkChanged) .SetState(sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, sellerAgentAddress, diff --git a/Lib9c/Action/Buy3.cs b/Lib9c/Action/Buy3.cs index 1e4888eccd..2baba493fe 100644 --- a/Lib9c/Action/Buy3.cs +++ b/Lib9c/Action/Buy3.cs @@ -62,6 +62,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(ctx.Signer, MarkChanged) .SetState(sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, sellerAgentAddress, diff --git a/Lib9c/Action/Buy4.cs b/Lib9c/Action/Buy4.cs index a9fe7d1a3c..dd4a019c0a 100644 --- a/Lib9c/Action/Buy4.cs +++ b/Lib9c/Action/Buy4.cs @@ -62,6 +62,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(ctx.Signer, MarkChanged) .SetState(sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, sellerAgentAddress, diff --git a/Lib9c/Action/Buy5.cs b/Lib9c/Action/Buy5.cs index 5a3a9a7dea..abf7b9d79d 100644 --- a/Lib9c/Action/Buy5.cs +++ b/Lib9c/Action/Buy5.cs @@ -70,6 +70,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(shardedShopAddress, MarkChanged) .SetState(purchaseInfo.sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.sellerAgentAddress, diff --git a/Lib9c/Action/Buy6.cs b/Lib9c/Action/Buy6.cs index 22a298117a..fcfaf6f6fa 100644 --- a/Lib9c/Action/Buy6.cs +++ b/Lib9c/Action/Buy6.cs @@ -70,6 +70,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(shardedShopAddress, MarkChanged) .SetState(purchaseInfo.sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.sellerAgentAddress, diff --git a/Lib9c/Action/Buy7.cs b/Lib9c/Action/Buy7.cs index bbbec30db6..6b6ce539b2 100644 --- a/Lib9c/Action/Buy7.cs +++ b/Lib9c/Action/Buy7.cs @@ -209,6 +209,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(shardedShopAddress, MarkChanged) .SetState(purchaseInfo.sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.sellerAgentAddress, diff --git a/Lib9c/Action/Buy8.cs b/Lib9c/Action/Buy8.cs index b80b9145cc..97e2ffff25 100644 --- a/Lib9c/Action/Buy8.cs +++ b/Lib9c/Action/Buy8.cs @@ -89,6 +89,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(orderReceiptAddress, MarkChanged) .SetState(digestListAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.SellerAgentAddress, diff --git a/Lib9c/Action/Buy9.cs b/Lib9c/Action/Buy9.cs index 825f8b0e15..364b2a81ef 100644 --- a/Lib9c/Action/Buy9.cs +++ b/Lib9c/Action/Buy9.cs @@ -89,6 +89,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(orderReceiptAddress, MarkChanged) .SetState(digestListAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, purchaseInfo.SellerAgentAddress, diff --git a/Lib9c/Action/BuyMultiple.cs b/Lib9c/Action/BuyMultiple.cs index 9794060d86..420186a8ac 100644 --- a/Lib9c/Action/BuyMultiple.cs +++ b/Lib9c/Action/BuyMultiple.cs @@ -235,6 +235,7 @@ public override IAccountStateDelta Execute(IActionContext context) states = states.SetState(sellerAvatarAddress, MarkChanged) .MarkBalanceChanged( + ctx, GoldCurrencyMock, ctx.Signer, sellerAgentAddress, diff --git a/Lib9c/Action/CancelMonsterCollect.cs b/Lib9c/Action/CancelMonsterCollect.cs index dc9fc8c6ce..0a09441752 100644 --- a/Lib9c/Action/CancelMonsterCollect.cs +++ b/Lib9c/Action/CancelMonsterCollect.cs @@ -41,7 +41,7 @@ public override IAccountStateDelta Execute(IActionContext context) { return states .SetState(collectionAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, collectionAddress, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, collectionAddress, context.Signer); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/ClaimWordBossKillReward.cs b/Lib9c/Action/ClaimWordBossKillReward.cs index b6497d9585..f0f7ad4f4c 100644 --- a/Lib9c/Action/ClaimWordBossKillReward.cs +++ b/Lib9c/Action/ClaimWordBossKillReward.cs @@ -60,6 +60,7 @@ public override IAccountStateDelta Execute(IActionContext context) Address worldBossAddress = Addresses.GetWorldBossAddress(raidId); var worldBossState = new WorldBossState((List) states.GetState(worldBossAddress)); return states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/CombinationEquipment0.cs b/Lib9c/Action/CombinationEquipment0.cs index c7daaadb30..dbb43db83b 100644 --- a/Lib9c/Action/CombinationEquipment0.cs +++ b/Lib9c/Action/CombinationEquipment0.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment10.cs b/Lib9c/Action/CombinationEquipment10.cs index aaa083b4a5..ae642af518 100644 --- a/Lib9c/Action/CombinationEquipment10.cs +++ b/Lib9c/Action/CombinationEquipment10.cs @@ -82,7 +82,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, BlacksmithAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100220ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment11.cs b/Lib9c/Action/CombinationEquipment11.cs index 95d39e58eb..8d3bf3a08e 100644 --- a/Lib9c/Action/CombinationEquipment11.cs +++ b/Lib9c/Action/CombinationEquipment11.cs @@ -83,7 +83,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, ItemEnhancement10.GetFeeStoreAddress()); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, ItemEnhancement10.GetFeeStoreAddress()); } CheckObsolete(ActionObsoleteConfig.V100270ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment2.cs b/Lib9c/Action/CombinationEquipment2.cs index 4bd14f9253..f885146f85 100644 --- a/Lib9c/Action/CombinationEquipment2.cs +++ b/Lib9c/Action/CombinationEquipment2.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment3.cs b/Lib9c/Action/CombinationEquipment3.cs index d6db5412df..58c0504f63 100644 --- a/Lib9c/Action/CombinationEquipment3.cs +++ b/Lib9c/Action/CombinationEquipment3.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment4.cs b/Lib9c/Action/CombinationEquipment4.cs index ff582d00d1..c9bf7e0f12 100644 --- a/Lib9c/Action/CombinationEquipment4.cs +++ b/Lib9c/Action/CombinationEquipment4.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment5.cs b/Lib9c/Action/CombinationEquipment5.cs index d3f4b9c024..823edca66b 100644 --- a/Lib9c/Action/CombinationEquipment5.cs +++ b/Lib9c/Action/CombinationEquipment5.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment6.cs b/Lib9c/Action/CombinationEquipment6.cs index c0fb09000c..39994f26dc 100644 --- a/Lib9c/Action/CombinationEquipment6.cs +++ b/Lib9c/Action/CombinationEquipment6.cs @@ -62,7 +62,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment7.cs b/Lib9c/Action/CombinationEquipment7.cs index 5f9196541c..2b74760923 100644 --- a/Lib9c/Action/CombinationEquipment7.cs +++ b/Lib9c/Action/CombinationEquipment7.cs @@ -61,7 +61,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment8.cs b/Lib9c/Action/CombinationEquipment8.cs index f6a2d3fac4..37d7393a39 100644 --- a/Lib9c/Action/CombinationEquipment8.cs +++ b/Lib9c/Action/CombinationEquipment8.cs @@ -82,7 +82,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, BlacksmithAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, BlacksmithAddress); } CheckObsolete(ActionObsoleteConfig.V100086ObsoleteIndex, context); diff --git a/Lib9c/Action/CombinationEquipment9.cs b/Lib9c/Action/CombinationEquipment9.cs index 6e0af06a7e..365b42fbc4 100644 --- a/Lib9c/Action/CombinationEquipment9.cs +++ b/Lib9c/Action/CombinationEquipment9.cs @@ -82,7 +82,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, BlacksmithAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, BlacksmithAddress); } context.UseGas(1); diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 85be38c698..5451012571 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -101,7 +101,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, signer); + .MarkBalanceChanged(ctx, GoldCurrencyMock, signer); } var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); diff --git a/Lib9c/Action/CreateAvatar0.cs b/Lib9c/Action/CreateAvatar0.cs index caf4cda219..0dd21e1f3e 100644 --- a/Lib9c/Action/CreateAvatar0.cs +++ b/Lib9c/Action/CreateAvatar0.cs @@ -91,7 +91,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states .SetState(avatarAddress, MarkChanged) .SetState(Addresses.Ranking, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CreateAvatar2.cs b/Lib9c/Action/CreateAvatar2.cs index 4e5abc096d..a9017775a7 100644 --- a/Lib9c/Action/CreateAvatar2.cs +++ b/Lib9c/Action/CreateAvatar2.cs @@ -89,7 +89,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states .SetState(avatarAddress, MarkChanged) .SetState(Addresses.Ranking, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CreateAvatar3.cs b/Lib9c/Action/CreateAvatar3.cs index 4212d287db..f879d79407 100644 --- a/Lib9c/Action/CreateAvatar3.cs +++ b/Lib9c/Action/CreateAvatar3.cs @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/CreateAvatar4.cs b/Lib9c/Action/CreateAvatar4.cs index 597709b5c6..fc17c8fca6 100644 --- a/Lib9c/Action/CreateAvatar4.cs +++ b/Lib9c/Action/CreateAvatar4.cs @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); diff --git a/Lib9c/Action/CreateAvatar5.cs b/Lib9c/Action/CreateAvatar5.cs index 0e04fd84bd..ab77cd953f 100644 --- a/Lib9c/Action/CreateAvatar5.cs +++ b/Lib9c/Action/CreateAvatar5.cs @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); diff --git a/Lib9c/Action/CreateAvatar6.cs b/Lib9c/Action/CreateAvatar6.cs index c0ffdbfb40..d4e32ce8cf 100644 --- a/Lib9c/Action/CreateAvatar6.cs +++ b/Lib9c/Action/CreateAvatar6.cs @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address, context.Signer); } context.UseGas(1); diff --git a/Lib9c/Action/DailyReward.cs b/Lib9c/Action/DailyReward.cs index c03672b9ed..abefef9cc2 100644 --- a/Lib9c/Action/DailyReward.cs +++ b/Lib9c/Action/DailyReward.cs @@ -35,7 +35,7 @@ public override IAccountStateDelta Execute(IActionContext context) { return states .SetState(avatarAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, avatarAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, avatarAddress); } var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); diff --git a/Lib9c/Action/DailyReward6.cs b/Lib9c/Action/DailyReward6.cs index 6324e562e8..c2d08fa50d 100644 --- a/Lib9c/Action/DailyReward6.cs +++ b/Lib9c/Action/DailyReward6.cs @@ -42,7 +42,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, avatarAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, avatarAddress); } context.UseGas(1); diff --git a/Lib9c/Action/Grinding.cs b/Lib9c/Action/Grinding.cs index 2b10efbc88..2da33e38d5 100644 --- a/Lib9c/Action/Grinding.cs +++ b/Lib9c/Action/Grinding.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(worldInformationAddress, MarkChanged) .SetState(questListAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); diff --git a/Lib9c/Action/ItemEnhancement0.cs b/Lib9c/Action/ItemEnhancement0.cs index 17f812a2d3..f2c7413b2a 100644 --- a/Lib9c/Action/ItemEnhancement0.cs +++ b/Lib9c/Action/ItemEnhancement0.cs @@ -52,7 +52,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement10.cs b/Lib9c/Action/ItemEnhancement10.cs index 788271e54a..640fd1847b 100644 --- a/Lib9c/Action/ItemEnhancement10.cs +++ b/Lib9c/Action/ItemEnhancement10.cs @@ -136,7 +136,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, GetFeeStoreAddress()) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, GetFeeStoreAddress()) .SetState(avatarAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) diff --git a/Lib9c/Action/ItemEnhancement2.cs b/Lib9c/Action/ItemEnhancement2.cs index 68d4079225..3703a1e88a 100644 --- a/Lib9c/Action/ItemEnhancement2.cs +++ b/Lib9c/Action/ItemEnhancement2.cs @@ -52,7 +52,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement3.cs b/Lib9c/Action/ItemEnhancement3.cs index d76a9c8f7e..926afdaba8 100644 --- a/Lib9c/Action/ItemEnhancement3.cs +++ b/Lib9c/Action/ItemEnhancement3.cs @@ -52,7 +52,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement4.cs b/Lib9c/Action/ItemEnhancement4.cs index 602947ce46..865f0be184 100644 --- a/Lib9c/Action/ItemEnhancement4.cs +++ b/Lib9c/Action/ItemEnhancement4.cs @@ -50,7 +50,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement5.cs b/Lib9c/Action/ItemEnhancement5.cs index b5d40f56ac..21a66392fa 100644 --- a/Lib9c/Action/ItemEnhancement5.cs +++ b/Lib9c/Action/ItemEnhancement5.cs @@ -50,7 +50,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement6.cs b/Lib9c/Action/ItemEnhancement6.cs index 34f5b5ef07..365983719a 100644 --- a/Lib9c/Action/ItemEnhancement6.cs +++ b/Lib9c/Action/ItemEnhancement6.cs @@ -52,7 +52,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(slotAddress, MarkChanged); } diff --git a/Lib9c/Action/ItemEnhancement7.cs b/Lib9c/Action/ItemEnhancement7.cs index f32bbeb2d4..342d20cb92 100644 --- a/Lib9c/Action/ItemEnhancement7.cs +++ b/Lib9c/Action/ItemEnhancement7.cs @@ -92,7 +92,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) diff --git a/Lib9c/Action/ItemEnhancement8.cs b/Lib9c/Action/ItemEnhancement8.cs index fbe7dda610..379e7c4512 100644 --- a/Lib9c/Action/ItemEnhancement8.cs +++ b/Lib9c/Action/ItemEnhancement8.cs @@ -56,7 +56,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) diff --git a/Lib9c/Action/ItemEnhancement9.cs b/Lib9c/Action/ItemEnhancement9.cs index ca6ffece86..2ad4ba1732 100644 --- a/Lib9c/Action/ItemEnhancement9.cs +++ b/Lib9c/Action/ItemEnhancement9.cs @@ -132,7 +132,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (ctx.Rehearsal) { return states - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, BlacksmithAddress) + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, BlacksmithAddress) .SetState(avatarAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(worldInformationAddress, MarkChanged) diff --git a/Lib9c/Action/MonsterCollect.cs b/Lib9c/Action/MonsterCollect.cs index 2d09604dd2..85f2a42817 100644 --- a/Lib9c/Action/MonsterCollect.cs +++ b/Lib9c/Action/MonsterCollect.cs @@ -39,10 +39,10 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 2), MarkChanged) .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 3), MarkChanged) .SetState(context.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 0)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 1)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 2)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 3)); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 0)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 1)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 2)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 3)); } var addressesHex = GetSignerAndOtherAddressesHex(context, context.Signer); diff --git a/Lib9c/Action/MonsterCollect0.cs b/Lib9c/Action/MonsterCollect0.cs index 72632152fa..a1775accfe 100644 --- a/Lib9c/Action/MonsterCollect0.cs +++ b/Lib9c/Action/MonsterCollect0.cs @@ -34,7 +34,7 @@ public override IAccountStateDelta Execute(IActionContext context) return states .SetState(monsterCollectionAddress, MarkChanged) .SetState(context.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, monsterCollectionAddress); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, monsterCollectionAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/MonsterCollect2.cs b/Lib9c/Action/MonsterCollect2.cs index e251cfa5ee..380eb0f7b6 100644 --- a/Lib9c/Action/MonsterCollect2.cs +++ b/Lib9c/Action/MonsterCollect2.cs @@ -34,10 +34,10 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 2), MarkChanged) .SetState(MonsterCollectionState.DeriveAddress(context.Signer, 3), MarkChanged) .SetState(context.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 0)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 1)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 2)) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 3)); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 0)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 1)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 2)) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, MonsterCollectionState.DeriveAddress(context.Signer, 3)); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/PrepareRewardAssets.cs b/Lib9c/Action/PrepareRewardAssets.cs index 1ed14c646d..adeaa48056 100644 --- a/Lib9c/Action/PrepareRewardAssets.cs +++ b/Lib9c/Action/PrepareRewardAssets.cs @@ -50,7 +50,7 @@ public override IAccountStateDelta Execute(IActionContext context) { foreach (var asset in Assets) { - return states.MarkBalanceChanged(asset.Currency, RewardPoolAddress); + return states.MarkBalanceChanged(context, asset.Currency, RewardPoolAddress); } } diff --git a/Lib9c/Action/Raid.cs b/Lib9c/Action/Raid.cs index 59b4ea1c2f..f30e6bcd69 100644 --- a/Lib9c/Action/Raid.cs +++ b/Lib9c/Action/Raid.cs @@ -300,6 +300,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/Raid1.cs b/Lib9c/Action/Raid1.cs index 34f1dca013..7199e6fad3 100644 --- a/Lib9c/Action/Raid1.cs +++ b/Lib9c/Action/Raid1.cs @@ -220,6 +220,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/Raid2.cs b/Lib9c/Action/Raid2.cs index d6a54b530c..8f8296d388 100644 --- a/Lib9c/Action/Raid2.cs +++ b/Lib9c/Action/Raid2.cs @@ -231,6 +231,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/Raid3.cs b/Lib9c/Action/Raid3.cs index dbda5f89ac..2193d6ffcb 100644 --- a/Lib9c/Action/Raid3.cs +++ b/Lib9c/Action/Raid3.cs @@ -298,6 +298,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/Raid4.cs b/Lib9c/Action/Raid4.cs index 567a8d2a3b..08484c4528 100644 --- a/Lib9c/Action/Raid4.cs +++ b/Lib9c/Action/Raid4.cs @@ -300,6 +300,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/Raid5.cs b/Lib9c/Action/Raid5.cs index 088424e8bc..1aa58b6664 100644 --- a/Lib9c/Action/Raid5.cs +++ b/Lib9c/Action/Raid5.cs @@ -301,6 +301,7 @@ public override IAccountStateDelta Execute(IActionContext context) // calculate with previous high score. int rank = WorldBossHelper.CalculateRank(bossRow, previousHighScore); states = states.SetWorldBossKillReward( + context, worldBossKillRewardRecordAddress, rewardRecord, rank, diff --git a/Lib9c/Action/RankingBattle0.cs b/Lib9c/Action/RankingBattle0.cs index de775be910..3d31cfd270 100644 --- a/Lib9c/Action/RankingBattle0.cs +++ b/Lib9c/Action/RankingBattle0.cs @@ -51,7 +51,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(WeeklyArenaAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/RankingBattle2.cs b/Lib9c/Action/RankingBattle2.cs index e331bfbd56..ad51a431e4 100644 --- a/Lib9c/Action/RankingBattle2.cs +++ b/Lib9c/Action/RankingBattle2.cs @@ -51,7 +51,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(WeeklyArenaAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/RankingBattle3.cs b/Lib9c/Action/RankingBattle3.cs index a3393994d1..a4d4e5f5ef 100644 --- a/Lib9c/Action/RankingBattle3.cs +++ b/Lib9c/Action/RankingBattle3.cs @@ -51,7 +51,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(WeeklyArenaAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/RankingBattle4.cs b/Lib9c/Action/RankingBattle4.cs index df305eca63..a8c60231bb 100644 --- a/Lib9c/Action/RankingBattle4.cs +++ b/Lib9c/Action/RankingBattle4.cs @@ -51,7 +51,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(AvatarAddress, MarkChanged) .SetState(WeeklyArenaAddress, MarkChanged) .SetState(ctx.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); + .MarkBalanceChanged(ctx, GoldCurrencyMock, ctx.Signer, WeeklyArenaAddress); } // Avoid InvalidBlockStateRootHashException diff --git a/Lib9c/Action/RedeemCode.cs b/Lib9c/Action/RedeemCode.cs index bb6c724b9b..b1b2474340 100644 --- a/Lib9c/Action/RedeemCode.cs +++ b/Lib9c/Action/RedeemCode.cs @@ -57,8 +57,8 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(questListAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) .SetState(context.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); diff --git a/Lib9c/Action/RedeemCode0.cs b/Lib9c/Action/RedeemCode0.cs index 1bd9411fcf..6848e544fc 100644 --- a/Lib9c/Action/RedeemCode0.cs +++ b/Lib9c/Action/RedeemCode0.cs @@ -46,8 +46,8 @@ public override IAccountStateDelta Execute(IActionContext context) states = states.SetState(RedeemCodeState.Address, MarkChanged); states = states.SetState(AvatarAddress, MarkChanged); states = states.SetState(context.Signer, MarkChanged); - states = states.MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address); - states = states.MarkBalanceChanged(GoldCurrencyMock, context.Signer); + states = states.MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address); + states = states.MarkBalanceChanged(context, GoldCurrencyMock, context.Signer); return states; } diff --git a/Lib9c/Action/RedeemCode2.cs b/Lib9c/Action/RedeemCode2.cs index 6a0cd57bf5..e7cb946b99 100644 --- a/Lib9c/Action/RedeemCode2.cs +++ b/Lib9c/Action/RedeemCode2.cs @@ -53,8 +53,8 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(questListAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) .SetState(context.Signer, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, GoldCurrencyState.Address) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer); + .MarkBalanceChanged(context, GoldCurrencyMock, GoldCurrencyState.Address) + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/RewardGold.cs b/Lib9c/Action/RewardGold.cs index 4f3300ae6e..9717d54a46 100644 --- a/Lib9c/Action/RewardGold.cs +++ b/Lib9c/Action/RewardGold.cs @@ -38,7 +38,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); var states = context.PreviousStates; - states = TransferMead(states); + states = TransferMead(context, states); states = GenesisGoldDistribution(context, states); var addressesHex = GetSignerAndOtherAddressesHex(context, context.Signer); var started = DateTimeOffset.UtcNow; @@ -302,7 +302,7 @@ public IAccountStateDelta MinerReward(IActionContext ctx, IAccountStateDelta sta return states; } - public static IAccountStateDelta TransferMead(IAccountStateDelta states) + public static IAccountStateDelta TransferMead(IActionContext context, IAccountStateDelta states) { #pragma warning disable LAA1002 var targetAddresses = states @@ -319,7 +319,7 @@ public static IAccountStateDelta TransferMead(IAccountStateDelta states) { try { - states = states.Mead(address, contract[2].ToInteger()); + states = states.Mead(context, address, contract[2].ToInteger()); } catch (InsufficientBalanceException) { diff --git a/Lib9c/Action/SecureMiningReward.cs b/Lib9c/Action/SecureMiningReward.cs index e3f836fea6..85cb7297c0 100644 --- a/Lib9c/Action/SecureMiningReward.cs +++ b/Lib9c/Action/SecureMiningReward.cs @@ -62,6 +62,7 @@ public override IAccountStateDelta Execute(IActionContext context) if (context.Rehearsal) { return state.MarkBalanceChanged( + context, NCG, AuthorizedMiners.Add(Recipient).Add(Treasury).ToArray() ); diff --git a/Lib9c/Action/Stake.cs b/Lib9c/Action/Stake.cs index 0b7b5f1b08..80a38e445f 100644 --- a/Lib9c/Action/Stake.cs +++ b/Lib9c/Action/Stake.cs @@ -57,6 +57,7 @@ public override IAccountStateDelta Execute(IActionContext context) { return states.SetState(StakeState.DeriveAddress(context.Signer), MarkChanged) .MarkBalanceChanged( + context, GoldCurrencyMock, context.Signer, StakeState.DeriveAddress(context.Signer)); diff --git a/Lib9c/Action/Stake0.cs b/Lib9c/Action/Stake0.cs index a0c3b7d3cc..a6241f95a2 100644 --- a/Lib9c/Action/Stake0.cs +++ b/Lib9c/Action/Stake0.cs @@ -61,6 +61,7 @@ public override IAccountStateDelta Execute(IActionContext context) { return states.SetState(StakeState.DeriveAddress(context.Signer), MarkChanged) .MarkBalanceChanged( + context, GoldCurrencyMock, context.Signer, StakeState.DeriveAddress(context.Signer)); diff --git a/Lib9c/Action/TransferAsset.cs b/Lib9c/Action/TransferAsset.cs index d1bf8e6569..bb72954458 100644 --- a/Lib9c/Action/TransferAsset.cs +++ b/Lib9c/Action/TransferAsset.cs @@ -89,7 +89,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return state.MarkBalanceChanged(Amount.Currency, new[] {Sender, Recipient}); + return state.MarkBalanceChanged(context, Amount.Currency, new[] {Sender, Recipient}); } var addressesHex = GetSignerAndOtherAddressesHex(context, signer); diff --git a/Lib9c/Action/TransferAsset0.cs b/Lib9c/Action/TransferAsset0.cs index a00d8dfdcf..3eff9b8a8f 100644 --- a/Lib9c/Action/TransferAsset0.cs +++ b/Lib9c/Action/TransferAsset0.cs @@ -80,7 +80,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return state.MarkBalanceChanged(Amount.Currency, new[] { Sender, Recipient }); + return state.MarkBalanceChanged(context, Amount.Currency, new[] { Sender, Recipient }); } CheckObsolete(ActionObsoleteConfig.V100080ObsoleteIndex, context); diff --git a/Lib9c/Action/TransferAsset2.cs b/Lib9c/Action/TransferAsset2.cs index bd51e27d1d..9d393ca45e 100644 --- a/Lib9c/Action/TransferAsset2.cs +++ b/Lib9c/Action/TransferAsset2.cs @@ -86,7 +86,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return state.MarkBalanceChanged(Amount.Currency, new[] { Sender, Recipient }); + return state.MarkBalanceChanged(context, Amount.Currency, new[] { Sender, Recipient }); } CheckObsolete(TransferAsset3.CrystalTransferringRestrictionStartIndex - 1, context); diff --git a/Lib9c/Action/TransferAsset3.cs b/Lib9c/Action/TransferAsset3.cs index d16939c6e1..90e9f5f6f8 100644 --- a/Lib9c/Action/TransferAsset3.cs +++ b/Lib9c/Action/TransferAsset3.cs @@ -99,7 +99,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return state.MarkBalanceChanged(Amount.Currency, new[] { Sender, Recipient }); + return state.MarkBalanceChanged(context, Amount.Currency, new[] { Sender, Recipient }); } context.UseGas(1); diff --git a/Lib9c/Action/TransferAssets.cs b/Lib9c/Action/TransferAssets.cs index 0fb592a639..e72f6d4b7a 100644 --- a/Lib9c/Action/TransferAssets.cs +++ b/Lib9c/Action/TransferAssets.cs @@ -85,7 +85,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return Recipients.Aggregate(state, (current, t) => current.MarkBalanceChanged(t.amount.Currency, new[] {Sender, t.recipient})); + return Recipients.Aggregate(state, (current, t) => current.MarkBalanceChanged(context, t.amount.Currency, new[] {Sender, t.recipient})); } if (Recipients.Count > RecipientsCapacity) diff --git a/Lib9c/Action/TransferAssets0.cs b/Lib9c/Action/TransferAssets0.cs index 373e19a5b8..d2d5d8f410 100644 --- a/Lib9c/Action/TransferAssets0.cs +++ b/Lib9c/Action/TransferAssets0.cs @@ -85,7 +85,7 @@ public override IAccountStateDelta Execute(IActionContext context) var state = context.PreviousStates; if (context.Rehearsal) { - return Recipients.Aggregate(state, (current, t) => current.MarkBalanceChanged(t.amount.Currency, new[] {Sender, t.recipient})); + return Recipients.Aggregate(state, (current, t) => current.MarkBalanceChanged(context, t.amount.Currency, new[] {Sender, t.recipient})); } context.UseGas(1); diff --git a/Lib9c/Action/UnlockEquipmentRecipe.cs b/Lib9c/Action/UnlockEquipmentRecipe.cs index 5ba7dd71a6..ad20b495da 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) .SetState(unlockedRecipeIdsAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, Addresses.UnlockEquipmentRecipe); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, Addresses.UnlockEquipmentRecipe); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); diff --git a/Lib9c/Action/UnlockEquipmentRecipe1.cs b/Lib9c/Action/UnlockEquipmentRecipe1.cs index 81b4fc6dd3..e75e3ad5b5 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe1.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe1.cs @@ -45,7 +45,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(inventoryAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) .SetState(unlockedRecipeIdsAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, Addresses.UnlockEquipmentRecipe); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, Addresses.UnlockEquipmentRecipe); } context.UseGas(1); diff --git a/Lib9c/Action/UnlockWorld.cs b/Lib9c/Action/UnlockWorld.cs index 31debc9106..057c775e57 100644 --- a/Lib9c/Action/UnlockWorld.cs +++ b/Lib9c/Action/UnlockWorld.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(questListAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, Addresses.UnlockWorld); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, Addresses.UnlockWorld); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); diff --git a/Lib9c/Action/UnlockWorld1.cs b/Lib9c/Action/UnlockWorld1.cs index 17659d92f8..1a40c11123 100644 --- a/Lib9c/Action/UnlockWorld1.cs +++ b/Lib9c/Action/UnlockWorld1.cs @@ -40,7 +40,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(questListAddress, MarkChanged) .SetState(inventoryAddress, MarkChanged) .SetState(AvatarAddress, MarkChanged) - .MarkBalanceChanged(GoldCurrencyMock, context.Signer, Addresses.UnlockWorld); + .MarkBalanceChanged(context, GoldCurrencyMock, context.Signer, Addresses.UnlockWorld); } context.UseGas(1); From edee0276bbea3e275dd3dfc373fd41baa05e4da7 Mon Sep 17 00:00:00 2001 From: tyrosine1153 Date: Tue, 27 Jun 2023 15:59:43 +0900 Subject: [PATCH 19/68] Add new column IsEnhanceable to StatBuffSheet --- Lib9c/Model/Buff/BuffFactory.cs | 3 +- Lib9c/TableCSV/Skill/SkillBuffSheet.csv | 6 +- Lib9c/TableCSV/Skill/SkillSheet.csv | 4 +- Lib9c/TableCSV/Skill/StatBuffSheet.csv | 234 ++++++++++++------------ Lib9c/TableData/Skill/StatBuffSheet.cs | 10 + Lib9c/TableData/TableExtensions.cs | 3 + 6 files changed, 142 insertions(+), 118 deletions(-) diff --git a/Lib9c/Model/Buff/BuffFactory.cs b/Lib9c/Model/Buff/BuffFactory.cs index 8aad6610dc..9914e0dd94 100644 --- a/Lib9c/Model/Buff/BuffFactory.cs +++ b/Lib9c/Model/Buff/BuffFactory.cs @@ -65,7 +65,8 @@ skill is BuffSkill && continue; var customField = skill.CustomField; - if (!customField.HasValue && + if (buffRow.IsEnhanceable && + !customField.HasValue && extraValueBuff) { var additionalValue = skill.Power; diff --git a/Lib9c/TableCSV/Skill/SkillBuffSheet.csv b/Lib9c/TableCSV/Skill/SkillBuffSheet.csv index 78e49a6abe..d5e83589ef 100644 --- a/Lib9c/TableCSV/Skill/SkillBuffSheet.csv +++ b/Lib9c/TableCSV/Skill/SkillBuffSheet.csv @@ -208,4 +208,8 @@ skill_id,buff_id 500016,504011 700001,701000 700002,702000 -700003,703000 \ No newline at end of file +700003,703000 +800001,801001 +800001,801002 +800002,802001 +800002,802002 diff --git a/Lib9c/TableCSV/Skill/SkillSheet.csv b/Lib9c/TableCSV/Skill/SkillSheet.csv index 63b30a92e7..097c21336e 100644 --- a/Lib9c/TableCSV/Skill/SkillSheet.csv +++ b/Lib9c/TableCSV/Skill/SkillSheet.csv @@ -159,4 +159,6 @@ _250001,속도 증가(전체),Normal,Buff,SpeedBuff,Ally,1,1 // 미구현 600001,출혈,Normal,Debuff,Buff,Enemy,1,15 700001,피해 감소 (고정),Normal,Buff,DamageReductionBuff,Self,1,15 700002,피해 감소 (비율),Normal,Buff,DamageReductionBuff,Self,1,15 -700003,치명 데미지 증가,Normal,Buff,CriticalDamageBuff,Self,1,15 \ No newline at end of file +700003,치명 데미지 증가,Normal,Buff,CriticalDamageBuff,Self,1,15 +800001,양날의 검,Normal,Buff,Buff,Self,1,10 +800002,기선제압,Normal,Buff,Buff,Self,1,10 diff --git a/Lib9c/TableCSV/Skill/StatBuffSheet.csv b/Lib9c/TableCSV/Skill/StatBuffSheet.csv index b07ce6473c..ef1868b91e 100644 --- a/Lib9c/TableCSV/Skill/StatBuffSheet.csv +++ b/Lib9c/TableCSV/Skill/StatBuffSheet.csv @@ -1,115 +1,119 @@ -id,group,_name,chance,duration,target_type,stat_type,modify_type,modify_value -101000,101000,체력 강화,20,10,Self,HP,Percentage,50 -101001,101000,체력 강화,100,25,Self,HP,Percentage,50 -102000,102000,공격 강화,20,10,Self,ATK,Percentage,25 -102001,102000,공격 강화,100,25,Self,ATK,Percentage,50 -102002,102000,공격 강화,100,10,Self,ATK,Percentage,25 -102003,102000,ATK UP (Stat conversion),100,10,Self,ATK,Add,0 -103000,103000,방어 강화,20,10,Self,DEF,Percentage,25 -103001,103000,방어 강화,100,25,Self,DEF,Percentage,50 -103002,103000,방어 강화,100,10,Self,DEF,Percentage,25 -103003,103000,DEF UP (Stat conversion),100,10,Self,DEF,Add,0 -104000,104000,치명 증가,20,10,Self,CRI,Percentage,50 -104001,104000,치명 증가,100,25,Self,CRI,Percentage,75 -104002,104000,치명 증가,100,10,Self,CRI,Percentage,25 -105000,105000,회피 증가,20,10,Self,HIT,Percentage,50 -105001,105000,회피 증가,100,25,Self,HIT,Percentage,75 -105002,105000,회피 증가,100,10,Self,HIT,Percentage,25 -106000,106000,속도 증가,20,10,Self,SPD,Percentage,50 -106001,106000,속도 증가,100,25,Self,SPD,Percentage,75 -106002,106000,속도 증가,100,10,Self,SPD,Percentage,25 -107000,107000,Armor Penetration (Stat conversion),100,10,Self,ArmorPenetration,Add,0 -108000,108000,Thorn (Stat conversion),100,10,Self,Thorn,Add,0 -202000,202000,공격 약화,20,10,Enemy,ATK,Percentage,-25 -202001,202000,공격 약화,100,10,Enemy,ATK,Percentage,-25 -202002,202000,ATK Down (Stat conversion),100,10,Enemy,ATK,Add,0 -202003,202000,ATK ALL Down (Stat conversion),100,6,Enemies,ATK,Add,0 -203001,203000,방어 약화,100,10,Enemy,DEF,Percentage,-25 -203002,203000,DEF Down (Stat conversion),100,10,Enemy,DEF,Add,0 -204001,204000,치명 감소,100,10,Enemy,CRI,Percentage,-25 -205001,205000,회피 감소,100,10,Enemy,HIT,Percentage,-25 -205002,205000,HIT Down (Stat conversion),100,10,Enemy,HIT,Add,0 -206001,206000,속도 감소,100,10,Enemy,SPD,Percentage,-25 -206002,206000,SPD Down (Stat conversion),100,10,Enemy,SPD,Add,0 -301000,301000,체력 강화 (10),100,150,Self,HP,Percentage,10 -302000,302000,공격 강화 (2),100,150,Self,ATK,Percentage,2 -302001,302000,공격 강화 (2),100,150,Self,ATK,Percentage,2 -302002,302000,공격 강화 (3),100,150,Self,ATK,Percentage,3 -302003,302000,공격 강화 (6),100,150,Self,ATK,Percentage,6 -302004,302000,공격 강화 (3),100,150,Self,ATK,Percentage,3 -302005,302000,공격 강화 (5),100,150,Self,ATK,Percentage,5 -302006,302000,공격 강화 (8),100,150,Self,ATK,Percentage,8 -302007,302000,S 올스텟,100,150,Self,ATK,Percentage,20 -302008,302000,S 공격력2,100,150,Self,ATK,Percentage,35 -302009,302000,공격 강화 (18),100,150,Self,ATK,Percentage,18 -302010,302000,SS 올스탯,100,150,Self,ATK,Percentage,50 -302011,302000,S 공격력1,100,150,Self,ATK,Percentage,60 -302012,302000,SS 공격력,100,150,Self,ATK,Percentage,90 -303000,303000,방어 강화 (2),100,150,Self,DEF,Percentage,2 -303001,303000,방어 강화 (2),100,150,Self,DEF,Percentage,2 -303002,303000,방어 강화 (3),100,150,Self,DEF,Percentage,3 -303003,303000,방어 강화 (6),100,150,Self,DEF,Percentage,6 -303004,303000,방어 강화 (3),100,150,Self,DEF,Percentage,3 -303005,303000,방어 강화 (5),100,150,Self,DEF,Percentage,5 -303006,303000,방어 강화 (8),100,150,Self,DEF,Percentage,8 -303007,303000,S 올스텟,100,150,Self,DEF,Percentage,20 -303008,303000,S 방어력2,100,150,Self,DEF,Percentage,35 -303009,303000,방어 강화 (18),100,150,Self,DEF,Percentage,18 -303010,303000,SS 올스탯,100,150,Self,DEF,Percentage,50 -303011,303000,S 방어력1,100,150,Self,DEF,Percentage,60 -303012,303000,SS 방어력,100,150,Self,DEF,Percentage,90 -304000,304000,치명 증가 (100),100,150,Self,CRI,Percentage,100 -304001,304000,치명 증가 (250),100,150,Self,CRI,Percentage,250 -305000,305000,명중 강화 (2),100,150,Self,HIT,Percentage,2 -305001,305000,명중 강화 (2),100,150,Self,HIT,Percentage,2 -305002,305000,명중 강화 (3),100,150,Self,HIT,Percentage,3 -305003,305000,명중 강화 (6),100,150,Self,HIT,Percentage,6 -305004,305000,명중 강화 (3),100,150,Self,HIT,Percentage,3 -305005,305000,명중 강화 (5),100,150,Self,HIT,Percentage,5 -305006,305000,명중 강화 (8),100,150,Self,HIT,Percentage,8 -305007,305000,S 올스텟,100,150,Self,HIT,Percentage,20 -305008,305000,S 명중2,100,150,Self,HIT,Percentage,35 -305009,305000,명중 강화 (18),100,150,Self,HIT,Percentage,18 -305010,305000,SS 올스탯,100,150,Self,HIT,Percentage,50 -305011,305000,S 명중1,100,150,Self,HIT,Percentage,60 -305012,305000,SS 명중,100,150,Self,HIT,Percentage,90 -306000,306000,속도 강화 (2),100,150,Self,SPD,Percentage,2 -306001,306000,속도 강화 (2),100,150,Self,SPD,Percentage,2 -306002,306000,속도 강화 (3),100,150,Self,SPD,Percentage,3 -306003,306000,속도 강화 (6),100,150,Self,SPD,Percentage,6 -306004,306000,속도 강화 (3),100,150,Self,SPD,Percentage,3 -306005,306000,속도 강화 (5),100,150,Self,SPD,Percentage,5 -306006,306000,속도 강화 (8),100,150,Self,SPD,Percentage,8 -306007,306000,S 올스텟,100,150,Self,SPD,Percentage,20 -306008,306000,S 속도2,100,150,Self,SPD,Percentage,35 -306009,306000,속도 강화 (18),100,150,Self,SPD,Percentage,18 -306010,306000,SS 올스탯,100,150,Self,SPD,Percentage,50 -306011,306000,S 속도1,100,150,Self,SPD,Percentage,60 -306012,306000,SS 속도,100,150,Self,SPD,Percentage,90 -501001,501001,Fenrir Rage ATK,100,5,Self,ATK,Percentage,50 -502001,502001,Fenrir Rage SPD,100,5,Self,SPD,Percentage,50 -503011,503011,Berserk ATK(60) Wave 1,100,150,Self,ATK,Percentage,60 -503012,503012,Berserk DEF(-100) Wave 1,100,150,Self,DEF,Percentage,-100 -503021,503011,Berserk ATK(80) Wave 2,100,150,Self,ATK,Percentage,80 -503022,503012,Berserk DEF(-100) Wave 2,100,150,Self,DEF,Percentage,-100 -503031,503011,Berserk ATK(100) Wave 3,100,150,Self,ATK,Percentage,100 -503032,503012,Berserk DEF(-100) Wave 3,100,150,Self,DEF,Percentage,-100 -503041,503011,Berserk ATK(120) Wave 4,100,150,Self,ATK,Percentage,120 -503042,503012,Berserk DEF(-100) Wave 4,100,150,Self,DEF,Percentage,-100 -503051,503011,Berserk ATK(150) Wave 5,100,150,Self,ATK,Percentage,150 -503052,503012,Berserk DEF(-100) Wave 5,100,150,Self,DEF,Percentage,-100 -503015,503015,Berserk CRI(1500),100,150,Self,CRI,Percentage,1500 -504001,504001,Serimnir Rage ATK,100,5,Self,ATK,Percentage,50 -504002,504002,Serimnir Rage SPD,100,5,Self,SPD,Percentage,50 -504003,504003,Serimnir Corrosion,100,6,Enemy,DEF,Percentage,-50 -504004,504004,Serimnir a Series Of Hits,100,3,Self,ATK,Percentage,50 -504005,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,36 -504006,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,56 -504007,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,86 -504008,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,5000 -504009,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,10000 -504010,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,20000 -504011,504011,Serimnir Furious Enemy CDMG,100,8,Enemy,CDMG,Add,10000 -701000,701000,DRV (Rune),100,0,Self,DRV,Add,0 -702000,701000,DRR (Rune),100,0,Self,DRR,Add,0 -703000,703000,CDMG (Rune),100,0,Self,CDMG,Add,0 \ No newline at end of file +id,group,_name,chance,duration,target_type,stat_type,modify_type,modify_value,is_enhanceable +101000,101000,체력 강화,20,10,Self,HP,Percentage,50,true +101001,101000,체력 강화,100,25,Self,HP,Percentage,50,true +102000,102000,공격 강화,20,10,Self,ATK,Percentage,25,true +102001,102000,공격 강화,100,25,Self,ATK,Percentage,50,true +102002,102000,공격 강화,100,10,Self,ATK,Percentage,25,true +102003,102000,ATK UP (Stat conversion),100,10,Self,ATK,Add,0,true +103000,103000,방어 강화,20,10,Self,DEF,Percentage,25,true +103001,103000,방어 강화,100,25,Self,DEF,Percentage,50,true +103002,103000,방어 강화,100,10,Self,DEF,Percentage,25,true +103003,103000,DEF UP (Stat conversion),100,10,Self,DEF,Add,0,true +104000,104000,치명 증가,20,10,Self,CRI,Percentage,50,true +104001,104000,치명 증가,100,25,Self,CRI,Percentage,75,true +104002,104000,치명 증가,100,10,Self,CRI,Percentage,25,true +105000,105000,회피 증가,20,10,Self,HIT,Percentage,50,true +105001,105000,회피 증가,100,25,Self,HIT,Percentage,75,true +105002,105000,회피 증가,100,10,Self,HIT,Percentage,25,true +106000,106000,속도 증가,20,10,Self,SPD,Percentage,50,true +106001,106000,속도 증가,100,25,Self,SPD,Percentage,75,true +106002,106000,속도 증가,100,10,Self,SPD,Percentage,25,true +107000,107000,Armor Penetration (Stat conversion),100,10,Self,ArmorPenetration,Add,0,true +108000,108000,Thorn (Stat conversion),100,10,Self,Thorn,Add,0,true +202000,202000,공격 약화,20,10,Enemy,ATK,Percentage,-25,true +202001,202000,공격 약화,100,10,Enemy,ATK,Percentage,-25,true +202002,202000,ATK Down (Stat conversion),100,10,Enemy,ATK,Add,0,true +202003,202000,ATK ALL Down (Stat conversion),100,6,Enemies,ATK,Add,0,true +203001,203000,방어 약화,100,10,Enemy,DEF,Percentage,-25,true +203002,203000,DEF Down (Stat conversion),100,10,Enemy,DEF,Add,0,true +204001,204000,치명 감소,100,10,Enemy,CRI,Percentage,-25,true +205001,205000,회피 감소,100,10,Enemy,HIT,Percentage,-25,true +205002,205000,HIT Down (Stat conversion),100,10,Enemy,HIT,Add,0,true +206001,206000,속도 감소,100,10,Enemy,SPD,Percentage,-25,true +206002,206000,SPD Down (Stat conversion),100,10,Enemy,SPD,Add,0,true +301000,301000,체력 강화 (10),100,150,Self,HP,Percentage,10,true +302000,302000,공격 강화 (2),100,150,Self,ATK,Percentage,2,true +302001,302000,공격 강화 (2),100,150,Self,ATK,Percentage,2,true +302002,302000,공격 강화 (3),100,150,Self,ATK,Percentage,3,true +302003,302000,공격 강화 (6),100,150,Self,ATK,Percentage,6,true +302004,302000,공격 강화 (3),100,150,Self,ATK,Percentage,3,true +302005,302000,공격 강화 (5),100,150,Self,ATK,Percentage,5,true +302006,302000,공격 강화 (8),100,150,Self,ATK,Percentage,8,true +302007,302000,S 올스텟,100,150,Self,ATK,Percentage,20,true +302008,302000,S 공격력2,100,150,Self,ATK,Percentage,35,true +302009,302000,공격 강화 (18),100,150,Self,ATK,Percentage,18,true +302010,302000,SS 올스탯,100,150,Self,ATK,Percentage,50,true +302011,302000,S 공격력1,100,150,Self,ATK,Percentage,60,true +302012,302000,SS 공격력,100,150,Self,ATK,Percentage,90,true +303000,303000,방어 강화 (2),100,150,Self,DEF,Percentage,2,true +303001,303000,방어 강화 (2),100,150,Self,DEF,Percentage,2,true +303002,303000,방어 강화 (3),100,150,Self,DEF,Percentage,3,true +303003,303000,방어 강화 (6),100,150,Self,DEF,Percentage,6,true +303004,303000,방어 강화 (3),100,150,Self,DEF,Percentage,3,true +303005,303000,방어 강화 (5),100,150,Self,DEF,Percentage,5,true +303006,303000,방어 강화 (8),100,150,Self,DEF,Percentage,8,true +303007,303000,S 올스텟,100,150,Self,DEF,Percentage,20,true +303008,303000,S 방어력2,100,150,Self,DEF,Percentage,35,true +303009,303000,방어 강화 (18),100,150,Self,DEF,Percentage,18,true +303010,303000,SS 올스탯,100,150,Self,DEF,Percentage,50,true +303011,303000,S 방어력1,100,150,Self,DEF,Percentage,60,true +303012,303000,SS 방어력,100,150,Self,DEF,Percentage,90,true +304000,304000,치명 증가 (100),100,150,Self,CRI,Percentage,100,true +304001,304000,치명 증가 (250),100,150,Self,CRI,Percentage,250,true +305000,305000,명중 강화 (2),100,150,Self,HIT,Percentage,2,true +305001,305000,명중 강화 (2),100,150,Self,HIT,Percentage,2,true +305002,305000,명중 강화 (3),100,150,Self,HIT,Percentage,3,true +305003,305000,명중 강화 (6),100,150,Self,HIT,Percentage,6,true +305004,305000,명중 강화 (3),100,150,Self,HIT,Percentage,3,true +305005,305000,명중 강화 (5),100,150,Self,HIT,Percentage,5,true +305006,305000,명중 강화 (8),100,150,Self,HIT,Percentage,8,true +305007,305000,S 올스텟,100,150,Self,HIT,Percentage,20,true +305008,305000,S 명중2,100,150,Self,HIT,Percentage,35,true +305009,305000,명중 강화 (18),100,150,Self,HIT,Percentage,18,true +305010,305000,SS 올스탯,100,150,Self,HIT,Percentage,50,true +305011,305000,S 명중1,100,150,Self,HIT,Percentage,60,true +305012,305000,SS 명중,100,150,Self,HIT,Percentage,90,true +306000,306000,속도 강화 (2),100,150,Self,SPD,Percentage,2,true +306001,306000,속도 강화 (2),100,150,Self,SPD,Percentage,2,true +306002,306000,속도 강화 (3),100,150,Self,SPD,Percentage,3,true +306003,306000,속도 강화 (6),100,150,Self,SPD,Percentage,6,true +306004,306000,속도 강화 (3),100,150,Self,SPD,Percentage,3,true +306005,306000,속도 강화 (5),100,150,Self,SPD,Percentage,5,true +306006,306000,속도 강화 (8),100,150,Self,SPD,Percentage,8,true +306007,306000,S 올스텟,100,150,Self,SPD,Percentage,20,true +306008,306000,S 속도2,100,150,Self,SPD,Percentage,35,true +306009,306000,속도 강화 (18),100,150,Self,SPD,Percentage,18,true +306010,306000,SS 올스탯,100,150,Self,SPD,Percentage,50,true +306011,306000,S 속도1,100,150,Self,SPD,Percentage,60,true +306012,306000,SS 속도,100,150,Self,SPD,Percentage,90,true +501001,501001,Fenrir Rage ATK,100,5,Self,ATK,Percentage,50,true +502001,502001,Fenrir Rage SPD,100,5,Self,SPD,Percentage,50,true +503011,503011,Berserk ATK(60) Wave 1,100,150,Self,ATK,Percentage,60,true +503012,503012,Berserk DEF(-100) Wave 1,100,150,Self,DEF,Percentage,-100,true +503021,503011,Berserk ATK(80) Wave 2,100,150,Self,ATK,Percentage,80,true +503022,503012,Berserk DEF(-100) Wave 2,100,150,Self,DEF,Percentage,-100,true +503031,503011,Berserk ATK(100) Wave 3,100,150,Self,ATK,Percentage,100,true +503032,503012,Berserk DEF(-100) Wave 3,100,150,Self,DEF,Percentage,-100,true +503041,503011,Berserk ATK(120) Wave 4,100,150,Self,ATK,Percentage,120,true +503042,503012,Berserk DEF(-100) Wave 4,100,150,Self,DEF,Percentage,-100,true +503051,503011,Berserk ATK(150) Wave 5,100,150,Self,ATK,Percentage,150,true +503052,503012,Berserk DEF(-100) Wave 5,100,150,Self,DEF,Percentage,-100,true +503015,503015,Berserk CRI(1500),100,150,Self,CRI,Percentage,1500,true +504001,504001,Serimnir Rage ATK,100,5,Self,ATK,Percentage,50,true +504002,504002,Serimnir Rage SPD,100,5,Self,SPD,Percentage,50,true +504003,504003,Serimnir Corrosion,100,6,Enemy,DEF,Percentage,-50,true +504004,504004,Serimnir a Series Of Hits,100,3,Self,ATK,Percentage,50,true +504005,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,36,true +504006,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,56,true +504007,504005,Serimnir Furious CRI,100,5,Self,CRI,Add,86,true +504008,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,5000,true +504009,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,10000,true +504010,504008,Serimnir Furious CDMG,100,5,Self,CDMG,Add,20000,true +504011,504011,Serimnir Furious Enemy CDMG,100,8,Enemy,CDMG,Add,10000,true +701000,701000,DRV (Rune),100,0,Self,DRV,Add,0,true +702000,701000,DRR (Rune),100,0,Self,DRR,Add,0,true +703000,703000,CDMG (Rune),100,0,Self,CDMG,Add,0,true +801001,801001,양날의 검 ATK,100,20,Self,ATK,Percentage,30,true +801002,801002,양날의 검 DEF,100,20,Self,DEF,Percentage,-20,false +802001,802001,기선제압 CRI(Self),100,20,Self,CRI,Percentage,20,true +802002,802002,기선제압 CRI(Enemy),100,20,Enemies,CRI,Percentage,-50,false diff --git a/Lib9c/TableData/Skill/StatBuffSheet.cs b/Lib9c/TableData/Skill/StatBuffSheet.cs index 02bdb7928d..cf82663356 100644 --- a/Lib9c/TableData/Skill/StatBuffSheet.cs +++ b/Lib9c/TableData/Skill/StatBuffSheet.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Nekoyume.Model.Stat; using Nekoyume.Model.Skill; +using static System.Boolean; using static Nekoyume.TableData.TableExtensions; namespace Nekoyume.TableData @@ -36,6 +37,7 @@ public class Row : SheetRow public StatType StatType { get; private set; } public StatModifier.OperationType OperationType { get; private set; } public int Value { get; private set; } + public bool IsEnhanceable { get; private set; } public override void Set(IReadOnlyList fields) { @@ -49,6 +51,14 @@ public override void Set(IReadOnlyList fields) StatType = (StatType)Enum.Parse(typeof(StatType), fields[5]); OperationType = (StatModifier.OperationType)Enum.Parse(typeof(StatModifier.OperationType), fields[6]); Value = ParseInt(fields[7]); + + if (fields.Count < 9) + { + IsEnhanceable = true; + return; + } + + IsEnhanceable = ParseBool(fields[8], true); } } diff --git a/Lib9c/TableData/TableExtensions.cs b/Lib9c/TableData/TableExtensions.cs index 9a3f3ab2ca..33e2bed784 100644 --- a/Lib9c/TableData/TableExtensions.cs +++ b/Lib9c/TableData/TableExtensions.cs @@ -18,6 +18,9 @@ public static bool TryParseLong(string value, out long result) => public static bool TryParseInt(string value, out int result) => int.TryParse(value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out result); + public static bool ParseBool(string value, bool defaultValue) => + bool.TryParse(value, out var result) ? result : defaultValue; + public static int ParseInt(string value) { if (TryParseInt(value, out var result)) From 1df26567444d33eb02a64673389876048ba2e16f Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 10:27:16 +0900 Subject: [PATCH 20/68] Rename garage action interfaces --- .Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs | 4 ++-- .Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs | 4 ++-- .Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs | 4 ++-- ...DeliverToOthersGarages.cs => IDeliverToOthersGaragesV1.cs} | 2 +- .../{ILoadIntoMyGarages.cs => ILoadIntoMyGaragesV1.cs} | 2 +- .../{IUnloadFromMyGarages.cs => IUnloadFromMyGaragesV1.cs} | 3 ++- Lib9c/Action/Garages/DeliverToOthersGarages.cs | 2 +- Lib9c/Action/Garages/LoadIntoMyGarages.cs | 2 +- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) rename Lib9c.Abstractions/{IDeliverToOthersGarages.cs => IDeliverToOthersGaragesV1.cs} (89%) rename Lib9c.Abstractions/{ILoadIntoMyGarages.cs => ILoadIntoMyGaragesV1.cs} (91%) rename Lib9c.Abstractions/{IUnloadFromMyGarages.cs => IUnloadFromMyGaragesV1.cs} (91%) diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs index 31842c043f..14f3a3943a 100644 --- a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -109,8 +109,8 @@ public void Serialize( Assert.Equal(action.Memo, des.Memo); Assert.Equal(ser, des.PlainValue); - var actionInter = (IDeliverToOthersGarages)action; - var desInter = (IDeliverToOthersGarages)des; + var actionInter = (IDeliverToOthersGaragesV1)action; + var desInter = (IDeliverToOthersGaragesV1)des; Assert.Equal(actionInter.RecipientAgentAddr, desInter.RecipientAgentAddr); Assert.True( actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? diff --git a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs index bc956c38e5..0139c9ab13 100644 --- a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs @@ -114,8 +114,8 @@ public void Serialize( Assert.Equal(action.Memo, des.Memo); Assert.Equal(ser, des.PlainValue); - var actionInter = (ILoadIntoMyGarages)action; - var desInter = (ILoadIntoMyGarages)des; + var actionInter = (ILoadIntoMyGaragesV1)action; + var desInter = (ILoadIntoMyGaragesV1)des; Assert.True( actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? desInter.FungibleAssetValues is null); diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index cffd8f34b8..038b5c64cf 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -94,8 +94,8 @@ public void Serialize( Assert.Equal(ser, des.PlainValue); - var actionInter = (IUnloadFromMyGarages)action; - var desInter = (IUnloadFromMyGarages)des; + var actionInter = (IUnloadFromMyGaragesV1)action; + var desInter = (IUnloadFromMyGaragesV1)des; Assert.True( actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? desInter.FungibleAssetValues is null); diff --git a/Lib9c.Abstractions/IDeliverToOthersGarages.cs b/Lib9c.Abstractions/IDeliverToOthersGaragesV1.cs similarity index 89% rename from Lib9c.Abstractions/IDeliverToOthersGarages.cs rename to Lib9c.Abstractions/IDeliverToOthersGaragesV1.cs index 242852d89f..4c40b61295 100644 --- a/Lib9c.Abstractions/IDeliverToOthersGarages.cs +++ b/Lib9c.Abstractions/IDeliverToOthersGaragesV1.cs @@ -5,7 +5,7 @@ namespace Lib9c.Abstractions { - public interface IDeliverToOthersGarages + public interface IDeliverToOthersGaragesV1 { Address RecipientAgentAddr { get; } IOrderedEnumerable? FungibleAssetValues { get; } diff --git a/Lib9c.Abstractions/ILoadIntoMyGarages.cs b/Lib9c.Abstractions/ILoadIntoMyGaragesV1.cs similarity index 91% rename from Lib9c.Abstractions/ILoadIntoMyGarages.cs rename to Lib9c.Abstractions/ILoadIntoMyGaragesV1.cs index e288ad81ba..69cfb4b492 100644 --- a/Lib9c.Abstractions/ILoadIntoMyGarages.cs +++ b/Lib9c.Abstractions/ILoadIntoMyGaragesV1.cs @@ -7,7 +7,7 @@ namespace Lib9c.Abstractions { - public interface ILoadIntoMyGarages + public interface ILoadIntoMyGaragesV1 { IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues { diff --git a/Lib9c.Abstractions/IUnloadFromMyGarages.cs b/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs similarity index 91% rename from Lib9c.Abstractions/IUnloadFromMyGarages.cs rename to Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs index 1adb8cad16..ea3bde4475 100644 --- a/Lib9c.Abstractions/IUnloadFromMyGarages.cs +++ b/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs @@ -7,7 +7,7 @@ namespace Lib9c.Abstractions { - public interface IUnloadFromMyGarages + public interface IUnloadFromMyGaragesV1 { IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues { @@ -15,6 +15,7 @@ public interface IUnloadFromMyGarages } Address? InventoryAddr { get; } + IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; } string? Memo { get; } } diff --git a/Lib9c/Action/Garages/DeliverToOthersGarages.cs b/Lib9c/Action/Garages/DeliverToOthersGarages.cs index 01d728a4c2..8065b3423d 100644 --- a/Lib9c/Action/Garages/DeliverToOthersGarages.cs +++ b/Lib9c/Action/Garages/DeliverToOthersGarages.cs @@ -17,7 +17,7 @@ namespace Nekoyume.Action.Garages { [ActionType("deliver_to_others_garages")] - public class DeliverToOthersGarages : GameAction, IDeliverToOthersGarages, IAction + public class DeliverToOthersGarages : GameAction, IDeliverToOthersGaragesV1, IAction { public Address RecipientAgentAddr { get; private set; } public IOrderedEnumerable? FungibleAssetValues { get; private set; } diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs index dae82c12b9..1d24d9f2c6 100644 --- a/Lib9c/Action/Garages/LoadIntoMyGarages.cs +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -20,7 +20,7 @@ namespace Nekoyume.Action.Garages { [ActionType("load_into_my_garages")] - public class LoadIntoMyGarages : GameAction, ILoadIntoMyGarages, IAction + public class LoadIntoMyGarages : GameAction, ILoadIntoMyGaragesV1, IAction { public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues { get; private set; } diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index 646a5aa4cc..a6abfcd9a8 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -17,7 +17,7 @@ namespace Nekoyume.Action.Garages { [ActionType("unload_from_my_garages")] - public class UnloadFromMyGarages : GameAction, IUnloadFromMyGarages, IAction + public class UnloadFromMyGarages : GameAction, IUnloadFromMyGaragesV1, IAction { public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues { get; private set; } From bdc072dd88a878f290983d76aa7dab830b1e3ba1 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 11:26:10 +0900 Subject: [PATCH 21/68] Change the IUnloadFromMyGarages interface --- .../Action/Garages/UnloadFromMyGaragesTest.cs | 94 ++++----- Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs | 4 +- Lib9c/Action/Garages/GarageUtils.cs | 180 ++++++------------ Lib9c/Action/Garages/LoadIntoMyGarages.cs | 60 ++++-- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 90 +++++---- 5 files changed, 204 insertions(+), 224 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index 038b5c64cf..7b1625f9fc 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -32,8 +32,8 @@ public class UnloadFromMyGaragesTest private readonly TableSheets _tableSheets; private readonly IAccountStateDelta _initialStatesWithAvatarStateV2; private readonly Currency _ncg; + private readonly Address _recipientAvatarAddr; private readonly (Address balanceAddr, FungibleAssetValue value)[] _fungibleAssetValues; - private readonly Address? _inventoryAddr; private readonly (HashDigest fungibleId, int count)[] _fungibleIdAndCounts; private readonly ITradableFungibleItem[] _tradableFungibleItems; private readonly IAccountStateDelta _previousStates; @@ -52,22 +52,42 @@ public UnloadFromMyGaragesTest() avatarIndex: AvatarIndex); _ncg = _initialStatesWithAvatarStateV2.GetGoldCurrency(); ( + _recipientAvatarAddr, _fungibleAssetValues, - _inventoryAddr, _fungibleIdAndCounts, _tradableFungibleItems, _previousStates ) = GetSuccessfulPreviousStatesWithPlainValue(); } - public static IEnumerable Get_Sample_PlainValue() => - LoadIntoMyGaragesTest.Get_Sample_PlainValue(); + public static IEnumerable Get_Sample_PlainValue() + { + var avatarAddr = Addresses.GetAvatarAddress(AgentAddr, AvatarIndex); + var fungibleAssetValues = GetFungibleAssetValues(AgentAddr, avatarAddr); + + var hex = string.Join( + string.Empty, + Enumerable.Range(0, 64).Select(i => (i % 10).ToString())); + var fungibleIdAndCounts = new[] + { + (HashDigest.FromString(hex), 1), + (HashDigest.FromString(hex), int.MaxValue), + }; + + yield return new object[] + { + avatarAddr, + fungibleAssetValues, + fungibleIdAndCounts, + "memo", + }; + } [Theory] [MemberData(nameof(Get_Sample_PlainValue))] public void Serialize( + Address recipientAvatarAddr, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, string? memo) { @@ -75,8 +95,8 @@ public void Serialize( { new UnloadFromMyGarages(), new UnloadFromMyGarages( + recipientAvatarAddr, fungibleAssetValues, - inventoryAddr, fungibleIdAndCounts, memo), }; @@ -85,9 +105,9 @@ public void Serialize( var ser = action.PlainValue; var des = new UnloadFromMyGarages(); des.LoadPlainValue(ser); + Assert.Equal(action.RecipientAvatarAddr, des.RecipientAvatarAddr); Assert.True(action.FungibleAssetValues?.SequenceEqual(des.FungibleAssetValues!) ?? des.FungibleAssetValues is null); - Assert.Equal(action.InventoryAddr, des.InventoryAddr); Assert.True(action.FungibleIdAndCounts?.SequenceEqual(des.FungibleIdAndCounts!) ?? des.FungibleIdAndCounts is null); Assert.Equal(action.Memo, des.Memo); @@ -99,7 +119,7 @@ public void Serialize( Assert.True( actionInter.FungibleAssetValues?.SequenceEqual(desInter.FungibleAssetValues!) ?? desInter.FungibleAssetValues is null); - Assert.Equal(actionInter.InventoryAddr, desInter.InventoryAddr); + Assert.Equal(actionInter.RecipientAvatarAddr, desInter.RecipientAvatarAddr); Assert.True( actionInter.FungibleIdAndCounts?.SequenceEqual(desInter.FungibleIdAndCounts!) ?? desInter.FungibleIdAndCounts is null); @@ -115,8 +135,8 @@ public void Execute_Success() 0, _previousStates, new TestRandom(), + _recipientAvatarAddr, _fungibleAssetValues, - _inventoryAddr, _fungibleIdAndCounts, "memo"); var garageBalanceAddr = @@ -134,14 +154,13 @@ public void Execute_Success() } } - if (action.InventoryAddr is null || - action.FungibleIdAndCounts is null) + if (action.FungibleIdAndCounts is null) { return; } - var inventoryState = nextStates.GetState(action.InventoryAddr.Value)!; - var inventory = new Inventory((List)inventoryState); + var inventoryAddr = _recipientAvatarAddr.Derive(SerializeKeys.LegacyInventoryKey); + var inventory = nextStates.GetInventory(inventoryAddr); foreach (var (fungibleId, count) in action.FungibleIdAndCounts) { var garageAddr = Addresses.GetGarageAddress( @@ -165,8 +184,8 @@ public void Execute_Throws_InvalidActionFieldException() 0, _previousStates, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, null)); // FungibleAssetValues contains negative value. @@ -177,20 +196,10 @@ public void Execute_Throws_InvalidActionFieldException() 0, _previousStates, new TestRandom(), + _recipientAvatarAddr, negativeFungibleAssetValues, - _inventoryAddr, null)); - // InventoryAddr is null when FungibleIdAndCounts is not null. - Assert.Throws(() => Execute( - AgentAddr, - 0, - _previousStates, - new TestRandom(), - null, - null, - _fungibleIdAndCounts)); - // Count of fungible id is negative. var negativeFungibleIdAndCounts = _fungibleIdAndCounts.Select(tuple => ( tuple.fungibleId, @@ -200,8 +209,8 @@ public void Execute_Throws_InvalidActionFieldException() 0, _previousStates, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, negativeFungibleIdAndCounts)); } @@ -222,20 +231,21 @@ public void Execute_Throws_Exception() 0, previousStatesWithEmptyBalances, new TestRandom(), + _recipientAvatarAddr, _fungibleAssetValues, - null, null)); // Inventory state is null. + var inventoryAddr = _recipientAvatarAddr.Derive(SerializeKeys.LegacyInventoryKey); var previousStatesWithNullInventoryState = - _previousStates.SetState(_inventoryAddr!.Value, Null.Value); + _previousStates.SetState(inventoryAddr, Null.Value); Assert.Throws(() => Execute( AgentAddr, 0, previousStatesWithNullInventoryState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); // The state in InventoryAddr is not Inventory. @@ -246,14 +256,14 @@ public void Execute_Throws_Exception() }) { var previousStatesWithInvalidInventoryState = - _previousStates.SetState(_inventoryAddr.Value, invalidInventoryState); + _previousStates.SetState(inventoryAddr, invalidInventoryState); Assert.Throws(() => Execute( AgentAddr, 0, previousStatesWithInvalidInventoryState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); } @@ -270,8 +280,8 @@ public void Execute_Throws_Exception() 0, previousStatesWithNullGarageState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); } @@ -293,8 +303,8 @@ public void Execute_Throws_Exception() 0, previousStatesWithNotEnoughCountOfGarageState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); } else @@ -304,8 +314,8 @@ public void Execute_Throws_Exception() 0, previousStatesWithNotEnoughCountOfGarageState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); } } @@ -314,17 +324,17 @@ public void Execute_Throws_Exception() for (var i = 0; i < _fungibleIdAndCounts.Length; i++) { var item = _tradableFungibleItems[i]; - var inventory = _previousStates.GetInventory(_inventoryAddr.Value); + var inventory = _previousStates.GetInventory(inventoryAddr); inventory.AddTradableFungibleItem(item, int.MaxValue); var previousStatesWithInvalidGarageState = - _previousStates.SetState(_inventoryAddr.Value, inventory.Serialize()); + _previousStates.SetState(inventoryAddr, inventory.Serialize()); Assert.Throws(() => Execute( AgentAddr, 0, previousStatesWithInvalidGarageState, new TestRandom(), + _recipientAvatarAddr, null, - _inventoryAddr, _fungibleIdAndCounts)); } } @@ -334,14 +344,14 @@ private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execu long blockIndex, IAccountStateDelta previousStates, IRandom random, + Address recipientAvatarAddr, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, string? memo = null) { var action = new UnloadFromMyGarages( + recipientAvatarAddr, fungibleAssetValues, - inventoryAddr, fungibleIdAndCounts, memo); return ( @@ -378,8 +388,8 @@ private static (Address balanceAddr, FungibleAssetValue value)[] } private ( + Address recipientAvatarAddr, (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, - Address? inventoryAddr, (HashDigest fungibleId, int count)[] fungibleIdAndCounts, ITradableFungibleItem[] _tradableFungibleItems, IAccountStateDelta previousStates) @@ -425,10 +435,8 @@ private static (Address balanceAddr, FungibleAssetValue value)[] count); }).ToArray(); return ( + recipientAvatarAddr: AvatarAddr, fungibleAssetValues, - inventoryAddr: Addresses.GetInventoryAddress( - AgentAddr, - AvatarIndex), fungibleItemAndCounts .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count)) .ToArray(), diff --git a/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs b/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs index ea3bde4475..9058a133a9 100644 --- a/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs +++ b/Lib9c.Abstractions/IUnloadFromMyGaragesV1.cs @@ -9,13 +9,13 @@ namespace Lib9c.Abstractions { public interface IUnloadFromMyGaragesV1 { + Address RecipientAvatarAddr { get; } + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues { get; } - Address? InventoryAddr { get; } - IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; } string? Memo { get; } } diff --git a/Lib9c/Action/Garages/GarageUtils.cs b/Lib9c/Action/Garages/GarageUtils.cs index b0cb1ba67a..2791c31143 100644 --- a/Lib9c/Action/Garages/GarageUtils.cs +++ b/Lib9c/Action/Garages/GarageUtils.cs @@ -10,164 +10,94 @@ using Libplanet.State; using Nekoyume.Exceptions; using Nekoyume.Model.Garages; -using Nekoyume.Model.State; namespace Nekoyume.Action.Garages { public static class GarageUtils { - public static ( - IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, - IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, - string? memo) - Deserialize(IValue? serialized) - { - if (serialized is null || serialized is Null) - { - throw new ArgumentNullException(nameof(serialized)); - } - - if (!(serialized is List list)) - { - throw new ArgumentException( - $"The type of {nameof(serialized)} must be bencodex list."); - } - - var fungibleAssetValues = list[0].Kind == ValueKind.Null - ? null - : ((List)list[0]).Select(e => - { - var l2 = (List)e; - return ( - l2[0].ToAddress(), - l2[1].ToFungibleAssetValue()); - }); - var inventoryAddr = list[1].Kind == ValueKind.Null - ? (Address?)null - : list[1].ToAddress(); - var fungibleIdAndCounts = list[2].Kind == ValueKind.Null - ? null - : ((List)list[2]).Select(e => - { - var l2 = (List)e; - return ( - l2[0].ToItemId(), - (int)((Integer)l2[1]).Value); - }); - var memo = list[3].Kind == ValueKind.Null - ? null - : (string)(Text)list[3]; - return MergeAndSort( - fungibleAssetValues, - inventoryAddr, - fungibleIdAndCounts, - memo); - } - - public static ( - IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, - IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, - string? memo) + public static IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? MergeAndSort( - IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, - IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, - string? memo) + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues) { - ( - IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? - fungibleAssetValues, - Address? inventoryAddr, - IOrderedEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, - string? memo) - result = (null, null, null, null); var favArr = fungibleAssetValues as (Address balanceAddr, FungibleAssetValue value)[] ?? fungibleAssetValues?.ToArray(); if (favArr is null || favArr.Length == 0) { - result.fungibleAssetValues = null; + return null; } - else + + var dict = new Dictionary>(); + foreach (var (balanceAddr, value) in favArr) { - var dict = new Dictionary>(); - foreach (var (balanceAddr, value) in favArr) + if (!dict.ContainsKey(balanceAddr)) { - if (!dict.ContainsKey(balanceAddr)) - { - dict[balanceAddr] = new Dictionary(); - } + dict[balanceAddr] = new Dictionary(); + } - if (dict[balanceAddr].ContainsKey(value.Currency)) - { - dict[balanceAddr][value.Currency] += value; - } - else - { - dict[balanceAddr][value.Currency] = value; - } + if (dict[balanceAddr].ContainsKey(value.Currency)) + { + dict[balanceAddr][value.Currency] += value; } + else + { + dict[balanceAddr][value.Currency] = value; + } + } #pragma warning disable LAA1002 - var arr = dict + var arr = dict #pragma warning restore LAA1002 - .Select(pair => ( - balanceAddr: pair.Key, - value: pair.Value.Values.ToArray())) - .SelectMany(tuple => - tuple.value.Select(value => (tuple.balanceAddr, value))) - .Where(tuple => tuple.value.Sign != 0) - .ToArray(); - result.fungibleAssetValues = arr.Any() - ? arr - .OrderBy(tuple => tuple.balanceAddr) - .ThenBy(tuple => tuple.value.GetHashCode()) - : null; - } - - result.inventoryAddr = inventoryAddr; + .Select(pair => ( + balanceAddr: pair.Key, + value: pair.Value.Values.ToArray())) + .SelectMany(tuple => + tuple.value.Select(value => (tuple.balanceAddr, value))) + .Where(tuple => tuple.value.Sign != 0) + .ToArray(); + return arr.Any() + ? arr + .OrderBy(tuple => tuple.balanceAddr) + .ThenBy(tuple => tuple.value.GetHashCode()) + : null; + } + public static IOrderedEnumerable<(HashDigest fungibleId, int count)>? + MergeAndSort( + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts) + { var fiArr = fungibleIdAndCounts as (HashDigest fungibleId, int count)[] ?? fungibleIdAndCounts?.ToArray(); if (fiArr is null || fiArr.Length == 0) { - result.fungibleIdAndCounts = null; + return null; } - else + + var dict = new Dictionary, int>(); + foreach (var (fungibleId, count) in fiArr) { - var dict = new Dictionary, int>(); - foreach (var (fungibleId, count) in fiArr) + if (dict.ContainsKey(fungibleId)) + { + dict[fungibleId] += count; + } + else { - if (dict.ContainsKey(fungibleId)) - { - dict[fungibleId] += count; - } - else - { - dict[fungibleId] = count; - } + dict[fungibleId] = count; } + } #pragma warning disable LAA1002 - var arr = dict + var arr = dict #pragma warning restore LAA1002 - .Select(pair => (fungibleId: pair.Key, count: pair.Value)) - .Where(tuple => tuple.count != 0) - .ToArray(); - result.fungibleIdAndCounts = arr.Any() - ? arr - .OrderBy(tuple => tuple.fungibleId.GetHashCode()) - .ThenBy(tuple => tuple.count) - : null; - } - - result.memo = string.IsNullOrEmpty(memo) - ? null - : memo; - return result; + .Select(pair => (fungibleId: pair.Key, count: pair.Value)) + .Where(tuple => tuple.count != 0) + .ToArray(); + return arr.Any() + ? arr + .OrderBy(tuple => tuple.fungibleId.GetHashCode()) + .ThenBy(tuple => tuple.count) + : null; } public static IOrderedEnumerable<( diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs index 1d24d9f2c6..a86d75d97d 100644 --- a/Lib9c/Action/Garages/LoadIntoMyGarages.cs +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -57,7 +57,7 @@ FungibleIdAndCounts is null : new List(FungibleIdAndCounts.Select(tuple => new List( tuple.fungibleId.Serialize(), (Integer)tuple.count))), - Memo is null + string.IsNullOrEmpty(Memo) ? (IValue)Null.Value : (Text)Memo) } @@ -69,16 +69,10 @@ public LoadIntoMyGarages( IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, string? memo) { - ( - FungibleAssetValues, - InventoryAddr, - FungibleIdAndCounts, - Memo - ) = GarageUtils.MergeAndSort( - fungibleAssetValues, - inventoryAddr, - fungibleIdAndCounts, - memo); + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValues); + InventoryAddr = inventoryAddr; + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCounts); + Memo = memo; } public LoadIntoMyGarages() @@ -88,12 +82,44 @@ public LoadIntoMyGarages() protected override void LoadPlainValueInternal( IImmutableDictionary plainValue) { - ( - FungibleAssetValues, - InventoryAddr, - FungibleIdAndCounts, - Memo - ) = GarageUtils.Deserialize(plainValue["l"]); + var serialized = plainValue["l"]; + if (serialized is null || serialized is Null) + { + throw new ArgumentNullException(nameof(serialized)); + } + + if (!(serialized is List list)) + { + throw new ArgumentException( + $"The type of {nameof(serialized)} must be bencodex list."); + } + + var fungibleAssetValues = list[0].Kind == ValueKind.Null + ? null + : ((List)list[0]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToAddress(), + l2[1].ToFungibleAssetValue()); + }); + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValues); + InventoryAddr = list[1].Kind == ValueKind.Null + ? (Address?)null + : list[1].ToAddress(); + var fungibleIdAndCounts = list[2].Kind == ValueKind.Null + ? null + : ((List)list[2]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToItemId(), + (int)((Integer)l2[1]).Value); + }); + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCounts); + Memo = list[3].Kind == ValueKind.Null + ? null + : (string)(Text)list[3]; } public override IAccountStateDelta Execute(IActionContext context) diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index a6abfcd9a8..d30625cb8e 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -1,10 +1,12 @@ #nullable enable +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Security.Cryptography; using Bencodex.Types; +using Lib9c; using Lib9c.Abstractions; using Libplanet; using Libplanet.Action; @@ -19,16 +21,15 @@ namespace Nekoyume.Action.Garages [ActionType("unload_from_my_garages")] public class UnloadFromMyGarages : GameAction, IUnloadFromMyGaragesV1, IAction { - public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? - FungibleAssetValues { get; private set; } - /// - /// This address does not need to consider its owner. /// If the avatar state is v1, there is no separate inventory, /// so it should be execute another action first to migrate the avatar state to v2. /// And then, the inventory address will be set. /// - public Address? InventoryAddr { get; private set; } + public Address RecipientAvatarAddr { get; private set; } + + public IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? + FungibleAssetValues { get; private set; } public IOrderedEnumerable<(HashDigest fungibleId, int count)>? FungibleIdAndCounts { get; private set; } @@ -41,41 +42,33 @@ public class UnloadFromMyGarages : GameAction, IUnloadFromMyGaragesV1, IAction { "l", new List( + RecipientAvatarAddr.Serialize(), FungibleAssetValues is null ? (IValue)Null.Value : new List(FungibleAssetValues.Select(tuple => new List( tuple.balanceAddr.Serialize(), tuple.value.Serialize()))), - InventoryAddr is null - ? Null.Value - : InventoryAddr.Serialize(), FungibleIdAndCounts is null ? (IValue)Null.Value : new List(FungibleIdAndCounts.Select(tuple => new List( tuple.fungibleId.Serialize(), (Integer)tuple.count))), - Memo is null + string.IsNullOrEmpty(Memo) ? (IValue)Null.Value : (Text)Memo) } }.ToImmutableDictionary(); public UnloadFromMyGarages( + Address recipientAvatarAddr, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, - Address? inventoryAddr, IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, string? memo) { - ( - FungibleAssetValues, - InventoryAddr, - FungibleIdAndCounts, - Memo - ) = GarageUtils.MergeAndSort( - fungibleAssetValues, - inventoryAddr, - fungibleIdAndCounts, - memo); + RecipientAvatarAddr = recipientAvatarAddr; + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValues); + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCounts); + Memo = memo; } public UnloadFromMyGarages() @@ -85,12 +78,42 @@ public UnloadFromMyGarages() protected override void LoadPlainValueInternal( IImmutableDictionary plainValue) { - ( - FungibleAssetValues, - InventoryAddr, - FungibleIdAndCounts, - Memo - ) = GarageUtils.Deserialize(plainValue["l"]); + var serialized = plainValue["l"]; + if (serialized is null || serialized is Null) + { + throw new ArgumentNullException(nameof(serialized)); + } + + if (!(serialized is List list)) + { + throw new ArgumentException( + $"The type of {nameof(serialized)} must be bencodex list."); + } + + RecipientAvatarAddr = list[0].ToAddress(); + var fungibleAssetValues = list[1].Kind == ValueKind.Null + ? null + : ((List)list[1]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToAddress(), + l2[1].ToFungibleAssetValue()); + }); + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValues); + var fungibleIdAndCounts = list[2].Kind == ValueKind.Null + ? null + : ((List)list[2]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToItemId(), + (int)((Integer)l2[1]).Value); + }); + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCounts); + Memo = list[3].Kind == ValueKind.Null + ? null + : (string)(Text)list[3]; } public override IAccountStateDelta Execute(IActionContext context) @@ -138,13 +161,6 @@ private void ValidateFields(string addressesHex) return; } - if (!InventoryAddr.HasValue) - { - throw new InvalidActionFieldException( - $"[{addressesHex}] {nameof(InventoryAddr)} is required when " + - $"{nameof(FungibleIdAndCounts)} is set."); - } - foreach (var (fungibleId, count) in FungibleIdAndCounts) { if (count < 0) @@ -179,13 +195,13 @@ private IAccountStateDelta TransferFungibleItems( Address signer, IAccountStateDelta states) { - if (InventoryAddr is null || - FungibleIdAndCounts is null) + if (FungibleIdAndCounts is null) { return states; } - var inventory = states.GetInventory(InventoryAddr.Value); + var inventoryAddr = RecipientAvatarAddr.Derive(SerializeKeys.LegacyInventoryKey); + var inventory = states.GetInventory(inventoryAddr); var fungibleItemTuples = GarageUtils.WithGarageTuples( signer, states, @@ -199,7 +215,7 @@ private IAccountStateDelta TransferFungibleItems( states = states.SetState(garageAddr, garage.Serialize()); } - return states.SetState(InventoryAddr.Value, inventory.Serialize()); + return states.SetState(inventoryAddr, inventory.Serialize()); } } } From a420d4bf692f0f33717a4726dfb42449a69c6c25 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 11:26:22 +0900 Subject: [PATCH 22/68] Use gas in garage actions --- Lib9c/Action/Garages/DeliverToOthersGarages.cs | 1 + Lib9c/Action/Garages/LoadIntoMyGarages.cs | 1 + Lib9c/Action/Garages/UnloadFromMyGarages.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/Lib9c/Action/Garages/DeliverToOthersGarages.cs b/Lib9c/Action/Garages/DeliverToOthersGarages.cs index 8065b3423d..e8993eeb97 100644 --- a/Lib9c/Action/Garages/DeliverToOthersGarages.cs +++ b/Lib9c/Action/Garages/DeliverToOthersGarages.cs @@ -162,6 +162,7 @@ private void SetInternal( public override IAccountStateDelta Execute(IActionContext context) { + context.UseGas(1); var states = context.PreviousStates; if (context.Rehearsal) { diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs index a86d75d97d..ba34971878 100644 --- a/Lib9c/Action/Garages/LoadIntoMyGarages.cs +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -124,6 +124,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { + context.UseGas(1); var states = context.PreviousStates; if (context.Rehearsal) { diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index d30625cb8e..374c20063f 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -118,6 +118,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { + context.UseGas(1); var states = context.PreviousStates; if (context.Rehearsal) { From 9a5b4034035571e3835f17aee700de40871abf89 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 18:12:15 +0900 Subject: [PATCH 23/68] Introduce UnloadFromMyGaragesRecipientMail --- .../UnloadFromMyGaragesRecipientMailTest.cs | 55 +++++++++ Lib9c/Model/Mail/IMail.cs | 1 + Lib9c/Model/Mail/Mail.cs | 2 + .../Mail/UnloadFromMyGaragesRecipientMail.cs | 114 ++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 .Lib9c.Tests/Model/Mail/UnloadFromMyGaragesRecipientMailTest.cs create mode 100644 Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs diff --git a/.Lib9c.Tests/Model/Mail/UnloadFromMyGaragesRecipientMailTest.cs b/.Lib9c.Tests/Model/Mail/UnloadFromMyGaragesRecipientMailTest.cs new file mode 100644 index 0000000000..feecddc948 --- /dev/null +++ b/.Lib9c.Tests/Model/Mail/UnloadFromMyGaragesRecipientMailTest.cs @@ -0,0 +1,55 @@ +namespace Lib9c.Tests.Model.Mail +{ +#nullable enable + + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography; + using Bencodex.Types; + using Lib9c.Tests.Action.Garages; + using Libplanet; + using Libplanet.Assets; + using Nekoyume.Model.Mail; + using Xunit; + + public class UnloadFromMyGaragesRecipientMailTest + { + public static IEnumerable Get_Sample_PlainValue() => + UnloadFromMyGaragesTest.Get_Sample_PlainValue().Select(objects => + new[] + { + // objects[0], This test doesn't need to test recipientAvatarAddr. + objects[1], + objects[2], + objects[3], + }); + + [Theory] + [MemberData(nameof(Get_Sample_PlainValue))] + public void Serialize( + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCounts, + string? memo) + { + const long blockIndex = 0L; + var guid = Guid.NewGuid(); + var mail = new UnloadFromMyGaragesRecipientMail( + blockIndex, + guid, + blockIndex, + fungibleAssetValues, + fungibleIdAndCounts, + memo); + var mailValue = mail.Serialize(); + var de = new UnloadFromMyGaragesRecipientMail((Dictionary)mailValue); + Assert.True(mail.FungibleAssetValues?.SequenceEqual(de.FungibleAssetValues!) ?? + de.FungibleAssetValues is null); + Assert.True(mail.FungibleIdAndCounts?.SequenceEqual(de.FungibleIdAndCounts!) ?? + de.FungibleIdAndCounts is null); + Assert.Equal(mail.Memo, de.Memo); + var mailValue2 = de.Serialize(); + Assert.Equal(mailValue, mailValue2); + } + } +} diff --git a/Lib9c/Model/Mail/IMail.cs b/Lib9c/Model/Mail/IMail.cs index ff0b3d6576..4ad564b637 100644 --- a/Lib9c/Model/Mail/IMail.cs +++ b/Lib9c/Model/Mail/IMail.cs @@ -18,5 +18,6 @@ public interface IMail void Read(ProductBuyerMail productBuyerMail); void Read(ProductSellerMail productSellerMail); void Read(ProductCancelMail productCancelMail); + void Read(UnloadFromMyGaragesRecipientMail unloadFromMyGaragesRecipientMail); } } diff --git a/Lib9c/Model/Mail/Mail.cs b/Lib9c/Model/Mail/Mail.cs index 3d5fed9f0e..9c562e98ad 100644 --- a/Lib9c/Model/Mail/Mail.cs +++ b/Lib9c/Model/Mail/Mail.cs @@ -37,6 +37,8 @@ public abstract class Mail : IState [nameof(ProductBuyerMail)] = d => new ProductBuyerMail(d), [nameof(ProductSellerMail)] = d => new ProductSellerMail(d), [nameof(ProductCancelMail)] = d => new ProductCancelMail(d), + [nameof(UnloadFromMyGaragesRecipientMail)] = d => + new UnloadFromMyGaragesRecipientMail(d), }; public Guid id; diff --git a/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs b/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs new file mode 100644 index 0000000000..d1d2f0f5f9 --- /dev/null +++ b/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs @@ -0,0 +1,114 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using Bencodex.Types; +using Libplanet; +using Libplanet.Assets; +using Nekoyume.Action.Garages; +using Nekoyume.Model.State; + +namespace Nekoyume.Model.Mail +{ + public class UnloadFromMyGaragesRecipientMail : Mail + { + protected override string TypeId => nameof(UnloadFromMyGaragesRecipientMail); + public override MailType MailType => MailType.System; + + public readonly IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? + FungibleAssetValues; + + public readonly IOrderedEnumerable<(HashDigest fungibleId, int count)>? + FungibleIdAndCounts; + + public readonly string? Memo; + + public UnloadFromMyGaragesRecipientMail( + long blockIndex, + Guid id, + long requiredBlockIndex, + IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValue, + IEnumerable<(HashDigest fungibleId, int count)>? fungibleIdAndCount, + string? memo) + : base(blockIndex, id, requiredBlockIndex) + { + if (fungibleAssetValue is + IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)> oe) + { + FungibleAssetValues = oe; + } + else + { + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValue); + } + + if (fungibleIdAndCount is + IOrderedEnumerable<(HashDigest fungibleId, int count)> oe2) + { + FungibleIdAndCounts = oe2; + } + else + { + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCount); + } + + Memo = memo; + } + + public UnloadFromMyGaragesRecipientMail(Dictionary serialized) : + base(serialized) + { + var list = (List)serialized["l"]; + var fungibleAssetValues = list[0].Kind == ValueKind.Null + ? null + : ((List)list[0]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToAddress(), + l2[1].ToFungibleAssetValue() + ); + }); + FungibleAssetValues = GarageUtils.MergeAndSort(fungibleAssetValues); + var fungibleIdAndCounts = list[1].Kind == ValueKind.Null + ? null + : ((List)list[1]).Select(e => + { + var l2 = (List)e; + return ( + l2[0].ToItemId(), + (int)((Integer)l2[1]).Value); + }); + FungibleIdAndCounts = GarageUtils.MergeAndSort(fungibleIdAndCounts); + Memo = list[2].Kind == ValueKind.Null + ? null + : (string)(Text)list[2]; + } + + public override void Read(IMail mail) + { + mail.Read(this); + } + + public override IValue Serialize() + { + var dict = (Dictionary)base.Serialize(); + return dict.SetItem("l", new List( + FungibleAssetValues is null + ? (IValue)Null.Value + : new List(FungibleAssetValues.Select(tuple => new List( + tuple.balanceAddr.Serialize(), + tuple.value.Serialize()))), + FungibleIdAndCounts is null + ? (IValue)Null.Value + : new List(FungibleIdAndCounts.Select(tuple => new List( + tuple.fungibleId.Serialize(), + (Integer)tuple.count))), + Memo is null + ? (IValue)Null.Value + : (Text)Memo)); + } + } +} From 87e4ef0a4e648909d6d35c1a031a91f7ba2c3acd Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 18:12:54 +0900 Subject: [PATCH 24/68] Rename Mail.CleanUp2() to CleanUpV1() --- .Lib9c.Tests/Model/State/AvatarStateTest.cs | 2 +- Lib9c/Action/HackAndSlash3.cs | 2 +- Lib9c/Action/MimisbrunnrBattle0.cs | 2 +- Lib9c/Model/Mail/Mail.cs | 7 +++++-- Lib9c/Model/State/AvatarState.cs | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.Lib9c.Tests/Model/State/AvatarStateTest.cs b/.Lib9c.Tests/Model/State/AvatarStateTest.cs index 8362252922..29ee6572e0 100644 --- a/.Lib9c.Tests/Model/State/AvatarStateTest.cs +++ b/.Lib9c.Tests/Model/State/AvatarStateTest.cs @@ -375,7 +375,7 @@ public void CleanUpMail() mailBox.Add(mail); } - mailBox.CleanUp2(); + mailBox.CleanUpV1(); Assert.Equal(30, mailBox.Count); Assert.DoesNotContain(mailBox, m => m.blockIndex < 30); diff --git a/Lib9c/Action/HackAndSlash3.cs b/Lib9c/Action/HackAndSlash3.cs index d099b282b3..9b7105aba5 100644 --- a/Lib9c/Action/HackAndSlash3.cs +++ b/Lib9c/Action/HackAndSlash3.cs @@ -231,7 +231,7 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.UpdateQuestRewards2(materialSheet); avatarState.updatedAt = ctx.BlockIndex; - avatarState.mailBox.CleanUp2(); + avatarState.mailBox.CleanUpV1(); states = states.SetState(avatarAddress, avatarState.Serialize()); sw.Stop(); diff --git a/Lib9c/Action/MimisbrunnrBattle0.cs b/Lib9c/Action/MimisbrunnrBattle0.cs index 5d91cd0fbd..d87630bf66 100644 --- a/Lib9c/Action/MimisbrunnrBattle0.cs +++ b/Lib9c/Action/MimisbrunnrBattle0.cs @@ -265,7 +265,7 @@ public override IAccountStateDelta Execute(IActionContext context) avatarState.UpdateQuestRewards2(materialSheet); avatarState.updatedAt = ctx.BlockIndex; - avatarState.mailBox.CleanUp2(); + avatarState.mailBox.CleanUpV1(); states = states.SetState(avatarAddress, avatarState.Serialize()); sw.Stop(); diff --git a/Lib9c/Model/Mail/Mail.cs b/Lib9c/Model/Mail/Mail.cs index 9c562e98ad..52b9595eb7 100644 --- a/Lib9c/Model/Mail/Mail.cs +++ b/Lib9c/Model/Mail/Mail.cs @@ -151,11 +151,14 @@ public void CleanUp() } [Obsolete("Use CleanUp")] - public void CleanUp2() + public void CleanUpV1() { if (_mails.Count > 30) { - _mails = _mails.OrderByDescending(m => m.blockIndex).Take(30).ToList(); + _mails = _mails + .OrderByDescending(m => m.blockIndex) + .Take(30) + .ToList(); } } diff --git a/Lib9c/Model/State/AvatarState.cs b/Lib9c/Model/State/AvatarState.cs index f06c850cdc..c01ded7ae4 100644 --- a/Lib9c/Model/State/AvatarState.cs +++ b/Lib9c/Model/State/AvatarState.cs @@ -313,7 +313,7 @@ public void Update2(Mail.Mail mail) public void Update3(Mail.Mail mail) { mailBox.Add(mail); - mailBox.CleanUp2(); + mailBox.CleanUpV1(); } [Obsolete("No longer in use.")] From 964e6afaed2cad1b0120390fa5a7ba6011f67a2a Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Wed, 28 Jun 2023 18:13:25 +0900 Subject: [PATCH 25/68] Send UnloadFromMyGaragesRecipientMail to RecipientAvatarAddr in UnloadFromMyGarages action --- .../Action/Garages/UnloadFromMyGaragesTest.cs | 49 ++++++++++++------- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 43 +++++++++++++--- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index 7b1625f9fc..cac8907875 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -19,6 +19,7 @@ namespace Lib9c.Tests.Action.Garages using Nekoyume.Exceptions; using Nekoyume.Model.Garages; using Nekoyume.Model.Item; + using Nekoyume.Model.Mail; using Xunit; public class UnloadFromMyGaragesTest @@ -130,15 +131,17 @@ public void Serialize( [Fact] public void Execute_Success() { + const long blockIndex = 0L; + const string memo = "memo"; var (action, nextStates) = Execute( AgentAddr, - 0, + blockIndex, _previousStates, new TestRandom(), _recipientAvatarAddr, _fungibleAssetValues, _fungibleIdAndCounts, - "memo"); + memo); var garageBalanceAddr = Addresses.GetGarageBalanceAddress(AgentAddr); if (action.FungibleAssetValues is { }) @@ -154,25 +157,35 @@ public void Execute_Success() } } - if (action.FungibleIdAndCounts is null) + if (action.FungibleIdAndCounts is { }) { - return; + var inventoryAddr = _recipientAvatarAddr.Derive(SerializeKeys.LegacyInventoryKey); + var inventory = nextStates.GetInventory(inventoryAddr); + foreach (var (fungibleId, count) in action.FungibleIdAndCounts) + { + var garageAddr = Addresses.GetGarageAddress( + AgentAddr, + fungibleId); + Assert.True(nextStates.GetState(garageAddr) is Null); + Assert.True(inventory.HasTradableFungibleItem( + fungibleId, + requiredBlockIndex: null, + blockIndex: 0, + count)); + } } - var inventoryAddr = _recipientAvatarAddr.Derive(SerializeKeys.LegacyInventoryKey); - var inventory = nextStates.GetInventory(inventoryAddr); - foreach (var (fungibleId, count) in action.FungibleIdAndCounts) - { - var garageAddr = Addresses.GetGarageAddress( - AgentAddr, - fungibleId); - Assert.True(nextStates.GetState(garageAddr) is Null); - Assert.True(inventory.HasTradableFungibleItem( - fungibleId, - requiredBlockIndex: null, - blockIndex: 0, - count)); - } + var avatarDict = (Dictionary)nextStates.GetState(_recipientAvatarAddr)!; + var mailBox = new MailBox((List)avatarDict[SerializeKeys.MailBoxKey]); + Assert.Single(mailBox); + var mail = Assert.IsType(mailBox.First()); + Assert.Equal(blockIndex, mail.blockIndex); + Assert.Equal(blockIndex, mail.requiredBlockIndex); + Assert.True(action.FungibleAssetValues?.SequenceEqual(mail.FungibleAssetValues!) ?? + mail.FungibleAssetValues is null); + Assert.True(action.FungibleIdAndCounts?.SequenceEqual(mail.FungibleIdAndCounts!) ?? + mail.FungibleIdAndCounts is null); + Assert.Equal(action.Memo, mail.Memo); } [Fact] diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index 374c20063f..21e867059f 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -14,6 +14,7 @@ using Libplanet.State; using Nekoyume.Exceptions; using Nekoyume.Model.Item; +using Nekoyume.Model.Mail; using Nekoyume.Model.State; namespace Nekoyume.Action.Garages @@ -127,12 +128,9 @@ public override IAccountStateDelta Execute(IActionContext context) var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(addressesHex); - states = TransferFungibleAssetValues( - context.Signer, - states); - return TransferFungibleItems( - context.Signer, - states); + states = TransferFungibleAssetValues(context.Signer, states); + states = TransferFungibleItems(context.Signer, states); + return SendMail(context.BlockIndex, context.Random, states); } private void ValidateFields(string addressesHex) @@ -218,5 +216,38 @@ private IAccountStateDelta TransferFungibleItems( return states.SetState(inventoryAddr, inventory.Serialize()); } + + private IAccountStateDelta SendMail( + long blockIndex, + IRandom random, + IAccountStateDelta states) + { + var avatarValue = states.GetState(RecipientAvatarAddr); + if (!(avatarValue is Dictionary avatarDict)) + { + throw new FailedLoadStateException(RecipientAvatarAddr, typeof(AvatarState)); + } + + // NOTE: + // This action supports the avatar state v2 only. + // So, we just check the mail box with a newer key. + if (!avatarDict.ContainsKey(SerializeKeys.MailBoxKey)) + { + throw new KeyNotFoundException( + $"Dictionary key is not found: {SerializeKeys.MailBoxKey}"); + } + + var mailBox = new MailBox((List)avatarDict[SerializeKeys.MailBoxKey]); + mailBox.Add(new UnloadFromMyGaragesRecipientMail( + blockIndex, + random.GenerateRandomGuid(), + blockIndex, + FungibleAssetValues, + FungibleIdAndCounts, + Memo)); + mailBox.CleanUp(); + avatarDict = avatarDict.SetItem(SerializeKeys.MailBoxKey, mailBox.Serialize()); + return states.SetState(RecipientAvatarAddr, avatarDict); + } } } From 5d39b5dd783a0786a9181a7701e34b3ad6d3bc52 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 30 Jun 2023 11:37:07 +0900 Subject: [PATCH 26/68] Apply Libplanet changes --- .../Garages/DeliverToOthersGaragesTest.cs | 10 ++++-- .../Action/Garages/LoadIntoMyGaragesTest.cs | 35 +++++++++++-------- .../Action/Garages/UnloadFromMyGaragesTest.cs | 10 ++++-- .../Action/Garages/DeliverToOthersGarages.cs | 13 +++---- Lib9c/Action/Garages/LoadIntoMyGarages.cs | 20 ++++------- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 9 +++-- 6 files changed, 53 insertions(+), 44 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs index 14f3a3943a..6567da6562 100644 --- a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -216,12 +216,15 @@ public void Execute_Throws_Exception() { // Sender's FungibleAssetValue Garage does not have enough balance. var previousStatesWithEmptyBalances = _previousStates; + var actionContext = new ActionContext { Signer = SenderAgentAddr }; var senderFungibleAssetValueGarageAddr = Addresses.GetGarageBalanceAddress(SenderAgentAddr); foreach (var vaf in _fungibleAssetValues) { - previousStatesWithEmptyBalances = previousStatesWithEmptyBalances - .BurnAsset(senderFungibleAssetValueGarageAddr, vaf); + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances.BurnAsset( + actionContext, + senderFungibleAssetValueGarageAddr, + vaf); } Assert.Throws(() => Execute( @@ -368,6 +371,7 @@ private static FungibleAssetValue[] GetFungibleAssetValues() GetSuccessfulPreviousStatesWithPlainValue() { var previousStates = _initialStatesWithAvatarStateV2; + var actionContext = new ActionContext { Signer = Addresses.Admin }; var senderFavGarageBalanceAddr = Addresses.GetGarageBalanceAddress(SenderAgentAddr); var fungibleAssetValues = GetFungibleAssetValues(); @@ -376,6 +380,7 @@ private static FungibleAssetValue[] GetFungibleAssetValues() if (fav.Currency.Equals(_ncg)) { previousStates = previousStates.TransferAsset( + actionContext, Addresses.Admin, senderFavGarageBalanceAddr, fav); @@ -383,6 +388,7 @@ private static FungibleAssetValue[] GetFungibleAssetValues() } previousStates = previousStates.MintAsset( + actionContext, senderFavGarageBalanceAddr, fav); } diff --git a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs index 0139c9ab13..e0229470fa 100644 --- a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs @@ -260,8 +260,10 @@ public void Execute_Throws_InvalidActionFieldException() public void Execute_Throws_Exception() { // Balance does not enough to pay cost. - var previousStatesWithNotEnoughCost = _previousStates - .BurnAsset(AgentAddr, new FungibleAssetValue(Currencies.Garage, 1, 0)); + var previousStatesWithNotEnoughCost = _previousStates.BurnAsset( + new ActionContext { Signer = AgentAddr }, + AgentAddr, + new FungibleAssetValue(Currencies.Garage, 1, 0)); Assert.Throws(() => Execute( AgentAddr, 0, @@ -275,8 +277,10 @@ public void Execute_Throws_Exception() var previousStatesWithEmptyBalances = _previousStates; foreach (var (balanceAddr, value) in _fungibleAssetValues) { - previousStatesWithEmptyBalances = previousStatesWithEmptyBalances - .BurnAsset(balanceAddr, value); + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances.BurnAsset( + new ActionContext { Signer = AgentAddr }, + balanceAddr, + value); } Assert.Throws(() => Execute( @@ -406,16 +410,15 @@ private static (LoadIntoMyGarages action, IAccountStateDelta nextStates) Execute inventoryAddr, fungibleIdAndCounts, memo); - return ( - action, - action.Execute(new ActionContext - { - Signer = signer, - BlockIndex = blockIndex, - Rehearsal = false, - PreviousStates = previousStates, - Random = random, - })); + var context = new ActionContext + { + Signer = signer, + BlockIndex = blockIndex, + Rehearsal = false, + PreviousStates = previousStates, + Random = random, + }; + return (action, action.Execute(context)); } private static (Address balanceAddr, FungibleAssetValue value)[] @@ -457,11 +460,13 @@ private static (Address balanceAddr, FungibleAssetValue value)[] AgentAddr, _avatarAddress, _tableSheets); + var actionContext = new ActionContext { Signer = Addresses.Admin }; foreach (var (balanceAddr, value) in fungibleAssetValues) { if (value.Currency.Equals(_ncg)) { previousStates = previousStates.TransferAsset( + actionContext, Addresses.Admin, balanceAddr, value); @@ -469,6 +474,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] } previousStates = previousStates.MintAsset( + actionContext, balanceAddr, value); } @@ -491,6 +497,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] fungibleItemAndCounts .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count))); previousStates = previousStates.MintAsset( + new ActionContext { Signer = AgentAddr }, AgentAddr, garageCost); return ( diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index cac8907875..1e7467fc92 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -232,11 +232,14 @@ public void Execute_Throws_Exception() { // Agent's FungibleAssetValue garages does not have enough balance. var previousStatesWithEmptyBalances = _previousStates; + var actionContext = new ActionContext { Signer = AgentAddr }; var garageBalanceAddress = Addresses.GetGarageBalanceAddress(AgentAddr); foreach (var (_, value) in _fungibleAssetValues) { - previousStatesWithEmptyBalances = previousStatesWithEmptyBalances - .BurnAsset(garageBalanceAddress, value); + previousStatesWithEmptyBalances = previousStatesWithEmptyBalances.BurnAsset( + actionContext, + garageBalanceAddress, + value); } Assert.Throws(() => Execute( @@ -409,6 +412,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] GetSuccessfulPreviousStatesWithPlainValue() { var previousStates = _initialStatesWithAvatarStateV2; + var actionContext = new ActionContext { Signer = Addresses.Admin }; var garageBalanceAddress = Addresses.GetGarageBalanceAddress(AgentAddr); var fungibleAssetValues = GetFungibleAssetValues( AgentAddr, @@ -418,6 +422,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] if (value.Currency.Equals(_ncg)) { previousStates = previousStates.TransferAsset( + actionContext, Addresses.Admin, garageBalanceAddress, value); @@ -425,6 +430,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] } previousStates = previousStates.MintAsset( + actionContext, garageBalanceAddress, value); } diff --git a/Lib9c/Action/Garages/DeliverToOthersGarages.cs b/Lib9c/Action/Garages/DeliverToOthersGarages.cs index e8993eeb97..3141d4330c 100644 --- a/Lib9c/Action/Garages/DeliverToOthersGarages.cs +++ b/Lib9c/Action/Garages/DeliverToOthersGarages.cs @@ -171,12 +171,8 @@ public override IAccountStateDelta Execute(IActionContext context) var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(addressesHex); - states = SendBalances( - context.Signer, - states); - return SendFungibleItems( - context.Signer, - states); + states = SendBalances(context, states); + return SendFungibleItems(context.Signer, states); } private void ValidateFields(string addressesHex) @@ -218,7 +214,7 @@ private void ValidateFields(string addressesHex) } private IAccountStateDelta SendBalances( - Address signer, + IActionContext context, IAccountStateDelta states) { if (FungibleAssetValues is null) @@ -227,12 +223,13 @@ private IAccountStateDelta SendBalances( } var senderGarageBalanceAddress = - Addresses.GetGarageBalanceAddress(signer); + Addresses.GetGarageBalanceAddress(context.Signer); var recipientGarageBalanceAddr = Addresses.GetGarageBalanceAddress(RecipientAgentAddr); foreach (var fav in FungibleAssetValues) { states = states.TransferAsset( + context, senderGarageBalanceAddress, recipientGarageBalanceAddr, fav); diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs index ba34971878..8881096cc1 100644 --- a/Lib9c/Action/Garages/LoadIntoMyGarages.cs +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -132,26 +132,20 @@ public override IAccountStateDelta Execute(IActionContext context) } var addressesHex = GetSignerAndOtherAddressesHex(context); - ValidateFields( - context.Signer, - addressesHex); + ValidateFields(context.Signer, addressesHex); var sheet = states.GetSheet(); var garageCost = sheet.GetGarageCost( FungibleAssetValues?.Select(tuple => tuple.value), FungibleIdAndCounts); states = states.TransferAsset( + context, context.Signer, Addresses.GarageWallet, garageCost); - states = TransferFungibleAssetValues( - context.Signer, - states); - return TransferFungibleItems( - context.Signer, - context.BlockIndex, - states); + states = TransferFungibleAssetValues(context, states); + return TransferFungibleItems(context.Signer, context.BlockIndex, states); } private void ValidateFields( @@ -221,7 +215,7 @@ private void ValidateFields( } private IAccountStateDelta TransferFungibleAssetValues( - Address signer, + IActionContext context, IAccountStateDelta states) { if (FungibleAssetValues is null) @@ -230,10 +224,10 @@ private IAccountStateDelta TransferFungibleAssetValues( } var garageBalanceAddress = - Addresses.GetGarageBalanceAddress(signer); + Addresses.GetGarageBalanceAddress(context.Signer); foreach (var (balanceAddr, value) in FungibleAssetValues) { - states = states.TransferAsset(balanceAddr, garageBalanceAddress, value); + states = states.TransferAsset(context, balanceAddr, garageBalanceAddress, value); } return states; diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index 21e867059f..991a1f82d8 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -128,7 +128,7 @@ public override IAccountStateDelta Execute(IActionContext context) var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(addressesHex); - states = TransferFungibleAssetValues(context.Signer, states); + states = TransferFungibleAssetValues(context, states); states = TransferFungibleItems(context.Signer, states); return SendMail(context.BlockIndex, context.Random, states); } @@ -172,7 +172,7 @@ private void ValidateFields(string addressesHex) } private IAccountStateDelta TransferFungibleAssetValues( - Address signer, + IActionContext context, IAccountStateDelta states) { if (FungibleAssetValues is null) @@ -180,11 +180,10 @@ private IAccountStateDelta TransferFungibleAssetValues( return states; } - var garageBalanceAddress = - Addresses.GetGarageBalanceAddress(signer); + var garageBalanceAddress = Addresses.GetGarageBalanceAddress(context.Signer); foreach (var (balanceAddr, value) in FungibleAssetValues) { - states = states.TransferAsset(garageBalanceAddress, balanceAddr, value); + states = states.TransferAsset(context, garageBalanceAddress, balanceAddr, value); } return states; From 575abbd9ca0ec3b70fdf04ec6f7e211af824b57f Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 30 Jun 2023 14:12:01 +0900 Subject: [PATCH 27/68] Fix compile error --- Lib9c/Action/CreateAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 5451012571..35685583d2 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -167,7 +167,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Add Runes when executing on editor mode. #if LIB9C_DEV_EXTENSIONS || UNITY_EDITOR - states = CreateAvatar0.AddRunesForTest(avatarAddress, states); + states = CreateAvatar0.AddRunesForTest(ctx, avatarAddress, states); // Add pets for test if (states.TryGetSheet(out PetSheet petSheet)) From 2395fe4e5401b25c769580a25efe4790ba44d3a8 Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 30 Jun 2023 14:30:23 +0900 Subject: [PATCH 28/68] Add CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..813905d598 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +.Libplanet @boscohyun @sonohoshi @tyrosine1153 From 2f49a090c16da14943a3b74d8df012497ca3ba51 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Wed, 28 Jun 2023 17:11:49 +0900 Subject: [PATCH 29/68] Bump libplanet to 2.3.0-candidate --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index c59018e3f7..b1df89924b 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit c59018e3f7b058437f3ded9b3e3cc54e59ec2c53 +Subproject commit b1df89924b29ec1c9b2e1ec0a90e8116da645a03 From e9b71397c49722d99478760c95c9ef2f15d85333 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Wed, 28 Jun 2023 17:49:10 +0900 Subject: [PATCH 30/68] Accommodate libplanet 2.3.0 API changes --- .Lib9c.Benchmarks/Program.cs | 6 +- .Lib9c.Tests/Action/RawState.cs | 160 ----------------- .../Snapshot/TransferAsset0SnapshotTest.cs | 18 +- ...ransfer_asset.TransferCrystal.verified.txt | 75 ++++++-- ...ansfer_asset.TransferWithMemo.verified.txt | 75 ++++++-- .Lib9c.Tests/Action/State.cs | 162 +++++++++++++----- .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 +- .Lib9c.Tools/SubCommand/State.cs | 7 +- Lib9c.MessagePack/AccountStateDelta.cs | 34 ++-- .../Formatters/AccountStateDeltaFormatter.cs | 23 +-- ...xtensions.cs => AccountStateExtensions.cs} | 104 +++++------ Lib9c/Action/ActionBaseExtensions.cs | 75 +++++--- Lib9c/Action/RewardGold.cs | 4 +- 18 files changed, 409 insertions(+), 358 deletions(-) delete mode 100644 .Lib9c.Tests/Action/RawState.cs rename Lib9c/Action/{AccountStateViewExtensions.cs => AccountStateExtensions.cs} (95%) diff --git a/.Lib9c.Benchmarks/Program.cs b/.Lib9c.Benchmarks/Program.cs index 5c5556ccfc..fb1b5e7ce1 100644 --- a/.Lib9c.Benchmarks/Program.cs +++ b/.Lib9c.Benchmarks/Program.cs @@ -166,8 +166,7 @@ bool buildStateReferences .SelectMany(a => a.OutputStates.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.UpdatedFungibleAssets - .SelectMany(kv => kv.Value.Select(c => (kv.Key, c)))) + .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); if (!stateStore.ContainsStateRoot(block.StateRootHash)) @@ -188,8 +187,7 @@ private static ImmutableDictionary GetTotalDelta( .SelectMany(a => a.OutputStates.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.UpdatedFungibleAssets - .SelectMany(kv => kv.Value.Select(c => (kv.Key, c)))) + .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); IAccountStateDelta lastStates = actionEvaluations.Count > 0 diff --git a/.Lib9c.Tests/Action/RawState.cs b/.Lib9c.Tests/Action/RawState.cs deleted file mode 100644 index 15c6ae490f..0000000000 --- a/.Lib9c.Tests/Action/RawState.cs +++ /dev/null @@ -1,160 +0,0 @@ -namespace Lib9c.Tests.Action -{ - using System; - using System.Collections.Generic; - using System.Collections.Immutable; - using System.Linq; - using Bencodex.Types; - using Libplanet; - using Libplanet.Action; - using Libplanet.Assets; - using Libplanet.Consensus; - using Libplanet.State; - - /// - /// An implementation of for test. It handles states as raw like Libplanet does. - /// - public class RawState : IAccountStateDelta - { - private readonly IImmutableDictionary _rawStates; - - public RawState(IImmutableDictionary rawStates = null) - { - _rawStates = rawStates ?? ImmutableDictionary.Empty; - } - - public IImmutableSet
UpdatedAddresses => - StateUpdatedAddresses.Union(UpdatedFungibleAssets.Keys).ToImmutableHashSet(); - - public IImmutableSet
StateUpdatedAddresses => - _rawStates.Keys.Where(key => key.Length == Address.Size).Select(key => new Address(key)).ToImmutableHashSet(); - - public IImmutableDictionary> UpdatedFungibleAssets => - throw new NotSupportedException($"Currently, {nameof(UpdatedFungibleAssets)} is not supported in this implementation."); - - public IImmutableDictionary> TotalUpdatedFungibleAssets - { - get; - } - - public IImmutableSet TotalSupplyUpdatedCurrencies => - throw new NotSupportedException($"Currently, {nameof(TotalSupplyUpdatedCurrencies)} is not supported in this implementation."); - - public IValue GetState(Address address) - { - return _rawStates.TryGetValue(ToStateKey(address), out IValue value) ? value : null; - } - - public IReadOnlyList GetStates(IReadOnlyList
addresses) => - addresses.Select(GetState).ToArray(); - - public IAccountStateDelta SetState(Address address, IValue state) - { - return new RawState(_rawStates.SetItem(ToStateKey(address), state)); - } - - public FungibleAssetValue GetBalance(Address address, Currency currency) => - _rawStates.TryGetValue(ToBalanceKey(address, currency), out IValue value) - ? FungibleAssetValue.FromRawValue(currency, value is Bencodex.Types.Integer i ? i.Value : 0) - : currency * 0; - - public FungibleAssetValue GetTotalSupply(Currency currency) - { - if (!currency.TotalSupplyTrackable) - { - var msg = - $"The total supply value of the currency {currency} is not trackable" - + " because it is a legacy untracked currency which might have been" - + " established before the introduction of total supply tracking support."; - throw new TotalSupplyNotTrackableException(msg, currency); - } - - // Return dirty state if it exists. - if (_rawStates.TryGetValue(ToTotalSupplyKey(currency), out var value)) - { - return FungibleAssetValue.FromRawValue(currency, value is Bencodex.Types.Integer i ? i.Value : 0); - } - - return currency * 0; - } - - public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) - { - var currency = value.Currency; - var rawStates = _rawStates.SetItem( - ToBalanceKey(recipient, currency), - (Bencodex.Types.Integer)(GetBalance(recipient, currency) + value).RawValue); - if (value.Currency.TotalSupplyTrackable) - { - rawStates = rawStates.SetItem( - ToTotalSupplyKey(currency), - (Bencodex.Types.Integer)(GetTotalSupply(currency) + value).RawValue); - } - - return new RawState(rawStates); - } - - public IAccountStateDelta TransferAsset( - IActionContext context, - Address sender, - Address recipient, - FungibleAssetValue value, - bool allowNegativeBalance = false) - { - // Copy from Libplanet (AccountStateDeltaImpl.cs@66104588af35afbd18a41bb7857eacd9da190019) - if (value.Sign <= 0) - { - throw new ArgumentOutOfRangeException( - nameof(value), - "The value to transfer has to be greater than zero." - ); - } - - Currency currency = value.Currency; - FungibleAssetValue senderBalance = GetBalance(sender, currency); - FungibleAssetValue recipientBalance = GetBalance(recipient, currency); - - if (!allowNegativeBalance && senderBalance < value) - { - var msg = $"The account {sender}'s balance of {currency} is insufficient to " + - $"transfer: {senderBalance} < {value}."; - throw new InsufficientBalanceException(msg, sender, senderBalance); - } - - IImmutableDictionary newRawStates = _rawStates - .SetItem(ToBalanceKey(sender, currency), (Bencodex.Types.Integer)(senderBalance - value).RawValue) - .SetItem(ToBalanceKey(recipient, currency), (Bencodex.Types.Integer)(recipientBalance + value).RawValue); - return new RawState(newRawStates); - } - - public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) - { - var currency = value.Currency; - var rawStates = _rawStates.SetItem( - ToBalanceKey(owner, currency), - (Bencodex.Types.Integer)(GetBalance(owner, currency) - value).RawValue); - if (value.Currency.TotalSupplyTrackable) - { - rawStates = rawStates.SetItem( - ToTotalSupplyKey(currency), - (Bencodex.Types.Integer)(GetTotalSupply(currency) - value).RawValue); - } - - return new RawState(rawStates); - } - - public IAccountStateDelta SetValidator(Validator validator) - { - return new RawState(_rawStates); - } - - public virtual ValidatorSet GetValidatorSet() => new ValidatorSet(); - - private string ToStateKey(Address address) => address.ToHex().ToLowerInvariant(); - - private string ToBalanceKey(Address address, Currency currency) => "_" + address.ToHex().ToLowerInvariant() + - "_" + ByteUtil.Hex(currency.Hash.ByteArray); - - private string ToTotalSupplyKey(Currency currency) => "__" + ByteUtil.Hex(currency.Hash.ByteArray); - } -} diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index 97ed7a2978..b7d918a98b 100644 --- a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs +++ b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs @@ -5,6 +5,7 @@ namespace Lib9c.Tests.Action.Snapshot using Libplanet; using Libplanet.Assets; using Libplanet.Crypto; + using Libplanet.State; using Nekoyume.Action; using Nekoyume.Helper; using VerifyXunit; @@ -37,9 +38,17 @@ public Task TransferCrystal() "f8960846e9ae4ad1c23686f74c8e5f80f22336b6f2175be21db82afa8823c92d")); var senderAddress = senderPrivateKey.ToAddress(); var recipientAddress = recipientPrivateKey.ToAddress(); + + Assert.Equal("C61C376693E6B26717C9ee9aCA5A2453028f6ffA", senderAddress.ToHex()); + Assert.Equal("99A06c2Bd71f0EAa8196fE45BE5ca424eE809733", recipientAddress.ToHex()); + var crystal = CrystalCalculator.CRYSTAL; var context = new ActionContext(); - var state = new State().MintAsset(context, senderAddress, crystal * 100); + IAccountStateDelta state = new State().MintAsset(context, senderAddress, crystal * 100); + + Assert.Equal((crystal * 100).RawValue, state.GetBalance(senderAddress, crystal).RawValue); + Assert.Equal(0, state.GetBalance(recipientAddress, crystal).RawValue); + var actionContext = new ActionContext { Signer = senderAddress, @@ -49,9 +58,12 @@ public Task TransferCrystal() senderAddress, recipientAddress, crystal * 100); - var states = action.Execute(actionContext); + var outputState = action.Execute(actionContext); - return Verifier.Verify(states) + Assert.Equal((crystal * 100).RawValue, outputState.GetBalance(recipientAddress, crystal).RawValue); + Assert.Equal(0, outputState.GetBalance(senderAddress, crystal).RawValue); + + return Verifier.Verify(outputState) .UseTypeName((Text)GetActionTypeId()); } diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt index 7a14f0641b..6946b8890e 100644 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt @@ -1,42 +1,83 @@ { + Delta: { + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + FungibleUpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + UpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { + Ticker: CRYSTAL, + DecimalPlaces: 18, + Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, + TotalSupplyTrackable: false + } + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { + Ticker: CRYSTAL, + DecimalPlaces: 18, + Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, + TotalSupplyTrackable: false + } + } + ], + Fungibles: { + (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0, + (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000 + }, + ValidatorSet: { + Bencoded: [] + } + }, UpdatedAddresses: [ 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, C61C376693E6B26717C9ee9aCA5A2453028f6ffA ], - UpdatedFungibleAssets: { - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733: [ - { + UpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ], - C61C376693E6B26717C9ee9aCA5A2453028f6ffA: [ - { + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ] - }, - TotalUpdatedFungibleAssets: { - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733: [ - { + } + ], + TotalUpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ], - C61C376693E6B26717C9ee9aCA5A2453028f6ffA: [ - { + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ] - } -} + } + ] +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt index 7a14f0641b..6946b8890e 100644 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt @@ -1,42 +1,83 @@ { + Delta: { + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + FungibleUpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + UpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { + Ticker: CRYSTAL, + DecimalPlaces: 18, + Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, + TotalSupplyTrackable: false + } + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { + Ticker: CRYSTAL, + DecimalPlaces: 18, + Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, + TotalSupplyTrackable: false + } + } + ], + Fungibles: { + (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0, + (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000 + }, + ValidatorSet: { + Bencoded: [] + } + }, UpdatedAddresses: [ 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, C61C376693E6B26717C9ee9aCA5A2453028f6ffA ], - UpdatedFungibleAssets: { - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733: [ - { + UpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ], - C61C376693E6B26717C9ee9aCA5A2453028f6ffA: [ - { + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ] - }, - TotalUpdatedFungibleAssets: { - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733: [ - { + } + ], + TotalUpdatedFungibleAssets: [ + { + Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ], - C61C376693E6B26717C9ee9aCA5A2453028f6ffA: [ - { + }, + { + Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + Item2: { Ticker: CRYSTAL, DecimalPlaces: 18, Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, TotalSupplyTrackable: false } - ] - } -} + } + ] +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/State.cs b/.Lib9c.Tests/Action/State.cs index b090bdede1..56d4b8b75d 100644 --- a/.Lib9c.Tests/Action/State.cs +++ b/.Lib9c.Tests/Action/State.cs @@ -4,6 +4,7 @@ namespace Lib9c.Tests.Action using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; + using System.Numerics; using Bencodex.Types; using Libplanet; using Libplanet.Action; @@ -11,13 +12,17 @@ namespace Lib9c.Tests.Action using Libplanet.Consensus; using Libplanet.State; - public class State : IAccountStateDelta, IValidatorSupportStateDelta + public class State : IAccountStateDelta { private readonly IImmutableDictionary _state; - private readonly IImmutableDictionary<(Address, Currency), FungibleAssetValue> _balance; - private readonly IImmutableDictionary _totalSupplies; + private readonly IImmutableDictionary<(Address, Currency), BigInteger> _balance; + private readonly IImmutableDictionary _totalSupplies; private readonly ValidatorSet _validatorSet; + private readonly IAccountDelta _delta; + // Pretends all given arguments are part of the delta, i.e., have been modified + // using appropriate methods such as Transfer/Mint/Burn to set the values. + // Also convert to internal data types. public State( IImmutableDictionary state = null, IImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue> balance = null, @@ -25,42 +30,63 @@ public State( ValidatorSet validatorSet = null) { _state = state ?? ImmutableDictionary.Empty; - _balance = balance ?? ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty; - _totalSupplies = - totalSupplies ?? ImmutableDictionary.Empty; + _balance = balance is { } b + ? b.ToImmutableDictionary(kv => kv.Key, kv => kv.Value.RawValue) + : ImmutableDictionary<(Address, Currency), BigInteger>.Empty; + _totalSupplies = totalSupplies is { } t + ? t.ToImmutableDictionary(kv => kv.Key, kv => kv.Value.RawValue) + : ImmutableDictionary.Empty; _validatorSet = validatorSet ?? new ValidatorSet(); + + _delta = new Delta(_state, _balance, _totalSupplies, _validatorSet); } - public IImmutableSet
UpdatedAddresses => - StateUpdatedAddresses.Union(_balance.Keys.Select(pair => pair.Item1)); + // For Transfer/Mint/Burn + private State( + IImmutableDictionary state, + IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, + IImmutableDictionary totalSupplies, + ValidatorSet validatorSet) + { + _state = state; + _balance = balance; + _totalSupplies = totalSupplies; + _validatorSet = validatorSet; - public IImmutableSet
StateUpdatedAddresses => - _state.Keys.ToImmutableHashSet(); + _delta = new Delta(_state, _balance, _totalSupplies, _validatorSet); + } - public IImmutableDictionary> UpdatedFungibleAssets => - _balance.GroupBy(kv => kv.Key.Item1).ToImmutableDictionary( - g => g.Key, - g => (IImmutableSet)g.Select(kv => kv.Key.Item2).ToImmutableHashSet() - ); + public IAccountDelta Delta => _delta; - public IImmutableDictionary> TotalUpdatedFungibleAssets => - UpdatedFungibleAssets; + public IImmutableSet
UpdatedAddresses => _delta.UpdatedAddresses; - public IImmutableSet TotalSupplyUpdatedCurrencies => - _totalSupplies.Keys.ToImmutableHashSet(); + public IImmutableSet
StateUpdatedAddresses => _delta.StateUpdatedAddresses; - public IValue GetState(Address address) => - _state.TryGetValue(address, out IValue value) ? value : null; + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => _delta.UpdatedFungibleAssets; + + public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => _delta.UpdatedFungibleAssets; + + public IImmutableSet UpdatedTotalSupplyCurrencies => _delta.UpdatedTotalSupplyCurrencies; + + public IValue GetState(Address address) => _delta.States.TryGetValue(address, out IValue value) + ? value + : null; public IReadOnlyList GetStates(IReadOnlyList
addresses) => addresses.Select(GetState).ToArray(); public IAccountStateDelta SetState(Address address, IValue state) => - new State(_state.SetItem(address, state), _balance); + new State( + _state.SetItem(address, state), + _balance, + _totalSupplies, + _validatorSet); public FungibleAssetValue GetBalance(Address address, Currency currency) => - _balance.TryGetValue((address, currency), out FungibleAssetValue balance) ? balance : currency * 0; + _delta.Fungibles.TryGetValue((address, currency), out BigInteger rawValue) + ? FungibleAssetValue.FromRawValue(currency, rawValue) + : FungibleAssetValue.FromRawValue(currency, 0); public FungibleAssetValue GetTotalSupply(Currency currency) { @@ -74,12 +100,9 @@ public FungibleAssetValue GetTotalSupply(Currency currency) } // Return dirty state if it exists. - if (_totalSupplies.TryGetValue(currency, out var totalSupplyValue)) - { - return totalSupplyValue; - } - - return currency * 0; + return _delta.TotalSupplies.TryGetValue(currency, out var rawValue) + ? FungibleAssetValue.FromRawValue(currency, rawValue) + : FungibleAssetValue.FromRawValue(currency, 0); } public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) @@ -88,14 +111,15 @@ public IAccountStateDelta MintAsset(IActionContext context, Address recipient, F value.Currency.TotalSupplyTrackable ? _totalSupplies.SetItem( value.Currency, - GetTotalSupply(value.Currency) + value) + (GetTotalSupply(value.Currency) + value).RawValue) : _totalSupplies; return new State( _state, _balance.SetItem( (recipient, value.Currency), - GetBalance(recipient, value.Currency) + value), - totalSupplies + (GetBalance(recipient, value.Currency) + value).RawValue), + totalSupplies, + _validatorSet ); } @@ -105,14 +129,15 @@ public IAccountStateDelta BurnAsset(IActionContext context, Address owner, Fungi value.Currency.TotalSupplyTrackable ? _totalSupplies.SetItem( value.Currency, - GetTotalSupply(value.Currency) - value) + (GetTotalSupply(value.Currency) - value).RawValue) : _totalSupplies; return new State( _state, _balance.SetItem( (owner, value.Currency), - GetBalance(owner, value.Currency) - value), - totalSupplies); + (GetBalance(owner, value.Currency) - value).RawValue), + totalSupplies, + _validatorSet); } public IAccountStateDelta TransferAsset( @@ -143,19 +168,72 @@ public IAccountStateDelta TransferAsset( throw new InsufficientBalanceException(msg, sender, senderBalance); } - IImmutableDictionary<(Address, Currency), FungibleAssetValue> newBalance = _balance - .SetItem((sender, currency), senderBalance - value) - .SetItem((recipient, currency), recipientBalance + value); - return new State(_state, newBalance); + IImmutableDictionary<(Address, Currency), BigInteger> newBalance = _balance + .SetItem((sender, currency), (senderBalance - value).RawValue) + .SetItem((recipient, currency), (recipientBalance + value).RawValue); + return new State(_state, newBalance, _totalSupplies, _validatorSet); } public IAccountStateDelta SetValidator(Validator validator) { - return new State( - _state, - validatorSet: GetValidatorSet().Update(validator)); + return new State(_state, _balance, _totalSupplies, GetValidatorSet().Update(validator)); } public ValidatorSet GetValidatorSet() => _validatorSet; } + +#pragma warning disable SA1402 + public class Delta : IAccountDelta + { + private readonly IImmutableDictionary _state; + private readonly IImmutableDictionary<(Address, Currency), BigInteger> _balance; + private readonly IImmutableDictionary _totalSupplies; + private readonly ValidatorSet _validatorSet; + + public Delta() + : this( + ImmutableDictionary.Empty, + ImmutableDictionary<(Address, Currency), BigInteger>.Empty, + ImmutableDictionary.Empty, + null) + { + } + + public Delta( + IImmutableDictionary state, + IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, + IImmutableDictionary totalSupplies, + ValidatorSet validatorSet) + { + _state = state; + _balance = balance; + _totalSupplies = totalSupplies; + _validatorSet = validatorSet; + } + + public IImmutableSet
UpdatedAddresses => + StateUpdatedAddresses.Union(FungibleUpdatedAddresses); + + public IImmutableSet
StateUpdatedAddresses => _state.Keys.ToImmutableHashSet(); + + public IImmutableDictionary States => _state; + + public IImmutableSet
FungibleUpdatedAddresses => + UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet(); + + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => + Fungibles.Keys.ToImmutableHashSet(); + + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => + _balance; + + public IImmutableSet UpdatedTotalSupplyCurrencies => + TotalSupplies.Keys.ToImmutableHashSet(); + + public IImmutableDictionary TotalSupplies => + _totalSupplies; + + public ValidatorSet ValidatorSet => _validatorSet; + } +#pragma warning restore SA1402 } diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index ac2884ea4f..32ed2c9d29 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -295,11 +295,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index 0a6b3fbfca..5d99bef872 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -311,11 +311,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index fb40f51d3d..7c03536b61 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -233,11 +233,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency, Currencies.Mead, }.ToImmutableHashSet(), - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 34ba5532ef..97330ea834 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -257,11 +257,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index 7f273d02b6..bb3b4a35ac 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -351,11 +351,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 1d45534b04..74c60adaad 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -258,11 +258,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Keys + nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Values.SelectMany(v => v).ToImmutableHashSet()); + nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tools/SubCommand/State.cs b/.Lib9c.Tools/SubCommand/State.cs index 28ae45fc6c..65bce40b15 100644 --- a/.Lib9c.Tools/SubCommand/State.cs +++ b/.Lib9c.Tools/SubCommand/State.cs @@ -441,14 +441,13 @@ private static ImmutableDictionary GetTotalDelta( string validatorSetKey) { IImmutableSet
stateUpdatedAddresses = actionEvaluations - .SelectMany(a => a.OutputStates.StateUpdatedAddresses) + .SelectMany(a => a.OutputStates.Delta.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.UpdatedFungibleAssets - .SelectMany(kv => kv.Value.Select(c => (kv.Key, c)))) + .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); IImmutableSet updatedTotalSupplies = actionEvaluations - .SelectMany(a => a.OutputStates.TotalSupplyUpdatedCurrencies) + .SelectMany(a => a.OutputStates.Delta.UpdatedTotalSupplyCurrencies) .ToImmutableHashSet(); IAccountStateDelta lastStates = actionEvaluations.Count > 0 diff --git a/Lib9c.MessagePack/AccountStateDelta.cs b/Lib9c.MessagePack/AccountStateDelta.cs index 93875f420d..4377506037 100644 --- a/Lib9c.MessagePack/AccountStateDelta.cs +++ b/Lib9c.MessagePack/AccountStateDelta.cs @@ -23,18 +23,13 @@ public struct AccountStateDelta : IAccountStateDelta public IImmutableSet
StateUpdatedAddresses => _states.Keys.ToImmutableHashSet(); -#pragma warning disable LAA1002 - public IImmutableDictionary> UpdatedFungibleAssets => - _balances.GroupBy(kv => kv.Key.Item1).ToImmutableDictionary( - g => g.Key, - g => (IImmutableSet)g.Select(kv => kv.Key.Item2).ToImmutableHashSet() - ); + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => + _balances.Keys.ToImmutableHashSet(); - public IImmutableDictionary> TotalUpdatedFungibleAssets => - new Dictionary>().ToImmutableDictionary(); -#pragma warning restore LAA1002 + public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => + ImmutableHashSet<(Address, Currency)>.Empty; - public IImmutableSet TotalSupplyUpdatedCurrencies => + public IImmutableSet UpdatedTotalSupplyCurrencies => _totalSupplies.Keys.ToImmutableHashSet(); public AccountStateDelta( @@ -82,6 +77,8 @@ public AccountStateDelta(byte[] bytes) { } + public IAccountDelta Delta => new MockAccountDelta(); + public IValue? GetState(Address address) => _states.ContainsKey(address) ? _states[address] @@ -245,5 +242,22 @@ public ValidatorSet GetValidatorSet() { return new ValidatorSet(); } + + private class MockAccountDelta : IAccountDelta + { + public MockAccountDelta() + { + } + + public IImmutableSet
UpdatedAddresses => ImmutableHashSet
.Empty; + public IImmutableSet
StateUpdatedAddresses => ImmutableHashSet
.Empty; + public IImmutableDictionary States => ImmutableDictionary.Empty; + public IImmutableSet
FungibleUpdatedAddresses => ImmutableHashSet
.Empty; + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => ImmutableHashSet<(Address, Currency)>.Empty; + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => ImmutableDictionary<(Address, Currency), BigInteger>.Empty; + public IImmutableSet UpdatedTotalSupplyCurrencies => ImmutableHashSet.Empty; + public IImmutableDictionary TotalSupplies => ImmutableDictionary.Empty; + public ValidatorSet? ValidatorSet => null; + } } } diff --git a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs index cce10fe836..b38133dca7 100644 --- a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs +++ b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs @@ -4,8 +4,6 @@ using System.Linq; using Bencodex; using Bencodex.Types; -using Libplanet.Action; -using Libplanet.Assets; using Libplanet.State; using MessagePack; using MessagePack.Formatters; @@ -25,23 +23,18 @@ public void Serialize(ref MessagePackWriter writer, IAccountStateDelta value, ); var balance = new Bencodex.Types.List( #pragma warning disable LAA1002 - value.UpdatedFungibleAssets.SelectMany(ua => + value.UpdatedFungibleAssets.Select(pair => #pragma warning restore LAA1002 - ua.Value.Select(c => - { - FungibleAssetValue b = value.GetBalance(ua.Key, c); - return new Bencodex.Types.Dictionary(new[] - { - new KeyValuePair((Text) "address", (Binary) ua.Key.ByteArray), - new KeyValuePair((Text) "currency", c.Serialize()), - new KeyValuePair((Text) "amount", (Integer) b.RawValue), - }); - } - ) + new Bencodex.Types.Dictionary(new[] + { + new KeyValuePair((Text) "address", (Binary) pair.Item1.ByteArray), + new KeyValuePair((Text) "currency", pair.Item2.Serialize()), + new KeyValuePair((Text) "amount", (Integer) value.GetBalance(pair.Item1, pair.Item2).RawValue), + }) ).Cast() ); var totalSupply = new Dictionary( - value.TotalSupplyUpdatedCurrencies.Select(currency => + value.UpdatedTotalSupplyCurrencies.Select(currency => new KeyValuePair( (Binary)new Codec().Encode(currency.Serialize()), (Integer)value.GetTotalSupply(currency).RawValue))); diff --git a/Lib9c/Action/AccountStateViewExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs similarity index 95% rename from Lib9c/Action/AccountStateViewExtensions.cs rename to Lib9c/Action/AccountStateExtensions.cs index ccd1e386f8..59a7288324 100644 --- a/Lib9c/Action/AccountStateViewExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -21,12 +21,12 @@ namespace Nekoyume.Action { - public static class AccountStateViewExtensions + public static class AccountStateExtensions { private const int SheetsCacheSize = 100; private static readonly LruCache SheetsCache = new LruCache(SheetsCacheSize); - public static bool TryGetState(this IAccountStateView states, Address address, out T result) + public static bool TryGetState(this IAccountState states, Address address, out T result) where T : IValue { IValue raw = states.GetState(address); @@ -47,7 +47,7 @@ public static bool TryGetState(this IAccountStateView states, Address address return false; } - public static Dictionary GetStatesAsDict(this IAccountStateView states, params Address[] addresses) + public static Dictionary GetStatesAsDict(this IAccountState states, params Address[] addresses) { var result = new Dictionary(); var values = states.GetStates(addresses); @@ -61,7 +61,7 @@ public static Dictionary GetStatesAsDict(this IAccountStateView return result; } - public static AgentState GetAgentState(this IAccountStateView states, Address address) + public static AgentState GetAgentState(this IAccountState states, Address address) { var serializedAgent = states.GetState(address); if (serializedAgent is null) @@ -88,7 +88,7 @@ public static AgentState GetAgentState(this IAccountStateView states, Address ad } public static bool TryGetGoldBalance( - this IAccountStateView states, + this IAccountState states, Address address, Currency currency, out FungibleAssetValue balance) @@ -106,12 +106,12 @@ public static bool TryGetGoldBalance( } public static GoldBalanceState GetGoldBalanceState( - this IAccountStateView states, + this IAccountState states, Address address, Currency currency ) => new GoldBalanceState(address, states.GetBalance(address, currency)); - public static Currency GetGoldCurrency(this IAccountStateView states) + public static Currency GetGoldCurrency(this IAccountState states) { if (states.TryGetState(GoldCurrencyState.Address, out Dictionary asDict)) { @@ -124,7 +124,7 @@ public static Currency GetGoldCurrency(this IAccountStateView states) ); } - public static AvatarState GetAvatarState(this IAccountStateView states, Address address) + public static AvatarState GetAvatarState(this IAccountState states, Address address) { var serializedAvatar = states.GetState(address); if (serializedAvatar is null) @@ -150,7 +150,7 @@ public static AvatarState GetAvatarState(this IAccountStateView states, Address } } - public static AvatarState GetAvatarStateV2(this IAccountStateView states, Address address) + public static AvatarState GetAvatarStateV2(this IAccountState states, Address address) { var addresses = new List
{ @@ -200,7 +200,7 @@ public static AvatarState GetAvatarStateV2(this IAccountStateView states, Addres } public static bool TryGetAvatarState( - this IAccountStateView states, + this IAccountState states, Address agentAddress, Address avatarAddress, out AvatarState avatarState @@ -235,7 +235,7 @@ out AvatarState avatarState } public static bool TryGetAvatarStateV2( - this IAccountStateView states, + this IAccountState states, Address agentAddress, Address avatarAddress, out AvatarState avatarState, @@ -273,7 +273,7 @@ out bool migrationRequired } public static bool TryGetAgentAvatarStates( - this IAccountStateView states, + this IAccountState states, Address agentAddress, Address avatarAddress, out AgentState agentState, @@ -298,7 +298,7 @@ out AvatarState avatarState } public static bool TryGetAgentAvatarStatesV2( - this IAccountStateView states, + this IAccountState states, Address agentAddress, Address avatarAddress, out AgentState agentState, @@ -334,7 +334,7 @@ out bool avatarMigrationRequired return !(avatarState is null); } - public static WeeklyArenaState GetWeeklyArenaState(this IAccountStateView states, Address address) + public static WeeklyArenaState GetWeeklyArenaState(this IAccountState states, Address address) { var iValue = states.GetState(address); if (iValue is null) @@ -360,14 +360,14 @@ public static WeeklyArenaState GetWeeklyArenaState(this IAccountStateView states } } - public static WeeklyArenaState GetWeeklyArenaState(this IAccountStateView states, int index) + public static WeeklyArenaState GetWeeklyArenaState(this IAccountState states, int index) { var address = WeeklyArenaState.DeriveAddress(index); return GetWeeklyArenaState(states, address); } public static CombinationSlotState GetCombinationSlotState( - this IAccountStateView states, + this IAccountState states, Address avatarAddress, int index) { @@ -396,7 +396,7 @@ public static CombinationSlotState GetCombinationSlotState( } } - public static GameConfigState GetGameConfigState(this IAccountStateView states) + public static GameConfigState GetGameConfigState(this IAccountState states) { var value = states.GetState(GameConfigState.Address); if (value is null) @@ -416,7 +416,7 @@ public static GameConfigState GetGameConfigState(this IAccountStateView states) } } - public static RedeemCodeState GetRedeemCodeState(this IAccountStateView states) + public static RedeemCodeState GetRedeemCodeState(this IAccountState states) { var value = states.GetState(RedeemCodeState.Address); if (value is null) @@ -437,7 +437,7 @@ public static RedeemCodeState GetRedeemCodeState(this IAccountStateView states) } #nullable enable - public static IImmutableDictionary GetCouponWallet(this IAccountStateView states, Address agentAddress) + public static IImmutableDictionary GetCouponWallet(this IAccountState states, Address agentAddress) { Address walletAddress = agentAddress.Derive(CouponWalletKey); IValue? serialized = states.GetState(walletAddress); @@ -454,7 +454,7 @@ public static IImmutableDictionary GetCouponWallet(this IAccountSt #nullable disable public static IEnumerable GetGoldDistribution( - this IAccountStateView states) + this IAccountState states) { var value = states.GetState(Addresses.GoldDistribution); if (value is null) @@ -475,7 +475,7 @@ public static IEnumerable GetGoldDistribution( } } - public static T GetSheet(this IAccountStateView states) where T : ISheet, new() + public static T GetSheet(this IAccountState states) where T : ISheet, new() { var address = Addresses.GetSheetAddress(); @@ -506,7 +506,7 @@ public static IEnumerable GetGoldDistribution( } } - public static bool TryGetSheet(this IAccountStateView states, out T sheet) where T : ISheet, new() + public static bool TryGetSheet(this IAccountState states, out T sheet) where T : ISheet, new() { try { @@ -521,7 +521,7 @@ public static IEnumerable GetGoldDistribution( } public static Dictionary GetSheets( - this IAccountStateView states, + this IAccountState states, bool containAvatarSheets = false, bool containItemSheet = false, bool containQuestSheet = false, @@ -661,7 +661,7 @@ public static IEnumerable GetGoldDistribution( } public static Dictionary GetSheets( - this IAccountStateView states, + this IAccountState states, params Type[] sheetTypes) { Dictionary result = sheetTypes.ToDictionary( @@ -711,7 +711,7 @@ public static IEnumerable GetGoldDistribution( return result; } - public static string GetSheetCsv(this IAccountStateView states) where T : ISheet, new() + public static string GetSheetCsv(this IAccountState states) where T : ISheet, new() { var address = Addresses.GetSheetAddress(); var value = states.GetState(address); @@ -732,7 +732,7 @@ public static IEnumerable GetGoldDistribution( } } - public static ItemSheet GetItemSheet(this IAccountStateView states) + public static ItemSheet GetItemSheet(this IAccountState states) { var sheet = new ItemSheet(); sheet.Set(GetSheet(states), false); @@ -742,7 +742,7 @@ public static ItemSheet GetItemSheet(this IAccountStateView states) return sheet; } - public static StageSimulatorSheetsV1 GetStageSimulatorSheetsV1(this IAccountStateView states) + public static StageSimulatorSheetsV1 GetStageSimulatorSheetsV1(this IAccountState states) { return new StageSimulatorSheetsV1( GetSheet(states), @@ -760,7 +760,7 @@ public static StageSimulatorSheetsV1 GetStageSimulatorSheetsV1(this IAccountStat ); } - public static StageSimulatorSheets GetStageSimulatorSheets(this IAccountStateView states) + public static StageSimulatorSheets GetStageSimulatorSheets(this IAccountState states) { return new StageSimulatorSheets( GetSheet(states), @@ -779,7 +779,7 @@ public static StageSimulatorSheets GetStageSimulatorSheets(this IAccountStateVie ); } - public static RankingSimulatorSheetsV1 GetRankingSimulatorSheetsV1(this IAccountStateView states) + public static RankingSimulatorSheetsV1 GetRankingSimulatorSheetsV1(this IAccountState states) { return new RankingSimulatorSheetsV1( GetSheet(states), @@ -795,7 +795,7 @@ public static RankingSimulatorSheetsV1 GetRankingSimulatorSheetsV1(this IAccount ); } - public static RankingSimulatorSheets GetRankingSimulatorSheets(this IAccountStateView states) + public static RankingSimulatorSheets GetRankingSimulatorSheets(this IAccountState states) { return new RankingSimulatorSheets( GetSheet(states), @@ -812,7 +812,7 @@ public static RankingSimulatorSheets GetRankingSimulatorSheets(this IAccountStat ); } - public static QuestSheet GetQuestSheet(this IAccountStateView states) + public static QuestSheet GetQuestSheet(this IAccountState states) { var questSheet = new QuestSheet(); questSheet.Set(GetSheet(states), false); @@ -829,7 +829,7 @@ public static QuestSheet GetQuestSheet(this IAccountStateView states) return questSheet; } - public static AvatarSheets GetAvatarSheets(this IAccountStateView states) + public static AvatarSheets GetAvatarSheets(this IAccountState states) { return new AvatarSheets( GetSheet(states), @@ -841,7 +841,7 @@ public static AvatarSheets GetAvatarSheets(this IAccountStateView states) ); } - public static RankingState GetRankingState(this IAccountStateView states) + public static RankingState GetRankingState(this IAccountState states) { var value = states.GetState(Addresses.Ranking); if (value is null) @@ -852,7 +852,7 @@ public static RankingState GetRankingState(this IAccountStateView states) return new RankingState((Dictionary)value); } - public static RankingState1 GetRankingState1(this IAccountStateView states) + public static RankingState1 GetRankingState1(this IAccountState states) { var value = states.GetState(Addresses.Ranking); if (value is null) @@ -863,7 +863,7 @@ public static RankingState1 GetRankingState1(this IAccountStateView states) return new RankingState1((Dictionary)value); } - public static RankingState0 GetRankingState0(this IAccountStateView states) + public static RankingState0 GetRankingState0(this IAccountState states) { var value = states.GetState(Addresses.Ranking); if (value is null) @@ -874,7 +874,7 @@ public static RankingState0 GetRankingState0(this IAccountStateView states) return new RankingState0((Dictionary)value); } - public static ShopState GetShopState(this IAccountStateView states) + public static ShopState GetShopState(this IAccountState states) { var value = states.GetState(Addresses.Shop); if (value is null) @@ -886,7 +886,7 @@ public static ShopState GetShopState(this IAccountStateView states) } public static (Address arenaInfoAddress, ArenaInfo arenaInfo, bool isNewArenaInfo) GetArenaInfo( - this IAccountStateView states, + this IAccountState states, Address weeklyArenaAddress, AvatarState avatarState, CharacterSheet characterSheet, @@ -909,7 +909,7 @@ public static (Address arenaInfoAddress, ArenaInfo arenaInfo, bool isNewArenaInf } public static bool TryGetStakeState( - this IAccountStateView states, + this IAccountState states, Address agentAddress, out StakeState stakeState) { @@ -923,7 +923,7 @@ public static bool TryGetStakeState( return false; } - public static ArenaParticipants GetArenaParticipants(this IAccountStateView states, + public static ArenaParticipants GetArenaParticipants(this IAccountState states, Address arenaParticipantsAddress, int id, int round) { return states.TryGetState(arenaParticipantsAddress, out List list) @@ -931,7 +931,7 @@ public static ArenaParticipants GetArenaParticipants(this IAccountStateView stat : new ArenaParticipants(id, round); } - public static ArenaAvatarState GetArenaAvatarState(this IAccountStateView states, + public static ArenaAvatarState GetArenaAvatarState(this IAccountState states, Address arenaAvatarStateAddress, AvatarState avatarState) { return states.TryGetState(arenaAvatarStateAddress, out List list) @@ -939,7 +939,7 @@ public static ArenaAvatarState GetArenaAvatarState(this IAccountStateView states : new ArenaAvatarState(avatarState); } - public static bool TryGetArenaParticipants(this IAccountStateView states, + public static bool TryGetArenaParticipants(this IAccountState states, Address arenaParticipantsAddress, out ArenaParticipants arenaParticipants) { if (states.TryGetState(arenaParticipantsAddress, out List list)) @@ -952,7 +952,7 @@ public static bool TryGetArenaParticipants(this IAccountStateView states, return false; } - public static bool TryGetArenaAvatarState(this IAccountStateView states, + public static bool TryGetArenaAvatarState(this IAccountState states, Address arenaAvatarStateAddress, out ArenaAvatarState arenaAvatarState) { if (states.TryGetState(arenaAvatarStateAddress, out List list)) @@ -965,7 +965,7 @@ public static bool TryGetArenaAvatarState(this IAccountStateView states, return false; } - public static bool TryGetArenaScore(this IAccountStateView states, + public static bool TryGetArenaScore(this IAccountState states, Address arenaScoreAddress, out ArenaScore arenaScore) { if (states.TryGetState(arenaScoreAddress, out List list)) @@ -978,7 +978,7 @@ public static bool TryGetArenaScore(this IAccountStateView states, return false; } - public static bool TryGetArenaInformation(this IAccountStateView states, + public static bool TryGetArenaInformation(this IAccountState states, Address arenaInformationAddress, out ArenaInformation arenaInformation) { if (states.TryGetState(arenaInformationAddress, out List list)) @@ -991,7 +991,7 @@ public static bool TryGetArenaInformation(this IAccountStateView states, return false; } - public static AvatarState GetEnemyAvatarState(this IAccountStateView states, Address avatarAddress) + public static AvatarState GetEnemyAvatarState(this IAccountState states, Address avatarAddress) { AvatarState enemyAvatarState; try @@ -1013,7 +1013,7 @@ public static AvatarState GetEnemyAvatarState(this IAccountStateView states, Add return enemyAvatarState; } - public static CrystalCostState GetCrystalCostState(this IAccountStateView states, + public static CrystalCostState GetCrystalCostState(this IAccountState states, Address address) { return states.TryGetState(address, out List rawState) @@ -1026,7 +1026,7 @@ public static ( CrystalCostState WeeklyCostState, CrystalCostState PrevWeeklyCostState, CrystalCostState BeforePrevWeeklyCostState - ) GetCrystalCostStates(this IAccountStateView states, long blockIndex, long interval) + ) GetCrystalCostStates(this IAccountState states, long blockIndex, long interval) { int dailyCostIndex = (int) (blockIndex / CrystalCostState.DailyIntervalIndex); int weeklyCostIndex = (int) (blockIndex / interval); @@ -1050,7 +1050,7 @@ CrystalCostState BeforePrevWeeklyCostState beforePrevWeeklyCostState); } - public static void ValidateWorldId(this IAccountStateView states, Address avatarAddress, int worldId) + public static void ValidateWorldId(this IAccountState states, Address avatarAddress, int worldId) { if (worldId > 1) { @@ -1075,13 +1075,13 @@ public static void ValidateWorldId(this IAccountStateView states, Address avatar } } - public static RaiderState GetRaiderState(this IAccountStateView states, + public static RaiderState GetRaiderState(this IAccountState states, Address avatarAddress, int raidId) { return GetRaiderState(states, Addresses.GetRaiderAddress(avatarAddress, raidId)); } - public static RaiderState GetRaiderState(this IAccountStateView states, + public static RaiderState GetRaiderState(this IAccountState states, Address raiderAddress) { if (states.TryGetState(raiderAddress, out List rawRaider)) @@ -1093,7 +1093,7 @@ public static RaiderState GetRaiderState(this IAccountStateView states, } public static Dictionary GetSheetsV100291( - this IAccountStateView states, + this IAccountState states, bool containAvatarSheets = false, bool containItemSheet = false, bool containQuestSheet = false, @@ -1201,7 +1201,7 @@ public static RaiderState GetRaiderState(this IAccountStateView states, } public static Dictionary GetSheetsV1( - this IAccountStateView states, + this IAccountState states, bool containAvatarSheets = false, bool containItemSheet = false, bool containQuestSheet = false, diff --git a/Lib9c/Action/ActionBaseExtensions.cs b/Lib9c/Action/ActionBaseExtensions.cs index 3e4ff7d71a..875185f3b0 100644 --- a/Lib9c/Action/ActionBaseExtensions.cs +++ b/Lib9c/Action/ActionBaseExtensions.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; +using System.Numerics; using System.Security.Cryptography; using Bencodex.Types; using Libplanet; using Libplanet.Action; using Libplanet.Assets; using Libplanet.Blocks; +using Libplanet.Consensus; using Libplanet.State; using Libplanet.Tx; @@ -79,36 +80,37 @@ public void PutLog(string log) private class AddressTraceStateDelta : IAccountStateDelta { - private ImmutableHashSet
_updatedAddresses; + private AddressTraceDelta _delta; public AddressTraceStateDelta() - : this(ImmutableHashSet
.Empty) + : this(new AddressTraceDelta()) { } - public AddressTraceStateDelta(ImmutableHashSet
updatedAddresses) + public AddressTraceStateDelta(AddressTraceDelta delta) { - _updatedAddresses = updatedAddresses; + _delta = delta; } - public IImmutableSet
UpdatedAddresses => _updatedAddresses; + public IAccountDelta Delta => _delta; - public IImmutableSet
StateUpdatedAddresses => _updatedAddresses; + public IImmutableSet
UpdatedAddresses => _delta.UpdatedAddresses; - public IImmutableDictionary> UpdatedFungibleAssets - => ImmutableDictionary>.Empty; + public IImmutableSet
StateUpdatedAddresses => _delta.StateUpdatedAddresses; - public IImmutableDictionary> TotalUpdatedFungibleAssets - { - get; - } + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => + Delta.UpdatedFungibleAssets; + + public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => + throw new NotSupportedException(); - public IImmutableSet TotalSupplyUpdatedCurrencies - => ImmutableHashSet.Empty; + public IImmutableSet UpdatedTotalSupplyCurrencies + => Delta.UpdatedTotalSupplyCurrencies; public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) { - return new AddressTraceStateDelta(_updatedAddresses.Union(new [] { owner })); + return new AddressTraceStateDelta( + new AddressTraceDelta(Delta.UpdatedAddresses.Union(new [] { owner }))); } public FungibleAssetValue GetBalance(Address address, Currency currency) @@ -133,12 +135,14 @@ public FungibleAssetValue GetTotalSupply(Currency currency) public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) { - return new AddressTraceStateDelta(_updatedAddresses.Union(new[] { recipient })); + return new AddressTraceStateDelta( + new AddressTraceDelta(Delta.UpdatedAddresses.Union(new[] { recipient }))); } public IAccountStateDelta SetState(Address address, IValue state) { - return new AddressTraceStateDelta(_updatedAddresses.Union(new[] { address })); + return new AddressTraceStateDelta( + new AddressTraceDelta(Delta.UpdatedAddresses.Union(new[] { address }))); } public IAccountStateDelta TransferAsset( @@ -150,8 +154,39 @@ public IAccountStateDelta TransferAsset( ) { return new AddressTraceStateDelta( - _updatedAddresses.Union(new[] { sender, recipient }) - ); + new AddressTraceDelta(Delta.UpdatedAddresses.Union(new[] { sender, recipient }))); + } + + public ValidatorSet GetValidatorSet() => throw new NotSupportedException(); + + public IAccountStateDelta SetValidator(Validator validator) + { + throw new NotSupportedException(); + } + + public class AddressTraceDelta : IAccountDelta + { + private IImmutableSet
_updatedAddresses; + + public AddressTraceDelta() + : this(ImmutableHashSet
.Empty) + { + } + + public AddressTraceDelta(IImmutableSet
updatedAddresses) + { + _updatedAddresses = updatedAddresses; + } + + public IImmutableSet
UpdatedAddresses => _updatedAddresses; + public IImmutableSet
StateUpdatedAddresses => _updatedAddresses; + public IImmutableDictionary States => throw new NotSupportedException(); + public IImmutableSet
FungibleUpdatedAddresses => _updatedAddresses; + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => throw new NotSupportedException(); + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => throw new NotSupportedException(); + public IImmutableSet UpdatedTotalSupplyCurrencies => throw new NotSupportedException(); + public IImmutableDictionary TotalSupplies => throw new NotSupportedException(); + public ValidatorSet ValidatorSet => throw new NotSupportedException(); } } } diff --git a/Lib9c/Action/RewardGold.cs b/Lib9c/Action/RewardGold.cs index 9717d54a46..cf21974ead 100644 --- a/Lib9c/Action/RewardGold.cs +++ b/Lib9c/Action/RewardGold.cs @@ -308,8 +308,8 @@ public static IAccountStateDelta TransferMead(IActionContext context, IAccountSt var targetAddresses = states .TotalUpdatedFungibleAssets #pragma warning restore LAA1002 - .Where(d => d.Value.Contains(Currencies.Mead)) - .Select(kv => kv.Key) + .Where(pair => pair.Item2.Equals(Currencies.Mead)) + .Select(pair => pair.Item1) .Distinct(); foreach (var address in targetAddresses) { From dd1319c6cce916c2191c82caa85fd155d0faaa88 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 29 Jun 2023 11:14:12 +0900 Subject: [PATCH 31/68] Changed snapshot testing --- .../Snapshot/TransferAsset0SnapshotTest.cs | 52 ++++++++---- .../transfer_asset.PlainValue.verified.txt | 40 ++++----- ...set.TransferCrystal.fungibles.verified.txt | 4 + ...asset.TransferCrystal.summary.verified.txt | 19 +++++ ...ransfer_asset.TransferCrystal.verified.txt | 83 ------------------- ...et.TransferWithMemo.fungibles.verified.txt | 4 + ...sset.TransferWithMemo.summary.verified.txt | 19 +++++ ...ansfer_asset.TransferWithMemo.verified.txt | 83 ------------------- 8 files changed, 101 insertions(+), 203 deletions(-) create mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.fungibles.verified.txt create mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt delete mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt create mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.fungibles.verified.txt create mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt delete mode 100644 .Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index b7d918a98b..a00a891c02 100644 --- a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs +++ b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs @@ -1,5 +1,7 @@ namespace Lib9c.Tests.Action.Snapshot { + using System.Collections.Immutable; + using System.Numerics; using System.Threading.Tasks; using Bencodex.Types; using Libplanet; @@ -8,6 +10,7 @@ namespace Lib9c.Tests.Action.Snapshot using Libplanet.State; using Nekoyume.Action; using Nekoyume.Helper; + using VerifyTests; using VerifyXunit; using Xunit; using static ActionUtils; @@ -15,6 +18,11 @@ namespace Lib9c.Tests.Action.Snapshot [UsesVerify] public class TransferAsset0SnapshotTest { + public TransferAsset0SnapshotTest() + { + VerifierSettings.SortPropertiesAlphabetically(); + } + [Fact] public Task PlainValue() { @@ -23,7 +31,8 @@ public Task PlainValue() default(Address), Currency.Legacy("NNN", 2, null) * 100); - return Verifier.Verify(action.PlainValue) + return Verifier + .Verify(action.PlainValue) .UseTypeName((Text)GetActionTypeId()); } @@ -38,17 +47,9 @@ public Task TransferCrystal() "f8960846e9ae4ad1c23686f74c8e5f80f22336b6f2175be21db82afa8823c92d")); var senderAddress = senderPrivateKey.ToAddress(); var recipientAddress = recipientPrivateKey.ToAddress(); - - Assert.Equal("C61C376693E6B26717C9ee9aCA5A2453028f6ffA", senderAddress.ToHex()); - Assert.Equal("99A06c2Bd71f0EAa8196fE45BE5ca424eE809733", recipientAddress.ToHex()); - var crystal = CrystalCalculator.CRYSTAL; var context = new ActionContext(); IAccountStateDelta state = new State().MintAsset(context, senderAddress, crystal * 100); - - Assert.Equal((crystal * 100).RawValue, state.GetBalance(senderAddress, crystal).RawValue); - Assert.Equal(0, state.GetBalance(recipientAddress, crystal).RawValue); - var actionContext = new ActionContext { Signer = senderAddress, @@ -60,11 +61,18 @@ public Task TransferCrystal() crystal * 100); var outputState = action.Execute(actionContext); - Assert.Equal((crystal * 100).RawValue, outputState.GetBalance(recipientAddress, crystal).RawValue); - Assert.Equal(0, outputState.GetBalance(senderAddress, crystal).RawValue); - - return Verifier.Verify(outputState) - .UseTypeName((Text)GetActionTypeId()); + // Verifier does not handle tuples well when nested. + var summary = Verifier + .Verify(outputState) + .IgnoreMembersWithType>() + .IgnoreMembersWithType>() + .UseTypeName((Text)GetActionTypeId()) + .UseMethodName($"{nameof(TransferCrystal)}.summary"); + var fungibles = Verifier + .Verify(outputState.Delta.Fungibles) + .UseTypeName((Text)GetActionTypeId()) + .UseMethodName($"{nameof(TransferCrystal)}.fungibles"); + return Task.WhenAll(summary, fungibles); } [Fact] @@ -91,10 +99,20 @@ public Task TransferWithMemo() recipientAddress, crystal * 100, "MEMO"); - var states = action.Execute(actionContext); + var outputState = action.Execute(actionContext); - return Verifier.Verify(states) - .UseTypeName((Text)GetActionTypeId()); + // Verifier does not handle tuples well when nested. + var summary = Verifier + .Verify(outputState) + .IgnoreMembersWithType>() + .IgnoreMembersWithType>() + .UseTypeName((Text)GetActionTypeId()) + .UseMethodName($"{nameof(TransferWithMemo)}.summary"); + var fungibles = Verifier + .Verify(outputState.Delta.Fungibles) + .UseTypeName((Text)GetActionTypeId()) + .UseMethodName($"{nameof(TransferWithMemo)}.fungibles"); + return Task.WhenAll(summary, fungibles); } } } diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.PlainValue.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.PlainValue.verified.txt index e1c6cb385b..3694f6213a 100644 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.PlainValue.verified.txt +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.PlainValue.verified.txt @@ -1,10 +1,7 @@ { Bencodex.Types.Text "type_id": { - Value: transfer_asset, - Kind: Text, + EncodingLength: 18, Fingerprint: { - Kind: Text, - EncodingLength: 18, Digest: [ 116, 114, @@ -20,9 +17,12 @@ 115, 101, 116 - ] + ], + EncodingLength: 18, + Kind: Text }, - EncodingLength: 18 + Kind: Text, + Value: transfer_asset }, Bencodex.Types.Text "values": { Bencodex.Types.Text "amount": [ @@ -31,38 +31,38 @@ 2 ], Bencodex.Types.Text "minters": { + EncodingLength: 1, Fingerprint: { EncodingLength: 1 - }, - EncodingLength: 1 + } }, Bencodex.Types.Text "ticker": { - Value: NNN, - Kind: Text, + EncodingLength: 6, Fingerprint: { - Kind: Text, - EncodingLength: 6, Digest: [ 78, 78, 78 - ] + ], + EncodingLength: 6, + Kind: Text }, - EncodingLength: 6 + Kind: Text, + Value: NNN } }, { - Value: 10000, - Kind: Integer, + EncodingLength: 7, Fingerprint: { - Kind: Integer, - EncodingLength: 7, Digest: [ 16, 39 - ] + ], + EncodingLength: 7, + Kind: Integer }, - EncodingLength: 7 + Kind: Integer, + Value: 10000 } ], Bencodex.Types.Text "recipient": [ diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.fungibles.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.fungibles.verified.txt new file mode 100644 index 0000000000..abc9592fba --- /dev/null +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.fungibles.verified.txt @@ -0,0 +1,4 @@ +{ + (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000, + (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0 +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt new file mode 100644 index 0000000000..5d35a221d9 --- /dev/null +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt @@ -0,0 +1,19 @@ +{ + Delta: { + FungibleUpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + ValidatorSet: { + Bencoded: [] + } + }, + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ] +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt deleted file mode 100644 index 6946b8890e..0000000000 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.verified.txt +++ /dev/null @@ -1,83 +0,0 @@ -{ - Delta: { - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - FungibleUpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - UpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ], - Fungibles: { - (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0, - (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000 - }, - ValidatorSet: { - Bencoded: [] - } - }, - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - UpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ], - TotalUpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ] -} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.fungibles.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.fungibles.verified.txt new file mode 100644 index 0000000000..abc9592fba --- /dev/null +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.fungibles.verified.txt @@ -0,0 +1,4 @@ +{ + (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000, + (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0 +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt new file mode 100644 index 0000000000..5d35a221d9 --- /dev/null +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt @@ -0,0 +1,19 @@ +{ + Delta: { + FungibleUpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ], + ValidatorSet: { + Bencoded: [] + } + }, + UpdatedAddresses: [ + 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, + C61C376693E6B26717C9ee9aCA5A2453028f6ffA + ] +} \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt deleted file mode 100644 index 6946b8890e..0000000000 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.verified.txt +++ /dev/null @@ -1,83 +0,0 @@ -{ - Delta: { - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - FungibleUpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - UpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ], - Fungibles: { - (0xC61C376693E6B26717C9ee9aCA5A2453028f6ffA, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 0, - (0x99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, CRYSTAL (deedf7b43769c065ebc9ec7abe66a883df02407b)): 100000000000000000000 - }, - ValidatorSet: { - Bencoded: [] - } - }, - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - UpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ], - TotalUpdatedFungibleAssets: [ - { - Item1: C61C376693E6B26717C9ee9aCA5A2453028f6ffA, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - }, - { - Item1: 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - Item2: { - Ticker: CRYSTAL, - DecimalPlaces: 18, - Hash: deedf7b43769c065ebc9ec7abe66a883df02407b, - TotalSupplyTrackable: false - } - } - ] -} \ No newline at end of file From ada0b92145a0aa5ff4d8dc180bf4bfb14f6e4d8f Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Thu, 29 Jun 2023 17:46:12 +0900 Subject: [PATCH 32/68] Bump to libplanet 2.3.0 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index b1df89924b..4fefb5cea3 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit b1df89924b29ec1c9b2e1ec0a90e8116da645a03 +Subproject commit 4fefb5cea3ab3b9c4b4caa28c7aba0fafd39e109 From bd19d2cfd226ec8768a69fbc0758350508dc733f Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Mon, 3 Jul 2023 19:06:29 +0900 Subject: [PATCH 33/68] Removed unsupported methods --- Lib9c.Renderers/Renderers/ActionRenderer.cs | 65 --------------------- Lib9c.Renderers/Renderers/BlockRenderer.cs | 9 --- 2 files changed, 74 deletions(-) diff --git a/Lib9c.Renderers/Renderers/ActionRenderer.cs b/Lib9c.Renderers/Renderers/ActionRenderer.cs index 0ea3e406c1..638ef5e3de 100644 --- a/Lib9c.Renderers/Renderers/ActionRenderer.cs +++ b/Lib9c.Renderers/Renderers/ActionRenderer.cs @@ -25,9 +25,6 @@ public class ActionRenderer : IActionRenderer public Subject> ActionRenderSubject { get; } = new Subject>(); - public Subject> ActionUnrenderSubject { get; } - = new Subject>(); - public readonly Subject<(Block OldTip, Block NewTip)> BlockEndSubject = new Subject<(Block OldTip, Block NewTip)>(); @@ -50,20 +47,6 @@ public void RenderAction(IValue action, IActionContext context, IAccountStateDel RandomSeed = context.Random.Seed }); - public void UnrenderAction(IValue action, IActionContext context, IAccountStateDelta nextStates) => - ActionUnrenderSubject.OnNext(new ActionEvaluation - { - Action = context.BlockAction - ? new RewardGold() - : (ActionBase)_actionLoader.LoadAction(context.BlockIndex, action), - Signer = context.Signer, - BlockIndex = context.BlockIndex, - TxId = context.TxId, - OutputStates = nextStates, - PreviousStates = context.PreviousStates, - RandomSeed = context.Random.Seed - }); - public void RenderActionError( IValue action, IActionContext context, @@ -86,21 +69,6 @@ Exception exception }); } - public void UnrenderActionError(IValue action, IActionContext context, Exception exception) => - ActionUnrenderSubject.OnNext(new ActionEvaluation - { - Action = context.BlockAction - ? new RewardGold() - : (ActionBase)_actionLoader.LoadAction(context.BlockIndex, action), - Signer = context.Signer, - BlockIndex = context.BlockIndex, - TxId = context.TxId, - OutputStates = context.PreviousStates, - Exception = exception, - PreviousStates = context.PreviousStates, - RandomSeed = context.Random.Seed - }); - [Obsolete("Use BlockRenderer.RenderBlock(oldTip, newTip)")] public void RenderBlock(Block oldTip, Block newTip) { @@ -129,22 +97,6 @@ public IObservable> EveryRender() where T : ActionBase => Extra = eval.Extra, }); - public IObservable> EveryUnrender() where T : ActionBase => - ActionUnrenderSubject - .AsObservable() - .Where(eval => eval.Action is T) - .Select(eval => new ActionEvaluation - { - Action = (T)eval.Action, - Signer = eval.Signer, - BlockIndex = eval.BlockIndex, - TxId = eval.TxId, - OutputStates = eval.OutputStates, - Exception = eval.Exception, - PreviousStates = eval.PreviousStates, - RandomSeed = eval.RandomSeed - }); - public IObservable> EveryRender(Address updatedAddress) => ActionRenderSubject .AsObservable() @@ -161,22 +113,5 @@ public IObservable> EveryRender(Address updatedAddr RandomSeed = eval.RandomSeed, Extra = eval.Extra, }); - - public IObservable> EveryUnrender(Address updatedAddress) => - ActionUnrenderSubject - .AsObservable() - .Where(eval => eval.OutputStates.UpdatedAddresses.Contains(updatedAddress)) - .Select(eval => new ActionEvaluation - { - Action = eval.Action, - Signer = eval.Signer, - BlockIndex = eval.BlockIndex, - TxId = eval.TxId, - OutputStates = eval.OutputStates, - Exception = eval.Exception, - PreviousStates = eval.PreviousStates, - RandomSeed = eval.RandomSeed, - Extra = eval.Extra, - }); } } diff --git a/Lib9c.Renderers/Renderers/BlockRenderer.cs b/Lib9c.Renderers/Renderers/BlockRenderer.cs index 81923fc648..bc69d149f5 100644 --- a/Lib9c.Renderers/Renderers/BlockRenderer.cs +++ b/Lib9c.Renderers/Renderers/BlockRenderer.cs @@ -1,8 +1,5 @@ -using System; -using Libplanet.Action; using Libplanet.Blockchain.Renderers; using Libplanet.Blocks; -using Nekoyume.Action; #if UNITY_EDITOR || UNITY_STANDALONE using UniRx; #else @@ -19,12 +16,6 @@ public class BlockRenderer : IRenderer public readonly Subject<(NCBlock OldTip, NCBlock NewTip)> BlockSubject = new Subject<(NCBlock OldTip, NCBlock NewTip)>(); - public readonly Subject<(NCBlock OldTip, NCBlock NewTip, NCBlock Branchpoint)> ReorgSubject = - new Subject<(NCBlock OldTip, NCBlock NewTip, NCBlock Branchpoint)>(); - - public readonly Subject<(NCBlock OldTip, NCBlock NewTip, NCBlock Branchpoint)> ReorgEndSubject = - new Subject<(NCBlock OldTip, NCBlock NewTip, NCBlock Branchpoint)>(); - public void RenderBlock(NCBlock oldTip, NCBlock newTip) => BlockSubject.OnNext((oldTip, newTip)); } From e317aaea5b28b8b4dd74e478c6260db5f2345cbb Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 09:35:15 +0900 Subject: [PATCH 34/68] Bump libplanet to 2.4.0 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index 4fefb5cea3..720e0364ff 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit 4fefb5cea3ab3b9c4b4caa28c7aba0fafd39e109 +Subproject commit 720e0364ffcdaeac1460d530348447674b3391f3 From 37b30ea43d31dd8f889c27acd9bdec8e6af188dd Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 10:02:14 +0900 Subject: [PATCH 35/68] Accommodate API changes for libplanet 2.4.0 --- .Lib9c.Benchmarks/Program.cs | 10 ++-- .../Action/Craft/UnlocakCraftActionTest.cs | 2 +- .../Action/Craft/UnlockRecipeTest.cs | 4 +- .../Action/CreateOrReplaceAvatarTest.cs | 2 +- .../Action/FaucetCurrencyTest.cs | 2 +- .../Action/FaucetRuneTest.cs | 2 +- .../Action/ManipulateStateTest.cs | 2 +- .../Action/Stage/ClearStageTest.cs | 2 +- ...ustomActionsDeserializableValidatorTest.cs | 2 +- .Lib9c.Tests/Action/ActionContext.cs | 4 +- .../Action/ActionContextExtensionsTest.cs | 2 +- .Lib9c.Tests/Action/ActionEvaluationTest.cs | 4 +- .Lib9c.Tests/Action/ActivateAccount0Test.cs | 16 ++--- .Lib9c.Tests/Action/ActivateAccountTest.cs | 8 +-- .../Action/AddActivatedAccount0Test.cs | 12 ++-- .../Action/AddActivatedAccountTest.cs | 8 +-- .Lib9c.Tests/Action/AddRedeemCodeTest.cs | 12 ++-- .Lib9c.Tests/Action/ApprovePledgeTest.cs | 4 +- .Lib9c.Tests/Action/BattleArena10Test.cs | 38 ++++++------ .Lib9c.Tests/Action/BattleArena11Test.cs | 38 ++++++------ .Lib9c.Tests/Action/BattleArena12Test.cs | 38 ++++++------ .Lib9c.Tests/Action/BattleArena1Test.cs | 20 +++---- .Lib9c.Tests/Action/BattleArena2Test.cs | 26 ++++----- .Lib9c.Tests/Action/BattleArena3Test.cs | 26 ++++----- .Lib9c.Tests/Action/BattleArena4Test.cs | 32 +++++----- .Lib9c.Tests/Action/BattleArena5Test.cs | 30 +++++----- .Lib9c.Tests/Action/BattleArena6Test.cs | 32 +++++----- .Lib9c.Tests/Action/BattleArena7Test.cs | 32 +++++----- .Lib9c.Tests/Action/BattleArena8Test.cs | 38 ++++++------ .Lib9c.Tests/Action/BattleArena9Test.cs | 38 ++++++------ .Lib9c.Tests/Action/BattleGrandFinale1Test.cs | 16 ++--- .Lib9c.Tests/Action/BattleGrandFinale2Test.cs | 16 ++--- .Lib9c.Tests/Action/BattleGrandFinale3Test.cs | 16 ++--- .Lib9c.Tests/Action/Buy10Test.cs | 14 ++--- .Lib9c.Tests/Action/Buy11Test.cs | 16 ++--- .Lib9c.Tests/Action/Buy2Test.cs | 2 +- .Lib9c.Tests/Action/Buy3Test.cs | 12 ++-- .Lib9c.Tests/Action/Buy4Test.cs | 12 ++-- .Lib9c.Tests/Action/Buy5Test.cs | 16 ++--- .Lib9c.Tests/Action/Buy6Test.cs | 18 +++--- .Lib9c.Tests/Action/Buy7Test.cs | 22 +++---- .Lib9c.Tests/Action/Buy8Test.cs | 10 ++-- .Lib9c.Tests/Action/Buy9Test.cs | 10 ++-- .Lib9c.Tests/Action/BuyMultipleTest.cs | 16 ++--- .Lib9c.Tests/Action/BuyProduct0Test.cs | 2 +- .Lib9c.Tests/Action/BuyProductTest.cs | 2 +- .Lib9c.Tests/Action/BuyTest.cs | 14 ++--- .../Action/CancelMonsterCollectTest.cs | 12 ++-- .../Action/CancelProductRegistrationTest.cs | 6 +- .Lib9c.Tests/Action/ChargeActionPoint0Test.cs | 2 +- .Lib9c.Tests/Action/ChargeActionPoint2Test.cs | 6 +- .Lib9c.Tests/Action/ChargeActionPointTest.cs | 8 +-- .../ClaimMonsterCollectionReward0Test.cs | 12 ++-- .../ClaimMonsterCollectionReward2Test.cs | 14 ++--- .../ClaimMonsterCollectionRewardTest.cs | 14 ++--- .Lib9c.Tests/Action/ClaimRaidRewardTest.cs | 4 +- .Lib9c.Tests/Action/ClaimStakeReward1Test.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward2Test.cs | 4 +- .Lib9c.Tests/Action/ClaimStakeReward3Test.cs | 4 +- .Lib9c.Tests/Action/ClaimStakeRewardTest.cs | 2 +- .../Action/ClaimWorldBossKillRewardTest.cs | 4 +- .../Action/CombinationConsumable0Test.cs | 12 ++-- .../Action/CombinationConsumable2Test.cs | 2 +- .../Action/CombinationConsumable3Test.cs | 2 +- .../Action/CombinationConsumable4Test.cs | 2 +- .../Action/CombinationConsumable5Test.cs | 2 +- .../Action/CombinationConsumable6Test.cs | 2 +- .../Action/CombinationConsumable7Test.cs | 2 +- .../Action/CombinationConsumableTest.cs | 2 +- .../Action/CombinationEquipment0Test.cs | 16 ++--- .../Action/CombinationEquipment10Test.cs | 8 +-- .../Action/CombinationEquipment11Test.cs | 10 ++-- .../Action/CombinationEquipment12Test.cs | 4 +- .../Action/CombinationEquipment13Test.cs | 8 +-- .../Action/CombinationEquipment14Test.cs | 8 +-- .../Action/CombinationEquipment15Test.cs | 8 +-- .../Action/CombinationEquipment2Test.cs | 2 +- .../Action/CombinationEquipment3Test.cs | 4 +- .../Action/CombinationEquipment4Test.cs | 4 +- .../Action/CombinationEquipment5Test.cs | 4 +- .../Action/CombinationEquipment6Test.cs | 8 +-- .../Action/CombinationEquipment7Test.cs | 8 +-- .../Action/CombinationEquipment8Test.cs | 6 +- .../Action/CombinationEquipment9Test.cs | 6 +- .../Action/CombinationEquipmentTest.cs | 8 +-- .../Action/Coupons/IssueCouponsTest.cs | 12 ++-- .../Action/Coupons/RedeemCouponTest.cs | 28 ++++----- .../Action/Coupons/TransferCouponsTest.cs | 18 +++--- .Lib9c.Tests/Action/CreateAvatar0Test.cs | 14 ++--- .Lib9c.Tests/Action/CreateAvatar2Test.cs | 14 ++--- .Lib9c.Tests/Action/CreateAvatar3Test.cs | 14 ++--- .Lib9c.Tests/Action/CreateAvatar6Test.cs | 14 ++--- .Lib9c.Tests/Action/CreateAvatar7Test.cs | 14 ++--- .Lib9c.Tests/Action/CreateAvatarTest.cs | 14 ++--- .../Action/CreatePendingActivationTest.cs | 10 ++-- .../Action/CreatePendingActivationsTest.cs | 6 +- .Lib9c.Tests/Action/CreatePledgeTest.cs | 2 +- .Lib9c.Tests/Action/DailyReward0Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward2Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward3Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward4Test.cs | 8 +-- .Lib9c.Tests/Action/DailyReward5Test.cs | 6 +- .Lib9c.Tests/Action/DailyReward6Test.cs | 6 +- .Lib9c.Tests/Action/DailyRewardTest.cs | 6 +- .Lib9c.Tests/Action/EndPledgeTest.cs | 4 +- .../Action/EventConsumableItemCraftsTest.cs | 2 +- .../Action/EventDungeonBattleV1Test.cs | 2 +- .../Action/EventDungeonBattleV2Test.cs | 2 +- .../Action/EventDungeonBattleV3Test.cs | 2 +- .../Action/EventDungeonBattleV4Test.cs | 4 +- .../Action/EventDungeonBattleV5Test.cs | 4 +- .../Action/EventMaterialItemCraftsTest.cs | 2 +- .Lib9c.Tests/Action/GrindingTest.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash0Test.cs | 32 +++++----- .Lib9c.Tests/Action/HackAndSlash10Test.cs | 40 ++++++------- .Lib9c.Tests/Action/HackAndSlash11Test.cs | 38 ++++++------ .Lib9c.Tests/Action/HackAndSlash12Test.cs | 40 ++++++------- .Lib9c.Tests/Action/HackAndSlash13Test.cs | 42 +++++++------- .Lib9c.Tests/Action/HackAndSlash15Test.cs | 36 ++++++------ .Lib9c.Tests/Action/HackAndSlash16Test.cs | 38 ++++++------ .Lib9c.Tests/Action/HackAndSlash17Test.cs | 38 ++++++------ .Lib9c.Tests/Action/HackAndSlash18Test.cs | 42 +++++++------- .Lib9c.Tests/Action/HackAndSlash19Test.cs | 40 ++++++------- .Lib9c.Tests/Action/HackAndSlash20Test.cs | 58 +++++++++---------- .Lib9c.Tests/Action/HackAndSlash21Test.cs | 58 +++++++++---------- .Lib9c.Tests/Action/HackAndSlash2Test.cs | 32 +++++----- .Lib9c.Tests/Action/HackAndSlash3Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash4Test.cs | 32 +++++----- .Lib9c.Tests/Action/HackAndSlash5Test.cs | 30 +++++----- .Lib9c.Tests/Action/HackAndSlash6Test.cs | 34 +++++------ .Lib9c.Tests/Action/HackAndSlash7Test.cs | 38 ++++++------ .Lib9c.Tests/Action/HackAndSlash8Test.cs | 38 ++++++------ .Lib9c.Tests/Action/HackAndSlash9Test.cs | 42 +++++++------- .../Action/HackAndSlashRandomBuffTest.cs | 6 +- .Lib9c.Tests/Action/HackAndSlashSweep1Test.cs | 18 +++--- .Lib9c.Tests/Action/HackAndSlashSweep2Test.cs | 20 +++---- .Lib9c.Tests/Action/HackAndSlashSweep3Test.cs | 26 ++++----- .Lib9c.Tests/Action/HackAndSlashSweep4Test.cs | 24 ++++---- .Lib9c.Tests/Action/HackAndSlashSweep5Test.cs | 22 +++---- .Lib9c.Tests/Action/HackAndSlashSweep6Test.cs | 24 ++++---- .Lib9c.Tests/Action/HackAndSlashSweep7Test.cs | 24 ++++---- .Lib9c.Tests/Action/HackAndSlashSweep8Test.cs | 24 ++++---- .Lib9c.Tests/Action/HackAndSlashSweep9Test.cs | 28 ++++----- .Lib9c.Tests/Action/HackAndSlashTest14.cs | 36 ++++++------ .Lib9c.Tests/Action/InitializeStatesTest.cs | 10 ++-- .Lib9c.Tests/Action/ItemEnhancement0Test.cs | 24 ++++---- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 8 +-- .Lib9c.Tests/Action/ItemEnhancement2Test.cs | 22 +++---- .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 | 6 +- .Lib9c.Tests/Action/ItemEnhancement8Test.cs | 6 +- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 6 +- .Lib9c.Tests/Action/ItemEnhancementTest.cs | 2 +- .Lib9c.Tests/Action/JoinArena1Test.cs | 20 +++---- .Lib9c.Tests/Action/JoinArena2Test.cs | 20 +++---- .Lib9c.Tests/Action/JoinArena3Test.cs | 24 ++++---- .Lib9c.Tests/Action/MarketValidationTest.cs | 4 +- .../Action/MigrateMonsterCollectionTest.cs | 6 +- .../MigrationActivatedAccountsStateTest.cs | 2 +- .../Action/MigrationAvatarStateTest.cs | 2 +- .../Action/MigrationLegacyShopTest.cs | 4 +- .Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs | 20 +++---- .../Action/MimisbrunnrBattle10Test.cs | 24 ++++---- .../Action/MimisbrunnrBattle11Test.cs | 22 +++---- .../Action/MimisbrunnrBattle12Test.cs | 26 ++++----- .../Action/MimisbrunnrBattle13Test.cs | 26 ++++----- .Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs | 20 +++---- .Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs | 20 +++---- .Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs | 24 ++++---- .Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs | 24 ++++---- .Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs | 26 ++++----- .Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs | 26 ++++----- .Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs | 24 ++++---- .Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs | 26 ++++----- .Lib9c.Tests/Action/MonsterCollect0Test.cs | 18 +++--- .Lib9c.Tests/Action/MonsterCollect2Test.cs | 12 ++-- .Lib9c.Tests/Action/MonsterCollectTest.cs | 14 ++--- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 10 ++-- .Lib9c.Tests/Action/PetEnhancement0Test.cs | 2 +- .../Action/PrepareRewardAssetsTest.cs | 4 +- .Lib9c.Tests/Action/Raid1Test.cs | 8 +-- .Lib9c.Tests/Action/Raid2Test.cs | 6 +- .Lib9c.Tests/Action/Raid3Test.cs | 6 +- .Lib9c.Tests/Action/Raid4Test.cs | 10 ++-- .Lib9c.Tests/Action/Raid5Test.cs | 10 ++-- .Lib9c.Tests/Action/Raid6Test.cs | 10 ++-- .Lib9c.Tests/Action/RankingBattle0Test.cs | 16 ++--- .Lib9c.Tests/Action/RankingBattle10Test.cs | 20 +++---- .Lib9c.Tests/Action/RankingBattle11Test.cs | 26 ++++----- .Lib9c.Tests/Action/RankingBattle2Test.cs | 16 ++--- .Lib9c.Tests/Action/RankingBattle3Test.cs | 18 +++--- .Lib9c.Tests/Action/RankingBattle4Test.cs | 18 +++--- .Lib9c.Tests/Action/RankingBattle5Test.cs | 22 +++---- .Lib9c.Tests/Action/RankingBattle6Test.cs | 22 +++---- .Lib9c.Tests/Action/RankingBattle7Test.cs | 22 +++---- .Lib9c.Tests/Action/RankingBattle8Test.cs | 20 +++---- .Lib9c.Tests/Action/RankingBattle9Test.cs | 20 +++---- .Lib9c.Tests/Action/RankingBattleTest.cs | 2 +- .Lib9c.Tests/Action/RapidCombination0Test.cs | 10 ++-- .Lib9c.Tests/Action/RapidCombination2Test.cs | 10 ++-- .Lib9c.Tests/Action/RapidCombination3Test.cs | 10 ++-- .Lib9c.Tests/Action/RapidCombination4Test.cs | 14 ++--- .Lib9c.Tests/Action/RapidCombination5Test.cs | 16 ++--- .Lib9c.Tests/Action/RapidCombination6Test.cs | 20 +++---- .Lib9c.Tests/Action/RapidCombination8Test.cs | 18 +++--- .Lib9c.Tests/Action/RapidCombinationTest.cs | 18 +++--- .Lib9c.Tests/Action/RapidCombinationTest7.cs | 18 +++--- .Lib9c.Tests/Action/ReRegisterProduct0Test.cs | 4 +- .Lib9c.Tests/Action/ReRegisterProductTest.cs | 4 +- .Lib9c.Tests/Action/RedeemCode0Test.cs | 6 +- .Lib9c.Tests/Action/RedeemCodeTest.cs | 6 +- .Lib9c.Tests/Action/RegisterProduct0Test.cs | 6 +- .Lib9c.Tests/Action/RegisterProductTest.cs | 6 +- .Lib9c.Tests/Action/RenewAdminStateTest.cs | 12 ++-- .Lib9c.Tests/Action/RequestPledgeTest.cs | 4 +- .Lib9c.Tests/Action/RewardGoldTest.cs | 18 +++--- .Lib9c.Tests/Action/RuneEnhancement0Test.cs | 12 ++-- .Lib9c.Tests/Action/RuneEnhancementTest.cs | 14 ++--- .../Action/Scenario/ArenaScenarioTest.cs | 4 +- .../CombinationAndRapidCombinationTest.cs | 4 +- .Lib9c.Tests/Action/Scenario/ItemCraftTest.cs | 8 +-- .../Action/Scenario/MarketScenarioTest.cs | 24 ++++---- .../Action/Scenario/MeadScenarioTest.cs | 4 +- .../AdditionalOptionRateByFixedValueTest.cs | 4 +- .../Action/Scenario/Pet/CommonTest.cs | 4 +- .../Pet/DiscountMaterialCostCrystalTest.cs | 2 +- .../Pet/IncreaseBlockPerHourglassTest.cs | 4 +- .../Scenario/Pet/ReduceRequiredBlockTest.cs | 2 +- .../Action/Scenario/RapidCombinationTest.cs | 4 +- .../Action/Scenario/RuneScenarioTest.cs | 4 +- .../SellAndCancellationAndSellTest.cs | 6 +- .../StakeAndClaimStakeReward2ScenarioTest.cs | 28 ++++----- .../StakeAndClaimStakeReward3ScenarioTest.cs | 28 ++++----- .../StakeAndClaimStakeRewardScenarioTest.cs | 28 ++++----- .../Scenario/WorldUnlockScenarioTest.cs | 12 ++-- .Lib9c.Tests/Action/SecureMiningRewardTest.cs | 4 +- .Lib9c.Tests/Action/Sell0Test.cs | 12 ++-- .Lib9c.Tests/Action/Sell10Test.cs | 18 +++--- .Lib9c.Tests/Action/Sell11Test.cs | 22 +++---- .Lib9c.Tests/Action/Sell2Test.cs | 12 ++-- .Lib9c.Tests/Action/Sell3Test.cs | 12 ++-- .Lib9c.Tests/Action/Sell4Test.cs | 14 ++--- .Lib9c.Tests/Action/Sell5Test.cs | 12 ++-- .Lib9c.Tests/Action/Sell6Test.cs | 14 ++--- .Lib9c.Tests/Action/Sell7Test.cs | 18 +++--- .Lib9c.Tests/Action/Sell8Test.cs | 18 +++--- .Lib9c.Tests/Action/Sell9Test.cs | 18 +++--- .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 | 12 ++-- .Lib9c.Tests/Action/SellCancellation6Test.cs | 12 ++-- .Lib9c.Tests/Action/SellCancellation7Test.cs | 14 ++--- .Lib9c.Tests/Action/SellCancellation8Test.cs | 16 ++--- .Lib9c.Tests/Action/SellCancellationTest.cs | 18 +++--- .Lib9c.Tests/Action/SellTest.cs | 22 +++---- .../Snapshot/TransferAsset0SnapshotTest.cs | 4 +- .Lib9c.Tests/Action/Stake0Test.cs | 24 ++++---- .Lib9c.Tests/Action/StakeTest.cs | 24 ++++---- .Lib9c.Tests/Action/TransferAsset2Test.cs | 24 ++++---- .Lib9c.Tests/Action/TransferAsset3Test.cs | 22 +++---- .Lib9c.Tests/Action/TransferAssetTest.cs | 18 +++--- .Lib9c.Tests/Action/TransferAssetTest0.cs | 20 +++---- .Lib9c.Tests/Action/TransferAssets0Test.cs | 24 ++++---- .Lib9c.Tests/Action/TransferAssetsTest.cs | 20 +++---- .../Action/UnlockEquipmentRecipe1Test.cs | 4 +- .../Action/UnlockEquipmentRecipeTest.cs | 4 +- .Lib9c.Tests/Action/UnlockRuneSlotTest.cs | 18 +++--- .Lib9c.Tests/Action/UnlockWorld1Test.cs | 4 +- .Lib9c.Tests/Action/UnlockWorldTest.cs | 4 +- .Lib9c.Tests/Action/UpdateSell0Test.cs | 12 ++-- .Lib9c.Tests/Action/UpdateSell2Test.cs | 12 ++-- .Lib9c.Tests/Action/UpdateSell3Test.cs | 12 ++-- .Lib9c.Tests/Action/UpdateSell4Test.cs | 14 ++--- .Lib9c.Tests/Action/UpdateSellTest.cs | 14 ++--- .../Action/ValidatorSetOperateTest.cs | 16 ++--- .Lib9c.Tests/TestHelper/BlockChainHelper.cs | 2 +- .Lib9c.Tools/SubCommand/State.cs | 8 +-- .../Action/Craft/UnlockCraftAction.cs | 4 +- .../Action/Craft/UnlockRecipe.cs | 4 +- .../Action/CreateArenaDummy.cs | 10 ++-- .../Action/CreateOrReplaceAvatar.cs | 4 +- Lib9c.DevExtensions/Action/CreateTestbed.cs | 24 ++++---- Lib9c.DevExtensions/Action/FaucetCurrency.cs | 4 +- Lib9c.DevExtensions/Action/FaucetRune.cs | 4 +- Lib9c.DevExtensions/Action/ManipulateState.cs | 4 +- .../Action/Stage/ClearStage.cs | 4 +- .../Action/NCActionEvaluation.cs | 12 ++-- .../Formatters/AccountStateDeltaFormatter.cs | 6 +- Lib9c.Renderers/ActionEvaluation.cs | 4 +- Lib9c.Renderers/Renderers/ActionRenderer.cs | 18 +++--- Lib9c/Action/ActionBase.cs | 4 +- Lib9c/Action/ActionBaseExtensions.cs | 4 +- Lib9c/Action/ActionContextExtensions.cs | 2 +- Lib9c/Action/ActivateAccount.cs | 2 +- Lib9c/Action/ActivateAccount0.cs | 2 +- Lib9c/Action/AddActivatedAccount.cs | 2 +- Lib9c/Action/AddActivatedAccount0.cs | 2 +- Lib9c/Action/AddRedeemCode.cs | 2 +- Lib9c/Action/ApprovePledge.cs | 2 +- Lib9c/Action/BattleArena.cs | 2 +- Lib9c/Action/BattleArena1.cs | 2 +- Lib9c/Action/BattleArena10.cs | 2 +- Lib9c/Action/BattleArena11.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 | 2 +- Lib9c/Action/BuyProduct0.cs | 2 +- Lib9c/Action/CancelMonsterCollect.cs | 2 +- Lib9c/Action/CancelProductRegistration.cs | 2 +- Lib9c/Action/ChargeActionPoint.cs | 2 +- Lib9c/Action/ChargeActionPoint0.cs | 2 +- Lib9c/Action/ChargeActionPoint2.cs | 2 +- Lib9c/Action/ClaimMonsterCollectionReward.cs | 2 +- Lib9c/Action/ClaimMonsterCollectionReward0.cs | 2 +- Lib9c/Action/ClaimMonsterCollectionReward2.cs | 2 +- Lib9c/Action/ClaimRaidReward.cs | 2 +- Lib9c/Action/ClaimStakeReward.cs | 4 +- Lib9c/Action/ClaimStakeReward1.cs | 2 +- Lib9c/Action/ClaimStakeReward2.cs | 4 +- Lib9c/Action/ClaimStakeReward3.cs | 4 +- Lib9c/Action/ClaimWordBossKillReward.cs | 2 +- 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 | 2 +- Lib9c/Action/CombinationEquipment0.cs | 2 +- Lib9c/Action/CombinationEquipment10.cs | 2 +- Lib9c/Action/CombinationEquipment11.cs | 2 +- Lib9c/Action/CombinationEquipment12.cs | 2 +- Lib9c/Action/CombinationEquipment13.cs | 2 +- Lib9c/Action/CombinationEquipment14.cs | 2 +- Lib9c/Action/CombinationEquipment15.cs | 2 +- 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 | 4 +- Lib9c/Action/CreateAvatar0.cs | 18 +++--- Lib9c/Action/CreateAvatar2.cs | 6 +- Lib9c/Action/CreateAvatar3.cs | 6 +- Lib9c/Action/CreateAvatar4.cs | 6 +- Lib9c/Action/CreateAvatar5.cs | 6 +- Lib9c/Action/CreateAvatar6.cs | 6 +- Lib9c/Action/CreateAvatar7.cs | 4 +- Lib9c/Action/CreatePendingActivation.cs | 4 +- 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/Grinding.cs | 2 +- Lib9c/Action/HackAndSlash.cs | 4 +- 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 | 2 +- Lib9c/Action/HackAndSlash16.cs | 4 +- Lib9c/Action/HackAndSlash17.cs | 4 +- Lib9c/Action/HackAndSlash18.cs | 4 +- Lib9c/Action/HackAndSlash19.cs | 4 +- Lib9c/Action/HackAndSlash2.cs | 2 +- Lib9c/Action/HackAndSlash20.cs | 4 +- 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/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 +- .../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 | 2 +- Lib9c/Action/MonsterCollect0.cs | 2 +- Lib9c/Action/MonsterCollect2.cs | 2 +- Lib9c/Action/PatchTableSheet.cs | 2 +- Lib9c/Action/PetEnhancement.cs | 2 +- Lib9c/Action/PrepareRewardAssets.cs | 2 +- Lib9c/Action/Raid.cs | 2 +- Lib9c/Action/Raid1.cs | 2 +- Lib9c/Action/Raid2.cs | 2 +- Lib9c/Action/Raid3.cs | 2 +- Lib9c/Action/Raid4.cs | 2 +- Lib9c/Action/Raid5.cs | 2 +- Lib9c/Action/RankingBattle.cs | 2 +- Lib9c/Action/RankingBattle0.cs | 2 +- Lib9c/Action/RankingBattle10.cs | 2 +- Lib9c/Action/RankingBattle11.cs | 2 +- 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 | 2 +- Lib9c/Action/ReRegisterProduct0.cs | 2 +- Lib9c/Action/RedeemCode.cs | 2 +- Lib9c/Action/RedeemCode0.cs | 2 +- Lib9c/Action/RedeemCode2.cs | 2 +- Lib9c/Action/RegisterProduct.cs | 2 +- Lib9c/Action/RegisterProduct0.cs | 2 +- Lib9c/Action/RenewAdminState.cs | 2 +- Lib9c/Action/RequestPledge.cs | 2 +- Lib9c/Action/RewardGold.cs | 2 +- Lib9c/Action/RuneEnhancement.cs | 2 +- Lib9c/Action/RuneEnhancement0.cs | 2 +- Lib9c/Action/SecureMiningReward.cs | 2 +- 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 | 2 +- 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 | 2 +- Lib9c/Action/Stake0.cs | 2 +- Lib9c/Action/TransferAsset.cs | 2 +- Lib9c/Action/TransferAsset0.cs | 2 +- Lib9c/Action/TransferAsset2.cs | 2 +- Lib9c/Action/TransferAsset3.cs | 2 +- Lib9c/Action/TransferAssets.cs | 2 +- Lib9c/Action/TransferAssets0.cs | 2 +- Lib9c/Action/UnlockEquipmentRecipe.cs | 2 +- Lib9c/Action/UnlockEquipmentRecipe1.cs | 2 +- Lib9c/Action/UnlockRuneSlot.cs | 2 +- Lib9c/Action/UnlockWorld.cs | 2 +- Lib9c/Action/UnlockWorld1.cs | 2 +- Lib9c/Action/UpdateSell.cs | 2 +- Lib9c/Action/UpdateSell0.cs | 2 +- Lib9c/Action/UpdateSell2.cs | 2 +- Lib9c/Action/UpdateSell3.cs | 2 +- Lib9c/Action/UpdateSell4.cs | 2 +- Lib9c/Action/ValidatorSetOperate.cs | 2 +- 552 files changed, 2316 insertions(+), 2316 deletions(-) diff --git a/.Lib9c.Benchmarks/Program.cs b/.Lib9c.Benchmarks/Program.cs index fb1b5e7ce1..b8a4cf1a78 100644 --- a/.Lib9c.Benchmarks/Program.cs +++ b/.Lib9c.Benchmarks/Program.cs @@ -163,10 +163,10 @@ bool buildStateReferences ) { IImmutableSet
stateUpdatedAddresses = actionEvaluations - .SelectMany(a => a.OutputStates.StateUpdatedAddresses) + .SelectMany(a => a.OutputState.Delta.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) + .SelectMany(a => a.OutputState.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); if (!stateStore.ContainsStateRoot(block.StateRootHash)) @@ -184,14 +184,14 @@ private static ImmutableDictionary GetTotalDelta( Func<(Address, Currency), string> toFungibleAssetKey) { IImmutableSet
stateUpdatedAddresses = actionEvaluations - .SelectMany(a => a.OutputStates.StateUpdatedAddresses) + .SelectMany(a => a.OutputState.Delta.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) + .SelectMany(a => a.OutputState.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); IAccountStateDelta lastStates = actionEvaluations.Count > 0 - ? actionEvaluations[actionEvaluations.Count - 1].OutputStates + ? actionEvaluations[actionEvaluations.Count - 1].OutputState : null; ImmutableDictionary totalDelta = stateUpdatedAddresses.ToImmutableDictionary( diff --git a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs index fc2c31d146..114f735859 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs @@ -52,7 +52,7 @@ public void StageUnlockTest(string typeIdentifier, int expectedStage) var state = action.Execute(new ActionContext { - PreviousStates = _initialStateV2, + PreviousState = _initialStateV2, Signer = _agentAddress, BlockIndex = 0L }); diff --git a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs index c0e6fe1945..3744611828 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs @@ -57,7 +57,7 @@ public void UnlockRecipeTest_Equipment(ItemSubType targetType) var stateV2 = action.Execute(new ActionContext { - PreviousStates = _initialStateV2, + PreviousState = _initialStateV2, Signer = _agentAddress, BlockIndex = 0L, }); @@ -91,7 +91,7 @@ public void UnlockRecipeTest_Consumable(ItemSubType targetType) var stateV2 = action.Execute(new ActionContext { - PreviousStates = _initialStateV2, + PreviousState = _initialStateV2, Signer = _agentAddress, BlockIndex = 0L, }); diff --git a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs index a0719b5ede..8e134f0219 100644 --- a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs @@ -443,7 +443,7 @@ private static void Execute( crystalRandomBuff); var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = agentAddr, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs index 2773dc70df..9ee0deb070 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs @@ -67,7 +67,7 @@ int expectedCrystal FaucetNcg = faucetNcg, FaucetCrystal = faucetCrystal, }; - var state = action.Execute(new ActionContext { PreviousStates = _initialState }); + var state = action.Execute(new ActionContext { PreviousState = _initialState }); AgentState agentState = state.GetAgentState(_agentAddress); FungibleAssetValue expectedNcgAsset = new FungibleAssetValue(_ncg, expectedNcg, 0); diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs index d13995cd22..d99fc5d94f 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs @@ -86,7 +86,7 @@ public void Execute_FaucetRune(List faucetRuneInfos) AvatarAddress = _avatarAddress, FaucetRuneInfos = faucetRuneInfos, }; - var states = action.Execute(new ActionContext { PreviousStates = _initialState }); + var states = action.Execute(new ActionContext { PreviousState = _initialState }); foreach (var rune in faucetRuneInfos) { var expectedRune = RuneHelper.ToCurrency( diff --git a/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs b/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs index 19b4acea91..c89216cef1 100644 --- a/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs @@ -358,7 +358,7 @@ private IAccountStateDelta Manipulate( return action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = int.MaxValue / 2 }); diff --git a/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs b/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs index ffd01f1d09..bbbd81ce3f 100644 --- a/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs @@ -39,7 +39,7 @@ public void ClearStage() var state = action.Execute(new ActionContext { - PreviousStates = _initialStateV2, + PreviousState = _initialStateV2, Signer = _agentAddress, BlockIndex = 0L, }); diff --git a/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs b/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs index 42764b6808..6f2fd6806e 100644 --- a/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs +++ b/.Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs @@ -51,7 +51,7 @@ public void LoadPlainValue(IValue plainValue) public IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - return context.PreviousStates; + return context.PreviousState; } } diff --git a/.Lib9c.Tests/Action/ActionContext.cs b/.Lib9c.Tests/Action/ActionContext.cs index 2d327a660c..06ee898669 100644 --- a/.Lib9c.Tests/Action/ActionContext.cs +++ b/.Lib9c.Tests/Action/ActionContext.cs @@ -28,7 +28,7 @@ public class ActionContext : IActionContext public bool Rehearsal { get; set; } - public IAccountStateDelta PreviousStates { get; set; } + public IAccountStateDelta PreviousState { get; set; } public IRandom Random { get; set; } @@ -55,7 +55,7 @@ public IActionContext GetUnconsumedContext() BlockIndex = BlockIndex, BlockProtocolVersion = BlockProtocolVersion, Rehearsal = Rehearsal, - PreviousStates = PreviousStates, + PreviousState = PreviousState, Random = Random, PreviousStateRootHash = PreviousStateRootHash, }; diff --git a/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs b/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs index 0540aa6328..25340a8a81 100644 --- a/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs +++ b/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs @@ -145,7 +145,7 @@ public void IsMainNet(GoldCurrencyState goldCurrencyState, bool expected) var state = new State().SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); IActionContext context = new ActionContext { - PreviousStates = state, + PreviousState = state, }; Assert.Equal(expected, context.IsMainNet()); diff --git a/.Lib9c.Tests/Action/ActionEvaluationTest.cs b/.Lib9c.Tests/Action/ActionEvaluationTest.cs index 9ca6ebba18..5f09b12a60 100644 --- a/.Lib9c.Tests/Action/ActionEvaluationTest.cs +++ b/.Lib9c.Tests/Action/ActionEvaluationTest.cs @@ -111,9 +111,9 @@ public void Serialize_With_MessagePack(Type actionType) var deserialized = MessagePackSerializer.Deserialize(b); Assert.Equal(evaluation.Signer, deserialized.Signer); Assert.Equal(evaluation.BlockIndex, deserialized.BlockIndex); - var dict = (Dictionary)deserialized.OutputStates.GetState(default)!; + var dict = (Dictionary)deserialized.OutputState.GetState(default)!; Assert.Equal("value", (Text)dict["key"]); - Assert.Equal(_currency * 10000, deserialized.OutputStates.GetBalance(_signer, _currency)); + Assert.Equal(_currency * 10000, deserialized.OutputState.GetBalance(_signer, _currency)); if (actionType == typeof(RewardGold)) { Assert.Null(deserialized.Action); diff --git a/.Lib9c.Tests/Action/ActivateAccount0Test.cs b/.Lib9c.Tests/Action/ActivateAccount0Test.cs index 652b48798a..4d8f692d77 100644 --- a/.Lib9c.Tests/Action/ActivateAccount0Test.cs +++ b/.Lib9c.Tests/Action/ActivateAccount0Test.cs @@ -26,7 +26,7 @@ public void Execute() ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -50,7 +50,7 @@ public void Rehearsal() ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -61,7 +61,7 @@ public void Rehearsal() ActivatedAccountsState.Address, pendingActivation.address ), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } @@ -83,7 +83,7 @@ public void ExecuteWithInvalidSignature() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -107,7 +107,7 @@ public void ExecuteWithNonExistsPending() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -130,7 +130,7 @@ public void ExecuteWithNonExistsAccounts() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -151,7 +151,7 @@ public void ForbidReusingActivationKey() ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -160,7 +160,7 @@ public void ForbidReusingActivationKey() { action.Execute(new ActionContext() { - PreviousStates = nextState, + PreviousState = nextState, Signer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"), BlockIndex = 2, }); diff --git a/.Lib9c.Tests/Action/ActivateAccountTest.cs b/.Lib9c.Tests/Action/ActivateAccountTest.cs index 8285dbf9e5..9b548206b4 100644 --- a/.Lib9c.Tests/Action/ActivateAccountTest.cs +++ b/.Lib9c.Tests/Action/ActivateAccountTest.cs @@ -44,7 +44,7 @@ public void Execute(bool invalid, bool pendingExist, bool alreadyActivated, Type { IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, }); @@ -56,7 +56,7 @@ public void Execute(bool invalid, bool pendingExist, bool alreadyActivated, Type { Assert.Throws(exc, () => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = default, BlockIndex = 1, })); @@ -75,7 +75,7 @@ public void Rehearsal() Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -86,7 +86,7 @@ public void Rehearsal() activatedAddress, pendingActivation.address ), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index 2ef139d079..16d005ed1d 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -26,7 +26,7 @@ public void Execute() { BlockIndex = 1, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = admin, }); @@ -56,7 +56,7 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = admin, Rehearsal = true, }); @@ -67,7 +67,7 @@ public void Rehearsal() AdminState.Address, ActivatedAccountsState.Address, }.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } @@ -85,7 +85,7 @@ public void ExecuteWithNonExistsAccounts() { BlockIndex = 1, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = admin, }); }); @@ -109,7 +109,7 @@ public void CheckPermission() { BlockIndex = 1, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = newComer, }); }); @@ -120,7 +120,7 @@ public void CheckPermission() { BlockIndex = 101, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = admin, }); }); diff --git a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs index 2e08225dc4..a8ef185cd7 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs @@ -40,7 +40,7 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e { BlockIndex = blockIndex, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = signer, }); Assert.True(nextState.GetState(activatedAddress).ToBoolean()); @@ -51,7 +51,7 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e { BlockIndex = blockIndex, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = signer, })); } @@ -72,7 +72,7 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousStates = state, + PreviousState = state, Signer = admin, Rehearsal = true, }); @@ -83,7 +83,7 @@ public void Rehearsal() AdminState.Address, newComer.Derive(ActivationKey.DeriveKey), }.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs index 0b4c4e3591..8aeaa09305 100644 --- a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs @@ -31,7 +31,7 @@ public void CheckPermission() new ActionContext { BlockIndex = 101, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, } ); @@ -44,7 +44,7 @@ public void CheckPermission() new ActionContext { BlockIndex = 5, - PreviousStates = state, + PreviousState = state, Signer = new Address("019101FEec7ed4f918D396827E1277DEda1e20D4"), } ); @@ -69,7 +69,7 @@ public void Execute() { Signer = adminAddress, BlockIndex = 0, - PreviousStates = new State() + PreviousState = new State() .SetState(Addresses.Admin, adminState.Serialize()) .SetState(Addresses.RedeemCode, new RedeemCodeState(new RedeemCodeListSheet()).Serialize()), }); @@ -102,7 +102,7 @@ public void ExecuteThrowSheetRowValidateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = state, + PreviousState = state, }) ); } @@ -118,12 +118,12 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Rehearsal = true, }); Assert.Equal( - nextState.UpdatedAddresses, + nextState.Delta.UpdatedAddresses, new[] { Addresses.RedeemCode }.ToImmutableHashSet() ); } diff --git a/.Lib9c.Tests/Action/ApprovePledgeTest.cs b/.Lib9c.Tests/Action/ApprovePledgeTest.cs index 806262866b..23b15e90dc 100644 --- a/.Lib9c.Tests/Action/ApprovePledgeTest.cs +++ b/.Lib9c.Tests/Action/ApprovePledgeTest.cs @@ -34,7 +34,7 @@ public void Execute(int mead) var nextState = action.Execute(new ActionContext { Signer = address, - PreviousStates = states, + PreviousState = states, }); var contract = Assert.IsType(nextState.GetState(contractAddress)); @@ -72,7 +72,7 @@ public void Execute_Throw_Exception(bool invalidPatron, bool alreadyContract, Ty Assert.Throws(exc, () => action.Execute(new ActionContext { Signer = address, - PreviousStates = states, + PreviousState = states, })); } } diff --git a/.Lib9c.Tests/Action/BattleArena10Test.cs b/.Lib9c.Tests/Action/BattleArena10Test.cs index 33430f903d..23b30f1a16 100644 --- a/.Lib9c.Tests/Action/BattleArena10Test.cs +++ b/.Lib9c.Tests/Action/BattleArena10Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -918,7 +918,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -971,7 +971,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -1058,7 +1058,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -1203,7 +1203,7 @@ private void Execute( : roundData.StartBlockIndex + arenaInterval; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1308,7 +1308,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena11Test.cs b/.Lib9c.Tests/Action/BattleArena11Test.cs index 9fa9e9d1af..4b2247a291 100644 --- a/.Lib9c.Tests/Action/BattleArena11Test.cs +++ b/.Lib9c.Tests/Action/BattleArena11Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -918,7 +918,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -971,7 +971,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -1058,7 +1058,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -1203,7 +1203,7 @@ private void Execute( : roundData.StartBlockIndex + arenaInterval; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1308,7 +1308,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena12Test.cs b/.Lib9c.Tests/Action/BattleArena12Test.cs index 767f8f3dcc..54f7c8c132 100644 --- a/.Lib9c.Tests/Action/BattleArena12Test.cs +++ b/.Lib9c.Tests/Action/BattleArena12Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -918,7 +918,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -971,7 +971,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -1058,7 +1058,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -1203,7 +1203,7 @@ private void Execute( : roundData.StartBlockIndex + arenaInterval; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1308,7 +1308,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena1Test.cs b/.Lib9c.Tests/Action/BattleArena1Test.cs index 70798c7cb4..2693738add 100644 --- a/.Lib9c.Tests/Action/BattleArena1Test.cs +++ b/.Lib9c.Tests/Action/BattleArena1Test.cs @@ -207,7 +207,7 @@ public IAccountStateDelta JoinArena(IActionContext context, Address signer, Addr _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, @@ -291,7 +291,7 @@ public void Execute(long nextBlockIndex, int championshipId, int round, int tick var blockIndex = roundData.StartBlockIndex + nextBlockIndex; _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -385,7 +385,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -407,7 +407,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -429,7 +429,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -452,7 +452,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -474,7 +474,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -497,7 +497,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -543,7 +543,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -595,7 +595,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/BattleArena2Test.cs b/.Lib9c.Tests/Action/BattleArena2Test.cs index 4012097862..1f52d9adc9 100644 --- a/.Lib9c.Tests/Action/BattleArena2Test.cs +++ b/.Lib9c.Tests/Action/BattleArena2Test.cs @@ -211,7 +211,7 @@ public IAccountStateDelta JoinArena(IActionContext context, Address signer, Addr _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, @@ -306,7 +306,7 @@ public void Execute( var blockIndex = roundData.StartBlockIndex + nextBlockIndex; _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -414,7 +414,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -436,7 +436,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -458,7 +458,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -481,7 +481,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -503,7 +503,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -526,7 +526,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -572,7 +572,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -624,7 +624,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -677,7 +677,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -727,7 +727,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -788,7 +788,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/BattleArena3Test.cs b/.Lib9c.Tests/Action/BattleArena3Test.cs index b362516be8..27936fadae 100644 --- a/.Lib9c.Tests/Action/BattleArena3Test.cs +++ b/.Lib9c.Tests/Action/BattleArena3Test.cs @@ -211,7 +211,7 @@ public IAccountStateDelta JoinArena(IActionContext context, Address signer, Addr _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, @@ -306,7 +306,7 @@ public void Execute( var blockIndex = roundData.StartBlockIndex + nextBlockIndex; _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -414,7 +414,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -436,7 +436,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -458,7 +458,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -481,7 +481,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -503,7 +503,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -526,7 +526,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -572,7 +572,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -624,7 +624,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -677,7 +677,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -727,7 +727,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -788,7 +788,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/BattleArena4Test.cs b/.Lib9c.Tests/Action/BattleArena4Test.cs index e7188ab8d6..dfc8226ddb 100644 --- a/.Lib9c.Tests/Action/BattleArena4Test.cs +++ b/.Lib9c.Tests/Action/BattleArena4Test.cs @@ -211,7 +211,7 @@ public IAccountStateDelta JoinArena(IActionContext context, Address signer, Addr _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, @@ -306,7 +306,7 @@ public void Execute( _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -414,7 +414,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -436,7 +436,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -458,7 +458,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -481,7 +481,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -503,7 +503,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -526,7 +526,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -570,7 +570,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -620,7 +620,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -671,7 +671,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -719,7 +719,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -778,7 +778,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), })); @@ -837,7 +837,7 @@ public void Execute_CoolDownBlockException() var newState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = new TestRandom(), }); @@ -845,7 +845,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = blockIndex + 1, - PreviousStates = newState, + PreviousState = newState, Signer = _agent1Address, Random = new TestRandom(), })); @@ -925,7 +925,7 @@ public void Execute_v100291() var blockIndex = roundData.StartBlockIndex + 1; _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _agent1Address, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena5Test.cs b/.Lib9c.Tests/Action/BattleArena5Test.cs index 1bab467303..bb6eee0cda 100644 --- a/.Lib9c.Tests/Action/BattleArena5Test.cs +++ b/.Lib9c.Tests/Action/BattleArena5Test.cs @@ -208,7 +208,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -230,7 +230,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -253,7 +253,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -276,7 +276,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -298,7 +298,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -321,7 +321,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -382,7 +382,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -452,7 +452,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -520,7 +520,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -585,7 +585,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -664,7 +664,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -743,7 +743,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -751,7 +751,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -894,7 +894,7 @@ private void Execute( var blockIndex = roundData.StartBlockIndex + nextBlockIndex; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -999,7 +999,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena6Test.cs b/.Lib9c.Tests/Action/BattleArena6Test.cs index 2b06ecc562..d269eaabed 100644 --- a/.Lib9c.Tests/Action/BattleArena6Test.cs +++ b/.Lib9c.Tests/Action/BattleArena6Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -232,7 +232,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -255,7 +255,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -278,7 +278,7 @@ public void Execute_ActionObsoletedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -300,7 +300,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -323,7 +323,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -384,7 +384,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -454,7 +454,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -522,7 +522,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -587,7 +587,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -666,7 +666,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -750,7 +750,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -829,7 +829,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -837,7 +837,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -980,7 +980,7 @@ private void Execute( var blockIndex = roundData.StartBlockIndex + nextBlockIndex; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1085,7 +1085,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena7Test.cs b/.Lib9c.Tests/Action/BattleArena7Test.cs index 484d84f6ad..7af91c4702 100644 --- a/.Lib9c.Tests/Action/BattleArena7Test.cs +++ b/.Lib9c.Tests/Action/BattleArena7Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -993,7 +993,7 @@ private void Execute( var blockIndex = roundData.StartBlockIndex + nextBlockIndex; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1098,7 +1098,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena8Test.cs b/.Lib9c.Tests/Action/BattleArena8Test.cs index 8160f19e74..28b4ecd60c 100644 --- a/.Lib9c.Tests/Action/BattleArena8Test.cs +++ b/.Lib9c.Tests/Action/BattleArena8Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -918,7 +918,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -971,7 +971,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -1058,7 +1058,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -1203,7 +1203,7 @@ private void Execute( : roundData.StartBlockIndex + arenaInterval; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1308,7 +1308,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleArena9Test.cs b/.Lib9c.Tests/Action/BattleArena9Test.cs index fbe60e4588..a61ec0ba6f 100644 --- a/.Lib9c.Tests/Action/BattleArena9Test.cs +++ b/.Lib9c.Tests/Action/BattleArena9Test.cs @@ -210,7 +210,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -233,7 +233,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -257,7 +257,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent4Address, Random = new TestRandom(), BlockIndex = 1, @@ -281,7 +281,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -304,7 +304,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 4480001, @@ -328,7 +328,7 @@ public void Execute_ArenaParticipantsNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -390,7 +390,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, @@ -461,7 +461,7 @@ public void Execute_ValidateScoreDifferenceException(bool isSigner) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void Execute_ExceedPlayCountException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_ExceedTicketPurchaseLimitException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void Execute_ExceedTicketPurchaseLimitDuringIntervalException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -841,7 +841,7 @@ public void Execute_CoolDownBlockException() var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -849,7 +849,7 @@ public void Execute_CoolDownBlockException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex + 1, - PreviousStates = nextStates, + PreviousState = nextStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -918,7 +918,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 previousStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), }); @@ -971,7 +971,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = random, Rehearsal = false, @@ -1058,7 +1058,7 @@ public void Execute_ValidateDuplicateTicketPurchaseException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -1203,7 +1203,7 @@ private void Execute( : roundData.StartBlockIndex + arenaInterval; var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAgentAddress, Random = random, Rehearsal = false, @@ -1308,7 +1308,7 @@ private IAccountStateDelta JoinArena( states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs index c22e37f7c9..a4302e7c5c 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs @@ -208,14 +208,14 @@ public void Execute_AlreadyFoughtAvatarException() var next = action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, }); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = next, + PreviousState = next, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 2, @@ -236,7 +236,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -256,7 +256,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -276,7 +276,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -299,7 +299,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = blockIndex, @@ -347,7 +347,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAvatar.agentAddress, Random = new TestRandom(), BlockIndex = row.StartBlockIndex, @@ -426,7 +426,7 @@ private void Execute(long blockIndex, int grandFinaleId, int randomSeed, Address { Signer = myAgentAddr, BlockIndex = blockIndex, - PreviousStates = states, + PreviousState = states, Random = new TestRandom(randomSeed), }); Assert.True(nextStates.TryGetState( diff --git a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs index 72d070084c..480fb2b3fa 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs @@ -208,14 +208,14 @@ public void Execute_AlreadyFoughtAvatarException() var next = action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, }); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = next, + PreviousState = next, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 2, @@ -236,7 +236,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -256,7 +256,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -276,7 +276,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -299,7 +299,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = blockIndex, @@ -347,7 +347,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAvatar.agentAddress, Random = new TestRandom(), BlockIndex = row.StartBlockIndex, @@ -426,7 +426,7 @@ private void Execute(long blockIndex, int grandFinaleId, int randomSeed, Address { Signer = myAgentAddr, BlockIndex = blockIndex, - PreviousStates = states, + PreviousState = states, Random = new TestRandom(randomSeed), }); Assert.True(nextStates.TryGetState( diff --git a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs index a547ee9d66..443c42faad 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs @@ -208,14 +208,14 @@ public void Execute_AlreadyFoughtAvatarException() var next = action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 1, }); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = next, + PreviousState = next, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = 2, @@ -236,7 +236,7 @@ public void Execute_InvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -256,7 +256,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -276,7 +276,7 @@ public void Execute_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), })); @@ -299,7 +299,7 @@ public void Execute_ThisArenaIsClosedException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agent1Address, Random = new TestRandom(), BlockIndex = blockIndex, @@ -347,7 +347,7 @@ public void Execute_AddressNotFoundInArenaParticipantsException(bool excludeMe) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = myAvatar.agentAddress, Random = new TestRandom(), BlockIndex = row.StartBlockIndex, @@ -426,7 +426,7 @@ private void Execute(long blockIndex, int grandFinaleId, int randomSeed, Address { Signer = myAgentAddr, BlockIndex = blockIndex, - PreviousStates = states, + PreviousState = states, Random = new TestRandom(randomSeed), }); Assert.True(nextStates.TryGetState( diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 6836652219..5fbf10648e 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -331,7 +331,7 @@ public void Execute(params OrderData[] orderDataList) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -457,7 +457,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty Assert.Throws(exc, () => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -575,7 +575,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) IAccountStateDelta nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -700,7 +700,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -809,13 +809,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _buyerAgentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -857,7 +857,7 @@ public void Execute_With_Testbed() nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = nextState, + PreviousState = nextState, Random = new TestRandom(), Rehearsal = false, Signer = result.GetAgentState().address, diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index 1525320e82..88b5a592f0 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -337,7 +337,7 @@ public void Execute(params OrderData[] orderDataList) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -463,7 +463,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty Assert.Throws(exc, () => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -581,7 +581,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) IAccountStateDelta nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -706,7 +706,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -815,13 +815,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _buyerAgentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -866,7 +866,7 @@ public void Execute_With_Testbed() nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = nextState, + PreviousState = nextState, Random = new TestRandom(), Rehearsal = false, Signer = result.GetAgentState().address, @@ -985,7 +985,7 @@ public void Execute_ActionObsoletedException() buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = nextState, + PreviousState = nextState, Random = new TestRandom(), Rehearsal = false, Signer = result.GetAgentState().address, diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index 7d419b3afc..277c38c9b1 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -150,7 +150,7 @@ public void Execute() var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index eb269ea0d3..35a191c62f 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -164,7 +164,7 @@ public void Execute() var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -208,7 +208,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -229,7 +229,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -260,7 +260,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -281,7 +281,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -312,7 +312,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index 2373548a4e..8d4ffdc0e3 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -183,7 +183,7 @@ public void Execute() var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -232,7 +232,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -253,7 +253,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -284,7 +284,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -305,7 +305,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -336,7 +336,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index 956bdff14b..569f1e65e6 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -259,7 +259,7 @@ public void Execute(params ShopItemData[] shopItemMembers) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -336,7 +336,7 @@ public void Execute_ErrorCode_InvalidAddress() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -366,7 +366,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -402,7 +402,7 @@ public void Execute_Throw_NotEnoughClearedStageLevel() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -428,7 +428,7 @@ public void Execute_ErrorCode_ItemDoesNotExist() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -481,7 +481,7 @@ public void Execute_ErrorCode_InsufficientBalance() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -533,7 +533,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -583,7 +583,7 @@ public void Execute_ErrorCode_ShopItemExpired() action.Execute(new ActionContext() { BlockIndex = 11, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index ab9a372098..6473ca1935 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -319,7 +319,7 @@ out _ var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -414,7 +414,7 @@ public void Execute_ErrorCode_InvalidAddress() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -444,7 +444,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -480,7 +480,7 @@ public void Execute_Throw_NotEnoughClearedStageLevel() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -506,7 +506,7 @@ public void Execute_ErrorCode_ItemDoesNotExist() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -555,7 +555,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_Material(ItemSubType itemSubType) action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -607,7 +607,7 @@ public void Execute_ErrorCode_InsufficientBalance() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -689,7 +689,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar(ItemType itemType action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -739,7 +739,7 @@ public void Execute_ErrorCode_ShopItemExpired() action.Execute(new ActionContext() { BlockIndex = 11, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index 26ae35a716..8404cdffff 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -320,7 +320,7 @@ out _ var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -415,7 +415,7 @@ public void Execute_ErrorCode_InvalidAddress() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -445,7 +445,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -481,7 +481,7 @@ public void Execute_Throw_NotEnoughClearedStageLevel() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -507,7 +507,7 @@ public void Execute_ErrorCode_ItemDoesNotExist() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -556,7 +556,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_Material(ItemSubType itemSubType) action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -626,7 +626,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_20210604(ItemSubType itemSubType, action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -679,7 +679,7 @@ public void Execute_ErrorCode_InsufficientBalance() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -762,7 +762,7 @@ public void Execute_ErrorCode_ItemDoesNotExist_By_SellerAvatar(ItemType itemType var nextState = action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -819,7 +819,7 @@ public void Execute_ErrorCode_ShopItemExpired() action.Execute(new ActionContext() { BlockIndex = 11, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -872,7 +872,7 @@ public void Execute_ErrorCode_InvalidPrice(int shopPrice, int price) action.Execute(new ActionContext() { BlockIndex = 10, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index d7758d41cc..2d33969982 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -305,7 +305,7 @@ out _ var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -431,7 +431,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty Assert.Throws(exc, () => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -532,7 +532,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) IAccountStateDelta nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -591,13 +591,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _buyerAgentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private (AvatarState AvatarState, AgentState AgentState) CreateAvatarState( diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index 83a7f6371a..cf6d11f757 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -403,7 +403,7 @@ out _ var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -529,7 +529,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty Assert.Throws(exc, () => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -631,7 +631,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) IAccountStateDelta nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -690,13 +690,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _buyerAgentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private (AvatarState AvatarState, AgentState AgentState) CreateAvatarState( diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index 6927686480..f486e7a4f4 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -336,7 +336,7 @@ public void Execute(params ShopItemData[] productDatas) var nextState = buyMultipleAction.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -410,7 +410,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -429,7 +429,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -458,7 +458,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -476,7 +476,7 @@ public void ExecuteThrowItemDoesNotExistErrorByEmptyCollection() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -546,7 +546,7 @@ public void ExecuteInsufficientBalanceError() action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -600,7 +600,7 @@ public void ExecuteThrowShopItemExpiredError() action.Execute(new ActionContext() { BlockIndex = 11, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -657,7 +657,7 @@ public void SerializeWithDotnetAPI() action.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Signer = _buyerAgentAddress, }); diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index a1bdf61d5e..f387e8f7ed 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -304,7 +304,7 @@ public void Execute_Throw_Exception(params ExecuteMember[] validateMembers) }; Assert.Throws(validateMember.Exc, () => action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Random = new TestRandom(), Signer = BuyerAgentAddress, })); diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index 18e6ac5845..eeeba5cc94 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -304,7 +304,7 @@ public void Execute_Throw_Exception(params ExecuteMember[] validateMembers) }; Assert.Throws(validateMember.Exc, () => action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Random = new TestRandom(), Signer = BuyerAgentAddress, })); diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index 353acfad03..64c78afc61 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -346,7 +346,7 @@ public void Execute(params OrderData[] orderDataList) var expectedState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -360,7 +360,7 @@ public void Execute(params OrderData[] orderDataList) var actualState = buyProductAction.Execute(new ActionContext { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -491,7 +491,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty Assert.Throws(exc, () => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -621,7 +621,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) IAccountStateDelta nextState = action.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, }); @@ -655,7 +655,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember) Assert.Throws(exc, () => buyProductAction.Execute(new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _buyerAgentAddress, })); @@ -775,7 +775,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList) var nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _buyerAgentAddress, @@ -883,7 +883,7 @@ public void Execute_With_Testbed() nextState = buyAction.Execute(new ActionContext() { BlockIndex = 100, - PreviousStates = nextState, + PreviousState = nextState, Random = new TestRandom(), Rehearsal = false, Signer = result.GetAgentState().address, diff --git a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs index 5fe1816736..3fce08f27c 100644 --- a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs @@ -78,7 +78,7 @@ public void Execute(int prevLevel, int collectionLevel, long blockIndex) IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = blockIndex, }); @@ -107,7 +107,7 @@ public void Execute_Throw_FailedLoadStateException_AgentState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = new PrivateKey().ToAddress(), BlockIndex = 0, }) @@ -125,7 +125,7 @@ public void Execute_Throw_FailedLoadStateException_MonsterCollectionState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -151,7 +151,7 @@ public void Execute_Throw_InvalidLevelException(int prevLevel, int level) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -181,7 +181,7 @@ public void Execute_Throw_MonsterCollectionExpiredException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -204,7 +204,7 @@ public void Execute_Throw_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs index 704f9deca3..f14baefb02 100644 --- a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs +++ b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs @@ -119,7 +119,7 @@ bool invalidAgentAddress { Signer = _agentAddress, BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), }; Assert.Throws(() => action.Execute(actionContext)); @@ -146,7 +146,7 @@ public void Execute_Throw_ProductNotFoundException() }; var nexState = registerProduct.Execute(new ActionContext { - PreviousStates = prevState, + PreviousState = prevState, BlockIndex = 1L, Signer = _agentAddress, Random = new TestRandom(), @@ -186,7 +186,7 @@ public void Execute_Throw_ProductNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = nexState, + PreviousState = nexState, BlockIndex = 2L, Signer = _agentAddress, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs b/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs index edb2c5d471..46cb038aff 100644 --- a/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs +++ b/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs @@ -71,7 +71,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs index d195c5cef3..dbbae9e209 100644 --- a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs +++ b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs @@ -89,7 +89,7 @@ public void Execute(bool useTradable) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -111,7 +111,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Signer = default, }) @@ -144,7 +144,7 @@ public void Execute_Throw_NotEnoughMaterialException(bool useTradable) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/ChargeActionPointTest.cs b/.Lib9c.Tests/Action/ChargeActionPointTest.cs index d40363a2c1..11e2df6d23 100644 --- a/.Lib9c.Tests/Action/ChargeActionPointTest.cs +++ b/.Lib9c.Tests/Action/ChargeActionPointTest.cs @@ -106,7 +106,7 @@ public void Execute(bool useTradable, bool backward) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -162,7 +162,7 @@ public void Execute_Throw_Exception(bool useAvatarAddress, bool useTradable, boo Assert.Throws(exc, () => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -190,13 +190,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs index a45b46d9a7..b59762101f 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs @@ -145,7 +145,7 @@ public void Execute(int rewardLevel, int prevRewardLevel, int collectionLevel) IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = rewardLevel * MonsterCollectionState0.RewardInterval, Random = new TestRandom(), @@ -195,7 +195,7 @@ public void Execute_Throw_FailedLoadStateException_AgentState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = new PrivateKey().ToAddress(), BlockIndex = 0, }) @@ -213,7 +213,7 @@ public void Execute_Throw_FailedLoadStateException_MonsterCollectionState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -238,7 +238,7 @@ public void Execute_Throw_MonsterCollectionExpiredException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -266,7 +266,7 @@ public void Execute_Throw_RequiredBlockIndexException(long startedBlockIndex, lo Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = blockIndex, }) @@ -289,7 +289,7 @@ public void Execute_Throw_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = MonsterCollectionState0.ExpirationIndex, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs index ff366908a8..6ae2b7e6ac 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs @@ -104,7 +104,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo { action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = claimBlockIndex, Random = new TestRandom(), @@ -115,7 +115,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = claimBlockIndex, Random = new TestRandom(), @@ -156,7 +156,7 @@ public void Execute_Throw_FailedLoadStateException_AgentState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = new PrivateKey().ToAddress(), BlockIndex = 0, }) @@ -173,7 +173,7 @@ public void Execute_Throw_FailedLoadStateException_MonsterCollectionState() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -194,7 +194,7 @@ public void Execute_Throw_RequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -211,7 +211,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, BlockIndex = 0, Rehearsal = true, @@ -229,7 +229,7 @@ public void Rehearsal() MonsterCollectionState.DeriveAddress(_signer, 2), MonsterCollectionState.DeriveAddress(_signer, 3), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private class ExecuteFixture : IEnumerable diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs index 41f013c2a8..c38af8b78d 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs @@ -102,7 +102,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo { Assert.Throws(exc, () => _action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = claimBlockIndex, Random = new TestRandom(), @@ -112,7 +112,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long? receivedBlo { IAccountStateDelta nextState = _action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = claimBlockIndex, Random = new TestRandom(), @@ -148,7 +148,7 @@ public void Execute_Throw_FailedLoadStateException_AgentState() { Assert.Throws(() => _action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = new PrivateKey().ToAddress(), BlockIndex = 0, }) @@ -160,7 +160,7 @@ public void Execute_Throw_FailedLoadStateException_MonsterCollectionState() { Assert.Throws(() => _action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -176,7 +176,7 @@ public void Execute_Throw_RequiredBlockIndexException() Assert.Throws(() => _action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = _signer, BlockIndex = 0, }) @@ -188,7 +188,7 @@ public void Rehearsal() { IAccountStateDelta nextState = _action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, BlockIndex = 0, Rehearsal = true, @@ -206,7 +206,7 @@ public void Rehearsal() MonsterCollectionState.DeriveAddress(_signer, 2), MonsterCollectionState.DeriveAddress(_signer, 3), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private class ExecuteFixture : IEnumerable diff --git a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs index b7160130b1..7b96725f0f 100644 --- a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs @@ -90,7 +90,7 @@ public void Execute(Type exc, int rank, int latestRank) Signer = agentAddress, BlockIndex = 5055201L, Random = new TestRandom(randomSeed), - PreviousStates = state, + PreviousState = state, }); var crystalCurrency = CrystalCalculator.CRYSTAL; @@ -117,7 +117,7 @@ public void Execute(Type exc, int rank, int latestRank) Signer = default, BlockIndex = 5055201L, Random = new TestRandom(randomSeed), - PreviousStates = state, + PreviousState = state, })); } } diff --git a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs index 9bbbbd83d9..4474248615 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs @@ -88,7 +88,7 @@ public void Execute() var action = new ClaimStakeReward1(_avatarAddress); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval, }); diff --git a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs index e2ffa91f3b..951940671d 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs @@ -131,7 +131,7 @@ public void Execute_Throw_ActionObsoletedException() var action = new ClaimStakeReward2(_avatarAddress); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = ClaimStakeReward2.ObsoletedIndex + 1, })); @@ -159,7 +159,7 @@ private void Execute(Address avatarAddress, bool useOldTable) var action = new ClaimStakeReward2(avatarAddress); var states = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval, }); diff --git a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs index 83584ed401..25f28b1f64 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward3Test.cs @@ -56,7 +56,7 @@ public void Execute_Throw_ActionUnAvailableException(long blockIndex) var action = new ClaimStakeReward3(_avatarAddr); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialStatesWithAvatarStateV2, + PreviousState = _initialStatesWithAvatarStateV2, Signer = _agentAddr, BlockIndex = blockIndex, })); @@ -213,7 +213,7 @@ private void Execute( var action = new ClaimStakeReward3(avatarAddr); var states = action.Execute(new ActionContext { - PreviousStates = prevState, + PreviousState = prevState, Signer = agentAddr, BlockIndex = blockIndex, }); diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index 2403af0775..901dc2d5bc 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -238,7 +238,7 @@ private void Execute( var action = new ClaimStakeReward(avatarAddr); var states = action.Execute(new ActionContext { - PreviousStates = prevState, + PreviousState = prevState, Signer = agentAddr, BlockIndex = blockIndex, }); diff --git a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs index a739e4796d..76e02e8cb2 100644 --- a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs @@ -88,7 +88,7 @@ public void Execute(long blockIndex, Type exc) { BlockIndex = blockIndex, Signer = agentAddress, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), }); @@ -125,7 +125,7 @@ public void Execute(long blockIndex, Type exc) { BlockIndex = blockIndex, Signer = default, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), })); } diff --git a/.Lib9c.Tests/Action/CombinationConsumable0Test.cs b/.Lib9c.Tests/Action/CombinationConsumable0Test.cs index 5544fcf22b..9e52bce9d1 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable0Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable0Test.cs @@ -93,7 +93,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -119,7 +119,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -142,7 +142,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -172,7 +172,7 @@ public void ExecuteThrowCombinationSlotUnlockException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -202,7 +202,7 @@ public void ExecuteThrowSheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -234,7 +234,7 @@ public void ExecuteThrowNotEnoughMaterialException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs index c452e341ae..33a66af8b2 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs @@ -117,7 +117,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs index 2ae6254206..d7a0f58f72 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs @@ -117,7 +117,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs index b4667ed871..31c6d1f06d 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs @@ -117,7 +117,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs index 515b8132ac..c616dc6c9a 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs @@ -117,7 +117,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs index 813effb37c..f0679812fa 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs @@ -131,7 +131,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs index 7c6a26d9ac..e7bb05bc7c 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs @@ -129,7 +129,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumableTest.cs b/.Lib9c.Tests/Action/CombinationConsumableTest.cs index 97a33ef9be..8c61a55536 100644 --- a/.Lib9c.Tests/Action/CombinationConsumableTest.cs +++ b/.Lib9c.Tests/Action/CombinationConsumableTest.cs @@ -123,7 +123,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs index abc7a2cea8..7a073c0065 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs @@ -107,7 +107,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -160,7 +160,7 @@ public void ExecuteWithSubRecipe() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -185,7 +185,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -236,7 +236,7 @@ public void ExecuteThrowCombinationSlotUnlockException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -273,7 +273,7 @@ public void ExecuteThrowSheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -321,7 +321,7 @@ public void ExecuteThrowSheetRowColumnException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -358,7 +358,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -392,7 +392,7 @@ public void ExecuteThrowNotEnoughMaterialException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs index 1f80bd487f..20e3778265 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs @@ -145,13 +145,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -242,7 +242,7 @@ public void MadeWithMimisbrunnrRecipe( var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -337,7 +337,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs index 45126abd86..c2a7db0c67 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs @@ -152,13 +152,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -249,7 +249,7 @@ public void MadeWithMimisbrunnrRecipe( var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -344,7 +344,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -396,7 +396,7 @@ private void Execute_ActionObsoletedException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs index e33b433d63..54a7e319ea 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs @@ -296,7 +296,7 @@ bool previousCostStateExist { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -367,7 +367,7 @@ bool previousCostStateExist { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs index 33b2121828..7c53244f65 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs @@ -292,7 +292,7 @@ bool previousCostStateExist { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -363,7 +363,7 @@ bool previousCostStateExist { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -462,7 +462,7 @@ public void ExecuteBySuperCraft( { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -490,7 +490,7 @@ public void ExecuteBySuperCraft( { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs index c7d747dfeb..62f09d921f 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs @@ -293,7 +293,7 @@ bool previousCostStateExist { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -364,7 +364,7 @@ bool previousCostStateExist { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -469,7 +469,7 @@ public void ExecuteBySuperCraft( { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -497,7 +497,7 @@ public void ExecuteBySuperCraft( { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs index 0b83fd83ae..cb7f0fcc1f 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs @@ -293,7 +293,7 @@ bool previousCostStateExist { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -364,7 +364,7 @@ bool previousCostStateExist { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -469,7 +469,7 @@ public void ExecuteBySuperCraft( { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -497,7 +497,7 @@ public void ExecuteBySuperCraft( { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs index c1f47d91f3..96765f2ac7 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs @@ -126,7 +126,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs index ea6fb31ac2..a4bd913f7e 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs @@ -139,7 +139,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -205,7 +205,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs index 74bbbf22b1..360da2243d 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs @@ -139,7 +139,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -204,7 +204,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs index 72a438d6d9..70ff103179 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs @@ -139,7 +139,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -204,7 +204,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs index d183ac7606..8fb6a7c97a 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs @@ -154,7 +154,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -219,7 +219,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -258,13 +258,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] diff --git a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs index 55110d3472..1df708dc1f 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs @@ -155,7 +155,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -218,7 +218,7 @@ public void ExecuteThrowInsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -257,13 +257,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] diff --git a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs index 161b20db56..27042fbb16 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs @@ -144,13 +144,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -246,7 +246,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs index 88f52f5247..073b42e59e 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs @@ -144,13 +144,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -246,7 +246,7 @@ private void Execute(bool backward, int recipeId, int? subRecipeId, int mintNCG) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs index 9e29f33a05..c4bc27532b 100644 --- a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs +++ b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs @@ -295,7 +295,7 @@ bool previousCostStateExist { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -366,7 +366,7 @@ bool previousCostStateExist { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = blockIndex, Random = _random, @@ -471,7 +471,7 @@ public void ExecuteWithCheckingHammerPointState( { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -499,7 +499,7 @@ public void ExecuteWithCheckingHammerPointState( { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs b/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs index 794e5fd782..b4eabefc01 100644 --- a/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs +++ b/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs @@ -32,7 +32,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Random = random, BlockIndex = long.MaxValue, @@ -46,7 +46,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Random = random, BlockIndex = 0, @@ -61,7 +61,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Random = random, BlockIndex = 0, @@ -79,7 +79,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = true, Random = random, BlockIndex = 0, @@ -95,7 +95,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Random = random, BlockIndex = 0, @@ -109,7 +109,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Random = random, BlockIndex = 0, diff --git a/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs b/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs index 22305158ba..08f9808496 100644 --- a/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs +++ b/.Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs @@ -46,7 +46,7 @@ public void Execute() agent1Avatar0Address, new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, BlockIndex = 0, }, @@ -57,7 +57,7 @@ public void Execute() agent1Avatar1Address, new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, BlockIndex = 0, }, @@ -68,7 +68,7 @@ public void Execute() agent2Avatar0Address, new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress2, BlockIndex = 0, }, @@ -116,7 +116,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -145,7 +145,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = true, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -181,7 +181,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -197,7 +197,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -216,7 +216,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -236,7 +236,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -254,7 +254,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -276,7 +276,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -293,7 +293,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, @@ -313,7 +313,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress2, Random = random, @@ -335,7 +335,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Rehearsal = false, Signer = CouponsFixture.AgentAddress1, Random = random, diff --git a/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs b/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs index 18b0dfc1fd..0d00c7a419 100644 --- a/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs +++ b/.Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs @@ -40,7 +40,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, })); @@ -53,7 +53,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress2, Rehearsal = false, })); @@ -68,7 +68,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, })); @@ -82,7 +82,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, }); @@ -95,7 +95,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, }); @@ -110,7 +110,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, }); @@ -130,7 +130,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, })); @@ -159,7 +159,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = true, }); @@ -187,7 +187,7 @@ public void Execute() .Execute( new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = CouponsFixture.AgentAddress1, Rehearsal = false, }); diff --git a/.Lib9c.Tests/Action/CreateAvatar0Test.cs b/.Lib9c.Tests/Action/CreateAvatar0Test.cs index bdd8ddb722..e40a67340e 100644 --- a/.Lib9c.Tests/Action/CreateAvatar0Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar0Test.cs @@ -73,7 +73,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -116,7 +116,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -150,7 +150,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -177,7 +177,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -207,7 +207,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -260,7 +260,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -268,7 +268,7 @@ public void Rehearsal() Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreateAvatar2Test.cs b/.Lib9c.Tests/Action/CreateAvatar2Test.cs index fcd6c14fa9..a7abf239ae 100644 --- a/.Lib9c.Tests/Action/CreateAvatar2Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar2Test.cs @@ -70,7 +70,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -119,7 +119,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -160,7 +160,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -186,7 +186,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -222,7 +222,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -283,7 +283,7 @@ public void Rehearsal(int index) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -291,7 +291,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreateAvatar3Test.cs b/.Lib9c.Tests/Action/CreateAvatar3Test.cs index 90ed01cc47..ac718284b9 100644 --- a/.Lib9c.Tests/Action/CreateAvatar3Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar3Test.cs @@ -71,7 +71,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -121,7 +121,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -162,7 +162,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -188,7 +188,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -224,7 +224,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -288,7 +288,7 @@ public void Rehearsal(int index) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -296,7 +296,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreateAvatar6Test.cs b/.Lib9c.Tests/Action/CreateAvatar6Test.cs index 09e26ae24e..acca5bed8a 100644 --- a/.Lib9c.Tests/Action/CreateAvatar6Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar6Test.cs @@ -71,7 +71,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -121,7 +121,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -162,7 +162,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -188,7 +188,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -224,7 +224,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -288,7 +288,7 @@ public void Rehearsal(int index) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -296,7 +296,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreateAvatar7Test.cs b/.Lib9c.Tests/Action/CreateAvatar7Test.cs index 4363845ca4..4ba6d43537 100644 --- a/.Lib9c.Tests/Action/CreateAvatar7Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar7Test.cs @@ -58,7 +58,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -102,7 +102,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -143,7 +143,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -169,7 +169,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -205,7 +205,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -265,7 +265,7 @@ public void Rehearsal(int index) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -273,7 +273,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreateAvatarTest.cs b/.Lib9c.Tests/Action/CreateAvatarTest.cs index df9a685203..621a851a6b 100644 --- a/.Lib9c.Tests/Action/CreateAvatarTest.cs +++ b/.Lib9c.Tests/Action/CreateAvatarTest.cs @@ -56,7 +56,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -101,7 +101,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -142,7 +142,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -168,7 +168,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -204,7 +204,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -264,7 +264,7 @@ public void Rehearsal(int index) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -272,7 +272,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs index 7f5afe4c0c..009411fec0 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs @@ -30,7 +30,7 @@ public void Execute() var actionContext = new ActionContext() { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, }; @@ -60,7 +60,7 @@ public void CheckPermission() () => action.Execute(new ActionContext() { BlockIndex = 101, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, }) ); @@ -69,7 +69,7 @@ public void CheckPermission() () => action.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = default, }) ); @@ -90,12 +90,12 @@ public void Rehearsal() BlockIndex = 101, Signer = default, Rehearsal = true, - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), } ); Assert.Equal( ImmutableHashSet.Create(pendingActivation.address), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } } diff --git a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs index ab3c32e71f..f26b858081 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs @@ -34,7 +34,7 @@ PendingActivationState CreatePendingActivation() var actionContext = new ActionContext() { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, }; @@ -87,7 +87,7 @@ public void CheckPermission() () => action.Execute(new ActionContext() { BlockIndex = 101, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, }) ); @@ -96,7 +96,7 @@ public void CheckPermission() () => action.Execute(new ActionContext() { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = default, }) ); diff --git a/.Lib9c.Tests/Action/CreatePledgeTest.cs b/.Lib9c.Tests/Action/CreatePledgeTest.cs index af3a91c998..e269a20bf4 100644 --- a/.Lib9c.Tests/Action/CreatePledgeTest.cs +++ b/.Lib9c.Tests/Action/CreatePledgeTest.cs @@ -60,7 +60,7 @@ public void Execute(bool admin, Type exc) var actionContext = new ActionContext { Signer = singer, - PreviousStates = states, + PreviousState = states, }; if (exc is null) diff --git a/.Lib9c.Tests/Action/DailyReward0Test.cs b/.Lib9c.Tests/Action/DailyReward0Test.cs index cdc9823995..4a3a250040 100644 --- a/.Lib9c.Tests/Action/DailyReward0Test.cs +++ b/.Lib9c.Tests/Action/DailyReward0Test.cs @@ -65,7 +65,7 @@ public void Execute() var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Rehearsal = false, Signer = _agentAddress, }); @@ -85,7 +85,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward2Test.cs b/.Lib9c.Tests/Action/DailyReward2Test.cs index 2869605f71..65072cec81 100644 --- a/.Lib9c.Tests/Action/DailyReward2Test.cs +++ b/.Lib9c.Tests/Action/DailyReward2Test.cs @@ -67,7 +67,7 @@ public void Execute() var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -98,7 +98,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward3Test.cs b/.Lib9c.Tests/Action/DailyReward3Test.cs index 40aeca93d9..5a3d3ca8ae 100644 --- a/.Lib9c.Tests/Action/DailyReward3Test.cs +++ b/.Lib9c.Tests/Action/DailyReward3Test.cs @@ -67,7 +67,7 @@ public void Execute() var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -98,7 +98,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward4Test.cs b/.Lib9c.Tests/Action/DailyReward4Test.cs index e9e02e410c..529280f8e2 100644 --- a/.Lib9c.Tests/Action/DailyReward4Test.cs +++ b/.Lib9c.Tests/Action/DailyReward4Test.cs @@ -82,7 +82,7 @@ public void Execute(bool backward) var nextState = dailyRewardAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -113,7 +113,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) @@ -131,7 +131,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -145,7 +145,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/DailyReward5Test.cs b/.Lib9c.Tests/Action/DailyReward5Test.cs index 64c74048d1..c58fa24790 100644 --- a/.Lib9c.Tests/Action/DailyReward5Test.cs +++ b/.Lib9c.Tests/Action/DailyReward5Test.cs @@ -70,7 +70,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -81,7 +81,7 @@ public void Rehearsal() _avatarAddress, }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -163,7 +163,7 @@ private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, lo return dailyRewardAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/DailyReward6Test.cs b/.Lib9c.Tests/Action/DailyReward6Test.cs index 3b10970c8c..1f01d06695 100644 --- a/.Lib9c.Tests/Action/DailyReward6Test.cs +++ b/.Lib9c.Tests/Action/DailyReward6Test.cs @@ -72,7 +72,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -86,7 +86,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -191,7 +191,7 @@ private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, lo return dailyRewardAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/DailyRewardTest.cs b/.Lib9c.Tests/Action/DailyRewardTest.cs index f072dc0806..2dd166a355 100644 --- a/.Lib9c.Tests/Action/DailyRewardTest.cs +++ b/.Lib9c.Tests/Action/DailyRewardTest.cs @@ -70,13 +70,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, }); - var updatedAddress = Assert.Single(nextState.UpdatedAddresses); + var updatedAddress = Assert.Single(nextState.Delta.UpdatedAddresses); Assert.Equal(_avatarAddress, updatedAddress); } @@ -183,7 +183,7 @@ private IAccountStateDelta ExecuteInternal(IAccountStateDelta previousStates, lo return dailyRewardAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/EndPledgeTest.cs b/.Lib9c.Tests/Action/EndPledgeTest.cs index 36fefd4e7e..9cb4b7de06 100644 --- a/.Lib9c.Tests/Action/EndPledgeTest.cs +++ b/.Lib9c.Tests/Action/EndPledgeTest.cs @@ -35,7 +35,7 @@ public void Execute(int balance) var nextState = action.Execute(new ActionContext { Signer = patron, - PreviousStates = states, + PreviousState = states, }); Assert.Equal(Null.Value, nextState.GetState(agent.GetPledgeAddress())); Assert.Equal(mead * 0, nextState.GetBalance(agent, mead)); @@ -63,7 +63,7 @@ public void Execute_Throw_Exception(bool invalidSigner, bool invalidAgent, Type Assert.Throws(exc, () => action.Execute(new ActionContext { Signer = invalidSigner ? new PrivateKey().ToAddress() : patron, - PreviousStates = states, + PreviousState = states, })); } } diff --git a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs index 4418823fa3..29fb65fc43 100644 --- a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs @@ -154,7 +154,7 @@ private void Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs index c6753e88fb..bd0314b478 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs @@ -410,7 +410,7 @@ private IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs index 0ef33428a9..16ca596626 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs @@ -423,7 +423,7 @@ private IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs index 2bb3b49f87..9c952d5793 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs @@ -423,7 +423,7 @@ private IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs index beb6de5b48..c65500b7af 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs @@ -367,7 +367,7 @@ public void Execute_DuplicatedException(int slotIndex, int runeId, int slotIndex _initialStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agentAddress, Random = new TestRandom(), }); @@ -471,7 +471,7 @@ private IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs index f863d3e9f2..06b3031652 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs @@ -368,7 +368,7 @@ public void Execute_DuplicatedException(int slotIndex, int runeId, int slotIndex _initialStates = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = _initialStates, + PreviousState = _initialStates, Signer = _agentAddress, Random = new TestRandom(), }); @@ -472,7 +472,7 @@ private IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs index 241306c86d..f4dcc9f187 100644 --- a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs @@ -263,7 +263,7 @@ private void Execute( var nextStates = action.Execute(new ActionContext { - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index 67c9921b15..faeeb3d95a 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -211,7 +211,7 @@ Type exc { var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -237,7 +237,7 @@ Type exc { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/HackAndSlash0Test.cs b/.Lib9c.Tests/Action/HackAndSlash0Test.cs index ffe09f602c..7825cb7aa4 100644 --- a/.Lib9c.Tests/Action/HackAndSlash0Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash0Test.cs @@ -116,7 +116,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -161,7 +161,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -189,7 +189,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -218,7 +218,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -249,7 +249,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -281,7 +281,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -321,7 +321,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -352,7 +352,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -398,7 +398,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -430,7 +430,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -475,7 +475,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -521,7 +521,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -558,7 +558,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -595,13 +595,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -621,7 +621,7 @@ public void SerializeWithDotnetAPI() action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash10Test.cs b/.Lib9c.Tests/Action/HackAndSlash10Test.cs index 575f6d07d5..72fb4462fc 100644 --- a/.Lib9c.Tests/Action/HackAndSlash10Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash10Test.cs @@ -230,7 +230,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -317,7 +317,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId, int playCount // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -371,7 +371,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -434,7 +434,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -461,7 +461,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -499,7 +499,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -524,7 +524,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -551,7 +551,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -579,7 +579,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -615,7 +615,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -642,7 +642,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -684,7 +684,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -712,7 +712,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -754,7 +754,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -799,7 +799,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -832,7 +832,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -890,7 +890,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1054,7 +1054,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1132,13 +1132,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash11Test.cs b/.Lib9c.Tests/Action/HackAndSlash11Test.cs index 729247fb42..b5dbc9ca31 100644 --- a/.Lib9c.Tests/Action/HackAndSlash11Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash11Test.cs @@ -228,7 +228,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -305,7 +305,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId, int playCount // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -358,7 +358,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -420,7 +420,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -457,7 +457,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -481,7 +481,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -507,7 +507,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -534,7 +534,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -569,7 +569,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -595,7 +595,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -636,7 +636,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -663,7 +663,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -704,7 +704,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -748,7 +748,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -780,7 +780,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -837,7 +837,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1000,7 +1000,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1076,13 +1076,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash12Test.cs b/.Lib9c.Tests/Action/HackAndSlash12Test.cs index ad41e802f3..0c26db2355 100644 --- a/.Lib9c.Tests/Action/HackAndSlash12Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash12Test.cs @@ -202,7 +202,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -279,7 +279,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId, int playCount // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -342,7 +342,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -404,7 +404,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -441,7 +441,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -465,7 +465,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -491,7 +491,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -518,7 +518,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -553,7 +553,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -579,7 +579,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -620,7 +620,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -647,7 +647,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -688,7 +688,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -732,7 +732,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -764,7 +764,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -821,7 +821,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -891,7 +891,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -996,7 +996,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1072,13 +1072,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash13Test.cs b/.Lib9c.Tests/Action/HackAndSlash13Test.cs index 84da918ce5..73c193cfed 100644 --- a/.Lib9c.Tests/Action/HackAndSlash13Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash13Test.cs @@ -208,7 +208,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -288,7 +288,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -350,7 +350,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -411,7 +411,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -448,7 +448,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -471,7 +471,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -496,7 +496,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -522,7 +522,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -556,7 +556,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -593,7 +593,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -633,7 +633,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -659,7 +659,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -699,7 +699,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -742,7 +742,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -773,7 +773,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -830,7 +830,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -899,7 +899,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -930,7 +930,7 @@ public void ExecuteThrowActionObsoletedException() var state = _initialState.SetState(Addresses.GetSheetAddress(), _tableSheets.ArenaSheet.Serialize()); var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -1037,7 +1037,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1110,13 +1110,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash15Test.cs b/.Lib9c.Tests/Action/HackAndSlash15Test.cs index f8fcee3b9c..7a3dfdbac9 100644 --- a/.Lib9c.Tests/Action/HackAndSlash15Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash15Test.cs @@ -204,7 +204,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -284,7 +284,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -346,7 +346,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -407,7 +407,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -443,7 +443,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -468,7 +468,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -494,7 +494,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -528,7 +528,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -565,7 +565,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -605,7 +605,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -631,7 +631,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -671,7 +671,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -714,7 +714,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -745,7 +745,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -802,7 +802,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -871,7 +871,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -978,7 +978,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1128,7 +1128,7 @@ public void CheckCrystalRandomSkillState(bool forceClear, bool skillStateExist, var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash16Test.cs b/.Lib9c.Tests/Action/HackAndSlash16Test.cs index dfae3a62b0..e4c17f998d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash16Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash16Test.cs @@ -205,7 +205,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -285,7 +285,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -347,7 +347,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -408,7 +408,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -444,7 +444,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -469,7 +469,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -495,7 +495,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -529,7 +529,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -566,7 +566,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -606,7 +606,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -632,7 +632,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -672,7 +672,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -715,7 +715,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -750,7 +750,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -813,7 +813,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -882,7 +882,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -917,7 +917,7 @@ public void ExecuteThrowPlayCountIsZeroException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1023,7 +1023,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1173,7 +1173,7 @@ public void CheckCrystalRandomSkillState(bool forceClear, bool skillStateExist, var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash17Test.cs b/.Lib9c.Tests/Action/HackAndSlash17Test.cs index 18135c5987..15d4fa40e6 100644 --- a/.Lib9c.Tests/Action/HackAndSlash17Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash17Test.cs @@ -205,7 +205,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -285,7 +285,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -347,7 +347,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -408,7 +408,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -444,7 +444,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -469,7 +469,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -495,7 +495,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -529,7 +529,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -566,7 +566,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -606,7 +606,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -632,7 +632,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -672,7 +672,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -715,7 +715,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -750,7 +750,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -813,7 +813,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -882,7 +882,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -917,7 +917,7 @@ public void ExecuteThrowPlayCountIsZeroException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1023,7 +1023,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1173,7 +1173,7 @@ public void CheckCrystalRandomSkillState(bool forceClear, bool skillStateExist, var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash18Test.cs b/.Lib9c.Tests/Action/HackAndSlash18Test.cs index 61e2d73bc1..8d07a23a86 100644 --- a/.Lib9c.Tests/Action/HackAndSlash18Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash18Test.cs @@ -203,7 +203,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -283,7 +283,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -345,7 +345,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -406,7 +406,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -442,7 +442,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -467,7 +467,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -493,7 +493,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -527,7 +527,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -564,7 +564,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -604,7 +604,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -630,7 +630,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -670,7 +670,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -713,7 +713,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -748,7 +748,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -811,7 +811,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -880,7 +880,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -915,7 +915,7 @@ public void ExecuteThrowPlayCountIsZeroException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1008,7 +1008,7 @@ public void Execute_V100291() var nextState = action.Execute(new ActionContext { - PreviousStates = initialState, + PreviousState = initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1117,7 +1117,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1287,7 +1287,7 @@ public void CheckCrystalRandomSkillState( var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1407,7 +1407,7 @@ public void CheckUsedApByStaking(int level, int playCount) var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash19Test.cs b/.Lib9c.Tests/Action/HackAndSlash19Test.cs index b227f36e49..048ee555a2 100644 --- a/.Lib9c.Tests/Action/HackAndSlash19Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash19Test.cs @@ -203,7 +203,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -284,7 +284,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -347,7 +347,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -409,7 +409,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -446,7 +446,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -472,7 +472,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -499,7 +499,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -534,7 +534,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -572,7 +572,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -613,7 +613,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -640,7 +640,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -681,7 +681,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -725,7 +725,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -761,7 +761,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -825,7 +825,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -895,7 +895,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -931,7 +931,7 @@ public void ExecuteThrowPlayCountIsZeroException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1038,7 +1038,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1209,7 +1209,7 @@ public void CheckCrystalRandomSkillState( var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1331,7 +1331,7 @@ public void CheckUsedApByStaking(int level, int playCount) var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash20Test.cs b/.Lib9c.Tests/Action/HackAndSlash20Test.cs index f60fca29cd..0f6c4c0954 100644 --- a/.Lib9c.Tests/Action/HackAndSlash20Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash20Test.cs @@ -204,7 +204,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -285,7 +285,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -348,7 +348,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -410,7 +410,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -447,7 +447,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -473,7 +473,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -500,7 +500,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -535,7 +535,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -573,7 +573,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -614,7 +614,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -641,7 +641,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -682,7 +682,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -726,7 +726,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -762,7 +762,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -826,7 +826,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -896,7 +896,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -931,7 +931,7 @@ public void ExecuteThrowInvalidItemCountException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -968,7 +968,7 @@ public void ExecuteThrowPlayCountIsZeroException(int totalPlayCount, int apStone var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -995,7 +995,7 @@ public void ExecuteThrowUsageLimitExceedException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _avatarState.agentAddress, Random = new TestRandom(), })); @@ -1022,7 +1022,7 @@ public void ExecuteThrowNotEnoughMaterialException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _avatarState.agentAddress, Random = new TestRandom(), })); @@ -1128,7 +1128,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1299,7 +1299,7 @@ public void CheckCrystalRandomSkillState( var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1421,7 +1421,7 @@ public void CheckUsedApByStaking(int level, int playCount) var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1501,7 +1501,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1553,7 +1553,7 @@ public void ExecuteThrowInvalidRepeatPlayException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1648,7 +1648,7 @@ public void ExecuteTwoRepetitions() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1672,7 +1672,7 @@ public void ExecuteTwoRepetitions() action2.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1765,7 +1765,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -1787,7 +1787,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlash21Test.cs b/.Lib9c.Tests/Action/HackAndSlash21Test.cs index 1ca21a15eb..dfb9668154 100644 --- a/.Lib9c.Tests/Action/HackAndSlash21Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash21Test.cs @@ -205,7 +205,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -286,7 +286,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -349,7 +349,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -411,7 +411,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -448,7 +448,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -474,7 +474,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -501,7 +501,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -536,7 +536,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -574,7 +574,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -615,7 +615,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -642,7 +642,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -683,7 +683,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -727,7 +727,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -763,7 +763,7 @@ public void ExecuteThrowNotEnoughActionPointException(int ap, int playCount = 1) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -827,7 +827,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -897,7 +897,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -932,7 +932,7 @@ public void ExecuteThrowInvalidItemCountException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -969,7 +969,7 @@ public void ExecuteThrowPlayCountIsZeroException(int totalPlayCount, int apStone var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -996,7 +996,7 @@ public void ExecuteThrowUsageLimitExceedException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _avatarState.agentAddress, Random = new TestRandom(), })); @@ -1023,7 +1023,7 @@ public void ExecuteThrowNotEnoughMaterialException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _avatarState.agentAddress, Random = new TestRandom(), })); @@ -1129,7 +1129,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1300,7 +1300,7 @@ public void CheckCrystalRandomSkillState( var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1422,7 +1422,7 @@ public void CheckUsedApByStaking(int level, int playCount) var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1502,7 +1502,7 @@ public void CheckUsingApStoneWithStaking(int level, int apStoneCount, int totalR var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1554,7 +1554,7 @@ public void ExecuteThrowInvalidRepeatPlayException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = new TestRandom(), })); @@ -1649,7 +1649,7 @@ public void ExecuteTwoRepetitions() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1673,7 +1673,7 @@ public void ExecuteTwoRepetitions() action2.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1766,7 +1766,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -1788,7 +1788,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlash2Test.cs b/.Lib9c.Tests/Action/HackAndSlash2Test.cs index 756d8f88a6..77b6306edf 100644 --- a/.Lib9c.Tests/Action/HackAndSlash2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash2Test.cs @@ -118,7 +118,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -170,7 +170,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -198,7 +198,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -227,7 +227,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -258,7 +258,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -290,7 +290,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -330,7 +330,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -361,7 +361,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -407,7 +407,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -439,7 +439,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -484,7 +484,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -530,7 +530,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -567,7 +567,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -604,13 +604,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -630,7 +630,7 @@ public void SerializeWithDotnetAPI() action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash3Test.cs b/.Lib9c.Tests/Action/HackAndSlash3Test.cs index 3ea2e17ae0..85e2a377c4 100644 --- a/.Lib9c.Tests/Action/HackAndSlash3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash3Test.cs @@ -132,7 +132,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/HackAndSlash4Test.cs b/.Lib9c.Tests/Action/HackAndSlash4Test.cs index 0514462e24..a398eef5d2 100644 --- a/.Lib9c.Tests/Action/HackAndSlash4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash4Test.cs @@ -180,7 +180,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -259,7 +259,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -322,7 +322,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -351,7 +351,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -379,7 +379,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -408,7 +408,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -439,7 +439,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -471,7 +471,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -511,7 +511,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -542,7 +542,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -588,7 +588,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -620,7 +620,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -665,7 +665,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -711,7 +711,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -748,7 +748,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -775,7 +775,7 @@ public void Execute_Throw_ActionObsoletedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), BlockIndex = ActionObsoleteConfig.V100080ObsoleteIndex + 100000, diff --git a/.Lib9c.Tests/Action/HackAndSlash5Test.cs b/.Lib9c.Tests/Action/HackAndSlash5Test.cs index 4d2f673240..2f9f1a5a2d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash5Test.cs @@ -180,7 +180,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -260,7 +260,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -323,7 +323,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -352,7 +352,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -380,7 +380,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -409,7 +409,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -440,7 +440,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -472,7 +472,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -512,7 +512,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -543,7 +543,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -589,7 +589,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -621,7 +621,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -666,7 +666,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -712,7 +712,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -749,7 +749,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlash6Test.cs b/.Lib9c.Tests/Action/HackAndSlash6Test.cs index eb723a61a3..1f71609ac6 100644 --- a/.Lib9c.Tests/Action/HackAndSlash6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash6Test.cs @@ -196,7 +196,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -276,7 +276,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -339,7 +339,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -368,7 +368,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -408,7 +408,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -437,7 +437,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -468,7 +468,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -500,7 +500,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -540,7 +540,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -571,7 +571,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -617,7 +617,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -649,7 +649,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -694,7 +694,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -740,7 +740,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -777,7 +777,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -817,13 +817,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash7Test.cs b/.Lib9c.Tests/Action/HackAndSlash7Test.cs index 1883ba5d3e..ed5c75663e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash7Test.cs @@ -222,7 +222,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool contains, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -319,7 +319,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // First Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -327,7 +327,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -381,7 +381,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -444,7 +444,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -471,7 +471,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -509,7 +509,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -534,7 +534,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -561,7 +561,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -589,7 +589,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -625,7 +625,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -652,7 +652,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -694,7 +694,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -722,7 +722,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -764,7 +764,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -809,7 +809,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -842,7 +842,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -880,13 +880,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash8Test.cs b/.Lib9c.Tests/Action/HackAndSlash8Test.cs index c150bc641e..40f4082726 100644 --- a/.Lib9c.Tests/Action/HackAndSlash8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash8Test.cs @@ -228,7 +228,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -316,7 +316,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // First Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -324,7 +324,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -377,7 +377,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -439,7 +439,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -465,7 +465,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -502,7 +502,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -526,7 +526,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -552,7 +552,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -579,7 +579,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -614,7 +614,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -640,7 +640,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -681,7 +681,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -708,7 +708,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -749,7 +749,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -793,7 +793,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -825,7 +825,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -861,13 +861,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlash9Test.cs b/.Lib9c.Tests/Action/HackAndSlash9Test.cs index cf75ac3566..c11a857f0e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash9Test.cs @@ -230,7 +230,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -321,7 +321,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId, int playCount // First Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -340,7 +340,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId, int playCount // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -394,7 +394,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -457,7 +457,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -484,7 +484,7 @@ public void ExecuteThrowInvalidRankingMapAddress() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -522,7 +522,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -547,7 +547,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -574,7 +574,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -602,7 +602,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -638,7 +638,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -665,7 +665,7 @@ public void ExecuteThrowInvalidWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -707,7 +707,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -735,7 +735,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -777,7 +777,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -822,7 +822,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -855,7 +855,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -913,7 +913,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1077,7 +1077,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId, int playCo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1155,13 +1155,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } private static void SerializeException(Exception exec) diff --git a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs index fc81346794..3dd020ebc7 100644 --- a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs @@ -147,7 +147,7 @@ public void Execute(int stageId, bool advancedGacha, int balance, int gatheredSt { var nextState = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddress, Random = _random, }); @@ -162,7 +162,7 @@ public void Execute(int stageId, bool advancedGacha, int balance, int gatheredSt { action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddress, Random = _random, }); @@ -217,7 +217,7 @@ public void ContainMinimumBuffRank(bool advancedGacha, CrystalRandomBuffSheet.Ro }; var nextState = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddress, Random = _random, }); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs index f75f9b9a74..85c3efed39 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs @@ -166,7 +166,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -209,7 +209,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -229,7 +229,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -249,7 +249,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -268,7 +268,7 @@ public void Execute_InvalidStageException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -322,7 +322,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -376,7 +376,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -448,7 +448,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -517,7 +517,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs index f0edc1be5d..bcb460ce32 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs @@ -166,7 +166,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -209,7 +209,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -229,7 +229,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -249,7 +249,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -268,7 +268,7 @@ public void Execute_StageClearedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -306,7 +306,7 @@ public void Execute_InvalidStageException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -360,7 +360,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -414,7 +414,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -486,7 +486,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -555,7 +555,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs index 1b48874351..249e044903 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs @@ -194,7 +194,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool backward) state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -239,7 +239,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -259,7 +259,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -279,7 +279,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -298,7 +298,7 @@ public void Execute_StageClearedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -336,7 +336,7 @@ public void Execute_InvalidStageException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -390,7 +390,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -444,7 +444,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -522,7 +522,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -597,7 +597,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -672,7 +672,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -746,7 +746,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -767,7 +767,7 @@ public void Execute_ActionObsoletedException() var state = _initialState.SetState(Addresses.GetSheetAddress(), _tableSheets.ArenaSheet.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs index 19318f6b3b..5f4fa393ca 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs @@ -214,7 +214,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -259,7 +259,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -279,7 +279,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -300,7 +300,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -340,7 +340,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -394,7 +394,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -448,7 +448,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -526,7 +526,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -601,7 +601,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -676,7 +676,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -750,7 +750,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -771,7 +771,7 @@ public void Execute_ActionObsoletedException() var state = _initialState.SetState(Addresses.GetSheetAddress(), _tableSheets.ArenaSheet.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs index 997a5223e4..0f201f7b69 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs @@ -217,7 +217,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -262,7 +262,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -287,7 +287,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -313,7 +313,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -357,7 +357,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -422,7 +422,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -476,7 +476,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -554,7 +554,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -629,7 +629,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -704,7 +704,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -778,7 +778,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs index a305636242..6fc7cd6a82 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs @@ -224,7 +224,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -269,7 +269,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -294,7 +294,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -320,7 +320,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -364,7 +364,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -429,7 +429,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -483,7 +483,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -561,7 +561,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -636,7 +636,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -711,7 +711,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -785,7 +785,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -857,7 +857,7 @@ public void ExecuteWithStake(int stakingLevel) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs index e1fe6d158b..a77d4b50ff 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs @@ -227,7 +227,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -272,7 +272,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -297,7 +297,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -323,7 +323,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -367,7 +367,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -432,7 +432,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -486,7 +486,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -564,7 +564,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -639,7 +639,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -714,7 +714,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -788,7 +788,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -860,7 +860,7 @@ public void ExecuteWithStake(int stakingLevel) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs index 72e82421f0..1079dfc082 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs @@ -228,7 +228,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -274,7 +274,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -300,7 +300,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -327,7 +327,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -372,7 +372,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -438,7 +438,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -493,7 +493,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -572,7 +572,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -648,7 +648,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -724,7 +724,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -799,7 +799,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -872,7 +872,7 @@ public void ExecuteWithStake(int stakingLevel) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs index f36953dc09..e4215a82e6 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs @@ -229,7 +229,7 @@ public void Execute(int apStoneCount, int worldId, int stageId, bool challenge, state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = _random, }); @@ -275,7 +275,7 @@ public void Execute_FailedLoadStateException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -301,7 +301,7 @@ public void Execute_SheetRowNotFoundException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -328,7 +328,7 @@ public void Execute_SheetRowColumnException(int worldId, int stageId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -373,7 +373,7 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -439,7 +439,7 @@ public void Execute_InvalidWorldException(int worldId, bool backward, int stageI Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -494,7 +494,7 @@ public void Execute_UsageLimitExceedException(int apStoneCount, bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -573,7 +573,7 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -649,7 +649,7 @@ public void Execute_NotEnoughActionPointException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -725,7 +725,7 @@ public void Execute_PlayCountIsZeroException(bool backward) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -800,7 +800,7 @@ public void Execute_NotEnoughCombatPointException(int worldId, int stageId, bool Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -873,7 +873,7 @@ public void ExecuteWithStake(int stakingLevel) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -949,7 +949,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -972,7 +972,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlashTest14.cs b/.Lib9c.Tests/Action/HackAndSlashTest14.cs index 669859eb5c..e551a92063 100644 --- a/.Lib9c.Tests/Action/HackAndSlashTest14.cs +++ b/.Lib9c.Tests/Action/HackAndSlashTest14.cs @@ -195,7 +195,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, bool backward, bo var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -275,7 +275,7 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) // Second Execute state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -337,7 +337,7 @@ public void MaxLevelTest() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -398,7 +398,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -434,7 +434,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -459,7 +459,7 @@ public void ExecuteThrowSheetRowColumnException(int stageId) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -485,7 +485,7 @@ public void ExecuteThrowSheetRowNotFoundExceptionByStage() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -519,7 +519,7 @@ public void ExecuteThrowFailedAddWorldException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -556,7 +556,7 @@ public void Execute_Throw_InvalidWorldException(int worldId, int stageId, bool u var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -596,7 +596,7 @@ public void ExecuteThrowInvalidStageException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -622,7 +622,7 @@ public void ExecuteThrowInvalidStageExceptionUnlockedWorld() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -662,7 +662,7 @@ public void ExecuteThrowInvalidEquipmentException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -705,7 +705,7 @@ public void ExecuteThrowEquipmentSlotUnlockException(ItemSubType itemSubType) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -736,7 +736,7 @@ public void ExecuteThrowNotEnoughActionPointException() var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), })); @@ -793,7 +793,7 @@ public void ExecuteWithoutPlayCount() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -862,7 +862,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) var exec = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -969,7 +969,7 @@ public void CheckRewardItems(bool backward, int worldId, int stageId) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -1119,7 +1119,7 @@ public void CheckCrystalRandomSkillState(bool forceClear, bool skillStateExist, var ctx = new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/InitializeStatesTest.cs b/.Lib9c.Tests/Action/InitializeStatesTest.cs index 05b92a0c12..7e1852b194 100644 --- a/.Lib9c.Tests/Action/InitializeStatesTest.cs +++ b/.Lib9c.Tests/Action/InitializeStatesTest.cs @@ -61,7 +61,7 @@ public void Execute() { BlockIndex = 0, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), }); var addresses = new List
() @@ -127,7 +127,7 @@ public void ExecuteWithAuthorizedMinersState() { BlockIndex = 0, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), }); var fetchedState = new AuthorizedMinersState( @@ -175,7 +175,7 @@ public void ExecuteWithActivateAdminKey() { BlockIndex = 0, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), }); var fetchedState = new ActivatedAccountsState( @@ -226,7 +226,7 @@ public void ExecuteWithCredits() { BlockIndex = 0, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), }); var fetchedState = new CreditsState( @@ -271,7 +271,7 @@ public void ExecuteWithoutAdminState() { BlockIndex = 0, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), }); var fetchedState = new ActivatedAccountsState( diff --git a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs index 307271f269..958d34b756 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs @@ -107,7 +107,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -137,7 +137,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) @@ -157,7 +157,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -184,7 +184,7 @@ public void ExecuteThrowRequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -211,7 +211,7 @@ public void ExecuteThrowInvalidCastException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -240,7 +240,7 @@ public void ExecuteThrowCombinationSlotUnlockException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -272,7 +272,7 @@ public void ExecuteThrowEquipmentLevelExceededException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -302,7 +302,7 @@ public void ExecuteThrowNotEnoughMaterialException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -334,7 +334,7 @@ public void ExecuteThrowDuplicateMaterialException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -418,7 +418,7 @@ int materialLevel Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -510,13 +510,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 22fd1abd5d..25d0af6cac 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -146,7 +146,7 @@ public void Execute(int level, int expectedGold, bool backward) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -231,13 +231,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -282,7 +282,7 @@ public void Execute_ActionObsoletedException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs index 66a2493ee7..2e73bc3f63 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs @@ -106,7 +106,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -136,7 +136,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, BlockIndex = 0, }) @@ -156,7 +156,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -183,7 +183,7 @@ public void ExecuteThrowRequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -210,7 +210,7 @@ public void ExecuteThrowInvalidCastException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -239,7 +239,7 @@ public void ExecuteThrowCombinationSlotUnlockException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -271,7 +271,7 @@ public void ExecuteThrowEquipmentLevelExceededException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -301,7 +301,7 @@ public void ExecuteThrowNotEnoughMaterialException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -385,7 +385,7 @@ int materialLevel Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 0, }) @@ -475,13 +475,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs index dbb353b425..66b2781e90 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs @@ -122,7 +122,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs index c06f309a2a..fb19885476 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs @@ -123,7 +123,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs index 652e061764..58f26c9f01 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs @@ -123,7 +123,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs index 27a4ea2e75..5ffd63b6ee 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs @@ -123,7 +123,7 @@ public void Execute(int level, int expectedLevel, int expectedGold) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs index 29de65c85d..8aa0a2734b 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs @@ -138,7 +138,7 @@ public void Execute(int level, int expectedLevel, int expectedGold, bool backwar var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -200,13 +200,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs index 338b3c53d4..b867526d99 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs @@ -138,7 +138,7 @@ public void Execute(int level, int expectedLevel, int expectedGold, bool backwar var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -200,13 +200,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index 519dfd2217..d7c77f884c 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -140,7 +140,7 @@ public void Execute(int level, int expectedGold, bool backward) var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -225,13 +225,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 52ef5cfd92..9970c3ab39 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -177,7 +177,7 @@ bool stake var nextState = action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, BlockIndex = 1, Random = new TestRandom(randomSeed), diff --git a/.Lib9c.Tests/Action/JoinArena1Test.cs b/.Lib9c.Tests/Action/JoinArena1Test.cs index 1a8db86049..4f68f7ddc3 100644 --- a/.Lib9c.Tests/Action/JoinArena1Test.cs +++ b/.Lib9c.Tests/Action/JoinArena1Test.cs @@ -217,7 +217,7 @@ public void Execute(long blockIndex, int championshipId, int round, string balan state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -294,7 +294,7 @@ public void Execute_SheetRowNotFoundException(int championshipId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), })); @@ -319,7 +319,7 @@ public void Execute_RoundNotFoundByIdsException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -347,7 +347,7 @@ public void Execute_NotEnoughMedalException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 100, @@ -374,7 +374,7 @@ public void Execute_NotEnoughFungibleAssetValueException(int round, long blockIn Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = blockIndex, @@ -399,7 +399,7 @@ public void Execute_ArenaScoreAlreadyContainsException() state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -408,7 +408,7 @@ public void Execute_ArenaScoreAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 2, @@ -440,7 +440,7 @@ public void Execute_ArenaScoreAlreadyContainsException2() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -472,7 +472,7 @@ public void Execute_ArenaInformationAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -493,7 +493,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _signer2, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/JoinArena2Test.cs b/.Lib9c.Tests/Action/JoinArena2Test.cs index 402544ec27..06c18b1a50 100644 --- a/.Lib9c.Tests/Action/JoinArena2Test.cs +++ b/.Lib9c.Tests/Action/JoinArena2Test.cs @@ -218,7 +218,7 @@ public void Execute(long blockIndex, int championshipId, int round, string balan state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -296,7 +296,7 @@ public void Execute_SheetRowNotFoundException(int championshipId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), })); @@ -322,7 +322,7 @@ public void Execute_RoundNotFoundByIdsException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -351,7 +351,7 @@ public void Execute_NotEnoughMedalException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 100, @@ -379,7 +379,7 @@ public void Execute_NotEnoughFungibleAssetValueException(int round, long blockIn Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = blockIndex, @@ -405,7 +405,7 @@ public void Execute_ArenaScoreAlreadyContainsException() state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -414,7 +414,7 @@ public void Execute_ArenaScoreAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 2, @@ -447,7 +447,7 @@ public void Execute_ArenaScoreAlreadyContainsException2() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -480,7 +480,7 @@ public void Execute_ArenaInformationAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -502,7 +502,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _signer2, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/JoinArena3Test.cs b/.Lib9c.Tests/Action/JoinArena3Test.cs index 645b7e4a4d..e720e28ab8 100644 --- a/.Lib9c.Tests/Action/JoinArena3Test.cs +++ b/.Lib9c.Tests/Action/JoinArena3Test.cs @@ -221,7 +221,7 @@ public void Execute(long blockIndex, int championshipId, int round, string balan state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -299,7 +299,7 @@ public void Execute_SheetRowNotFoundException(int championshipId) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), })); @@ -325,7 +325,7 @@ public void Execute_RoundNotFoundByIdsException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -354,7 +354,7 @@ public void Execute_NotEnoughMedalException(int round) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 100, @@ -382,7 +382,7 @@ public void Execute_NotEnoughFungibleAssetValueException(int round, long blockIn Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = blockIndex, @@ -408,7 +408,7 @@ public void Execute_ArenaScoreAlreadyContainsException() state = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = _random, Rehearsal = false, @@ -417,7 +417,7 @@ public void Execute_ArenaScoreAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 2, @@ -450,7 +450,7 @@ public void Execute_ArenaScoreAlreadyContainsException2() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -483,7 +483,7 @@ public void Execute_ArenaInformationAlreadyContainsException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), BlockIndex = 1, @@ -505,7 +505,7 @@ public void Execute_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = _state, + PreviousState = _state, Signer = _signer2, Random = new TestRandom(), })); @@ -544,7 +544,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), }); @@ -565,7 +565,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _signer, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/MarketValidationTest.cs b/.Lib9c.Tests/Action/MarketValidationTest.cs index 432c851bc7..ed0b4cc21d 100644 --- a/.Lib9c.Tests/Action/MarketValidationTest.cs +++ b/.Lib9c.Tests/Action/MarketValidationTest.cs @@ -197,7 +197,7 @@ public void Validate_RegisterInfo(params RegisterInfosMember[] validateMembers) var actionContext = new ActionContext { Signer = AgentAddress, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), }; foreach (var validateMember in validateMembers) @@ -231,7 +231,7 @@ public void Validate_ProductInfo(params ProductInfosMember[] validateMembers) var actionContext = new ActionContext { Signer = AgentAddress, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), }; foreach (var validateMember in validateMembers) diff --git a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs index 60ecabe9e1..afcfacf166 100644 --- a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs +++ b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs @@ -80,7 +80,7 @@ public void Execute_ThrowsIfAlreadyStakeStateExists() MigrateMonsterCollection action = new MigrateMonsterCollection(_avatarAddress); Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signer, BlockIndex = 0, Random = new TestRandom(), @@ -101,7 +101,7 @@ public void Execute_After_V100220ObsoleteIndex() MigrateMonsterCollection action = new MigrateMonsterCollection(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signer, BlockIndex = ActionObsoleteConfig.V100220ObsoleteIndex + 1, Random = new TestRandom(), @@ -137,7 +137,7 @@ public void Execute(int collectionLevel, long claimBlockIndex, long receivedBloc MigrateMonsterCollection action = new MigrateMonsterCollection(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signer, BlockIndex = claimBlockIndex, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs index 51e5d539b0..26258fb032 100644 --- a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs @@ -26,7 +26,7 @@ public void Execute() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = admin, BlockIndex = 1, }); diff --git a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs index eb91a4bbcc..3ea7fb1611 100644 --- a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs @@ -49,7 +49,7 @@ public void Execute() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = admin, BlockIndex = 1, }); diff --git a/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs b/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs index 2b201708aa..a2be908f98 100644 --- a/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs +++ b/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs @@ -76,7 +76,7 @@ public void Execute(bool isAdmin, bool expire, Type exc) var nextState = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = states, + PreviousState = states, Signer = signer, }); @@ -90,7 +90,7 @@ public void Execute(bool isAdmin, bool expire, Type exc) Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = states, + PreviousState = states, Signer = signer, })); } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs index 8801b7c9d1..befd7f7ef1 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs @@ -167,7 +167,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int clearStageId) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -257,7 +257,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -284,7 +284,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -311,7 +311,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -338,7 +338,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -365,7 +365,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -408,7 +408,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -495,7 +495,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -537,7 +537,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -583,7 +583,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs index 8b5073b428..5cf056e708 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs @@ -157,7 +157,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -231,7 +231,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -257,7 +257,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -281,7 +281,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -305,7 +305,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -346,7 +346,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -430,7 +430,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -468,7 +468,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -511,7 +511,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -601,7 +601,7 @@ public void ExecuteThrowHighLevelItemRequirementException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -709,7 +709,7 @@ public void Execute_v100291() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -819,7 +819,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs index 467dfcb2b7..3782e17c0c 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs @@ -156,7 +156,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -231,7 +231,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -258,7 +258,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -283,7 +283,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -308,7 +308,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -350,7 +350,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -435,7 +435,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -474,7 +474,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -518,7 +518,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -609,7 +609,7 @@ public void ExecuteThrowHighLevelItemRequirementException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -715,7 +715,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs index 5872b80b7e..7c754a4c5e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs @@ -163,7 +163,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -238,7 +238,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -265,7 +265,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -290,7 +290,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -315,7 +315,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -357,7 +357,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -442,7 +442,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -481,7 +481,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -525,7 +525,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -616,7 +616,7 @@ public void ExecuteThrowHighLevelItemRequirementException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -722,7 +722,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -829,7 +829,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -852,7 +852,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs index 8a4a0847b2..e7e0d8f7d8 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs @@ -164,7 +164,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -239,7 +239,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -266,7 +266,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -291,7 +291,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -316,7 +316,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -358,7 +358,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -443,7 +443,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -482,7 +482,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -526,7 +526,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -617,7 +617,7 @@ public void ExecuteThrowHighLevelItemRequirementException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -723,7 +723,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -830,7 +830,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -853,7 +853,7 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 Assert.Throws(exception, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs index a6541ec4bf..f13bb436e9 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs @@ -167,7 +167,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int clearStageId) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -257,7 +257,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -284,7 +284,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -311,7 +311,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -338,7 +338,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -365,7 +365,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -408,7 +408,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -495,7 +495,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -537,7 +537,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -583,7 +583,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs index 8289debfff..770835b632 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs @@ -167,7 +167,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int clearStageId) var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -258,7 +258,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -285,7 +285,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -312,7 +312,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -339,7 +339,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -366,7 +366,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -409,7 +409,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -496,7 +496,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -538,7 +538,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -584,7 +584,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs index f4482a3110..add4d9604a 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs @@ -180,7 +180,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int clearStageId, var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -267,7 +267,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -294,7 +294,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -319,7 +319,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -344,7 +344,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -369,7 +369,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -411,7 +411,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -496,7 +496,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -536,7 +536,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -580,7 +580,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -616,13 +616,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs index 8145ab4d49..449ace9afd 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs @@ -175,7 +175,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int clearStageId, var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -260,7 +260,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -286,7 +286,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -310,7 +310,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -334,7 +334,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -358,7 +358,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -399,7 +399,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -483,7 +483,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -522,7 +522,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -565,7 +565,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -600,13 +600,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs index 29340af1c1..e8c6093a3c 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs @@ -185,7 +185,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -271,7 +271,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -298,7 +298,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -323,7 +323,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -348,7 +348,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -373,7 +373,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -415,7 +415,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -500,7 +500,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -539,7 +539,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -583,7 +583,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -704,7 +704,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -759,13 +759,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs index 475fc33589..7fbe73cce5 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs @@ -185,7 +185,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -271,7 +271,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -298,7 +298,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -323,7 +323,7 @@ public void ExecuteThrowInvalidRankingMapAddress() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -348,7 +348,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -373,7 +373,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -415,7 +415,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -500,7 +500,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -539,7 +539,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -583,7 +583,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -704,7 +704,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -759,13 +759,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs index 29298a7f9c..83b44bb322 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs @@ -180,7 +180,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -255,7 +255,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -281,7 +281,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -305,7 +305,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -329,7 +329,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -370,7 +370,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -454,7 +454,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext() { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -492,7 +492,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -535,7 +535,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -655,7 +655,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -708,13 +708,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs index 6d0de11f45..59519d322d 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs @@ -156,7 +156,7 @@ public void Execute(int avatarLevel, int worldId, int stageId, int playCount, in var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -230,7 +230,7 @@ public void ExecuteThrowInvalidStageException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -256,7 +256,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, }); }); @@ -280,7 +280,7 @@ public void ExecuteThrowSheetRowNotFound() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -304,7 +304,7 @@ public void ExecuteThrowSheetRowColumn() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, }); }); @@ -345,7 +345,7 @@ public void ExecuteThrowNotEnoughActionPoint() { action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -429,7 +429,7 @@ public void ExecuteThrowInvalidWorld(int avatarLevel, int worldId, int stageId, { action.Execute(new ActionContext { - PreviousStates = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, }); }); } @@ -467,7 +467,7 @@ public void ExecuteThrowFailedAddWorldExceptionWhenDoesNotMimisbrunnr(int alread { action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, }); }); @@ -510,7 +510,7 @@ public void ExecuteEquippableItemValidation() action.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Rehearsal = false, Random = new TestRandom(), @@ -600,7 +600,7 @@ public void ExecuteThrowHighLevelItemRequirementException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = avatarState.agentAddress, Random = random, })); @@ -705,7 +705,7 @@ public void CheckRewardItems(bool backward, int stageIndex, int playCount) var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -759,13 +759,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MonsterCollect0Test.cs b/.Lib9c.Tests/Action/MonsterCollect0Test.cs index 20f8dea707..7a417ec9c6 100644 --- a/.Lib9c.Tests/Action/MonsterCollect0Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect0Test.cs @@ -82,7 +82,7 @@ public void Execute(bool exist, int level, int monsterCollectionRound, int prevL IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = blockIndex, }); @@ -111,7 +111,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, BlockIndex = 1, })); @@ -138,7 +138,7 @@ public void Execute_Throw_InvalidMonsterCollectionRoundException(int agentCollec Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -159,7 +159,7 @@ public void Execute_Throw_SheetRowNotFoundException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -175,7 +175,7 @@ public void Execute_Throw_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -198,7 +198,7 @@ public void Execute_Throw_MonsterCollectionExpiredException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = prevMonsterCollectionState.ExpiredBlockIndex + 1, })); @@ -221,7 +221,7 @@ public void Execute_Throw_InvalidLevelException(int prevLevel, int level) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -238,7 +238,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, Rehearsal = true, }); @@ -249,7 +249,7 @@ public void Rehearsal() collectionAddress, }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MonsterCollect2Test.cs b/.Lib9c.Tests/Action/MonsterCollect2Test.cs index 707f8d4ed9..48170016df 100644 --- a/.Lib9c.Tests/Action/MonsterCollect2Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect2Test.cs @@ -91,7 +91,7 @@ public void Execute(int? prevLevel, int level, long blockIndex, Type exc, int? e { Assert.Throws(excType, () => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = blockIndex, })); @@ -100,7 +100,7 @@ public void Execute(int? prevLevel, int level, long blockIndex, Type exc, int? e { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = blockIndex, }); @@ -133,7 +133,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, BlockIndex = 1, })); @@ -149,7 +149,7 @@ public void Execute_Throw_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -164,7 +164,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, Rehearsal = true, }); @@ -178,7 +178,7 @@ public void Rehearsal() MonsterCollectionState.DeriveAddress(_signer, 3), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/MonsterCollectTest.cs b/.Lib9c.Tests/Action/MonsterCollectTest.cs index 9239b56ba9..5d02d49ac7 100644 --- a/.Lib9c.Tests/Action/MonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/MonsterCollectTest.cs @@ -92,7 +92,7 @@ public void Execute(int balance, int? prevLevel, int level, long blockIndex, Typ { Assert.Throws(excType, () => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = blockIndex, })); @@ -101,7 +101,7 @@ public void Execute(int balance, int? prevLevel, int level, long blockIndex, Typ { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = blockIndex, }); @@ -134,7 +134,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, BlockIndex = 1, })); @@ -150,7 +150,7 @@ public void Execute_Throw_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signer, BlockIndex = 1, })); @@ -170,7 +170,7 @@ public void Execute_Throw_InvalidOperationException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signer, BlockIndex = 1, })); @@ -185,7 +185,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), Signer = _signer, Rehearsal = true, }); @@ -199,7 +199,7 @@ public void Rehearsal() MonsterCollectionState.DeriveAddress(_signer, 3), }; - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 1fc49086b1..0a8c2e3435 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -53,7 +53,7 @@ public void Execute() var nextState = patchTableSheetAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Rehearsal = false, }); @@ -72,7 +72,7 @@ public void Execute() nextState = patchTableSheetAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Rehearsal = false, }); @@ -102,7 +102,7 @@ public void CheckPermission() new ActionContext() { BlockIndex = 101, - PreviousStates = state, + PreviousState = state, Signer = adminAddress, } ); @@ -115,7 +115,7 @@ public void CheckPermission() new ActionContext() { BlockIndex = 5, - PreviousStates = state, + PreviousState = state, Signer = new Address("019101FEec7ed4f918D396827E1277DEda1e20D4"), } ); @@ -142,7 +142,7 @@ public void ExecuteNewTable() var nextState = action.Execute( new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = adminAddress, } ); diff --git a/.Lib9c.Tests/Action/PetEnhancement0Test.cs b/.Lib9c.Tests/Action/PetEnhancement0Test.cs index 9baa0a0ac4..b7b43259ec 100644 --- a/.Lib9c.Tests/Action/PetEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/PetEnhancement0Test.cs @@ -372,7 +372,7 @@ private static IAccountStateDelta Execute( var nextStates = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = prevStates, + PreviousState = prevStates, Random = new TestRandom(), Rehearsal = false, Signer = agentAddr, diff --git a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs index e5ed049ed4..9d24165999 100644 --- a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs +++ b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs @@ -47,7 +47,7 @@ public void Execute(bool admin, bool includeNcg, Type exc) { Signer = admin ? adminAddress : poolAddress, BlockIndex = 1, - PreviousStates = state, + PreviousState = state, }); foreach (var asset in assets) { @@ -60,7 +60,7 @@ public void Execute(bool admin, bool includeNcg, Type exc) { Signer = admin ? adminAddress : poolAddress, BlockIndex = 1, - PreviousStates = state, + PreviousState = state, })); } } diff --git a/.Lib9c.Tests/Action/Raid1Test.cs b/.Lib9c.Tests/Action/Raid1Test.cs index 3c4eb54288..5f092de1a4 100644 --- a/.Lib9c.Tests/Action/Raid1Test.cs +++ b/.Lib9c.Tests/Action/Raid1Test.cs @@ -212,7 +212,7 @@ long executeOffset var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -349,7 +349,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -462,7 +462,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + Raid4.RequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -560,7 +560,7 @@ public void Execute_Throw_ActionObsoletedException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Raid2Test.cs b/.Lib9c.Tests/Action/Raid2Test.cs index 121cc71607..1d5ab5feba 100644 --- a/.Lib9c.Tests/Action/Raid2Test.cs +++ b/.Lib9c.Tests/Action/Raid2Test.cs @@ -224,7 +224,7 @@ bool raiderListExist var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -367,7 +367,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -481,7 +481,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + Raid4.RequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Raid3Test.cs b/.Lib9c.Tests/Action/Raid3Test.cs index 1886b93d39..b75b23dae1 100644 --- a/.Lib9c.Tests/Action/Raid3Test.cs +++ b/.Lib9c.Tests/Action/Raid3Test.cs @@ -225,7 +225,7 @@ bool raiderListExist var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -368,7 +368,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -483,7 +483,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + Raid4.RequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Raid4Test.cs b/.Lib9c.Tests/Action/Raid4Test.cs index 5775e72426..704b3f4674 100644 --- a/.Lib9c.Tests/Action/Raid4Test.cs +++ b/.Lib9c.Tests/Action/Raid4Test.cs @@ -246,7 +246,7 @@ int runeId2 var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -400,7 +400,7 @@ Dictionary rewardMap state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -409,7 +409,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -524,7 +524,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + Raid4.RequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -625,7 +625,7 @@ public void Execute_With_Free_Crystal_Fee() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Raid5Test.cs b/.Lib9c.Tests/Action/Raid5Test.cs index cea946b201..5ca7c4298a 100644 --- a/.Lib9c.Tests/Action/Raid5Test.cs +++ b/.Lib9c.Tests/Action/Raid5Test.cs @@ -246,7 +246,7 @@ int runeId2 var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -400,7 +400,7 @@ Dictionary rewardMap state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -409,7 +409,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -526,7 +526,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + gameConfigState.WorldBossRequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -627,7 +627,7 @@ public void Execute_With_Free_Crystal_Fee() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Raid6Test.cs b/.Lib9c.Tests/Action/Raid6Test.cs index 13b731e761..336a867fb9 100644 --- a/.Lib9c.Tests/Action/Raid6Test.cs +++ b/.Lib9c.Tests/Action/Raid6Test.cs @@ -246,7 +246,7 @@ int runeId2 var ctx = new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -400,7 +400,7 @@ Dictionary rewardMap state = unlockRuneSlot.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, Random = new TestRandom(), }); @@ -409,7 +409,7 @@ Dictionary rewardMap Assert.Throws(exc, () => action.Execute(new ActionContext { BlockIndex = blockIndex + executeOffset, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -526,7 +526,7 @@ Dictionary rewardMap var nextState = action.Execute(new ActionContext { BlockIndex = worldBossRow.StartedBlockIndex + gameConfigState.WorldBossRequiredInterval, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, @@ -627,7 +627,7 @@ public void Execute_With_Free_Crystal_Fee() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(randomSeed), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/RankingBattle0Test.cs b/.Lib9c.Tests/Action/RankingBattle0Test.cs index 9e7177e078..0bea0db5fd 100644 --- a/.Lib9c.Tests/Action/RankingBattle0Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle0Test.cs @@ -133,7 +133,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -167,7 +167,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -212,7 +212,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -247,7 +247,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -279,7 +279,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -325,7 +325,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException( { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -366,7 +366,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -417,7 +417,7 @@ public void ExecuteThrowNotEnoughFungibleAssetValueException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle10Test.cs b/.Lib9c.Tests/Action/RankingBattle10Test.cs index 2ddac7ab6d..f922416f46 100644 --- a/.Lib9c.Tests/Action/RankingBattle10Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle10Test.cs @@ -213,7 +213,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -267,7 +267,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -311,7 +311,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -345,7 +345,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -376,7 +376,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -409,7 +409,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -449,7 +449,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -482,13 +482,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -538,7 +538,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle11Test.cs b/.Lib9c.Tests/Action/RankingBattle11Test.cs index 9700fc141a..32b669f776 100644 --- a/.Lib9c.Tests/Action/RankingBattle11Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle11Test.cs @@ -196,7 +196,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -338,7 +338,7 @@ public void Execute_Backward_Compatible(bool isNew, bool avatarBackward, bool en var nextState = action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -393,7 +393,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -437,7 +437,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -471,7 +471,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -502,7 +502,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -535,7 +535,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -575,7 +575,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -650,7 +650,7 @@ public void Execute_Throw_NotEnoughAvatarLevelException(int avatarLevel) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = random, BlockIndex = 3806324 + 1, // Ranking Battle Action throws NotEnoughAvatarLevelException when BlockIndex is higher than 3806324. @@ -684,13 +684,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -740,7 +740,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -776,7 +776,7 @@ public void Execute_ActionObsoletedException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle2Test.cs b/.Lib9c.Tests/Action/RankingBattle2Test.cs index 2abc3e145d..f600df95d2 100644 --- a/.Lib9c.Tests/Action/RankingBattle2Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle2Test.cs @@ -126,7 +126,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -160,7 +160,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -205,7 +205,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -240,7 +240,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -272,7 +272,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -318,7 +318,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException( { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -359,7 +359,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -381,7 +381,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle3Test.cs b/.Lib9c.Tests/Action/RankingBattle3Test.cs index 59d05ded64..cc7b77d60b 100644 --- a/.Lib9c.Tests/Action/RankingBattle3Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle3Test.cs @@ -126,7 +126,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -160,7 +160,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -205,7 +205,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -240,7 +240,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -272,7 +272,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -318,7 +318,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException( { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -359,7 +359,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -381,7 +381,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -446,7 +446,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle4Test.cs b/.Lib9c.Tests/Action/RankingBattle4Test.cs index f278235617..ea224b0570 100644 --- a/.Lib9c.Tests/Action/RankingBattle4Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle4Test.cs @@ -163,7 +163,7 @@ public void Execute(bool isNew) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -196,7 +196,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -241,7 +241,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -276,7 +276,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -308,7 +308,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -342,7 +342,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -383,7 +383,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -405,7 +405,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -470,7 +470,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle5Test.cs b/.Lib9c.Tests/Action/RankingBattle5Test.cs index 4be495db00..3530ef0a3c 100644 --- a/.Lib9c.Tests/Action/RankingBattle5Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle5Test.cs @@ -193,7 +193,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -226,7 +226,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -271,7 +271,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -306,7 +306,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -338,7 +338,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -372,7 +372,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -413,7 +413,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -447,13 +447,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -470,7 +470,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -535,7 +535,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle6Test.cs b/.Lib9c.Tests/Action/RankingBattle6Test.cs index 4066ff608a..3a6c937905 100644 --- a/.Lib9c.Tests/Action/RankingBattle6Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle6Test.cs @@ -193,7 +193,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -226,7 +226,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -271,7 +271,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -306,7 +306,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -338,7 +338,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -372,7 +372,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -413,7 +413,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -447,13 +447,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -470,7 +470,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -535,7 +535,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle7Test.cs b/.Lib9c.Tests/Action/RankingBattle7Test.cs index 88839ac4e9..73e182eec4 100644 --- a/.Lib9c.Tests/Action/RankingBattle7Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle7Test.cs @@ -193,7 +193,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -226,7 +226,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -271,7 +271,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -306,7 +306,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -338,7 +338,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -372,7 +372,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -413,7 +413,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -447,13 +447,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -470,7 +470,7 @@ public void SerializeWithDotnetAPI() }; action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -535,7 +535,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle8Test.cs b/.Lib9c.Tests/Action/RankingBattle8Test.cs index b45436f132..c6f3d988de 100644 --- a/.Lib9c.Tests/Action/RankingBattle8Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle8Test.cs @@ -208,7 +208,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -263,7 +263,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -308,7 +308,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -343,7 +343,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -375,7 +375,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -409,7 +409,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -450,7 +450,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -484,13 +484,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -543,7 +543,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattle9Test.cs b/.Lib9c.Tests/Action/RankingBattle9Test.cs index d750e6ef04..255cec7975 100644 --- a/.Lib9c.Tests/Action/RankingBattle9Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle9Test.cs @@ -208,7 +208,7 @@ public void Execute(bool isNew, bool avatarBackward, bool enemyBackward) var nextState = action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -263,7 +263,7 @@ public void ExecuteThrowInvalidAddressException() { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -308,7 +308,7 @@ public void ExecuteThrowFailedLoadStateException(int caseIndex) { action.Execute(new ActionContext() { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = signer, Random = new TestRandom(), Rehearsal = false, @@ -343,7 +343,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -375,7 +375,7 @@ public void ExecuteThrowWeeklyArenaStateAlreadyEndedException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -409,7 +409,7 @@ public void ExecuteThrowWeeklyArenaStateNotContainsAvatarAddressException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -450,7 +450,7 @@ public void ExecuteThrowNotEnoughWeeklyArenaChallengeCountException() { action.Execute(new ActionContext() { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, @@ -484,13 +484,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -543,7 +543,7 @@ public void MultipleEquipmentTest(ItemSubType type, int maxCount) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RankingBattleTest.cs b/.Lib9c.Tests/Action/RankingBattleTest.cs index 252277e987..ef4cb8b7f7 100644 --- a/.Lib9c.Tests/Action/RankingBattleTest.cs +++ b/.Lib9c.Tests/Action/RankingBattleTest.cs @@ -168,7 +168,7 @@ public void ExecuteActionObsoletedException() { action.Execute(new ActionContext { - PreviousStates = previousState, + PreviousState = previousState, Signer = _agent1Address, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/RapidCombination0Test.cs b/.Lib9c.Tests/Action/RapidCombination0Test.cs index cee423b67c..dbb1b5ee88 100644 --- a/.Lib9c.Tests/Action/RapidCombination0Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination0Test.cs @@ -121,7 +121,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, }); @@ -155,7 +155,7 @@ public void ExecuteThrowCombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -209,7 +209,7 @@ public void ExecuteThrowCombinationSlotUnlockException(int avatarClearedStage, i Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -265,7 +265,7 @@ public void ExecuteThrowRequiredBlockIndexException(int itemRequiredBlockIndex, Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -333,7 +333,7 @@ public void ExecuteThrowNotEnoughMaterialException(int alreadyHasCount, int requ Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); diff --git a/.Lib9c.Tests/Action/RapidCombination2Test.cs b/.Lib9c.Tests/Action/RapidCombination2Test.cs index a7d14c842c..4f1d548c83 100644 --- a/.Lib9c.Tests/Action/RapidCombination2Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination2Test.cs @@ -121,7 +121,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, }); @@ -155,7 +155,7 @@ public void ExecuteThrowCombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -209,7 +209,7 @@ public void ExecuteThrowCombinationSlotUnlockException(int avatarClearedStage, i Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -265,7 +265,7 @@ public void ExecuteThrowRequiredBlockIndexException(int itemRequiredBlockIndex, Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -333,7 +333,7 @@ public void ExecuteThrowNotEnoughMaterialException(int alreadyHasCount, int requ Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); diff --git a/.Lib9c.Tests/Action/RapidCombination3Test.cs b/.Lib9c.Tests/Action/RapidCombination3Test.cs index a56383b77b..9f92a515c5 100644 --- a/.Lib9c.Tests/Action/RapidCombination3Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination3Test.cs @@ -122,7 +122,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, }); @@ -156,7 +156,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -210,7 +210,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -266,7 +266,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -342,7 +342,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); diff --git a/.Lib9c.Tests/Action/RapidCombination4Test.cs b/.Lib9c.Tests/Action/RapidCombination4Test.cs index bf6f4499c8..2d53e27c31 100644 --- a/.Lib9c.Tests/Action/RapidCombination4Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination4Test.cs @@ -137,7 +137,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, }); @@ -171,7 +171,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -225,7 +225,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -281,7 +281,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -357,7 +357,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -393,13 +393,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] diff --git a/.Lib9c.Tests/Action/RapidCombination5Test.cs b/.Lib9c.Tests/Action/RapidCombination5Test.cs index 129ceee9aa..3eca37dd0a 100644 --- a/.Lib9c.Tests/Action/RapidCombination5Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination5Test.cs @@ -137,7 +137,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -171,7 +171,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -225,7 +225,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -281,7 +281,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -357,7 +357,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, })); @@ -393,13 +393,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -525,7 +525,7 @@ public void Execute_Throw_RequiredAppraiseBlockException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); diff --git a/.Lib9c.Tests/Action/RapidCombination6Test.cs b/.Lib9c.Tests/Action/RapidCombination6Test.cs index 694fbec1ac..8c9cb18cca 100644 --- a/.Lib9c.Tests/Action/RapidCombination6Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination6Test.cs @@ -139,7 +139,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -173,7 +173,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -227,7 +227,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -283,7 +283,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -359,7 +359,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, })); @@ -395,13 +395,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -527,7 +527,7 @@ public void Execute_Throw_RequiredAppraiseBlockException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -703,7 +703,7 @@ public void Execute_Throw_InvalidOperationException_When_TargetSlotCreatedBy( { action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -713,7 +713,7 @@ public void Execute_Throw_InvalidOperationException_When_TargetSlotCreatedBy( { action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); diff --git a/.Lib9c.Tests/Action/RapidCombination8Test.cs b/.Lib9c.Tests/Action/RapidCombination8Test.cs index 9d54e19a23..bab26f22e2 100644 --- a/.Lib9c.Tests/Action/RapidCombination8Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination8Test.cs @@ -139,7 +139,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -173,7 +173,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -227,7 +227,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -283,7 +283,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -359,7 +359,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, })); @@ -395,13 +395,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -527,7 +527,7 @@ public void Execute_Throw_RequiredAppraiseBlockException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -698,7 +698,7 @@ public void Execute_NotThrow_InvalidOperationException_When_TargetSlotCreatedBy( action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); diff --git a/.Lib9c.Tests/Action/RapidCombinationTest.cs b/.Lib9c.Tests/Action/RapidCombinationTest.cs index 9a65884fd8..08c8a22dcf 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest.cs @@ -139,7 +139,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -173,7 +173,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -227,7 +227,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -283,7 +283,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -359,7 +359,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, })); @@ -395,13 +395,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -527,7 +527,7 @@ public void Execute_Throw_RequiredAppraiseBlockException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -698,7 +698,7 @@ public void Execute_NotThrow_InvalidOperationException_When_TargetSlotCreatedBy( action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); diff --git a/.Lib9c.Tests/Action/RapidCombinationTest7.cs b/.Lib9c.Tests/Action/RapidCombinationTest7.cs index c6d5f3ded8..1ba97cb9e5 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest7.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest7.cs @@ -139,7 +139,7 @@ public void Execute(bool backward) var nextState = action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); @@ -173,7 +173,7 @@ public void Execute_Throw_CombinationSlotResultNullException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -227,7 +227,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException(int avatarClearedS Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -283,7 +283,7 @@ public void Execute_Throw_RequiredBlockIndexException(int itemRequiredBlockIndex Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = contextBlockIndex, })); @@ -359,7 +359,7 @@ public void Execute_Throw_NotEnoughMaterialException(int materialCount, int trad Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, })); @@ -395,13 +395,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Theory] @@ -527,7 +527,7 @@ public void Execute_Throw_RequiredAppraiseBlockException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 1, })); @@ -698,7 +698,7 @@ public void Execute_NotThrow_InvalidOperationException_When_TargetSlotCreatedBy( action.Execute(new ActionContext { - PreviousStates = tempState, + PreviousState = tempState, Signer = _agentAddress, BlockIndex = 51, }); diff --git a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs index cc039ec5a4..0537ddc379 100644 --- a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs @@ -235,7 +235,7 @@ bool fromPreviousAction var expectedState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -282,7 +282,7 @@ bool fromPreviousAction var actualState = reRegister.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index 2ae9679112..58af0d2eaa 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -235,7 +235,7 @@ bool fromPreviousAction var expectedState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -282,7 +282,7 @@ bool fromPreviousAction var actualState = reRegister.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/RedeemCode0Test.cs b/.Lib9c.Tests/Action/RedeemCode0Test.cs index 2602d76200..0d4fe78005 100644 --- a/.Lib9c.Tests/Action/RedeemCode0Test.cs +++ b/.Lib9c.Tests/Action/RedeemCode0Test.cs @@ -92,7 +92,7 @@ public void Execute() { BlockIndex = 1, Miner = default, - PreviousStates = initialState, + PreviousState = initialState, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -125,13 +125,13 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), Rehearsal = true, Signer = _agentAddress, }); Assert.Equal( - nextState.UpdatedAddresses, + nextState.Delta.UpdatedAddresses, new[] { _avatarAddress, _agentAddress, RedeemCodeState.Address, GoldCurrencyState.Address }.ToImmutableHashSet() ); } diff --git a/.Lib9c.Tests/Action/RedeemCodeTest.cs b/.Lib9c.Tests/Action/RedeemCodeTest.cs index 610edddfc5..23447b5fc8 100644 --- a/.Lib9c.Tests/Action/RedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/RedeemCodeTest.cs @@ -107,7 +107,7 @@ public void Execute(bool backward) { BlockIndex = 1, Miner = default, - PreviousStates = initialState, + PreviousState = initialState, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -140,7 +140,7 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousStates = new State(), + PreviousState = new State(), Rehearsal = true, Signer = _agentAddress, }); @@ -156,7 +156,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyWorldInformationKey), _avatarAddress.Derive(LegacyQuestListKey), }.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } } diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index dbac77b50c..70c06ddc1e 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -243,7 +243,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _agentAddress, }); @@ -296,7 +296,7 @@ public void Execute_Validate_RegisterInfos(params ValidateMember[] validateMembe }; Assert.Throws(validateMember.Exc, () => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _agentAddress, })); @@ -369,7 +369,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo Signer = _agentAddress, BlockIndex = blockIndex, Random = new TestRandom(), - PreviousStates = _initialState, + PreviousState = _initialState, })); } diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 11e01340f4..0116ac1052 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -243,7 +243,7 @@ public void Execute() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _agentAddress, }); @@ -296,7 +296,7 @@ public void Execute_Validate_RegisterInfos(params ValidateMember[] validateMembe }; Assert.Throws(validateMember.Exc, () => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _agentAddress, })); @@ -370,7 +370,7 @@ public void Execute_Throw_ItemDoesNotExistException(ProductType type, int itemCo Signer = _agentAddress, BlockIndex = blockIndex, Random = new TestRandom(), - PreviousStates = _initialState, + PreviousState = _initialState, })); } diff --git a/.Lib9c.Tests/Action/RenewAdminStateTest.cs b/.Lib9c.Tests/Action/RenewAdminStateTest.cs index 98ee163b21..2d5d861ad8 100644 --- a/.Lib9c.Tests/Action/RenewAdminStateTest.cs +++ b/.Lib9c.Tests/Action/RenewAdminStateTest.cs @@ -36,7 +36,7 @@ public void Execute() var action = new RenewAdminState(newValidUntil); var stateDelta = action.Execute(new ActionContext { - PreviousStates = _stateDelta, + PreviousState = _stateDelta, Signer = _adminPrivateKey.ToAddress(), }); @@ -55,7 +55,7 @@ public void RejectSignerExceptAdminAddress() var userPrivateKey = new PrivateKey(); action.Execute(new ActionContext { - PreviousStates = _stateDelta, + PreviousState = _stateDelta, Signer = userPrivateKey.ToAddress(), }); }); @@ -69,7 +69,7 @@ public void RenewAdminStateEvenAlreadyExpired() var stateDelta = action.Execute(new ActionContext { BlockIndex = _validUntil + 1, - PreviousStates = _stateDelta, + PreviousState = _stateDelta, Signer = _adminPrivateKey.ToAddress(), }); @@ -105,7 +105,7 @@ public void CreatePendingActivationsAfterRenewAdminState() Assert.Throws(() => createPendingActivations.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = _stateDelta, + PreviousState = _stateDelta, Signer = _adminPrivateKey.ToAddress(), })); @@ -114,7 +114,7 @@ public void CreatePendingActivationsAfterRenewAdminState() var stateDelta = action.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = _stateDelta, + PreviousState = _stateDelta, Signer = _adminPrivateKey.ToAddress(), }); @@ -125,7 +125,7 @@ public void CreatePendingActivationsAfterRenewAdminState() stateDelta = createPendingActivations.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = stateDelta, + PreviousState = stateDelta, Signer = _adminPrivateKey.ToAddress(), }); diff --git a/.Lib9c.Tests/Action/RequestPledgeTest.cs b/.Lib9c.Tests/Action/RequestPledgeTest.cs index 01cdf957c1..5fd8f3b027 100644 --- a/.Lib9c.Tests/Action/RequestPledgeTest.cs +++ b/.Lib9c.Tests/Action/RequestPledgeTest.cs @@ -35,7 +35,7 @@ public void Execute(int contractedMead) var nextState = action.Execute(new ActionContext { Signer = patron, - PreviousStates = states, + PreviousState = states, }); var contract = Assert.IsType(nextState.GetState(address.GetPledgeAddress())); @@ -62,7 +62,7 @@ public void Execute_Throw_AlreadyContractedException() Assert.Throws(() => action.Execute(new ActionContext { Signer = patron, - PreviousStates = states, + PreviousState = states, })); } } diff --git a/.Lib9c.Tests/Action/RewardGoldTest.cs b/.Lib9c.Tests/Action/RewardGoldTest.cs index 85f564d0cd..cf01f11de9 100644 --- a/.Lib9c.Tests/Action/RewardGoldTest.cs +++ b/.Lib9c.Tests/Action/RewardGoldTest.cs @@ -127,7 +127,7 @@ public void WeeklyArenaRankingBoard(bool resetCount, bool updateNext) var ctx = new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _baseState, + PreviousState = _baseState, Miner = default, }; @@ -142,12 +142,12 @@ public void WeeklyArenaRankingBoard(bool resetCount, bool updateNext) var currentWeeklyState = nextState.GetWeeklyArenaState(0); var nextWeeklyState = nextState.GetWeeklyArenaState(1); - Assert.Contains(WeeklyArenaState.DeriveAddress(0), nextState.UpdatedAddresses); - Assert.Contains(WeeklyArenaState.DeriveAddress(1), nextState.UpdatedAddresses); + Assert.Contains(WeeklyArenaState.DeriveAddress(0), nextState.Delta.UpdatedAddresses); + Assert.Contains(WeeklyArenaState.DeriveAddress(1), nextState.Delta.UpdatedAddresses); if (updateNext) { - Assert.Contains(WeeklyArenaState.DeriveAddress(2), nextState.UpdatedAddresses); + Assert.Contains(WeeklyArenaState.DeriveAddress(2), nextState.Delta.UpdatedAddresses); Assert.Equal(blockIndex, nextWeeklyState.ResetIndex); } @@ -233,7 +233,7 @@ public void PrepareNextArena(int prevWeeklyIndex, int targetWeeklyIndex, long bl var ctx = new ActionContext() { BlockIndex = blockIndex, - PreviousStates = _baseState, + PreviousState = _baseState, Miner = default, }; @@ -313,7 +313,7 @@ public void ResetChallengeCount() var migrationCtx = new ActionContext { BlockIndex = RankingBattle11.UpdateTargetBlockIndex, - PreviousStates = _baseState, + PreviousState = _baseState, Miner = default, }; @@ -342,7 +342,7 @@ public void ResetChallengeCount() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Miner = default, }; @@ -376,7 +376,7 @@ public void GoldDistributedEachAccount() var ctx = new ActionContext() { BlockIndex = 0, - PreviousStates = _baseState, + PreviousState = _baseState, }; IAccountStateDelta delta; @@ -442,7 +442,7 @@ public void MiningReward() var ctx = new ActionContext() { BlockIndex = 0, - PreviousStates = _baseState, + PreviousState = _baseState, Miner = miner, }; diff --git a/.Lib9c.Tests/Action/RuneEnhancement0Test.cs b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs index 42b9c7c6f9..5ba311a434 100644 --- a/.Lib9c.Tests/Action/RuneEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs @@ -108,7 +108,7 @@ public void Execute(int seed) var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = rand, Rehearsal = false, Signer = agentAddress, @@ -203,7 +203,7 @@ public void Execute_RuneCostNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -268,7 +268,7 @@ public void Execute_RuneCostDataNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -361,7 +361,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -385,7 +385,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -439,7 +439,7 @@ public void Execute_TryCountIsZeroException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, diff --git a/.Lib9c.Tests/Action/RuneEnhancementTest.cs b/.Lib9c.Tests/Action/RuneEnhancementTest.cs index 0a1c7d939f..d1db93ea0c 100644 --- a/.Lib9c.Tests/Action/RuneEnhancementTest.cs +++ b/.Lib9c.Tests/Action/RuneEnhancementTest.cs @@ -118,7 +118,7 @@ public void Execute(int seed) var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = rand, Rehearsal = false, Signer = agentAddress, @@ -222,7 +222,7 @@ public void Execute_RuneCostNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -296,7 +296,7 @@ public void Execute_RuneCostDataNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -398,7 +398,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -422,7 +422,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -485,7 +485,7 @@ public void Execute_TryCountIsZeroException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -537,7 +537,7 @@ public void Execute_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, diff --git a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs index e0f65f3b4b..d6fd27d15e 100644 --- a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs @@ -114,7 +114,7 @@ public IAccountStateDelta JoinArena( _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, @@ -145,7 +145,7 @@ public IAccountStateDelta BattleArena( _state = action.Execute(new ActionContext { - PreviousStates = _state, + PreviousState = _state, Signer = signer, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs index efa324a4cc..1b080d3348 100644 --- a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs @@ -188,7 +188,7 @@ public void Case(int randomSeed, int[] optionNumbers) var random = new TestRandom(randomSeed); nextState = combinationEquipmentAction.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, BlockIndex = 0, Random = random, Signer = _agentAddress, @@ -284,7 +284,7 @@ public void Case(int randomSeed, int[] optionNumbers) nextState = rapidCombinationAction.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, BlockIndex = GameConfig.RequiredAppraiseBlock, Random = random, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs b/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs index de318d1410..067b05e0d0 100644 --- a/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ItemCraftTest.cs @@ -127,7 +127,7 @@ public void CraftEquipmentTest(int randomSeed, int[] targetItemIdList) stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -214,7 +214,7 @@ public void CraftConsumableTest(int randomSeed, int[] targetItemIdList) stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -298,7 +298,7 @@ int[] targetItemIdList stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = eventRow.StartBlockIndex, Random = random, @@ -396,7 +396,7 @@ int[] targetItemIdList stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = eventRow.StartBlockIndex, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index 8dc45a8d39..e3bfeb56eb 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -161,7 +161,7 @@ public void Register_And_Buy() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = random, Signer = _sellerAgentAddress, }); @@ -235,7 +235,7 @@ public void Register_And_Buy() var nextState2 = action2.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = nextState, + PreviousState = nextState, Random = random, Signer = _sellerAgentAddress2, }); @@ -293,7 +293,7 @@ public void Register_And_Buy() var latestState = action3.Execute(new ActionContext { BlockIndex = 3L, - PreviousStates = nextState2, + PreviousState = nextState2, Random = random, Signer = _buyerAgentAddress, }); @@ -392,7 +392,7 @@ public void Register_And_Cancel() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _sellerAgentAddress, }); @@ -480,7 +480,7 @@ public void Register_And_Cancel() var latestState = action2.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = nextState, + PreviousState = nextState, Random = new TestRandom(), Signer = _sellerAgentAddress, }); @@ -564,7 +564,7 @@ public void Register_And_ReRegister() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _sellerAgentAddress, }); @@ -688,7 +688,7 @@ public void Register_And_ReRegister() var latestState = action2.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = nextState, + PreviousState = nextState, Random = random, Signer = _sellerAgentAddress, }); @@ -809,7 +809,7 @@ public void ReRegister_Order() var nextState = action.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = _sellerAgentAddress, }); @@ -892,7 +892,7 @@ public void HardFork() var nextState = action.Execute(new ActionContext { BlockIndex = 1L, - PreviousStates = _initialState, + PreviousState = _initialState, Random = random, Signer = _sellerAgentAddress, }); @@ -969,7 +969,7 @@ public void HardFork() var canceledState = cancelAction.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = nextState, + PreviousState = nextState, Random = random, Signer = _sellerAgentAddress, }); @@ -1052,7 +1052,7 @@ public void HardFork() Assert.Throws(() => reRegisterAction.Execute(new ActionContext { BlockIndex = 2L, - PreviousStates = nextState, + PreviousState = nextState, Random = random, Signer = _sellerAgentAddress, })); @@ -1067,7 +1067,7 @@ public void HardFork() var tradedState = buyAction.Execute(new ActionContext { BlockIndex = 3L, - PreviousStates = nextState, + PreviousState = nextState, Random = random, Signer = _buyerAgentAddress, }); diff --git a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs index 3a6657f822..c06a66dc68 100644 --- a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs @@ -93,7 +93,7 @@ bool IsTarget(Type type) var action = (IAction)Activator.CreateInstance(typeId)!; var actionContext = new ActionContext { - PreviousStates = new State(), + PreviousState = new State(), }; try { @@ -119,7 +119,7 @@ private IAccountStateDelta Execute(IActionContext context, IAccountStateDelta st var executedState = action.Execute(new ActionContext { Signer = signer, - PreviousStates = nextState, + PreviousState = nextState, }); return RewardGold.TransferMead(context, executedState); } diff --git a/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs index 1468dc4e36..9903f89947 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs @@ -126,7 +126,7 @@ int petLevel }; stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -166,7 +166,7 @@ int petLevel }; stateV2 = petAction.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs index b1bf1cf154..4a19f52057 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs @@ -114,7 +114,7 @@ public void PetCannotBeUsedToTwoSlotsAtTheSameTime() }; stateV2 = action1.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -132,7 +132,7 @@ public void PetCannotBeUsedToTwoSlotsAtTheSameTime() Assert.Throws(() => action2.Execute( new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 1L, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs index 12d251ad53..9d14c3e9e9 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs @@ -126,7 +126,7 @@ public void CraftEquipmentTest( stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs index f756d5c53c..f07fcb2a20 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs @@ -160,7 +160,7 @@ public void RapidCombinationTest_Equipment( stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -174,7 +174,7 @@ public void RapidCombinationTest_Equipment( }; stateV2 = rapidAction.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = stateV2.GetGameConfigState().RequiredAppraiseBlock, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs b/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs index 3cf9afeaed..be6321b7d2 100644 --- a/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs +++ b/.Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs @@ -117,7 +117,7 @@ public void CombinationEquipmentTest( stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs b/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs index b102f7fda1..5d7c952004 100644 --- a/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RapidCombinationTest.cs @@ -146,7 +146,7 @@ int expectedHourGlassCount stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = 0L, Random = random, @@ -168,7 +168,7 @@ int expectedHourGlassCount }; stateV2 = action.Execute(new ActionContext { - PreviousStates = stateV2, + PreviousState = stateV2, Signer = _agentAddr, BlockIndex = stateV2.GetGameConfigState().RequiredAppraiseBlock, Random = random, diff --git a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs index 09bf0a772c..eaf8fe287a 100644 --- a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs @@ -79,7 +79,7 @@ public void Craft_And_Equip() var state = craftAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = initialState, + PreviousState = initialState, Random = new TestRandom(), Signer = agentAddress, }); @@ -109,7 +109,7 @@ public void Craft_And_Equip() var nextState = has.Execute(new ActionContext { BlockIndex = 2, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(), Signer = agentAddress, }); diff --git a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs index cb790f3c5c..3c24132ba3 100644 --- a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs +++ b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs @@ -112,7 +112,7 @@ public void Execute_With_TradableMaterial() nextStates = sellAction.Execute(new ActionContext { Signer = _agentAddress, - PreviousStates = nextStates, + PreviousState = nextStates, BlockIndex = sellBlockIndex, Random = random, Rehearsal = false, @@ -140,7 +140,7 @@ public void Execute_With_TradableMaterial() nextStates = sellCancellationAction.Execute(new ActionContext { Signer = _agentAddress, - PreviousStates = nextStates, + PreviousState = nextStates, BlockIndex = sellBlockIndex + 1L, Random = random, Rehearsal = false, @@ -161,7 +161,7 @@ public void Execute_With_TradableMaterial() nextStates = newSellAction.Execute(new ActionContext { Signer = _agentAddress, - PreviousStates = nextStates, + PreviousState = nextStates, BlockIndex = sellBlockIndex + 2L, Random = random, Rehearsal = false, diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs index abf89c1ed0..3c216744e0 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs @@ -637,7 +637,7 @@ public void StakeAndClaimStakeReward(long stakeAmount, (int ItemId, int Amount)[ IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 0, }); @@ -648,7 +648,7 @@ public void StakeAndClaimStakeReward(long stakeAmount, (int ItemId, int Amount)[ action = new ClaimStakeReward2(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = receiveBlockIndex, }); @@ -688,7 +688,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 0, }); @@ -705,7 +705,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward2(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = newStakeBlockIndex, }); @@ -715,7 +715,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = newStakeBlockIndex, }); @@ -762,7 +762,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 0, }); @@ -779,7 +779,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward2(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval - 1, }); @@ -788,7 +788,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta // 락업기간 이전에 deposit을 감소해서 save할때 락업되어 거부되는가 Assert.Throws(() => states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval - 1, })); @@ -820,7 +820,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 0, }); @@ -832,7 +832,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new action = new ClaimStakeReward2(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = claimBlockIndex, }); @@ -854,7 +854,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new action = new Stake(newStakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval, }); @@ -884,7 +884,7 @@ public void StakeLessAfterLockup(long initialBalance, long stakeAmount, long new action = new ClaimStakeReward2(_avatarAddress); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval + 1, }); @@ -912,7 +912,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() IAction action = new Stake(500); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 0, }); @@ -920,7 +920,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() action = new ClaimStakeReward2(_avatarAddress); Assert.Throws(() => states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.RewardInterval - 1, })); diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs index bcadbae5d8..8a278ca4f9 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward3ScenarioTest.cs @@ -607,7 +607,7 @@ public void StakeAndClaimStakeReward( IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -619,7 +619,7 @@ public void StakeAndClaimStakeReward( action = new ClaimStakeReward3(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = receiveBlockIndex, }); @@ -660,7 +660,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -677,7 +677,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward3(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = newStakeBlockIndex, }); @@ -687,7 +687,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = newStakeBlockIndex, }); @@ -734,7 +734,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -751,7 +751,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward3(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, }); @@ -760,7 +760,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta // 락업기간 이전에 deposit을 감소해서 save할때 락업되어 거부되는가 Assert.Throws(() => states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, })); @@ -796,7 +796,7 @@ public void StakeLessAfterLockup( IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -808,7 +808,7 @@ public void StakeLessAfterLockup( action = new ClaimStakeReward3(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = claimBlockIndex, }); @@ -830,7 +830,7 @@ public void StakeLessAfterLockup( action = new Stake(newStakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval, }); @@ -860,7 +860,7 @@ public void StakeLessAfterLockup( action = new ClaimStakeReward3(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval + 1, }); @@ -888,7 +888,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() IAction action = new Stake(500); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -896,7 +896,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() action = new ClaimStakeReward3(_avatarAddr); Assert.Throws(() => states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.RewardInterval - 1, })); diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs index d72ae993c3..7241e3ffc0 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeRewardScenarioTest.cs @@ -690,7 +690,7 @@ public void StakeAndClaimStakeReward( IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -704,7 +704,7 @@ public void StakeAndClaimStakeReward( action = new ClaimStakeReward(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = receiveBlockIndex, }); @@ -758,7 +758,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -775,7 +775,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = newStakeBlockIndex, }); @@ -785,7 +785,7 @@ public void StakeAndStakeMore(long initialBalance, long stakeAmount, long newSta // 락업기간 이전에 deposit을 추가해서 save 할 수 있는지 states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = newStakeBlockIndex, }); @@ -833,7 +833,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -850,7 +850,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta action = new ClaimStakeReward(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, }); @@ -860,7 +860,7 @@ public void StakeAndStakeLess(long initialBalance, long stakeAmount, long newSta Assert.Throws(() => states = action.Execute( new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval - 1, })); @@ -897,7 +897,7 @@ public void StakeLessAfterLockup( IAction action = new Stake(stakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -909,7 +909,7 @@ public void StakeLessAfterLockup( action = new ClaimStakeReward(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = claimBlockIndex, }); @@ -931,7 +931,7 @@ public void StakeLessAfterLockup( action = new Stake(newStakeAmount); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval, }); @@ -964,7 +964,7 @@ public void StakeLessAfterLockup( action = new ClaimStakeReward(_avatarAddr); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.LockupInterval + 1, @@ -993,7 +993,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() IAction action = new Stake(500); states = action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex, }); @@ -1002,7 +1002,7 @@ public void StakeAndClaimStakeRewardBeforeRewardInterval() Assert.Throws(() => states = action.Execute( new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _agentAddr, BlockIndex = ClaimStakeReward2.ObsoletedIndex + StakeState.RewardInterval - 1, })); diff --git a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs index 9de878fe21..8a360f38a0 100644 --- a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs @@ -104,7 +104,7 @@ public void UnlockWorldByHackAndSlashAfterPatchTableWithAddRow( }; nextState = hackAndSlash.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -136,7 +136,7 @@ public void UnlockWorldByHackAndSlashAfterPatchTableWithAddRow( }; nextState = patchTableSheet.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = AdminState.Address, Random = new TestRandom(), Rehearsal = false, @@ -147,7 +147,7 @@ public void UnlockWorldByHackAndSlashAfterPatchTableWithAddRow( nextState = hackAndSlash.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -226,7 +226,7 @@ public void UnlockWorldByMimisbrunnrBattleAfterPatchTableWithChangeRow( { nextState = mimisbrunnrBattle.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, @@ -246,7 +246,7 @@ public void UnlockWorldByMimisbrunnrBattleAfterPatchTableWithChangeRow( nextState = patchTableSheet.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = AdminState.Address, Random = new TestRandom(), Rehearsal = false, @@ -257,7 +257,7 @@ public void UnlockWorldByMimisbrunnrBattleAfterPatchTableWithChangeRow( nextState = mimisbrunnrBattle.Execute(new ActionContext { - PreviousStates = nextState, + PreviousState = nextState, Signer = _agentAddress, Random = new TestRandom(), Rehearsal = false, diff --git a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs index 9536cf61c8..a4e9491292 100644 --- a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs +++ b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs @@ -52,7 +52,7 @@ public void Execute() IAccountStateDelta nextState = action.Execute( new ActionContext { - PreviousStates = _previousState, + PreviousState = _previousState, Signer = _admin, Rehearsal = false, BlockIndex = 1, @@ -82,7 +82,7 @@ public void Execute_InvalidSigner() Assert.Throws(() => action.Execute( new ActionContext { - PreviousStates = _previousState, + PreviousState = _previousState, Signer = invalidSigner, Rehearsal = false, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/Sell0Test.cs b/.Lib9c.Tests/Action/Sell0Test.cs index 3debc2baa8..4599fd5457 100644 --- a/.Lib9c.Tests/Action/Sell0Test.cs +++ b/.Lib9c.Tests/Action/Sell0Test.cs @@ -104,7 +104,7 @@ public void Execute() var nextState = sellAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -137,7 +137,7 @@ public void ExecuteThrowInvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -155,7 +155,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -184,7 +184,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -202,7 +202,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -229,7 +229,7 @@ public void ExecuteThrowRequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell10Test.cs b/.Lib9c.Tests/Action/Sell10Test.cs index d58e2decb9..e1ee81f5b0 100644 --- a/.Lib9c.Tests/Action/Sell10Test.cs +++ b/.Lib9c.Tests/Action/Sell10Test.cs @@ -164,7 +164,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -235,7 +235,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -256,7 +256,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -288,7 +288,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -327,7 +327,7 @@ public void Execute_Throw_ItemDoesNotExistException(bool isLock) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -358,7 +358,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -409,7 +409,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -447,13 +447,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/Sell11Test.cs b/.Lib9c.Tests/Action/Sell11Test.cs index 317b9b4751..48ea71557c 100644 --- a/.Lib9c.Tests/Action/Sell11Test.cs +++ b/.Lib9c.Tests/Action/Sell11Test.cs @@ -164,7 +164,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -241,7 +241,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_InvalidCurrencyPrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -262,7 +262,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_NonZeroMinorUnitPrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_NegativePrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -304,7 +304,7 @@ public void Execute_Throw_InvalidOperationException_DueTo_EmptyState() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -336,7 +336,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -375,7 +375,7 @@ public void Execute_Throw_ItemDoesNotExistException(bool isLock) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -406,7 +406,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -457,7 +457,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -495,13 +495,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/Sell2Test.cs b/.Lib9c.Tests/Action/Sell2Test.cs index cb2da199ae..32d1cc3591 100644 --- a/.Lib9c.Tests/Action/Sell2Test.cs +++ b/.Lib9c.Tests/Action/Sell2Test.cs @@ -121,7 +121,7 @@ public void Execute() var nextState = sellAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = random, @@ -174,7 +174,7 @@ public void ExecuteThrowInvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -192,7 +192,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -221,7 +221,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -239,7 +239,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -267,7 +267,7 @@ public void ExecuteThrowRequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/Sell3Test.cs b/.Lib9c.Tests/Action/Sell3Test.cs index f4f8c86f03..c19399622c 100644 --- a/.Lib9c.Tests/Action/Sell3Test.cs +++ b/.Lib9c.Tests/Action/Sell3Test.cs @@ -132,7 +132,7 @@ public void Execute() var nextState = sellAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = random, @@ -175,7 +175,7 @@ public void ExecuteThrowInvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -193,7 +193,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -222,7 +222,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -240,7 +240,7 @@ public void ExecuteThrowItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -268,7 +268,7 @@ public void ExecuteThrowRequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/Sell4Test.cs b/.Lib9c.Tests/Action/Sell4Test.cs index 046610b436..e2fbe84d55 100644 --- a/.Lib9c.Tests/Action/Sell4Test.cs +++ b/.Lib9c.Tests/Action/Sell4Test.cs @@ -159,7 +159,7 @@ public void Execute(ItemType itemType, bool shopItemExist, int blockIndex) var nextState = sellAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -205,7 +205,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -224,7 +224,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -254,7 +254,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -273,7 +273,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -302,7 +302,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -331,7 +331,7 @@ public void Execute_Throw_RequiredBlockIndexException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/Sell5Test.cs b/.Lib9c.Tests/Action/Sell5Test.cs index 5eb6104274..1c136070eb 100644 --- a/.Lib9c.Tests/Action/Sell5Test.cs +++ b/.Lib9c.Tests/Action/Sell5Test.cs @@ -179,7 +179,7 @@ int expectedProductsCount var nextState = sellAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -280,7 +280,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -300,7 +300,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -331,7 +331,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -351,7 +351,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -381,7 +381,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/Sell6Test.cs b/.Lib9c.Tests/Action/Sell6Test.cs index 4f0a19a6fd..0d1674482a 100644 --- a/.Lib9c.Tests/Action/Sell6Test.cs +++ b/.Lib9c.Tests/Action/Sell6Test.cs @@ -180,7 +180,7 @@ int expectedProductsCount var nextState = sellAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -511,7 +511,7 @@ public void Execute_20210604( var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -583,7 +583,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -603,7 +603,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -634,7 +634,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -654,7 +654,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -684,7 +684,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/Sell7Test.cs b/.Lib9c.Tests/Action/Sell7Test.cs index d84870930c..6348104fce 100644 --- a/.Lib9c.Tests/Action/Sell7Test.cs +++ b/.Lib9c.Tests/Action/Sell7Test.cs @@ -194,7 +194,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -276,7 +276,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -297,7 +297,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -329,7 +329,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -350,7 +350,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -381,7 +381,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -432,7 +432,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -470,13 +470,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/Sell8Test.cs b/.Lib9c.Tests/Action/Sell8Test.cs index c9ceddb139..3df907d76f 100644 --- a/.Lib9c.Tests/Action/Sell8Test.cs +++ b/.Lib9c.Tests/Action/Sell8Test.cs @@ -194,7 +194,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -269,7 +269,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -290,7 +290,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -322,7 +322,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -343,7 +343,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -374,7 +374,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -425,7 +425,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -463,13 +463,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/Sell9Test.cs b/.Lib9c.Tests/Action/Sell9Test.cs index c1a837278f..055937acdf 100644 --- a/.Lib9c.Tests/Action/Sell9Test.cs +++ b/.Lib9c.Tests/Action/Sell9Test.cs @@ -164,7 +164,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -235,7 +235,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -256,7 +256,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -288,7 +288,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -327,7 +327,7 @@ public void Execute_Throw_ItemDoesNotExistException(bool isLock) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -358,7 +358,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -409,7 +409,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -447,13 +447,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/SellCancellation0Test.cs b/.Lib9c.Tests/Action/SellCancellation0Test.cs index afc7de2a1a..a94e708c58 100644 --- a/.Lib9c.Tests/Action/SellCancellation0Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation0Test.cs @@ -104,7 +104,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation2Test.cs b/.Lib9c.Tests/Action/SellCancellation2Test.cs index a49e68229d..784d4f65a4 100644 --- a/.Lib9c.Tests/Action/SellCancellation2Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation2Test.cs @@ -121,7 +121,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation3Test.cs b/.Lib9c.Tests/Action/SellCancellation3Test.cs index eca607ca8b..0685f25274 100644 --- a/.Lib9c.Tests/Action/SellCancellation3Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation3Test.cs @@ -131,7 +131,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -161,7 +161,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation4Test.cs b/.Lib9c.Tests/Action/SellCancellation4Test.cs index 25e9c674d3..2421ecca8e 100644 --- a/.Lib9c.Tests/Action/SellCancellation4Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation4Test.cs @@ -131,7 +131,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -161,7 +161,7 @@ public void Execute() var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = previousStates, + PreviousState = previousStates, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellation5Test.cs b/.Lib9c.Tests/Action/SellCancellation5Test.cs index 2321f08854..6f2592aee6 100644 --- a/.Lib9c.Tests/Action/SellCancellation5Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation5Test.cs @@ -158,7 +158,7 @@ public void Execute(ItemType itemType, string guid, bool contain) var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -188,7 +188,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = default, }) @@ -219,7 +219,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Signer = _agentAddress, })); } @@ -256,7 +256,7 @@ public void Execute_Throw_ItemDoesNotExistException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -296,7 +296,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -336,7 +336,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) diff --git a/.Lib9c.Tests/Action/SellCancellation6Test.cs b/.Lib9c.Tests/Action/SellCancellation6Test.cs index 360ed043b3..47dda389d6 100644 --- a/.Lib9c.Tests/Action/SellCancellation6Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation6Test.cs @@ -193,7 +193,7 @@ public void Execute(ItemType itemType, string guid, bool contain, int itemCount, var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -241,7 +241,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = default, }) @@ -272,7 +272,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Signer = _agentAddress, })); } @@ -341,7 +341,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) ItemDoesNotExistException exc = Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -382,7 +382,7 @@ public void Execute_Throw_InvalidAddressException_From_Agent() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -422,7 +422,7 @@ public void Execute_Throw_InvalidAddressException_From_Avatar() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) diff --git a/.Lib9c.Tests/Action/SellCancellation7Test.cs b/.Lib9c.Tests/Action/SellCancellation7Test.cs index 0d7ab9f6fd..4a5bf18951 100644 --- a/.Lib9c.Tests/Action/SellCancellation7Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation7Test.cs @@ -227,7 +227,7 @@ bool backward var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -280,7 +280,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = default, }) @@ -311,7 +311,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Signer = _agentAddress, })); } @@ -385,7 +385,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) ItemDoesNotExistException exc = Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -446,7 +446,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -479,13 +479,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] diff --git a/.Lib9c.Tests/Action/SellCancellation8Test.cs b/.Lib9c.Tests/Action/SellCancellation8Test.cs index acfb944e7d..9a043ebc28 100644 --- a/.Lib9c.Tests/Action/SellCancellation8Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation8Test.cs @@ -229,7 +229,7 @@ bool fromPreviousAction var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = default, }) @@ -314,7 +314,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Signer = _agentAddress, })); } @@ -403,7 +403,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) ItemDoesNotExistException exc = Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -467,7 +467,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -500,13 +500,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -674,7 +674,7 @@ bool fromPreviousAction var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellCancellationTest.cs b/.Lib9c.Tests/Action/SellCancellationTest.cs index 354ac0fc0f..3ab9c0a2c2 100644 --- a/.Lib9c.Tests/Action/SellCancellationTest.cs +++ b/.Lib9c.Tests/Action/SellCancellationTest.cs @@ -233,7 +233,7 @@ bool fromPreviousAction var expectedState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -261,7 +261,7 @@ bool fromPreviousAction var actualState = cancelProductRegistration.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -318,7 +318,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Random = new TestRandom(), Signer = default, }) @@ -349,7 +349,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Signer = _agentAddress, })); } @@ -438,7 +438,7 @@ public void Execute_Throw_ItemDoesNotExistException(ItemType itemType) ItemDoesNotExistException exc = Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -502,7 +502,7 @@ public void Execute_Throw_InvalidAddressException(bool useAgentAddress, bool use Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Signer = _agentAddress, }) @@ -535,13 +535,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } [Fact] @@ -709,7 +709,7 @@ bool fromPreviousAction var nextState = sellCancellationAction.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/SellTest.cs b/.Lib9c.Tests/Action/SellTest.cs index b003b357d4..8d734ea0bd 100644 --- a/.Lib9c.Tests/Action/SellTest.cs +++ b/.Lib9c.Tests/Action/SellTest.cs @@ -163,7 +163,7 @@ bool backward var nextState = sellAction.Execute(new ActionContext { BlockIndex = blockIndex, - PreviousStates = previousStates, + PreviousState = previousStates, Rehearsal = false, Signer = _agentAddress, Random = new TestRandom(), @@ -240,7 +240,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_InvalidCurrencyPrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -261,7 +261,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_NonZeroMinorUnitPrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -282,7 +282,7 @@ public void Execute_Throw_InvalidPriceException_DueTo_NegativePrice() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -303,7 +303,7 @@ public void Execute_Throw_InvalidOperationException_DueTo_EmptyState() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -335,7 +335,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -374,7 +374,7 @@ public void Execute_Throw_ItemDoesNotExistException(bool isLock) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -405,7 +405,7 @@ public void Execute_Throw_InvalidItemTypeException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 11, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, Random = new TestRandom(), })); @@ -456,7 +456,7 @@ public void Execute_Throw_DuplicateOrderIdException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 1, - PreviousStates = previousStates, + PreviousState = previousStates, Signer = _agentAddress, Random = new TestRandom(), })); @@ -494,13 +494,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index a00a891c02..a9b0ec1204 100644 --- a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs +++ b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs @@ -53,7 +53,7 @@ public Task TransferCrystal() var actionContext = new ActionContext { Signer = senderAddress, - PreviousStates = state, + PreviousState = state, }; var action = new TransferAsset0( senderAddress, @@ -92,7 +92,7 @@ public Task TransferWithMemo() var actionContext = new ActionContext { Signer = senderAddress, - PreviousStates = state, + PreviousState = state, }; var action = new TransferAsset0( senderAddress, diff --git a/.Lib9c.Tests/Action/Stake0Test.cs b/.Lib9c.Tests/Action/Stake0Test.cs index c1140811eb..9a0d3b89e3 100644 --- a/.Lib9c.Tests/Action/Stake0Test.cs +++ b/.Lib9c.Tests/Action/Stake0Test.cs @@ -59,7 +59,7 @@ public void Execute_Throws_WhenNotEnoughBalance() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 100, })); @@ -83,7 +83,7 @@ public void Execute_Throws_WhenThereIsMonsterCollection() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 100, })); @@ -101,7 +101,7 @@ public void Execute_Throws_WhenClaimableExisting() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.RewardInterval, })); @@ -113,7 +113,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() var action = new Stake0(51); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -122,7 +122,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() var updateAction = new Stake0(0); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, })); @@ -131,7 +131,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() updateAction = new Stake0(50); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, })); @@ -147,7 +147,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() updateAction = new Stake0(51); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 4611070, })); @@ -155,7 +155,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() // At 4611070 - 99, it should be updated. Assert.True(updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 4611070 - 99, }).TryGetStakeState(_signerAddress, out stakeState)); @@ -168,7 +168,7 @@ public void Execute() var action = new Stake0(100); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -201,7 +201,7 @@ public void Execute() var cancelAction = new Stake0(0); states = cancelAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval, }); @@ -217,7 +217,7 @@ public void Update() var action = new Stake0(50); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -232,7 +232,7 @@ public void Update() var updateAction = new Stake0(100); states = updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, }); diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index 49b860f71e..f8c42eae2b 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -59,7 +59,7 @@ public void Execute_Throws_WhenNotEnoughBalance() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 100, })); @@ -83,7 +83,7 @@ public void Execute_Throws_WhenThereIsMonsterCollection() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 100, })); @@ -101,7 +101,7 @@ public void Execute_Throws_WhenClaimableExisting() Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.RewardInterval, })); @@ -113,7 +113,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() var action = new Stake(51); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -122,7 +122,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() var updateAction = new Stake(0); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, })); @@ -131,7 +131,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() updateAction = new Stake(50); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, })); @@ -147,7 +147,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() updateAction = new Stake(51); Assert.Throws(() => updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 4611070, })); @@ -155,7 +155,7 @@ public void Execute_Throws_WhenCancelOrUpdateWhileLockup() // At 4611070 - 99, it should be updated. Assert.True(updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 4611070 - 99, }).TryGetStakeState(_signerAddress, out stakeState)); @@ -168,7 +168,7 @@ public void Execute() var action = new Stake(100); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -201,7 +201,7 @@ public void Execute() var cancelAction = new Stake(0); states = cancelAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = StakeState.LockupInterval, }); @@ -217,7 +217,7 @@ public void Update() var action = new Stake(50); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _signerAddress, BlockIndex = 0, }); @@ -232,7 +232,7 @@ public void Update() var updateAction = new Stake(100); states = updateAction.Execute(new ActionContext { - PreviousStates = states, + PreviousState = states, Signer = _signerAddress, BlockIndex = 1, }); diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index 32ed2c9d29..1bb6bfaca7 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -64,7 +64,7 @@ public void Execute() ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -93,7 +93,7 @@ public void ExecuteWithInvalidSigner() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -124,7 +124,7 @@ public void ExecuteWithInvalidRecipient() // No exception should be thrown when its index is less then 380000. _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -134,7 +134,7 @@ public void ExecuteWithInvalidRecipient() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 380001, @@ -164,7 +164,7 @@ public void ExecuteWithInsufficientBalance() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -194,7 +194,7 @@ public void ExecuteWithMinterAsSender() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -228,7 +228,7 @@ public void ExecuteWithMinterAsRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -263,7 +263,7 @@ public void ExecuteWithUnactivatedRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -284,7 +284,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -295,11 +295,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] @@ -394,7 +394,7 @@ public void CheckObsolete() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index 5d99bef872..56dde3ba42 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -89,7 +89,7 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -118,7 +118,7 @@ public void ExecuteWithInvalidSigner() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -150,7 +150,7 @@ public void ExecuteWithInvalidRecipient() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -180,7 +180,7 @@ public void ExecuteWithInsufficientBalance() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -210,7 +210,7 @@ public void ExecuteWithMinterAsSender() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -244,7 +244,7 @@ public void ExecuteWithMinterAsRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -279,7 +279,7 @@ public void ExecuteWithUnactivatedRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -300,7 +300,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -311,11 +311,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] @@ -385,7 +385,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() ); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index 7c03536b61..9d58c01bd2 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -67,7 +67,7 @@ public void Execute() ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -97,7 +97,7 @@ public void Execute_Throw_InvalidTransferSignerException() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -130,7 +130,7 @@ public void Execute_Throw_InvalidTransferRecipientException() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -161,7 +161,7 @@ public void Execute_Throw_InsufficientBalanceException() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -198,7 +198,7 @@ public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -222,7 +222,7 @@ public void Rehearsal() var context = new ActionContext(); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State().MintAsset(context, _sender, Currencies.Mead * 1), + PreviousState = new State().MintAsset(context, _sender, Currencies.Mead * 1), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -233,11 +233,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency, Currencies.Mead, }.ToImmutableHashSet(), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] @@ -308,7 +308,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() ); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 97330ea834..e51f0d6771 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -59,7 +59,7 @@ public void Execute() ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -88,7 +88,7 @@ public void ExecuteWithInvalidSigner() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -119,7 +119,7 @@ public void ExecuteWithInvalidRecipient() // No exception should be thrown when its index is less then 380000. _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -129,7 +129,7 @@ public void ExecuteWithInvalidRecipient() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 380001, @@ -159,7 +159,7 @@ public void ExecuteWithInsufficientBalance() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -189,7 +189,7 @@ public void ExecuteWithMinterAsSender() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -223,7 +223,7 @@ public void ExecuteWithMinterAsRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -246,7 +246,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -257,11 +257,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index bb3b4a35ac..51f560686a 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -114,7 +114,7 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -146,7 +146,7 @@ public void ExecuteWithInvalidSigner() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -180,7 +180,7 @@ public void ExecuteWithInvalidRecipient() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -212,7 +212,7 @@ public void ExecuteWithInsufficientBalance() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -244,7 +244,7 @@ public void ExecuteWithMinterAsSender() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -280,7 +280,7 @@ public void ExecuteWithMinterAsRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -317,7 +317,7 @@ public void ExecuteWithUnactivatedRecipient() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -340,7 +340,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -351,11 +351,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] @@ -472,7 +472,7 @@ public void Execute_Throw_ArgumentOutOfRangeException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -503,7 +503,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() ); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 74c60adaad..9281e0878f 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -86,7 +86,7 @@ public void Execute() ); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -120,7 +120,7 @@ public void Execute_Throw_InvalidTransferSignerException() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, // 송금자가 직접 사인하지 않으면 실패해야 합니다. Signer = _recipient, Rehearsal = false, @@ -154,7 +154,7 @@ public void Execute_Throw_InvalidTransferRecipientException() { _ = action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -187,7 +187,7 @@ public void Execute_Throw_InsufficientBalanceException() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -222,7 +222,7 @@ public void Execute_Throw_InvalidTransferMinterException() { action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -247,7 +247,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousStates = new State(ImmutableDictionary.Empty), + PreviousState = new State(ImmutableDictionary.Empty), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -258,11 +258,11 @@ public void Rehearsal() _sender, _recipient ), - nextState.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet() ); Assert.Equal( new[] { _currency }, - nextState.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); + nextState.Delta.UpdatedFungibleAssets.Select(pair => pair.Item2).ToImmutableHashSet()); } [Theory] @@ -379,7 +379,7 @@ public void Execute_Throw_ArgumentOutOfRangeException() { action.Execute(new ActionContext() { - PreviousStates = new State(), + PreviousState = new State(), Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -410,7 +410,7 @@ public void Execute_Throw_InvalidTransferCurrencyException() ); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = prevState, + PreviousState = prevState, Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs index 7c37ee739d..8a59f1e7db 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs @@ -143,7 +143,7 @@ Type exc { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -161,7 +161,7 @@ Type exc { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs index a59c79ef9b..be1396455f 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs @@ -143,7 +143,7 @@ Type exc { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -161,7 +161,7 @@ Type exc { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs index b7076d9a13..6902af9ffe 100644 --- a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs +++ b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs @@ -78,7 +78,7 @@ public void Execute(int slotIndex) var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -129,7 +129,7 @@ public void Execute_InsufficientBalanceException() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -138,7 +138,7 @@ public void Execute_InsufficientBalanceException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -158,7 +158,7 @@ public void Execute_SlotNotFoundException() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -167,7 +167,7 @@ public void Execute_SlotNotFoundException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -187,7 +187,7 @@ public void Execute_MismatchRuneSlotTypeException() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -196,7 +196,7 @@ public void Execute_MismatchRuneSlotTypeException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, @@ -220,7 +220,7 @@ public void Execute_SlotIsAlreadyUnlockedException() var ctx = new ActionContext { BlockIndex = blockIndex, - PreviousStates = state, + PreviousState = state, Random = new TestRandom(0), Rehearsal = false, Signer = agentAddress, @@ -231,7 +231,7 @@ public void Execute_SlotIsAlreadyUnlockedException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, Random = new TestRandom(), BlockIndex = blockIndex, diff --git a/.Lib9c.Tests/Action/UnlockWorld1Test.cs b/.Lib9c.Tests/Action/UnlockWorld1Test.cs index ef3f683cd9..a509e939cc 100644 --- a/.Lib9c.Tests/Action/UnlockWorld1Test.cs +++ b/.Lib9c.Tests/Action/UnlockWorld1Test.cs @@ -156,7 +156,7 @@ Type exc { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -174,7 +174,7 @@ Type exc { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/UnlockWorldTest.cs b/.Lib9c.Tests/Action/UnlockWorldTest.cs index 9bdef08cc0..f5d62ae2ef 100644 --- a/.Lib9c.Tests/Action/UnlockWorldTest.cs +++ b/.Lib9c.Tests/Action/UnlockWorldTest.cs @@ -158,7 +158,7 @@ Type exc { IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, @@ -176,7 +176,7 @@ Type exc { Assert.Throws(exc, () => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/UpdateSell0Test.cs b/.Lib9c.Tests/Action/UpdateSell0Test.cs index dca888301c..ce45a4c9b3 100644 --- a/.Lib9c.Tests/Action/UpdateSell0Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell0Test.cs @@ -244,7 +244,7 @@ bool legacy var nextState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -276,7 +276,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -298,7 +298,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -331,7 +331,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -371,13 +371,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/UpdateSell2Test.cs b/.Lib9c.Tests/Action/UpdateSell2Test.cs index e535d456cb..617f262a27 100644 --- a/.Lib9c.Tests/Action/UpdateSell2Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell2Test.cs @@ -225,7 +225,7 @@ bool fromPreviousAction var nextState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -257,7 +257,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -279,7 +279,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -312,7 +312,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -352,13 +352,13 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, Rehearsal = true, }); - Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.UpdatedAddresses); + Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses); } } } diff --git a/.Lib9c.Tests/Action/UpdateSell3Test.cs b/.Lib9c.Tests/Action/UpdateSell3Test.cs index 8554da6fd0..aab0dd612d 100644 --- a/.Lib9c.Tests/Action/UpdateSell3Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell3Test.cs @@ -231,7 +231,7 @@ bool fromPreviousAction var nextState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -319,7 +319,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -358,7 +358,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -383,7 +383,7 @@ public void Execute_ActionObsoletedException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = ActionObsoleteConfig.V100320ObsoleteIndex + 1, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/UpdateSell4Test.cs b/.Lib9c.Tests/Action/UpdateSell4Test.cs index 725ed77dc6..8bc42dd880 100644 --- a/.Lib9c.Tests/Action/UpdateSell4Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell4Test.cs @@ -231,7 +231,7 @@ bool fromPreviousAction var nextState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -319,7 +319,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -358,7 +358,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -392,7 +392,7 @@ public void PurchaseInfos_Capacity(int count, bool exc) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -401,7 +401,7 @@ public void PurchaseInfos_Capacity(int count, bool exc) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/UpdateSellTest.cs b/.Lib9c.Tests/Action/UpdateSellTest.cs index 24f62ebc49..b7477ca764 100644 --- a/.Lib9c.Tests/Action/UpdateSellTest.cs +++ b/.Lib9c.Tests/Action/UpdateSellTest.cs @@ -231,7 +231,7 @@ bool fromPreviousAction var nextState = action.Execute(new ActionContext { BlockIndex = 101, - PreviousStates = prevState, + PreviousState = prevState, Random = new TestRandom(), Rehearsal = false, Signer = _agentAddress, @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = new State(), + PreviousState = new State(), Signer = _agentAddress, })); } @@ -319,7 +319,7 @@ public void Execute_Throw_NotEnoughClearedStageLevelException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -358,7 +358,7 @@ public void Execute_Throw_InvalidPriceException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -392,7 +392,7 @@ public void PurchaseInfos_Capacity(int count, bool exc) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } @@ -401,7 +401,7 @@ public void PurchaseInfos_Capacity(int count, bool exc) Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousStates = _initialState, + PreviousState = _initialState, Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs index d56edace54..38d583d0d3 100644 --- a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs +++ b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs @@ -54,7 +54,7 @@ public void CheckPermission() var nextState = action.Execute( new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = adminAddress, }); Assert.Single(nextState.GetValidatorSet().Validators); @@ -82,7 +82,7 @@ public void CheckPermission_Throws_PermissionDenied() new ActionContext() { BlockIndex = 5, - PreviousStates = state, + PreviousState = state, Signer = new Address("019101FEec7ed4f918D396827E1277DEda1e20D4"), } ); @@ -97,7 +97,7 @@ public void Append_Throws_WhenAlreadyExistValidator() InvalidOperationException exc = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, })); Assert.Equal( "Cannot append validator when its already exist.", @@ -112,7 +112,7 @@ public void Update_Throws_WhenDoNotExistValidator() InvalidOperationException exc = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, })); Assert.Equal( "Cannot update validator when its do not exist.", @@ -127,7 +127,7 @@ public void Remove_Throws_WhenDoNotExistValidator() InvalidOperationException exc = Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, })); Assert.Equal( "Cannot remove validator when its do not exist.", @@ -142,7 +142,7 @@ public void Append() var action = ValidatorSetOperate.Append(validator); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, }); var validatorSet = states.GetValidatorSet(); @@ -157,7 +157,7 @@ public void Update() var action = ValidatorSetOperate.Update(validator); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, }); var validatorSet = states.GetValidatorSet(); @@ -171,7 +171,7 @@ public void Remove() var action = ValidatorSetOperate.Remove(_validator); var states = action.Execute(new ActionContext { - PreviousStates = _initialState, + PreviousState = _initialState, }); var validatorSet = states.GetValidatorSet(); diff --git a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs index 351da86652..eb7bd69be9 100644 --- a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs +++ b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs @@ -157,7 +157,7 @@ public static MakeInitialStateResult MakeInitialState() var nextState = action.Execute(new ActionContext() { BlockIndex = 0, - PreviousStates = initialState, + PreviousState = initialState, Random = new TestRandom(), Rehearsal = false, }); diff --git a/.Lib9c.Tools/SubCommand/State.cs b/.Lib9c.Tools/SubCommand/State.cs index 65bce40b15..ac52b815dd 100644 --- a/.Lib9c.Tools/SubCommand/State.cs +++ b/.Lib9c.Tools/SubCommand/State.cs @@ -441,17 +441,17 @@ private static ImmutableDictionary GetTotalDelta( string validatorSetKey) { IImmutableSet
stateUpdatedAddresses = actionEvaluations - .SelectMany(a => a.OutputStates.Delta.StateUpdatedAddresses) + .SelectMany(a => a.OutputState.Delta.StateUpdatedAddresses) .ToImmutableHashSet(); IImmutableSet<(Address, Currency)> updatedFungibleAssets = actionEvaluations - .SelectMany(a => a.OutputStates.Delta.UpdatedFungibleAssets) + .SelectMany(a => a.OutputState.Delta.UpdatedFungibleAssets) .ToImmutableHashSet(); IImmutableSet updatedTotalSupplies = actionEvaluations - .SelectMany(a => a.OutputStates.Delta.UpdatedTotalSupplyCurrencies) + .SelectMany(a => a.OutputState.Delta.UpdatedTotalSupplyCurrencies) .ToImmutableHashSet(); IAccountStateDelta lastStates = actionEvaluations.Count > 0 - ? actionEvaluations[actionEvaluations.Count - 1].OutputStates + ? actionEvaluations[actionEvaluations.Count - 1].OutputState : null; ImmutableDictionary totalDelta = stateUpdatedAddresses.ToImmutableDictionary( diff --git a/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs b/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs index b743f65c5b..f7ec86b7b4 100644 --- a/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs +++ b/Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs @@ -27,10 +27,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; int targetStage; if (ActionType.TypeIdentifier is Text text) diff --git a/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs b/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs index 53c614e30c..26bb7d3e19 100644 --- a/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs +++ b/Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs @@ -22,10 +22,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; var recipeIdList = List.Empty; for (var i = 1; i <= TargetStage; i++) { diff --git a/Lib9c.DevExtensions/Action/CreateArenaDummy.cs b/Lib9c.DevExtensions/Action/CreateArenaDummy.cs index fa7921a1ac..1220c36b36 100644 --- a/Lib9c.DevExtensions/Action/CreateArenaDummy.cs +++ b/Lib9c.DevExtensions/Action/CreateArenaDummy.cs @@ -57,7 +57,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; @@ -95,7 +95,7 @@ public override IAccountStateDelta Execute(IActionContext context) var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); - var rankingState = context.PreviousStates.GetRankingState(); + var rankingState = context.PreviousState.GetRankingState(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); // create ArenaScore @@ -117,9 +117,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentAddress, avatarAddress, context.BlockIndex, - context.PreviousStates.GetAvatarSheets(), - context.PreviousStates.GetSheet(), - context.PreviousStates.GetGameConfigState(), + context.PreviousState.GetAvatarSheets(), + context.PreviousState.GetSheet(), + context.PreviousState.GetGameConfigState(), rankingMapAddress); if (!states.TryGetAvatarStateV2(context.Signer, myAvatarAddress, diff --git a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs index b914690635..3f631abafb 100644 --- a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs +++ b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs @@ -368,11 +368,11 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } return Execute( - context.PreviousStates, + context.PreviousState, context.Random, context.BlockIndex, context.Signer); diff --git a/Lib9c.DevExtensions/Action/CreateTestbed.cs b/Lib9c.DevExtensions/Action/CreateTestbed.cs index 53eca6c9eb..b982abec7d 100644 --- a/Lib9c.DevExtensions/Action/CreateTestbed.cs +++ b/Lib9c.DevExtensions/Action/CreateTestbed.cs @@ -80,7 +80,7 @@ public override IAccountStateDelta Execute(IActionContext context) .ToList(); var agentAddress = _privateKey.PublicKey.ToAddress(); - var states = context.PreviousStates; + var states = context.PreviousState; var avatarAddress = agentAddress.Derive( string.Format( @@ -149,24 +149,24 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(_slotIndex, avatarAddress); - var rankingState = context.PreviousStates.GetRankingState(); + var rankingState = context.PreviousState.GetRankingState(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); avatarState = TestbedHelper.CreateAvatarState(sellData.Avatar.Name, agentAddress, avatarAddress, context.BlockIndex, - context.PreviousStates.GetAvatarSheets(), - context.PreviousStates.GetSheet(), - context.PreviousStates.GetGameConfigState(), + context.PreviousState.GetAvatarSheets(), + context.PreviousState.GetSheet(), + context.PreviousState.GetGameConfigState(), rankingMapAddress); // Add item - var costumeItemSheet = context.PreviousStates.GetSheet(); - var equipmentItemSheet = context.PreviousStates.GetSheet(); - var optionSheet = context.PreviousStates.GetSheet(); - var skillSheet = context.PreviousStates.GetSheet(); - var materialItemSheet = context.PreviousStates.GetSheet(); - var consumableItemSheet = context.PreviousStates.GetSheet(); + var costumeItemSheet = context.PreviousState.GetSheet(); + var equipmentItemSheet = context.PreviousState.GetSheet(); + var optionSheet = context.PreviousState.GetSheet(); + var skillSheet = context.PreviousState.GetSheet(); + var materialItemSheet = context.PreviousState.GetSheet(); + var consumableItemSheet = context.PreviousState.GetSheet(); for (var i = 0; i < sellData.Items.Length; i++) { TestbedHelper.AddItem(costumeItemSheet, @@ -209,7 +209,7 @@ public override IAccountStateDelta Execute(IActionContext context) addedItemInfos[i].OrderId); var balance = - context.PreviousStates.GetBalance(agentAddress, states.GetGoldCurrency()); + context.PreviousState.GetBalance(agentAddress, states.GetGoldCurrency()); var price = new FungibleAssetValue(balance.Currency, sellData.Items[i].Price, 0); var order = OrderFactory.Create(agentAddress, avatarAddress, addedItemInfos[i].OrderId, diff --git a/Lib9c.DevExtensions/Action/FaucetCurrency.cs b/Lib9c.DevExtensions/Action/FaucetCurrency.cs index 8a44ce2293..eff57dd5bf 100644 --- a/Lib9c.DevExtensions/Action/FaucetCurrency.cs +++ b/Lib9c.DevExtensions/Action/FaucetCurrency.cs @@ -24,10 +24,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; if (FaucetNcg > 0) { var ncg = states.GetGoldCurrency(); diff --git a/Lib9c.DevExtensions/Action/FaucetRune.cs b/Lib9c.DevExtensions/Action/FaucetRune.cs index 63fce9eb39..c70e426254 100644 --- a/Lib9c.DevExtensions/Action/FaucetRune.cs +++ b/Lib9c.DevExtensions/Action/FaucetRune.cs @@ -26,10 +26,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; if (!(FaucetRuneInfos is null)) { RuneSheet runeSheet = states.GetSheet(); diff --git a/Lib9c.DevExtensions/Action/ManipulateState.cs b/Lib9c.DevExtensions/Action/ManipulateState.cs index a557cb6424..8c13a3e7bc 100644 --- a/Lib9c.DevExtensions/Action/ManipulateState.cs +++ b/Lib9c.DevExtensions/Action/ManipulateState.cs @@ -49,10 +49,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - return Execute(context, context.PreviousStates, StateList, BalanceList); + return Execute(context, context.PreviousState, StateList, BalanceList); } public static IAccountStateDelta Execute( diff --git a/Lib9c.DevExtensions/Action/Stage/ClearStage.cs b/Lib9c.DevExtensions/Action/Stage/ClearStage.cs index 7bd25935f4..3111b76559 100644 --- a/Lib9c.DevExtensions/Action/Stage/ClearStage.cs +++ b/Lib9c.DevExtensions/Action/Stage/ClearStage.cs @@ -24,10 +24,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; var worldInformation = new WorldInformation( context.BlockIndex, states.GetSheet(), diff --git a/Lib9c.MessagePack/Action/NCActionEvaluation.cs b/Lib9c.MessagePack/Action/NCActionEvaluation.cs index afba18e7b6..8e40143520 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 OutputStates { get; set; } + public IAccountStateDelta OutputState { get; set; } [Key(4)] [MessagePackFormatter(typeof(ExceptionFormatter))] @@ -36,7 +36,7 @@ public struct NCActionEvaluation [Key(5)] [MessagePackFormatter(typeof(AccountStateDeltaFormatter))] - public IAccountStateDelta PreviousStates { get; set; } + public IAccountStateDelta PreviousState { get; set; } [Key(6)] public int RandomSeed { get; set; } @@ -60,9 +60,9 @@ Dictionary extra Action = action; Signer = signer; BlockIndex = blockIndex; - OutputStates = outputStates; + OutputState = outputStates; Exception = exception; - PreviousStates = previousStates; + PreviousState = previousStates; RandomSeed = randomSeed; Extra = extra; } @@ -74,9 +74,9 @@ public ActionEvaluation ToActionEvaluation() Action = Action is null ? new RewardGold() : Action, Signer = Signer, BlockIndex = BlockIndex, - OutputStates = OutputStates, + OutputState = OutputState, Exception = Exception, - PreviousStates = PreviousStates, + PreviousState = PreviousState, RandomSeed = RandomSeed, Extra = Extra }; diff --git a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs index b38133dca7..d52a82088f 100644 --- a/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs +++ b/Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs @@ -16,14 +16,14 @@ public void Serialize(ref MessagePackWriter writer, IAccountStateDelta value, MessagePackSerializerOptions options) { var state = new Dictionary( - value.UpdatedAddresses.Select(addr => new KeyValuePair( + value.Delta.UpdatedAddresses.Select(addr => new KeyValuePair( (Binary)addr.ToByteArray(), value.GetState(addr) ?? new Bencodex.Types.Null() )) ); var balance = new Bencodex.Types.List( #pragma warning disable LAA1002 - value.UpdatedFungibleAssets.Select(pair => + value.Delta.UpdatedFungibleAssets.Select(pair => #pragma warning restore LAA1002 new Bencodex.Types.Dictionary(new[] { @@ -34,7 +34,7 @@ public void Serialize(ref MessagePackWriter writer, IAccountStateDelta value, ).Cast() ); var totalSupply = new Dictionary( - value.UpdatedTotalSupplyCurrencies.Select(currency => + value.Delta.UpdatedTotalSupplyCurrencies.Select(currency => new KeyValuePair( (Binary)new Codec().Encode(currency.Serialize()), (Integer)value.GetTotalSupply(currency).RawValue))); diff --git a/Lib9c.Renderers/ActionEvaluation.cs b/Lib9c.Renderers/ActionEvaluation.cs index f0d1c5e505..d5446d2eaa 100644 --- a/Lib9c.Renderers/ActionEvaluation.cs +++ b/Lib9c.Renderers/ActionEvaluation.cs @@ -20,11 +20,11 @@ public struct ActionEvaluation public TxId? TxId { get; set; } - public IAccountStateDelta OutputStates { get; set; } + public IAccountStateDelta OutputState { get; set; } public Exception? Exception { get; set; } - public IAccountStateDelta PreviousStates { get; set; } + public IAccountStateDelta PreviousState { get; set; } public int RandomSeed { get; set; } diff --git a/Lib9c.Renderers/Renderers/ActionRenderer.cs b/Lib9c.Renderers/Renderers/ActionRenderer.cs index 638ef5e3de..3ed1949dac 100644 --- a/Lib9c.Renderers/Renderers/ActionRenderer.cs +++ b/Lib9c.Renderers/Renderers/ActionRenderer.cs @@ -42,8 +42,8 @@ public void RenderAction(IValue action, IActionContext context, IAccountStateDel Signer = context.Signer, BlockIndex = context.BlockIndex, TxId = context.TxId, - OutputStates = nextStates, - PreviousStates = context.PreviousStates, + OutputState = nextStates, + PreviousState = context.PreviousState, RandomSeed = context.Random.Seed }); @@ -62,9 +62,9 @@ Exception exception Signer = context.Signer, BlockIndex = context.BlockIndex, TxId = context.TxId, - OutputStates = context.PreviousStates, + OutputState = context.PreviousState, Exception = exception, - PreviousStates = context.PreviousStates, + PreviousState = context.PreviousState, RandomSeed = context.Random.Seed }); } @@ -90,9 +90,9 @@ public IObservable> EveryRender() where T : ActionBase => Signer = eval.Signer, BlockIndex = eval.BlockIndex, TxId = eval.TxId, - OutputStates = eval.OutputStates, + OutputState = eval.OutputState, Exception = eval.Exception, - PreviousStates = eval.PreviousStates, + PreviousState = eval.PreviousState, RandomSeed = eval.RandomSeed, Extra = eval.Extra, }); @@ -100,16 +100,16 @@ public IObservable> EveryRender() where T : ActionBase => public IObservable> EveryRender(Address updatedAddress) => ActionRenderSubject .AsObservable() - .Where(eval => eval.OutputStates.UpdatedAddresses.Contains(updatedAddress)) + .Where(eval => eval.OutputState.Delta.UpdatedAddresses.Contains(updatedAddress)) .Select(eval => new ActionEvaluation { Action = eval.Action, Signer = eval.Signer, BlockIndex = eval.BlockIndex, TxId = eval.TxId, - OutputStates = eval.OutputStates, + OutputState = eval.OutputState, Exception = eval.Exception, - PreviousStates = eval.PreviousStates, + PreviousState = eval.PreviousState, RandomSeed = eval.RandomSeed, Extra = eval.Extra, }); diff --git a/Lib9c/Action/ActionBase.cs b/Lib9c/Action/ActionBase.cs index 030fac855c..488a77a278 100644 --- a/Lib9c/Action/ActionBase.cs +++ b/Lib9c/Action/ActionBase.cs @@ -63,14 +63,14 @@ protected IAccountStateDelta LogError(IActionContext context, string message, pa values.CopyTo(prependedValues, 2); string msg = $"#{{BlockIndex}} {actionType} (by {{Signer}}): {message}"; Log.Error(msg, prependedValues); - return context.PreviousStates; + return context.PreviousState; } protected bool TryGetAdminState(IActionContext ctx, out AdminState state) { state = default; - IValue rawState = ctx.PreviousStates.GetState(AdminState.Address); + IValue rawState = ctx.PreviousState.GetState(AdminState.Address); if (rawState is Bencodex.Types.Dictionary asDict) { state = new AdminState(asDict); diff --git a/Lib9c/Action/ActionBaseExtensions.cs b/Lib9c/Action/ActionBaseExtensions.cs index 875185f3b0..528ee53c18 100644 --- a/Lib9c/Action/ActionBaseExtensions.cs +++ b/Lib9c/Action/ActionBaseExtensions.cs @@ -26,7 +26,7 @@ public static IImmutableSet
CalculateUpdateAddresses(this IEnumerable true; - public IAccountStateDelta PreviousStates => new AddressTraceStateDelta(); + public IAccountStateDelta PreviousState => new AddressTraceStateDelta(); public IRandom Random => default; diff --git a/Lib9c/Action/ActionContextExtensions.cs b/Lib9c/Action/ActionContextExtensions.cs index 3b31099819..6d24187e9b 100644 --- a/Lib9c/Action/ActionContextExtensions.cs +++ b/Lib9c/Action/ActionContextExtensions.cs @@ -7,7 +7,7 @@ public static class ActionContextExtensions { public static bool IsMainNet(this IActionContext context) { - var goldCurrency = context.PreviousStates.GetGoldCurrency(); + var goldCurrency = context.PreviousState.GetGoldCurrency(); return goldCurrency.Minters .Contains(new Address("47d082a115c63e7b58b1532d20e631538eafadde")) && goldCurrency.Ticker == "NCG" diff --git a/Lib9c/Action/ActivateAccount.cs b/Lib9c/Action/ActivateAccount.cs index d54ec2b67a..2d372e85cb 100644 --- a/Lib9c/Action/ActivateAccount.cs +++ b/Lib9c/Action/ActivateAccount.cs @@ -46,7 +46,7 @@ public ActivateAccount(Address pendingAddress, byte[] signature) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousStates; + IAccountStateDelta 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 e5487f57d5..43e000634f 100644 --- a/Lib9c/Action/ActivateAccount0.cs +++ b/Lib9c/Action/ActivateAccount0.cs @@ -45,7 +45,7 @@ public ActivateAccount0(Address pendingAddress, byte[] signature) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousStates; + IAccountStateDelta state = context.PreviousState; if (context.Rehearsal) { diff --git a/Lib9c/Action/AddActivatedAccount.cs b/Lib9c/Action/AddActivatedAccount.cs index 95d7a89b3e..09ed8386f0 100644 --- a/Lib9c/Action/AddActivatedAccount.cs +++ b/Lib9c/Action/AddActivatedAccount.cs @@ -40,7 +40,7 @@ public AddActivatedAccount() public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousStates; + IAccountStateDelta 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 72409dfc18..c11cee1e72 100644 --- a/Lib9c/Action/AddActivatedAccount0.cs +++ b/Lib9c/Action/AddActivatedAccount0.cs @@ -39,7 +39,7 @@ public AddActivatedAccount0() public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousStates; + IAccountStateDelta state = context.PreviousState; if (context.Rehearsal) { diff --git a/Lib9c/Action/AddRedeemCode.cs b/Lib9c/Action/AddRedeemCode.cs index cd17ebf6c8..5bfba2d875 100644 --- a/Lib9c/Action/AddRedeemCode.cs +++ b/Lib9c/Action/AddRedeemCode.cs @@ -20,7 +20,7 @@ public class AddRedeemCode : GameAction, IAddRedeemCodeV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/ApprovePledge.cs b/Lib9c/Action/ApprovePledge.cs index 5768d75959..ff9c13ad62 100644 --- a/Lib9c/Action/ApprovePledge.cs +++ b/Lib9c/Action/ApprovePledge.cs @@ -29,7 +29,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); Address signer = context.Signer; - var states = context.PreviousStates; + var states = context.PreviousState; var contractAddress = signer.GetPledgeAddress(); if (!states.TryGetState(contractAddress, out List contract)) { diff --git a/Lib9c/Action/BattleArena.cs b/Lib9c/Action/BattleArena.cs index 9af310a2b2..1099b09562 100644 --- a/Lib9c/Action/BattleArena.cs +++ b/Lib9c/Action/BattleArena.cs @@ -89,7 +89,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena1.cs b/Lib9c/Action/BattleArena1.cs index 95a181f76b..2613ba448a 100644 --- a/Lib9c/Action/BattleArena1.cs +++ b/Lib9c/Action/BattleArena1.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena10.cs b/Lib9c/Action/BattleArena10.cs index 7729246b7b..001b9193a0 100644 --- a/Lib9c/Action/BattleArena10.cs +++ b/Lib9c/Action/BattleArena10.cs @@ -92,7 +92,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena11.cs b/Lib9c/Action/BattleArena11.cs index 785934d1c2..04eecb0d86 100644 --- a/Lib9c/Action/BattleArena11.cs +++ b/Lib9c/Action/BattleArena11.cs @@ -90,7 +90,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena2.cs b/Lib9c/Action/BattleArena2.cs index 5cc391397d..805c39313e 100644 --- a/Lib9c/Action/BattleArena2.cs +++ b/Lib9c/Action/BattleArena2.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena3.cs b/Lib9c/Action/BattleArena3.cs index a70a25d5f4..9952575b06 100644 --- a/Lib9c/Action/BattleArena3.cs +++ b/Lib9c/Action/BattleArena3.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena4.cs b/Lib9c/Action/BattleArena4.cs index 5d20931849..0eec374510 100644 --- a/Lib9c/Action/BattleArena4.cs +++ b/Lib9c/Action/BattleArena4.cs @@ -86,7 +86,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena5.cs b/Lib9c/Action/BattleArena5.cs index 5e71cbbe02..503f9d95cf 100644 --- a/Lib9c/Action/BattleArena5.cs +++ b/Lib9c/Action/BattleArena5.cs @@ -87,7 +87,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena6.cs b/Lib9c/Action/BattleArena6.cs index 2af8379a6d..87d828a0ea 100644 --- a/Lib9c/Action/BattleArena6.cs +++ b/Lib9c/Action/BattleArena6.cs @@ -88,7 +88,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena7.cs b/Lib9c/Action/BattleArena7.cs index 039ab847f4..8fa871b380 100644 --- a/Lib9c/Action/BattleArena7.cs +++ b/Lib9c/Action/BattleArena7.cs @@ -96,7 +96,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena8.cs b/Lib9c/Action/BattleArena8.cs index 4ac2a081da..8b39baa276 100644 --- a/Lib9c/Action/BattleArena8.cs +++ b/Lib9c/Action/BattleArena8.cs @@ -96,7 +96,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleArena9.cs b/Lib9c/Action/BattleArena9.cs index 8511bdaa23..755ed36836 100644 --- a/Lib9c/Action/BattleArena9.cs +++ b/Lib9c/Action/BattleArena9.cs @@ -95,7 +95,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleGrandFinale.cs b/Lib9c/Action/BattleGrandFinale.cs index 6f18027920..9a52dc92e6 100644 --- a/Lib9c/Action/BattleGrandFinale.cs +++ b/Lib9c/Action/BattleGrandFinale.cs @@ -80,7 +80,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleGrandFinale1.cs b/Lib9c/Action/BattleGrandFinale1.cs index e760d1fddd..cdae6b209d 100644 --- a/Lib9c/Action/BattleGrandFinale1.cs +++ b/Lib9c/Action/BattleGrandFinale1.cs @@ -79,7 +79,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BattleGrandFinale2.cs b/Lib9c/Action/BattleGrandFinale2.cs index d8ba7c0df9..8117ffe6cb 100644 --- a/Lib9c/Action/BattleGrandFinale2.cs +++ b/Lib9c/Action/BattleGrandFinale2.cs @@ -80,7 +80,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Buy.cs b/Lib9c/Action/Buy.cs index d6531cd9b2..8a7c002929 100644 --- a/Lib9c/Action/Buy.cs +++ b/Lib9c/Action/Buy.cs @@ -69,7 +69,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var buyerInventoryAddress = buyerAvatarAddress.Derive(LegacyInventoryKey); var buyerWorldInformationAddress = buyerAvatarAddress.Derive(LegacyWorldInformationKey); var buyerQuestListAddress = buyerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Buy0.cs b/Lib9c/Action/Buy0.cs index 5bada46594..8bd941f168 100644 --- a/Lib9c/Action/Buy0.cs +++ b/Lib9c/Action/Buy0.cs @@ -55,7 +55,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states diff --git a/Lib9c/Action/Buy10.cs b/Lib9c/Action/Buy10.cs index 13ae1b8b3d..198abb1a0e 100644 --- a/Lib9c/Action/Buy10.cs +++ b/Lib9c/Action/Buy10.cs @@ -63,7 +63,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var buyerInventoryAddress = buyerAvatarAddress.Derive(LegacyInventoryKey); var buyerWorldInformationAddress = buyerAvatarAddress.Derive(LegacyWorldInformationKey); var buyerQuestListAddress = buyerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Buy11.cs b/Lib9c/Action/Buy11.cs index 2d70d26be9..42237da7d7 100644 --- a/Lib9c/Action/Buy11.cs +++ b/Lib9c/Action/Buy11.cs @@ -68,7 +68,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var buyerInventoryAddress = buyerAvatarAddress.Derive(LegacyInventoryKey); var buyerWorldInformationAddress = buyerAvatarAddress.Derive(LegacyWorldInformationKey); var buyerQuestListAddress = buyerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Buy2.cs b/Lib9c/Action/Buy2.cs index a77a9596a0..46f52c6d81 100644 --- a/Lib9c/Action/Buy2.cs +++ b/Lib9c/Action/Buy2.cs @@ -57,7 +57,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states diff --git a/Lib9c/Action/Buy3.cs b/Lib9c/Action/Buy3.cs index 2baba493fe..074e3e9699 100644 --- a/Lib9c/Action/Buy3.cs +++ b/Lib9c/Action/Buy3.cs @@ -54,7 +54,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states diff --git a/Lib9c/Action/Buy4.cs b/Lib9c/Action/Buy4.cs index dd4a019c0a..7d885188a3 100644 --- a/Lib9c/Action/Buy4.cs +++ b/Lib9c/Action/Buy4.cs @@ -54,7 +54,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states diff --git a/Lib9c/Action/Buy5.cs b/Lib9c/Action/Buy5.cs index abf7b9d79d..fc9c9d0858 100644 --- a/Lib9c/Action/Buy5.cs +++ b/Lib9c/Action/Buy5.cs @@ -59,7 +59,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { foreach (var purchaseInfo in purchaseInfos) diff --git a/Lib9c/Action/Buy6.cs b/Lib9c/Action/Buy6.cs index fcfaf6f6fa..d0f7dd0dc5 100644 --- a/Lib9c/Action/Buy6.cs +++ b/Lib9c/Action/Buy6.cs @@ -59,7 +59,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { foreach (var purchaseInfo in purchaseInfos) diff --git a/Lib9c/Action/Buy7.cs b/Lib9c/Action/Buy7.cs index 6b6ce539b2..582faf1e72 100644 --- a/Lib9c/Action/Buy7.cs +++ b/Lib9c/Action/Buy7.cs @@ -198,7 +198,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { foreach (var purchaseInfo in purchaseInfos) diff --git a/Lib9c/Action/Buy8.cs b/Lib9c/Action/Buy8.cs index 97e2ffff25..3adce537a6 100644 --- a/Lib9c/Action/Buy8.cs +++ b/Lib9c/Action/Buy8.cs @@ -64,7 +64,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var buyerInventoryAddress = buyerAvatarAddress.Derive(LegacyInventoryKey); var buyerWorldInformationAddress = buyerAvatarAddress.Derive(LegacyWorldInformationKey); var buyerQuestListAddress = buyerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Buy9.cs b/Lib9c/Action/Buy9.cs index 364b2a81ef..ec8821836e 100644 --- a/Lib9c/Action/Buy9.cs +++ b/Lib9c/Action/Buy9.cs @@ -64,7 +64,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var buyerInventoryAddress = buyerAvatarAddress.Derive(LegacyInventoryKey); var buyerWorldInformationAddress = buyerAvatarAddress.Derive(LegacyWorldInformationKey); var buyerQuestListAddress = buyerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/BuyMultiple.cs b/Lib9c/Action/BuyMultiple.cs index 420186a8ac..159018633c 100644 --- a/Lib9c/Action/BuyMultiple.cs +++ b/Lib9c/Action/BuyMultiple.cs @@ -220,7 +220,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { diff --git a/Lib9c/Action/BuyProduct.cs b/Lib9c/Action/BuyProduct.cs index ab9a2f4b07..872c40897c 100644 --- a/Lib9c/Action/BuyProduct.cs +++ b/Lib9c/Action/BuyProduct.cs @@ -33,7 +33,7 @@ public class BuyProduct : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/BuyProduct0.cs b/Lib9c/Action/BuyProduct0.cs index affdddbc7b..e475b9e7a8 100644 --- a/Lib9c/Action/BuyProduct0.cs +++ b/Lib9c/Action/BuyProduct0.cs @@ -33,7 +33,7 @@ public class BuyProduct0 : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/CancelMonsterCollect.cs b/Lib9c/Action/CancelMonsterCollect.cs index 0a09441752..1b7f0a4e34 100644 --- a/Lib9c/Action/CancelMonsterCollect.cs +++ b/Lib9c/Action/CancelMonsterCollect.cs @@ -35,7 +35,7 @@ public class CancelMonsterCollect : GameAction, ICancelMonsterCollectV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta 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 034aafb9d0..09eeb2b8bb 100644 --- a/Lib9c/Action/CancelProductRegistration.cs +++ b/Lib9c/Action/CancelProductRegistration.cs @@ -28,7 +28,7 @@ public class CancelProductRegistration : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/ChargeActionPoint.cs b/Lib9c/Action/ChargeActionPoint.cs index d93f26856f..749bdffcbe 100644 --- a/Lib9c/Action/ChargeActionPoint.cs +++ b/Lib9c/Action/ChargeActionPoint.cs @@ -33,7 +33,7 @@ public class ChargeActionPoint : GameAction, IChargeActionPointV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/ChargeActionPoint0.cs b/Lib9c/Action/ChargeActionPoint0.cs index 5b2750f283..132332f1f9 100644 --- a/Lib9c/Action/ChargeActionPoint0.cs +++ b/Lib9c/Action/ChargeActionPoint0.cs @@ -26,7 +26,7 @@ public class ChargeActionPoint0 : GameAction, IChargeActionPointV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/ChargeActionPoint2.cs b/Lib9c/Action/ChargeActionPoint2.cs index 512a0d3f2d..f8f5f577ea 100644 --- a/Lib9c/Action/ChargeActionPoint2.cs +++ b/Lib9c/Action/ChargeActionPoint2.cs @@ -25,7 +25,7 @@ public class ChargeActionPoint2 : GameAction, IChargeActionPointV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/ClaimMonsterCollectionReward.cs b/Lib9c/Action/ClaimMonsterCollectionReward.cs index 76cbd4a11d..530b513905 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward.cs @@ -39,7 +39,7 @@ public override IAccountStateDelta Execute(IActionContext context) public static IAccountStateDelta Claim(IActionContext context, Address avatarAddress, string addressesHex) { - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta 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 56c4936215..4228db348f 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward0.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward0.cs @@ -29,7 +29,7 @@ public class ClaimMonsterCollectionReward0 : GameAction, IClaimMonsterCollection public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta 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 42cd0cdae7..e99e23d723 100644 --- a/Lib9c/Action/ClaimMonsterCollectionReward2.cs +++ b/Lib9c/Action/ClaimMonsterCollectionReward2.cs @@ -27,7 +27,7 @@ public class ClaimMonsterCollectionReward2 : GameAction, IClaimMonsterCollection public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta 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 6668a68685..9569e44fca 100644 --- a/Lib9c/Action/ClaimRaidReward.cs +++ b/Lib9c/Action/ClaimRaidReward.cs @@ -36,7 +36,7 @@ public ClaimRaidReward(Address avatarAddress) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/ClaimStakeReward.cs b/Lib9c/Action/ClaimStakeReward.cs index bbda002147..3f88d1ca9f 100644 --- a/Lib9c/Action/ClaimStakeReward.cs +++ b/Lib9c/Action/ClaimStakeReward.cs @@ -126,10 +126,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); if (!states.TryGetStakeState(context.Signer, out var stakeState)) { diff --git a/Lib9c/Action/ClaimStakeReward1.cs b/Lib9c/Action/ClaimStakeReward1.cs index 40aa51f4aa..152e6c7f72 100644 --- a/Lib9c/Action/ClaimStakeReward1.cs +++ b/Lib9c/Action/ClaimStakeReward1.cs @@ -35,7 +35,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); CheckObsolete(ObsoleteIndex, context); - var states = context.PreviousStates; + var states = context.PreviousState; if (!states.TryGetStakeState(context.Signer, out StakeState stakeState)) { throw new FailedLoadStateException(nameof(StakeState)); diff --git a/Lib9c/Action/ClaimStakeReward2.cs b/Lib9c/Action/ClaimStakeReward2.cs index ec465a8885..414f4f116d 100644 --- a/Lib9c/Action/ClaimStakeReward2.cs +++ b/Lib9c/Action/ClaimStakeReward2.cs @@ -40,9 +40,9 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; CheckObsolete(ObsoletedIndex, context); var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); if (!states.TryGetStakeState(context.Signer, out StakeState stakeState)) diff --git a/Lib9c/Action/ClaimStakeReward3.cs b/Lib9c/Action/ClaimStakeReward3.cs index cb8a3368b8..085056878b 100644 --- a/Lib9c/Action/ClaimStakeReward3.cs +++ b/Lib9c/Action/ClaimStakeReward3.cs @@ -171,13 +171,13 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } CheckActionAvailable(ClaimStakeReward2.ObsoletedIndex, context); CheckObsolete(ObsoleteBlockIndex, context); - var states = context.PreviousStates; + var states = context.PreviousState; var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); if (!states.TryGetStakeState(context.Signer, out StakeState stakeState)) { diff --git a/Lib9c/Action/ClaimWordBossKillReward.cs b/Lib9c/Action/ClaimWordBossKillReward.cs index f0f7ad4f4c..aa22df6b69 100644 --- a/Lib9c/Action/ClaimWordBossKillReward.cs +++ b/Lib9c/Action/ClaimWordBossKillReward.cs @@ -25,7 +25,7 @@ public class ClaimWordBossKillReward : GameAction, IClaimWordBossKillRewardV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/CombinationConsumable.cs b/Lib9c/Action/CombinationConsumable.cs index 81078d9099..58bebc1326 100644 --- a/Lib9c/Action/CombinationConsumable.cs +++ b/Lib9c/Action/CombinationConsumable.cs @@ -60,7 +60,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary rewards, Address recip public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states.SetCouponWallet( diff --git a/Lib9c/Action/Coupons/RedeemCoupon.cs b/Lib9c/Action/Coupons/RedeemCoupon.cs index 6f2f6dadc1..9a6d36280e 100644 --- a/Lib9c/Action/Coupons/RedeemCoupon.cs +++ b/Lib9c/Action/Coupons/RedeemCoupon.cs @@ -32,7 +32,7 @@ public RedeemCoupon(Guid couponId, Address avatarAddress) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Coupons/TransferCoupons.cs b/Lib9c/Action/Coupons/TransferCoupons.cs index 9347f5f4f4..d09459f558 100644 --- a/Lib9c/Action/Coupons/TransferCoupons.cs +++ b/Lib9c/Action/Coupons/TransferCoupons.cs @@ -31,7 +31,7 @@ public IImmutableDictionary> CouponsPerRecipient public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var signerWallet = states.GetCouponWallet(context.Signer); var orderedRecipients = CouponsPerRecipient.OrderBy(pair => pair.Key); foreach ((Address recipient, IImmutableSet couponIds) in orderedRecipients) diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 5451012571..0770e2010f 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -70,7 +70,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); IActionContext ctx = context; var signer = ctx.Signer; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -145,7 +145,7 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); avatarState = CreateAvatar0.CreateAvatarState(name, avatarAddress, ctx, materialItemSheet, default); diff --git a/Lib9c/Action/CreateAvatar0.cs b/Lib9c/Action/CreateAvatar0.cs index 0dd21e1f3e..cdea385770 100644 --- a/Lib9c/Action/CreateAvatar0.cs +++ b/Lib9c/Action/CreateAvatar0.cs @@ -72,7 +72,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(ctx.Signer, MarkChanged); @@ -139,9 +139,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - var rankingState = ctx.PreviousStates.GetRankingState0(); + var rankingState = ctx.PreviousState.GetRankingState0(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); @@ -179,7 +179,7 @@ public static AvatarState CreateAvatarState(string name, MaterialItemSheet materialItemSheet, Address rankingMapAddress) { - var state = ctx.PreviousStates; + var state = ctx.PreviousState; var gameConfigState = state.GetGameConfigState(); var avatarState = new AvatarState( avatarAddress, @@ -193,9 +193,9 @@ public static AvatarState CreateAvatarState(string name, #if LIB9C_DEV_EXTENSIONS || UNITY_EDITOR var data = TestbedHelper.LoadData("TestbedCreateAvatar"); - var costumeItemSheet = ctx.PreviousStates.GetSheet(); - var equipmentItemSheet = ctx.PreviousStates.GetSheet(); - var consumableItemSheet = ctx.PreviousStates.GetSheet(); + var costumeItemSheet = ctx.PreviousState.GetSheet(); + var equipmentItemSheet = ctx.PreviousState.GetSheet(); + var consumableItemSheet = ctx.PreviousState.GetSheet(); AddItemsForTest( avatarState: avatarState, random: ctx.Random, @@ -207,8 +207,8 @@ public static AvatarState CreateAvatarState(string name, data.TradableMaterialCount, data.FoodCount); - var skillSheet = ctx.PreviousStates.GetSheet(); - var optionSheet = ctx.PreviousStates.GetSheet(); + var skillSheet = ctx.PreviousState.GetSheet(); + var optionSheet = ctx.PreviousState.GetSheet(); var items = data.CustomEquipmentItems; foreach (var item in items) diff --git a/Lib9c/Action/CreateAvatar2.cs b/Lib9c/Action/CreateAvatar2.cs index a9017775a7..ff0c350d9e 100644 --- a/Lib9c/Action/CreateAvatar2.cs +++ b/Lib9c/Action/CreateAvatar2.cs @@ -63,7 +63,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -135,9 +135,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - var rankingState = ctx.PreviousStates.GetRankingState0(); + var rankingState = ctx.PreviousState.GetRankingState0(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); diff --git a/Lib9c/Action/CreateAvatar3.cs b/Lib9c/Action/CreateAvatar3.cs index f879d79407..37f1a23179 100644 --- a/Lib9c/Action/CreateAvatar3.cs +++ b/Lib9c/Action/CreateAvatar3.cs @@ -60,7 +60,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -138,9 +138,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - var rankingState = ctx.PreviousStates.GetRankingState0(); + var rankingState = ctx.PreviousState.GetRankingState0(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); diff --git a/Lib9c/Action/CreateAvatar4.cs b/Lib9c/Action/CreateAvatar4.cs index fc17c8fca6..f8503ed561 100644 --- a/Lib9c/Action/CreateAvatar4.cs +++ b/Lib9c/Action/CreateAvatar4.cs @@ -60,7 +60,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -136,9 +136,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - var rankingState = ctx.PreviousStates.GetRankingState0(); + var rankingState = ctx.PreviousState.GetRankingState0(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); diff --git a/Lib9c/Action/CreateAvatar5.cs b/Lib9c/Action/CreateAvatar5.cs index ab77cd953f..db63d197d0 100644 --- a/Lib9c/Action/CreateAvatar5.cs +++ b/Lib9c/Action/CreateAvatar5.cs @@ -60,7 +60,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -136,9 +136,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - RankingState1 rankingState = ctx.PreviousStates.GetRankingState1(); + RankingState1 rankingState = ctx.PreviousState.GetRankingState1(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); diff --git a/Lib9c/Action/CreateAvatar6.cs b/Lib9c/Action/CreateAvatar6.cs index bd3b47836b..485f2e75e9 100644 --- a/Lib9c/Action/CreateAvatar6.cs +++ b/Lib9c/Action/CreateAvatar6.cs @@ -60,7 +60,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -137,9 +137,9 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); - RankingState rankingState = ctx.PreviousStates.GetRankingState(); + RankingState rankingState = ctx.PreviousState.GetRankingState(); var rankingMapAddress = rankingState.UpdateRankingMap(avatarAddress); diff --git a/Lib9c/Action/CreateAvatar7.cs b/Lib9c/Action/CreateAvatar7.cs index bc3738a319..18160c5cb7 100644 --- a/Lib9c/Action/CreateAvatar7.cs +++ b/Lib9c/Action/CreateAvatar7.cs @@ -64,7 +64,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = ctx.Signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -139,7 +139,7 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); avatarState = CreateAvatar0.CreateAvatarState(name, avatarAddress, ctx, materialItemSheet, default); diff --git a/Lib9c/Action/CreatePendingActivation.cs b/Lib9c/Action/CreatePendingActivation.cs index 54542da1ce..c6f17bfe4a 100644 --- a/Lib9c/Action/CreatePendingActivation.cs +++ b/Lib9c/Action/CreatePendingActivation.cs @@ -47,13 +47,13 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates.SetState(PendingActivation.address, MarkChanged); + return context.PreviousState.SetState(PendingActivation.address, MarkChanged); } CheckObsolete(ActionObsoleteConfig.V200030ObsoleteIndex, context); CheckPermission(context); - return context.PreviousStates.SetState( + return context.PreviousState.SetState( PendingActivation.address, PendingActivation.Serialize() ); diff --git a/Lib9c/Action/CreatePendingActivations.cs b/Lib9c/Action/CreatePendingActivations.cs index 4160e5d3d7..cda42a5e96 100644 --- a/Lib9c/Action/CreatePendingActivations.cs +++ b/Lib9c/Action/CreatePendingActivations.cs @@ -46,7 +46,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); CheckObsolete(ActionObsoleteConfig.V200030ObsoleteIndex, context); CheckPermission(context); - var state = context.PreviousStates; + var state = context.PreviousState; foreach ((byte[] address, byte[] nonce, byte[] publicKey) in PendingActivations) { state = state.SetState( diff --git a/Lib9c/Action/CreatePledge.cs b/Lib9c/Action/CreatePledge.cs index b75ca4bc32..b96ab2bf89 100644 --- a/Lib9c/Action/CreatePledge.cs +++ b/Lib9c/Action/CreatePledge.cs @@ -49,7 +49,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); CheckPermission(context); - var states = context.PreviousStates; + var states = context.PreviousState; var mead = Mead * Currencies.Mead; var contractList = List.Empty .Add(PatronAddress.Serialize()) diff --git a/Lib9c/Action/DailyReward.cs b/Lib9c/Action/DailyReward.cs index abefef9cc2..03047d375b 100644 --- a/Lib9c/Action/DailyReward.cs +++ b/Lib9c/Action/DailyReward.cs @@ -30,7 +30,7 @@ public class DailyReward : GameAction, IDailyRewardV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/DailyReward0.cs b/Lib9c/Action/DailyReward0.cs index 65253540cf..759c606796 100644 --- a/Lib9c/Action/DailyReward0.cs +++ b/Lib9c/Action/DailyReward0.cs @@ -23,7 +23,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/DailyReward2.cs b/Lib9c/Action/DailyReward2.cs index 771cc02039..ab4e3ce43a 100644 --- a/Lib9c/Action/DailyReward2.cs +++ b/Lib9c/Action/DailyReward2.cs @@ -30,7 +30,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/DailyReward3.cs b/Lib9c/Action/DailyReward3.cs index 500b03e66b..09f7540247 100644 --- a/Lib9c/Action/DailyReward3.cs +++ b/Lib9c/Action/DailyReward3.cs @@ -29,7 +29,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/DailyReward4.cs b/Lib9c/Action/DailyReward4.cs index c49d54a323..9fa054189b 100644 --- a/Lib9c/Action/DailyReward4.cs +++ b/Lib9c/Action/DailyReward4.cs @@ -30,7 +30,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/DailyReward5.cs b/Lib9c/Action/DailyReward5.cs index 075fdd067e..fa9ba9599b 100644 --- a/Lib9c/Action/DailyReward5.cs +++ b/Lib9c/Action/DailyReward5.cs @@ -24,7 +24,7 @@ public class DailyReward5 : GameAction, IDailyRewardV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states.SetState(avatarAddress, MarkChanged); diff --git a/Lib9c/Action/DailyReward6.cs b/Lib9c/Action/DailyReward6.cs index 5e3a97ff5c..ff05384969 100644 --- a/Lib9c/Action/DailyReward6.cs +++ b/Lib9c/Action/DailyReward6.cs @@ -31,7 +31,7 @@ public class DailyReward6 : GameAction, IDailyRewardV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/EndPledge.cs b/Lib9c/Action/EndPledge.cs index 67f1744128..09fa7916b0 100644 --- a/Lib9c/Action/EndPledge.cs +++ b/Lib9c/Action/EndPledge.cs @@ -29,7 +29,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); Address signer = context.Signer; - var states = context.PreviousStates; + var states = context.PreviousState; var contractAddress = AgentAddress.GetPledgeAddress(); if (states.TryGetState(contractAddress, out List contract)) { diff --git a/Lib9c/Action/EventConsumableItemCrafts.cs b/Lib9c/Action/EventConsumableItemCrafts.cs index 2038e0cac8..67ddb31043 100644 --- a/Lib9c/Action/EventConsumableItemCrafts.cs +++ b/Lib9c/Action/EventConsumableItemCrafts.cs @@ -78,7 +78,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary new Address(a)).ToList(); if (context.Rehearsal) diff --git a/Lib9c/Action/MigrationLegacyShop0.cs b/Lib9c/Action/MigrationLegacyShop0.cs index fe14e266dc..9a7289f367 100644 --- a/Lib9c/Action/MigrationLegacyShop0.cs +++ b/Lib9c/Action/MigrationLegacyShop0.cs @@ -19,7 +19,7 @@ public class MigrationLegacyShop0 : GameAction, IMigrationLegacyShopV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var sellerAvatarAddresses = _avatarAddressesHex.Select(a => new Address(a)).ToList(); if (context.Rehearsal) diff --git a/Lib9c/Action/MimisbrunnrBattle.cs b/Lib9c/Action/MimisbrunnrBattle.cs index 6d27fa598c..82ab9da82d 100644 --- a/Lib9c/Action/MimisbrunnrBattle.cs +++ b/Lib9c/Action/MimisbrunnrBattle.cs @@ -80,7 +80,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle0.cs b/Lib9c/Action/MimisbrunnrBattle0.cs index 5d91cd0fbd..ef965ffa05 100644 --- a/Lib9c/Action/MimisbrunnrBattle0.cs +++ b/Lib9c/Action/MimisbrunnrBattle0.cs @@ -72,7 +72,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(RankingMapAddress, MarkChanged); diff --git a/Lib9c/Action/MimisbrunnrBattle10.cs b/Lib9c/Action/MimisbrunnrBattle10.cs index 2e357b2c03..11145bd4f8 100644 --- a/Lib9c/Action/MimisbrunnrBattle10.cs +++ b/Lib9c/Action/MimisbrunnrBattle10.cs @@ -71,7 +71,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle11.cs b/Lib9c/Action/MimisbrunnrBattle11.cs index a705a0a6a9..b23f55be27 100644 --- a/Lib9c/Action/MimisbrunnrBattle11.cs +++ b/Lib9c/Action/MimisbrunnrBattle11.cs @@ -80,7 +80,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle12.cs b/Lib9c/Action/MimisbrunnrBattle12.cs index 7f459ae740..83aaadefae 100644 --- a/Lib9c/Action/MimisbrunnrBattle12.cs +++ b/Lib9c/Action/MimisbrunnrBattle12.cs @@ -81,7 +81,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle2.cs b/Lib9c/Action/MimisbrunnrBattle2.cs index 538ba5c7c7..4b4392091d 100644 --- a/Lib9c/Action/MimisbrunnrBattle2.cs +++ b/Lib9c/Action/MimisbrunnrBattle2.cs @@ -72,7 +72,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(RankingMapAddress, MarkChanged); diff --git a/Lib9c/Action/MimisbrunnrBattle3.cs b/Lib9c/Action/MimisbrunnrBattle3.cs index fd3d911db1..dd17b0bb40 100644 --- a/Lib9c/Action/MimisbrunnrBattle3.cs +++ b/Lib9c/Action/MimisbrunnrBattle3.cs @@ -72,7 +72,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(RankingMapAddress, MarkChanged); diff --git a/Lib9c/Action/MimisbrunnrBattle4.cs b/Lib9c/Action/MimisbrunnrBattle4.cs index 8d14f79e87..a08b4d8150 100644 --- a/Lib9c/Action/MimisbrunnrBattle4.cs +++ b/Lib9c/Action/MimisbrunnrBattle4.cs @@ -71,7 +71,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle5.cs b/Lib9c/Action/MimisbrunnrBattle5.cs index 2261f6e8ba..ac03c17dd2 100644 --- a/Lib9c/Action/MimisbrunnrBattle5.cs +++ b/Lib9c/Action/MimisbrunnrBattle5.cs @@ -65,7 +65,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle6.cs b/Lib9c/Action/MimisbrunnrBattle6.cs index d64e49c367..1d848f63f3 100644 --- a/Lib9c/Action/MimisbrunnrBattle6.cs +++ b/Lib9c/Action/MimisbrunnrBattle6.cs @@ -69,7 +69,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle7.cs b/Lib9c/Action/MimisbrunnrBattle7.cs index 7fe043cf3a..5a76f6e93f 100644 --- a/Lib9c/Action/MimisbrunnrBattle7.cs +++ b/Lib9c/Action/MimisbrunnrBattle7.cs @@ -69,7 +69,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle8.cs b/Lib9c/Action/MimisbrunnrBattle8.cs index 2a3821e519..169279441b 100644 --- a/Lib9c/Action/MimisbrunnrBattle8.cs +++ b/Lib9c/Action/MimisbrunnrBattle8.cs @@ -71,7 +71,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MimisbrunnrBattle9.cs b/Lib9c/Action/MimisbrunnrBattle9.cs index 356957a3bb..7b3a26d9bd 100644 --- a/Lib9c/Action/MimisbrunnrBattle9.cs +++ b/Lib9c/Action/MimisbrunnrBattle9.cs @@ -70,7 +70,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/MonsterCollect.cs b/Lib9c/Action/MonsterCollect.cs index 85f2a42817..956b4f541a 100644 --- a/Lib9c/Action/MonsterCollect.cs +++ b/Lib9c/Action/MonsterCollect.cs @@ -30,7 +30,7 @@ public class MonsterCollect : GameAction, IMonsterCollectV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/MonsterCollect0.cs b/Lib9c/Action/MonsterCollect0.cs index a1775accfe..e29060f2dd 100644 --- a/Lib9c/Action/MonsterCollect0.cs +++ b/Lib9c/Action/MonsterCollect0.cs @@ -27,7 +27,7 @@ public class MonsterCollect0 : GameAction, IMonsterCollectV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta 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 380eb0f7b6..d1a86025c1 100644 --- a/Lib9c/Action/MonsterCollect2.cs +++ b/Lib9c/Action/MonsterCollect2.cs @@ -25,7 +25,7 @@ public class MonsterCollect2 : GameAction, IMonsterCollectV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/PatchTableSheet.cs b/Lib9c/Action/PatchTableSheet.cs index a5ae999fbe..9330e0f169 100644 --- a/Lib9c/Action/PatchTableSheet.cs +++ b/Lib9c/Action/PatchTableSheet.cs @@ -39,7 +39,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var sheetAddress = Addresses.TableSheet.Derive(TableName); if (ctx.Rehearsal) { diff --git a/Lib9c/Action/PetEnhancement.cs b/Lib9c/Action/PetEnhancement.cs index ac60cfbc7c..fcf7becb47 100644 --- a/Lib9c/Action/PetEnhancement.cs +++ b/Lib9c/Action/PetEnhancement.cs @@ -43,7 +43,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/PrepareRewardAssets.cs b/Lib9c/Action/PrepareRewardAssets.cs index adeaa48056..9b2e5cb256 100644 --- a/Lib9c/Action/PrepareRewardAssets.cs +++ b/Lib9c/Action/PrepareRewardAssets.cs @@ -45,7 +45,7 @@ public override void LoadPlainValue(IValue plainValue) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { foreach (var asset in Assets) diff --git a/Lib9c/Action/Raid.cs b/Lib9c/Action/Raid.cs index f30e6bcd69..734327dfd6 100644 --- a/Lib9c/Action/Raid.cs +++ b/Lib9c/Action/Raid.cs @@ -45,7 +45,7 @@ public class Raid : GameAction, IRaidV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid1.cs b/Lib9c/Action/Raid1.cs index 7199e6fad3..ebe3b924f8 100644 --- a/Lib9c/Action/Raid1.cs +++ b/Lib9c/Action/Raid1.cs @@ -38,7 +38,7 @@ public class Raid1 : GameAction, IRaidV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid2.cs b/Lib9c/Action/Raid2.cs index 8f8296d388..f7f89784ca 100644 --- a/Lib9c/Action/Raid2.cs +++ b/Lib9c/Action/Raid2.cs @@ -42,7 +42,7 @@ public class Raid2 : GameAction, IRaidV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid3.cs b/Lib9c/Action/Raid3.cs index 2193d6ffcb..3c5fd76b34 100644 --- a/Lib9c/Action/Raid3.cs +++ b/Lib9c/Action/Raid3.cs @@ -46,7 +46,7 @@ public class Raid3 : GameAction, IRaidV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid4.cs b/Lib9c/Action/Raid4.cs index 08484c4528..dc4db9b07b 100644 --- a/Lib9c/Action/Raid4.cs +++ b/Lib9c/Action/Raid4.cs @@ -47,7 +47,7 @@ public class Raid4 : GameAction, IRaidV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/Raid5.cs b/Lib9c/Action/Raid5.cs index 1aa58b6664..a2bd6da274 100644 --- a/Lib9c/Action/Raid5.cs +++ b/Lib9c/Action/Raid5.cs @@ -46,7 +46,7 @@ public class Raid5 : GameAction, IRaidV2 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RankingBattle.cs b/Lib9c/Action/RankingBattle.cs index cec73e07fd..1bb3da0c9f 100644 --- a/Lib9c/Action/RankingBattle.cs +++ b/Lib9c/Action/RankingBattle.cs @@ -47,7 +47,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); var ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle0.cs b/Lib9c/Action/RankingBattle0.cs index 3d31cfd270..65e3d8f8d9 100644 --- a/Lib9c/Action/RankingBattle0.cs +++ b/Lib9c/Action/RankingBattle0.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(ctx.Signer, MarkChanged) diff --git a/Lib9c/Action/RankingBattle10.cs b/Lib9c/Action/RankingBattle10.cs index 129877b0a0..9f091741c4 100644 --- a/Lib9c/Action/RankingBattle10.cs +++ b/Lib9c/Action/RankingBattle10.cs @@ -46,7 +46,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle11.cs b/Lib9c/Action/RankingBattle11.cs index 1c09b62ea8..8b5db07ac0 100644 --- a/Lib9c/Action/RankingBattle11.cs +++ b/Lib9c/Action/RankingBattle11.cs @@ -54,7 +54,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle2.cs b/Lib9c/Action/RankingBattle2.cs index ad51a431e4..b17faa986a 100644 --- a/Lib9c/Action/RankingBattle2.cs +++ b/Lib9c/Action/RankingBattle2.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(ctx.Signer, MarkChanged) diff --git a/Lib9c/Action/RankingBattle3.cs b/Lib9c/Action/RankingBattle3.cs index a4d4e5f5ef..90ebde277f 100644 --- a/Lib9c/Action/RankingBattle3.cs +++ b/Lib9c/Action/RankingBattle3.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(ctx.Signer, MarkChanged) diff --git a/Lib9c/Action/RankingBattle4.cs b/Lib9c/Action/RankingBattle4.cs index a8c60231bb..12b88e23c4 100644 --- a/Lib9c/Action/RankingBattle4.cs +++ b/Lib9c/Action/RankingBattle4.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { return states.SetState(ctx.Signer, MarkChanged) diff --git a/Lib9c/Action/RankingBattle5.cs b/Lib9c/Action/RankingBattle5.cs index f072fb7979..d8a9423c02 100644 --- a/Lib9c/Action/RankingBattle5.cs +++ b/Lib9c/Action/RankingBattle5.cs @@ -45,7 +45,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle6.cs b/Lib9c/Action/RankingBattle6.cs index 7befce4d48..f83452c0a4 100644 --- a/Lib9c/Action/RankingBattle6.cs +++ b/Lib9c/Action/RankingBattle6.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle7.cs b/Lib9c/Action/RankingBattle7.cs index db1740463e..6ac2de855a 100644 --- a/Lib9c/Action/RankingBattle7.cs +++ b/Lib9c/Action/RankingBattle7.cs @@ -44,7 +44,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle8.cs b/Lib9c/Action/RankingBattle8.cs index e8ff2f93e4..822c651847 100644 --- a/Lib9c/Action/RankingBattle8.cs +++ b/Lib9c/Action/RankingBattle8.cs @@ -47,7 +47,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RankingBattle9.cs b/Lib9c/Action/RankingBattle9.cs index 6157c2ca25..ecb688cff8 100644 --- a/Lib9c/Action/RankingBattle9.cs +++ b/Lib9c/Action/RankingBattle9.cs @@ -47,7 +47,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = avatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RapidCombination.cs b/Lib9c/Action/RapidCombination.cs index 40f3401d91..e64ba60be4 100644 --- a/Lib9c/Action/RapidCombination.cs +++ b/Lib9c/Action/RapidCombination.cs @@ -35,7 +35,7 @@ public class RapidCombination : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination0.cs b/Lib9c/Action/RapidCombination0.cs index 2def293d6c..1110c1a728 100644 --- a/Lib9c/Action/RapidCombination0.cs +++ b/Lib9c/Action/RapidCombination0.cs @@ -53,7 +53,7 @@ public override IValue Serialize() => public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination2.cs b/Lib9c/Action/RapidCombination2.cs index 652abbe0b6..c5f2e34ea1 100644 --- a/Lib9c/Action/RapidCombination2.cs +++ b/Lib9c/Action/RapidCombination2.cs @@ -28,7 +28,7 @@ public class RapidCombination2 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination3.cs b/Lib9c/Action/RapidCombination3.cs index 075402fad1..ba173df8f8 100644 --- a/Lib9c/Action/RapidCombination3.cs +++ b/Lib9c/Action/RapidCombination3.cs @@ -28,7 +28,7 @@ public class RapidCombination3 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination4.cs b/Lib9c/Action/RapidCombination4.cs index 9d7e11c024..db847fad36 100644 --- a/Lib9c/Action/RapidCombination4.cs +++ b/Lib9c/Action/RapidCombination4.cs @@ -29,7 +29,7 @@ public class RapidCombination4 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination5.cs b/Lib9c/Action/RapidCombination5.cs index fa54e23552..74a7b3e55d 100644 --- a/Lib9c/Action/RapidCombination5.cs +++ b/Lib9c/Action/RapidCombination5.cs @@ -56,7 +56,7 @@ public override IValue Serialize() => public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination6.cs b/Lib9c/Action/RapidCombination6.cs index 000d0acab5..5422c1c179 100644 --- a/Lib9c/Action/RapidCombination6.cs +++ b/Lib9c/Action/RapidCombination6.cs @@ -35,7 +35,7 @@ public class RapidCombination6 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination7.cs b/Lib9c/Action/RapidCombination7.cs index 7081846515..c4d3cb3d76 100644 --- a/Lib9c/Action/RapidCombination7.cs +++ b/Lib9c/Action/RapidCombination7.cs @@ -33,7 +33,7 @@ public class RapidCombination7 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/RapidCombination8.cs b/Lib9c/Action/RapidCombination8.cs index 73518c1a90..a1e21b4091 100644 --- a/Lib9c/Action/RapidCombination8.cs +++ b/Lib9c/Action/RapidCombination8.cs @@ -34,7 +34,7 @@ public class RapidCombination8 : GameAction, IRapidCombinationV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var slotAddress = avatarAddress.Derive( string.Format( CultureInfo.InvariantCulture, diff --git a/Lib9c/Action/ReRegisterProduct.cs b/Lib9c/Action/ReRegisterProduct.cs index 642744d274..0655931335 100644 --- a/Lib9c/Action/ReRegisterProduct.cs +++ b/Lib9c/Action/ReRegisterProduct.cs @@ -27,7 +27,7 @@ public class ReRegisterProduct : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/ReRegisterProduct0.cs b/Lib9c/Action/ReRegisterProduct0.cs index ef131132c4..1fe188fe7e 100644 --- a/Lib9c/Action/ReRegisterProduct0.cs +++ b/Lib9c/Action/ReRegisterProduct0.cs @@ -27,7 +27,7 @@ public class ReRegisterProduct0 : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta states = context.PreviousStates; + IAccountStateDelta states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RedeemCode.cs b/Lib9c/Action/RedeemCode.cs index b1b2474340..b2e6cfb978 100644 --- a/Lib9c/Action/RedeemCode.cs +++ b/Lib9c/Action/RedeemCode.cs @@ -44,7 +44,7 @@ public RedeemCode(string code, Address avatarAddress) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RedeemCode0.cs b/Lib9c/Action/RedeemCode0.cs index 6848e544fc..74df8d94a1 100644 --- a/Lib9c/Action/RedeemCode0.cs +++ b/Lib9c/Action/RedeemCode0.cs @@ -40,7 +40,7 @@ public RedeemCode0(string code, Address avatarAddress) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { states = states.SetState(RedeemCodeState.Address, MarkChanged); diff --git a/Lib9c/Action/RedeemCode2.cs b/Lib9c/Action/RedeemCode2.cs index e7cb946b99..9e270c2d46 100644 --- a/Lib9c/Action/RedeemCode2.cs +++ b/Lib9c/Action/RedeemCode2.cs @@ -40,7 +40,7 @@ public RedeemCode2(string code, Address avatarAddress) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index 9ac54f7537..09601341d6 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -29,7 +29,7 @@ public class RegisterProduct : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RegisterProduct0.cs b/Lib9c/Action/RegisterProduct0.cs index 2a83cbdadb..748540beb4 100644 --- a/Lib9c/Action/RegisterProduct0.cs +++ b/Lib9c/Action/RegisterProduct0.cs @@ -29,7 +29,7 @@ public class RegisterProduct0 : GameAction public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RenewAdminState.cs b/Lib9c/Action/RenewAdminState.cs index 8d24e70137..beb3c09d8c 100644 --- a/Lib9c/Action/RenewAdminState.cs +++ b/Lib9c/Action/RenewAdminState.cs @@ -35,7 +35,7 @@ public RenewAdminState(long newValidUntil) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states diff --git a/Lib9c/Action/RequestPledge.cs b/Lib9c/Action/RequestPledge.cs index 484b1d35bc..6842b176fa 100644 --- a/Lib9c/Action/RequestPledge.cs +++ b/Lib9c/Action/RequestPledge.cs @@ -37,7 +37,7 @@ public override void LoadPlainValue(IValue plainValue) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var contractAddress = AgentAddress.GetPledgeAddress(); if (states.TryGetState(contractAddress, out List _)) { diff --git a/Lib9c/Action/RewardGold.cs b/Lib9c/Action/RewardGold.cs index cf21974ead..751978aa4c 100644 --- a/Lib9c/Action/RewardGold.cs +++ b/Lib9c/Action/RewardGold.cs @@ -37,7 +37,7 @@ public override void LoadPlainValue(IValue plainValue) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; states = TransferMead(context, states); states = GenesisGoldDistribution(context, states); var addressesHex = GetSignerAndOtherAddressesHex(context, context.Signer); diff --git a/Lib9c/Action/RuneEnhancement.cs b/Lib9c/Action/RuneEnhancement.cs index 1b14a3f45d..b5f2a06bb0 100644 --- a/Lib9c/Action/RuneEnhancement.cs +++ b/Lib9c/Action/RuneEnhancement.cs @@ -46,7 +46,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/RuneEnhancement0.cs b/Lib9c/Action/RuneEnhancement0.cs index 7670f8431a..886e745f3b 100644 --- a/Lib9c/Action/RuneEnhancement0.cs +++ b/Lib9c/Action/RuneEnhancement0.cs @@ -48,7 +48,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { return states; diff --git a/Lib9c/Action/SecureMiningReward.cs b/Lib9c/Action/SecureMiningReward.cs index 85cb7297c0..ab3c963eec 100644 --- a/Lib9c/Action/SecureMiningReward.cs +++ b/Lib9c/Action/SecureMiningReward.cs @@ -58,7 +58,7 @@ public SecureMiningReward(Address recipient) public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - IAccountStateDelta state = context.PreviousStates; + IAccountStateDelta state = context.PreviousState; if (context.Rehearsal) { return state.MarkBalanceChanged( diff --git a/Lib9c/Action/Sell.cs b/Lib9c/Action/Sell.cs index b213c014c3..46d6f6150c 100644 --- a/Lib9c/Action/Sell.cs +++ b/Lib9c/Action/Sell.cs @@ -64,7 +64,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Sell0.cs b/Lib9c/Action/Sell0.cs index 3fb9a0f9db..30551ea2cd 100644 --- a/Lib9c/Action/Sell0.cs +++ b/Lib9c/Action/Sell0.cs @@ -46,7 +46,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(ShopState.Address, MarkChanged); diff --git a/Lib9c/Action/Sell10.cs b/Lib9c/Action/Sell10.cs index 80044ee171..747e4a4adc 100644 --- a/Lib9c/Action/Sell10.cs +++ b/Lib9c/Action/Sell10.cs @@ -65,7 +65,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Sell11.cs b/Lib9c/Action/Sell11.cs index 70cb4f6b0a..552aef007d 100644 --- a/Lib9c/Action/Sell11.cs +++ b/Lib9c/Action/Sell11.cs @@ -64,7 +64,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Sell2.cs b/Lib9c/Action/Sell2.cs index 162ae1aada..b3a6516506 100644 --- a/Lib9c/Action/Sell2.cs +++ b/Lib9c/Action/Sell2.cs @@ -46,7 +46,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(ShopState.Address, MarkChanged); diff --git a/Lib9c/Action/Sell3.cs b/Lib9c/Action/Sell3.cs index ca19b4c29b..0d8ede1274 100644 --- a/Lib9c/Action/Sell3.cs +++ b/Lib9c/Action/Sell3.cs @@ -46,7 +46,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(ShopState.Address, MarkChanged); diff --git a/Lib9c/Action/Sell4.cs b/Lib9c/Action/Sell4.cs index aac0510287..d9a93d0000 100644 --- a/Lib9c/Action/Sell4.cs +++ b/Lib9c/Action/Sell4.cs @@ -53,7 +53,7 @@ public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); IActionContext ctx = context; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; if (ctx.Rehearsal) { states = states.SetState(sellerAvatarAddress, MarkChanged); diff --git a/Lib9c/Action/Sell5.cs b/Lib9c/Action/Sell5.cs index dedc0dce34..8a0630bc01 100644 --- a/Lib9c/Action/Sell5.cs +++ b/Lib9c/Action/Sell5.cs @@ -62,7 +62,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { states = states.SetState(sellerAvatarAddress, MarkChanged); diff --git a/Lib9c/Action/Sell6.cs b/Lib9c/Action/Sell6.cs index fabb476283..c988b8ec84 100644 --- a/Lib9c/Action/Sell6.cs +++ b/Lib9c/Action/Sell6.cs @@ -61,7 +61,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; if (context.Rehearsal) { states = states.SetState(sellerAvatarAddress, MarkChanged); diff --git a/Lib9c/Action/Sell7.cs b/Lib9c/Action/Sell7.cs index 82d16eee62..a1945de285 100644 --- a/Lib9c/Action/Sell7.cs +++ b/Lib9c/Action/Sell7.cs @@ -62,7 +62,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Sell8.cs b/Lib9c/Action/Sell8.cs index 6a62203a12..6fac68d1cc 100644 --- a/Lib9c/Action/Sell8.cs +++ b/Lib9c/Action/Sell8.cs @@ -62,7 +62,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/Sell9.cs b/Lib9c/Action/Sell9.cs index 2ed753b062..02241e5fbd 100644 --- a/Lib9c/Action/Sell9.cs +++ b/Lib9c/Action/Sell9.cs @@ -61,7 +61,7 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var inventoryAddress = sellerAvatarAddress.Derive(LegacyInventoryKey); var worldInformationAddress = sellerAvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = sellerAvatarAddress.Derive(LegacyQuestListKey); diff --git a/Lib9c/Action/SellCancellation.cs b/Lib9c/Action/SellCancellation.cs index 84ea2628fa..311ddcbd03 100644 --- a/Lib9c/Action/SellCancellation.cs +++ b/Lib9c/Action/SellCancellation.cs @@ -90,7 +90,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary current.MarkBalanceChanged(context, t.amount.Currency, new[] {Sender, t.recipient})); diff --git a/Lib9c/Action/TransferAssets0.cs b/Lib9c/Action/TransferAssets0.cs index f3ad86b9d7..9d89ad1f3f 100644 --- a/Lib9c/Action/TransferAssets0.cs +++ b/Lib9c/Action/TransferAssets0.cs @@ -82,7 +82,7 @@ public override IValue PlainValue public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(4); - var state = context.PreviousStates; + var state = context.PreviousState; if (context.Rehearsal) { return Recipients.Aggregate(state, (current, t) => current.MarkBalanceChanged(context, t.amount.Currency, new[] {Sender, t.recipient})); diff --git a/Lib9c/Action/UnlockEquipmentRecipe.cs b/Lib9c/Action/UnlockEquipmentRecipe.cs index ad20b495da..ff295308dd 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe.cs @@ -31,7 +31,7 @@ public class UnlockEquipmentRecipe : GameAction, IUnlockEquipmentRecipeV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); diff --git a/Lib9c/Action/UnlockEquipmentRecipe1.cs b/Lib9c/Action/UnlockEquipmentRecipe1.cs index 4b4d94a811..4f3ce71fe8 100644 --- a/Lib9c/Action/UnlockEquipmentRecipe1.cs +++ b/Lib9c/Action/UnlockEquipmentRecipe1.cs @@ -32,7 +32,7 @@ public class UnlockEquipmentRecipe1: GameAction, IUnlockEquipmentRecipeV1 public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var states = context.PreviousState; var worldInformationAddress = AvatarAddress.Derive(LegacyWorldInformationKey); var questListAddress = AvatarAddress.Derive(LegacyQuestListKey); var inventoryAddress = AvatarAddress.Derive(LegacyInventoryKey); diff --git a/Lib9c/Action/UnlockRuneSlot.cs b/Lib9c/Action/UnlockRuneSlot.cs index a42d794a17..501f857eec 100644 --- a/Lib9c/Action/UnlockRuneSlot.cs +++ b/Lib9c/Action/UnlockRuneSlot.cs @@ -42,7 +42,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary func = Operator.ToFunc(); From a973652c959454115721eed406bd58cfd5cc5ca7 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 10:54:15 +0900 Subject: [PATCH 36/68] Rewrite attribute checking logic --- .../Factory/ClaimStakeRewardFactoryTest.cs | 6 ++++-- .../Action/Scenario/MeadScenarioTest.cs | 19 ++++++------------- .Lib9c.Tests/Action/Snapshot/ActionUtils.cs | 5 ++--- .Lib9c.Tools/SubCommand/Action.cs | 18 +++++------------- Lib9c/Action/ActionObsoleteAttribute.cs | 1 + 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs index 9cf3b364f6..15bdc79cde 100644 --- a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs +++ b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs @@ -63,8 +63,10 @@ public void Create_ByVersion_Success(string expectActionType, int version) { var addr = new PrivateKey().ToAddress(); var action = ClaimStakeRewardFactory.CreateByVersion(version, addr); - var actualActionType = (string)(Text)ActionTypeAttribute.ValueOf(action.GetType())!; - Assert.Equal(expectActionType, actualActionType); + var actualActionType = action + .GetType() + .GetCustomAttribute()?.TypeIdentifier; + Assert.Equal(new Text(expectActionType), actualActionType); } } } diff --git a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs index c06a66dc68..04933ee60d 100644 --- a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs @@ -64,23 +64,16 @@ public void Contract() public void UseGas() { Type baseType = typeof(Nekoyume.Action.ActionBase); - Type attrType = typeof(ActionTypeAttribute); - Type obsoleteType = typeof(ActionObsoleteAttribute); bool IsTarget(Type type) { return baseType.IsAssignableFrom(type) && - type.IsDefined(attrType) && - type != typeof(InitializeStates) && - ActionTypeAttribute.ValueOf(type) is { } && - ( - !type.IsDefined(obsoleteType) || - type - .GetCustomAttributes() - .OfType() - .Select(attr => attr.ObsoleteIndex) - .FirstOrDefault() > ActionObsoleteConfig.V200030ObsoleteIndex - ); + type != typeof(InitializeStates) && + type.GetCustomAttribute() is { } && + ( + !(type.GetCustomAttribute()?.ObsoleteIndex is { } obsoleteIndex) || + obsoleteIndex > ActionObsoleteConfig.V200030ObsoleteIndex + ); } var assembly = baseType.Assembly; diff --git a/.Lib9c.Tests/Action/Snapshot/ActionUtils.cs b/.Lib9c.Tests/Action/Snapshot/ActionUtils.cs index 066290acdd..ee11c2ad6a 100644 --- a/.Lib9c.Tests/Action/Snapshot/ActionUtils.cs +++ b/.Lib9c.Tests/Action/Snapshot/ActionUtils.cs @@ -12,9 +12,8 @@ public static IValue GetActionTypeId() { Type attrType = typeof(ActionTypeAttribute); Type actionType = typeof(T); - return actionType.IsDefined(attrType) && - ActionTypeAttribute.ValueOf(actionType) is { } tid - ? tid + return actionType.GetCustomAttribute() is { } attr + ? attr.TypeIdentifier : throw new ArgumentException( $"The action type attribute is missing for {typeof(T)}."); } diff --git a/.Lib9c.Tools/SubCommand/Action.cs b/.Lib9c.Tools/SubCommand/Action.cs index e56ab4c869..2384172811 100644 --- a/.Lib9c.Tools/SubCommand/Action.cs +++ b/.Lib9c.Tools/SubCommand/Action.cs @@ -23,31 +23,23 @@ public void List( ) { Type baseType = typeof(Nekoyume.Action.ActionBase); - Type attrType = typeof(ActionTypeAttribute); - Type obsoleteType = typeof(ActionObsoleteAttribute); bool IsTarget(Type type) { return baseType.IsAssignableFrom(type) && - type.IsDefined(attrType) && - ActionTypeAttribute.ValueOf(type) is { } && + type.GetCustomAttribute() is { } && ( !excludeObsolete || - !type.IsDefined(obsoleteType) || - type - .GetCustomAttributes() - .OfType() - .Select(attr => attr.ObsoleteIndex) - .FirstOrDefault() > blockIndex + !(type.GetCustomAttribute() is { } aoAttr) || + aoAttr.ObsoleteIndex > blockIndex ); } var assembly = baseType.Assembly; var typeIds = assembly.GetTypes() .Where(IsTarget) - .Select(type => ActionTypeAttribute.ValueOf(type)) - .Where(type => type is Text) - .Cast() + .Select(type => type.GetCustomAttribute()?.TypeIdentifier) + .OfType() .OrderBy(type => type); foreach (Text typeId in typeIds) { diff --git a/Lib9c/Action/ActionObsoleteAttribute.cs b/Lib9c/Action/ActionObsoleteAttribute.cs index 5a0ff08d55..53990e9dd7 100644 --- a/Lib9c/Action/ActionObsoleteAttribute.cs +++ b/Lib9c/Action/ActionObsoleteAttribute.cs @@ -14,6 +14,7 @@ namespace Nekoyume.Action /// starting from + 2. /// /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class ActionObsoleteAttribute : Attribute { public ActionObsoleteAttribute(long obsoleteIndex) From 5c0faf9698447f4e907db08e61c1c4fbb6e7f11c Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 12:57:49 +0900 Subject: [PATCH 37/68] Code cleanup --- .Lib9c.Tests/Action/ActivateAccount0Test.cs | 4 ++-- .Lib9c.Tests/Action/ActivateAccountTest.cs | 2 +- .Lib9c.Tests/Action/AddActivatedAccount0Test.cs | 2 +- .Lib9c.Tests/Action/AddRedeemCodeTest.cs | 2 +- .Lib9c.Tests/Action/CreatePendingActivationTest.cs | 2 +- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 4 ++-- .Lib9c.Tests/Action/State.cs | 9 +++++++++ .Lib9c.Tests/Action/TransferAsset2Test.cs | 2 +- .Lib9c.Tests/Action/TransferAsset3Test.cs | 2 +- .Lib9c.Tests/Action/TransferAssetTest0.cs | 2 +- .Lib9c.Tests/Action/TransferAssets0Test.cs | 2 +- .Lib9c.Tests/Action/TransferAssetsTest.cs | 2 +- 12 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.Lib9c.Tests/Action/ActivateAccount0Test.cs b/.Lib9c.Tests/Action/ActivateAccount0Test.cs index 4d8f692d77..908805f306 100644 --- a/.Lib9c.Tests/Action/ActivateAccount0Test.cs +++ b/.Lib9c.Tests/Action/ActivateAccount0Test.cs @@ -50,7 +50,7 @@ public void Rehearsal() ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -123,7 +123,7 @@ public void ExecuteWithNonExistsAccounts() ActivationKey.Create(privateKey, nonce); // state가 올바르게 초기화되지 않은 상태를 가정합니다. - var state = new State(ImmutableDictionary.Empty); + var state = new State(); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); Assert.Throws(() => diff --git a/.Lib9c.Tests/Action/ActivateAccountTest.cs b/.Lib9c.Tests/Action/ActivateAccountTest.cs index 9b548206b4..7b2432e5db 100644 --- a/.Lib9c.Tests/Action/ActivateAccountTest.cs +++ b/.Lib9c.Tests/Action/ActivateAccountTest.cs @@ -75,7 +75,7 @@ public void Rehearsal() Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index 16d005ed1d..56dbf8f7ea 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -75,7 +75,7 @@ public void Rehearsal() public void ExecuteWithNonExistsAccounts() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State(ImmutableDictionary.Empty); + var state = new State(); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); diff --git a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs index 8aeaa09305..040f53181d 100644 --- a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs @@ -19,7 +19,7 @@ public void CheckPermission() var adminState = new AdminState(adminAddress, 100); var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()); - var state = new State(initStates, ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty); + var state = new State(initStates); var action = new AddRedeemCode { redeemCsv = "New Value", diff --git a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs index 009411fec0..7737c8c1d2 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs @@ -90,7 +90,7 @@ public void Rehearsal() BlockIndex = 101, Signer = default, Rehearsal = true, - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), } ); Assert.Equal( diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 0a8c2e3435..c4334f35ce 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -89,7 +89,7 @@ public void CheckPermission() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); - var state = new State(initStates, ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty); + var state = new State(initStates); var action = new PatchTableSheet() { TableName = tableName, @@ -132,7 +132,7 @@ public void ExecuteNewTable() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); - var state = new State(initStates, ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty); + var state = new State(initStates); var action = new PatchTableSheet() { TableName = nameof(CostumeStatSheet), diff --git a/.Lib9c.Tests/Action/State.cs b/.Lib9c.Tests/Action/State.cs index 56d4b8b75d..d01d735cc0 100644 --- a/.Lib9c.Tests/Action/State.cs +++ b/.Lib9c.Tests/Action/State.cs @@ -20,6 +20,15 @@ public class State : IAccountStateDelta private readonly ValidatorSet _validatorSet; private readonly IAccountDelta _delta; + public State() + : this( + ImmutableDictionary.Empty, + ImmutableDictionary<(Address Address, Currency Currency), BigInteger>.Empty, + ImmutableDictionary.Empty, + new ValidatorSet()) + { + } + // Pretends all given arguments are part of the delta, i.e., have been modified // using appropriate methods such as Transfer/Mint/Burn to set the values. // Also convert to internal data types. diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index 1bb6bfaca7..06dd85f0cc 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -284,7 +284,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index 56dde3ba42..a9d7111475 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -300,7 +300,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index e51f0d6771..72044efcda 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -246,7 +246,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index 51f560686a..ca6b6b556b 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -340,7 +340,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 9281e0878f..313bd83d64 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -247,7 +247,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(ImmutableDictionary.Empty), + PreviousState = new State(), Signer = default, Rehearsal = true, BlockIndex = 1, From 3d4a94a147e8b78f9d08be7b092a8b10e3b3bb62 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 13:03:15 +0900 Subject: [PATCH 38/68] Renamed State to MockStateDelta; separated Delta to MockDelta --- .../Action/CreateOrReplaceAvatarTest.cs | 2 +- .../Action/FaucetCurrencyTest.cs | 2 +- .../Action/FaucetRuneTest.cs | 2 +- .../Action/AccountStateDeltaExtensionsTest.cs | 6 +- .../Action/AccountStateViewExtensionsTest.cs | 46 ++++---- .../Action/ActionContextExtensionsTest.cs | 2 +- .Lib9c.Tests/Action/ActionEvaluationTest.cs | 2 +- .Lib9c.Tests/Action/ActivateAccount0Test.cs | 12 +- .Lib9c.Tests/Action/ActivateAccountTest.cs | 8 +- .../Action/AddActivatedAccount0Test.cs | 8 +- .../Action/AddActivatedAccountTest.cs | 6 +- .Lib9c.Tests/Action/AddRedeemCodeTest.cs | 8 +- .Lib9c.Tests/Action/ApprovePledgeTest.cs | 4 +- .Lib9c.Tests/Action/ArenahelperTest.cs | 2 +- .Lib9c.Tests/Action/BattleArena10Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena11Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena12Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena1Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena2Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena3Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena4Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena5Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena6Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena7Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena8Test.cs | 2 +- .Lib9c.Tests/Action/BattleArena9Test.cs | 2 +- .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 | 6 +- .Lib9c.Tests/Action/Buy4Test.cs | 6 +- .Lib9c.Tests/Action/Buy5Test.cs | 4 +- .Lib9c.Tests/Action/Buy6Test.cs | 4 +- .Lib9c.Tests/Action/Buy7Test.cs | 4 +- .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 | 2 +- .../Action/CancelMonsterCollectTest.cs | 2 +- .../Action/CancelProductRegistrationTest.cs | 2 +- .Lib9c.Tests/Action/ChargeActionPoint0Test.cs | 2 +- .Lib9c.Tests/Action/ChargeActionPoint2Test.cs | 4 +- .Lib9c.Tests/Action/ChargeActionPointTest.cs | 4 +- .../ClaimMonsterCollectionReward0Test.cs | 2 +- .../ClaimMonsterCollectionReward2Test.cs | 4 +- .../ClaimMonsterCollectionRewardTest.cs | 4 +- .Lib9c.Tests/Action/ClaimRaidRewardTest.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward1Test.cs | 2 +- .Lib9c.Tests/Action/ClaimStakeReward2Test.cs | 2 +- .../Action/ClaimWorldBossKillRewardTest.cs | 2 +- .../Action/CombinationConsumable0Test.cs | 4 +- .../Action/CombinationConsumable2Test.cs | 2 +- .../Action/CombinationConsumable3Test.cs | 2 +- .../Action/CombinationConsumable4Test.cs | 2 +- .../Action/CombinationConsumable5Test.cs | 2 +- .../Action/CombinationConsumable6Test.cs | 2 +- .../Action/CombinationConsumable7Test.cs | 2 +- .../Action/CombinationConsumableTest.cs | 2 +- .../Action/CombinationEquipment0Test.cs | 4 +- .../Action/CombinationEquipment10Test.cs | 4 +- .../Action/CombinationEquipment11Test.cs | 4 +- .../Action/CombinationEquipment12Test.cs | 2 +- .../Action/CombinationEquipment13Test.cs | 2 +- .../Action/CombinationEquipment14Test.cs | 2 +- .../Action/CombinationEquipment15Test.cs | 2 +- .../Action/CombinationEquipment2Test.cs | 2 +- .../Action/CombinationEquipment3Test.cs | 2 +- .../Action/CombinationEquipment4Test.cs | 2 +- .../Action/CombinationEquipment5Test.cs | 2 +- .../Action/CombinationEquipment6Test.cs | 4 +- .../Action/CombinationEquipment7Test.cs | 4 +- .../Action/CombinationEquipment8Test.cs | 4 +- .../Action/CombinationEquipment9Test.cs | 4 +- .../Action/CombinationEquipmentTest.cs | 2 +- .../Action/Coupons/IssueCouponsTest.cs | 2 +- .../Action/Coupons/RedeemCouponTest.cs | 2 +- .../Action/Coupons/TransferCouponsTest.cs | 2 +- .Lib9c.Tests/Action/CreateAvatar0Test.cs | 12 +- .Lib9c.Tests/Action/CreateAvatar2Test.cs | 12 +- .Lib9c.Tests/Action/CreateAvatar3Test.cs | 12 +- .Lib9c.Tests/Action/CreateAvatar6Test.cs | 12 +- .Lib9c.Tests/Action/CreateAvatar7Test.cs | 12 +- .Lib9c.Tests/Action/CreateAvatarTest.cs | 12 +- .../Action/CreatePendingActivationTest.cs | 6 +- .../Action/CreatePendingActivationsTest.cs | 4 +- .Lib9c.Tests/Action/CreatePledgeTest.cs | 2 +- .Lib9c.Tests/Action/DailyReward0Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward2Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward3Test.cs | 4 +- .Lib9c.Tests/Action/DailyReward4Test.cs | 6 +- .Lib9c.Tests/Action/DailyReward5Test.cs | 6 +- .Lib9c.Tests/Action/DailyReward6Test.cs | 6 +- .Lib9c.Tests/Action/DailyRewardTest.cs | 6 +- .Lib9c.Tests/Action/EndPledgeTest.cs | 4 +- .../Action/EventConsumableItemCraftsTest.cs | 2 +- .../Action/EventDungeonBattleV1Test.cs | 2 +- .../Action/EventDungeonBattleV2Test.cs | 2 +- .../Action/EventDungeonBattleV3Test.cs | 2 +- .../Action/EventDungeonBattleV4Test.cs | 2 +- .../Action/EventDungeonBattleV5Test.cs | 2 +- .../Action/EventMaterialItemCraftsTest.cs | 2 +- .Lib9c.Tests/Action/GrindingTest.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash0Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash10Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash11Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash12Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash13Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash15Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash16Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash17Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash18Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash19Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash20Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash21Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash2Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash3Test.cs | 2 +- .Lib9c.Tests/Action/HackAndSlash4Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash5Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlash6Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash7Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash8Test.cs | 6 +- .Lib9c.Tests/Action/HackAndSlash9Test.cs | 6 +- .../Action/HackAndSlashRandomBuffTest.cs | 2 +- .Lib9c.Tests/Action/HackAndSlashSweep1Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep2Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep3Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep4Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep5Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep6Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep7Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep8Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashSweep9Test.cs | 4 +- .Lib9c.Tests/Action/HackAndSlashTest14.cs | 4 +- .Lib9c.Tests/Action/InitializeStatesTest.cs | 10 +- .Lib9c.Tests/Action/ItemEnhancement0Test.cs | 6 +- .Lib9c.Tests/Action/ItemEnhancement10Test.cs | 4 +- .Lib9c.Tests/Action/ItemEnhancement2Test.cs | 6 +- .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 | 4 +- .Lib9c.Tests/Action/ItemEnhancement8Test.cs | 4 +- .Lib9c.Tests/Action/ItemEnhancement9Test.cs | 4 +- .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 +- .../Action/MigrationAvatarStateTest.cs | 2 +- .../Action/MigrationLegacyShopTest.cs | 2 +- .Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs | 4 +- .../Action/MimisbrunnrBattle10Test.cs | 4 +- .../Action/MimisbrunnrBattle11Test.cs | 4 +- .../Action/MimisbrunnrBattle12Test.cs | 4 +- .../Action/MimisbrunnrBattle13Test.cs | 4 +- .Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs | 4 +- .Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs | 4 +- .Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs | 6 +- .Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs | 6 +- .Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs | 6 +- .Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs | 6 +- .Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs | 6 +- .Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs | 6 +- .Lib9c.Tests/Action/MockDelta.cs | 72 ++++++++++++ .../Action/{State.cs => MockStateDelta.cs} | 107 +++++------------- .Lib9c.Tests/Action/MonsterCollect0Test.cs | 6 +- .Lib9c.Tests/Action/MonsterCollect2Test.cs | 6 +- .Lib9c.Tests/Action/MonsterCollectTest.cs | 6 +- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 6 +- .../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 | 6 +- .Lib9c.Tests/Action/Raid5Test.cs | 6 +- .Lib9c.Tests/Action/Raid6Test.cs | 6 +- .Lib9c.Tests/Action/RankingBattle0Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle10Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle11Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle2Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle3Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle4Test.cs | 2 +- .Lib9c.Tests/Action/RankingBattle5Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle6Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle7Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle8Test.cs | 4 +- .Lib9c.Tests/Action/RankingBattle9Test.cs | 4 +- .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 | 4 +- .Lib9c.Tests/Action/RapidCombination5Test.cs | 4 +- .Lib9c.Tests/Action/RapidCombination6Test.cs | 4 +- .Lib9c.Tests/Action/RapidCombination8Test.cs | 4 +- .Lib9c.Tests/Action/RapidCombinationTest.cs | 4 +- .Lib9c.Tests/Action/RapidCombinationTest7.cs | 4 +- .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 +- .Lib9c.Tests/Action/RuneEnhancement0Test.cs | 10 +- .Lib9c.Tests/Action/RuneEnhancementTest.cs | 12 +- .../Action/Scenario/ArenaScenarioTest.cs | 2 +- .../CombinationAndRapidCombinationTest.cs | 2 +- .../Action/Scenario/MarketScenarioTest.cs | 2 +- .../Action/Scenario/MeadScenarioTest.cs | 4 +- .../Action/Scenario/RuneScenarioTest.cs | 2 +- .../SellAndCancellationAndSellTest.cs | 2 +- .../StakeAndClaimStakeReward2ScenarioTest.cs | 2 +- .../Scenario/WorldUnlockScenarioTest.cs | 2 +- .Lib9c.Tests/Action/SecureMiningRewardTest.cs | 6 +- .Lib9c.Tests/Action/Sell0Test.cs | 4 +- .Lib9c.Tests/Action/Sell10Test.cs | 6 +- .Lib9c.Tests/Action/Sell11Test.cs | 6 +- .Lib9c.Tests/Action/Sell2Test.cs | 4 +- .Lib9c.Tests/Action/Sell3Test.cs | 4 +- .Lib9c.Tests/Action/Sell4Test.cs | 4 +- .Lib9c.Tests/Action/Sell5Test.cs | 4 +- .Lib9c.Tests/Action/Sell6Test.cs | 4 +- .Lib9c.Tests/Action/Sell7Test.cs | 6 +- .Lib9c.Tests/Action/Sell8Test.cs | 6 +- .Lib9c.Tests/Action/Sell9Test.cs | 6 +- .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 | 2 +- .Lib9c.Tests/Action/SellCancellation6Test.cs | 2 +- .Lib9c.Tests/Action/SellCancellation7Test.cs | 4 +- .Lib9c.Tests/Action/SellCancellation8Test.cs | 4 +- .Lib9c.Tests/Action/SellCancellationTest.cs | 4 +- .Lib9c.Tests/Action/SellTest.cs | 6 +- .../Snapshot/TransferAsset0SnapshotTest.cs | 4 +- .Lib9c.Tests/Action/Stake0Test.cs | 2 +- .Lib9c.Tests/Action/StakeTest.cs | 2 +- .Lib9c.Tests/Action/TransferAsset2Test.cs | 36 +++--- .Lib9c.Tests/Action/TransferAsset3Test.cs | 40 +++---- .Lib9c.Tests/Action/TransferAssetTest.cs | 30 ++--- .Lib9c.Tests/Action/TransferAssetTest0.cs | 26 ++--- .Lib9c.Tests/Action/TransferAssets0Test.cs | 42 +++---- .Lib9c.Tests/Action/TransferAssetsTest.cs | 32 +++--- .../Action/UnlockEquipmentRecipe1Test.cs | 2 +- .../Action/UnlockEquipmentRecipeTest.cs | 2 +- .Lib9c.Tests/Action/UnlockRuneSlotTest.cs | 2 +- .Lib9c.Tests/Action/UnlockWorld1Test.cs | 2 +- .Lib9c.Tests/Action/UnlockWorldTest.cs | 2 +- .Lib9c.Tests/Action/UpdateSell0Test.cs | 6 +- .Lib9c.Tests/Action/UpdateSell2Test.cs | 6 +- .Lib9c.Tests/Action/UpdateSell3Test.cs | 6 +- .Lib9c.Tests/Action/UpdateSell4Test.cs | 6 +- .Lib9c.Tests/Action/UpdateSellTest.cs | 6 +- .../Action/ValidatorSetOperateTest.cs | 10 +- .../Extensions/SheetsExtensionsTest.cs | 2 +- .Lib9c.Tests/TestHelper/BlockChainHelper.cs | 2 +- .Lib9c.Tests/Util/InitializeUtil.cs | 2 +- 269 files changed, 727 insertions(+), 710 deletions(-) create mode 100644 .Lib9c.Tests/Action/MockDelta.cs rename .Lib9c.Tests/Action/{State.cs => MockStateDelta.cs} (69%) diff --git a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs index 8e134f0219..aeee7ce766 100644 --- a/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/CreateOrReplaceAvatarTest.cs @@ -28,7 +28,7 @@ public class CreateOrReplaceAvatarTest public CreateOrReplaceAvatarTest() { - _initialStates = new Lib9c.Tests.Action.State(); + _initialStates = new Lib9c.Tests.Action.MockStateDelta(); #pragma warning disable CS0618 var ncgCurrency = Currency.Legacy("NCG", 2, null); diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs index 9ee0deb070..4c6ca5d9cc 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs @@ -35,7 +35,7 @@ public FaucetCurrencyTest(ITestOutputHelper outputHelper) var balance = ImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue>.Empty .Add((GoldCurrencyState.Address, _ncg), _ncg * int.MaxValue); - _initialState = new Lib9c.Tests.Action.State(balance: balance); + _initialState = new Lib9c.Tests.Action.MockStateDelta(balances: balance); var goldCurrencyState = new GoldCurrencyState(_ncg); _agentAddress = new PrivateKey().ToAddress(); diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs index d99fc5d94f..5075e11a3e 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs @@ -33,7 +33,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new Lib9c.Tests.Action.State(); + _initialState = new Lib9c.Tests.Action.MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs index 32fe6157f0..1ec70f5fb3 100644 --- a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs @@ -46,7 +46,7 @@ public AccountStateDeltaExtensionsTest() public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrystal, Type exc) { var context = new ActionContext(); - IAccountStateDelta states = new State(); + IAccountStateDelta states = new MockStateDelta(); var rewardInfoAddress = new PrivateKey().ToAddress(); var rewardRecord = new WorldBossKillRewardRecord(); for (int i = 0; i < level; i++) @@ -106,7 +106,7 @@ public void SetWorldBossKillReward(int level, int expectedRune, int expectedCrys [Fact] public void SetCouponWallet() { - IAccountStateDelta states = new State(); + IAccountStateDelta 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"); @@ -169,7 +169,7 @@ public void Mead(int agentBalance) var mead = Currencies.Mead; var price = RequestPledge.DefaultRefillMead * mead; ActionContext context = new ActionContext(); - IAccountStateDelta states = new State() + IAccountStateDelta 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 e1b50771da..ccaece1c7e 100644 --- a/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs @@ -49,8 +49,8 @@ public AccountStateViewExtensionsTest() [Fact] public void TryGetAvatarState() { - var states = new State(); - states = (State)states.SetState(_avatarAddress, _avatarState.Serialize()); + var states = new MockStateDelta(); + states = (MockStateDelta)states.SetState(_avatarAddress, _avatarState.Serialize()); Assert.True(states.TryGetAvatarState(_agentAddress, _avatarAddress, out var avatarState2)); Assert.Equal(_avatarAddress, avatarState2.address); @@ -60,7 +60,7 @@ public void TryGetAvatarState() [Fact] public void TryGetAvatarStateEmptyAddress() { - var states = new State(); + var states = new MockStateDelta(); Assert.False(states.TryGetAvatarState(default, default, out _)); } @@ -68,7 +68,7 @@ public void TryGetAvatarStateEmptyAddress() [Fact] public void TryGetAvatarStateAddressKeyNotFoundException() { - var states = new State().SetState(default, Dictionary.Empty); + var states = new MockStateDelta().SetState(default, Dictionary.Empty); Assert.False(states.TryGetAvatarState(default, default, out _)); } @@ -76,7 +76,7 @@ public void TryGetAvatarStateAddressKeyNotFoundException() [Fact] public void TryGetAvatarStateKeyNotFoundException() { - var states = new State() + var states = new MockStateDelta() .SetState( default, Dictionary.Empty @@ -89,7 +89,7 @@ public void TryGetAvatarStateKeyNotFoundException() [Fact] public void TryGetAvatarStateInvalidCastException() { - var states = new State().SetState(default, default(Text)); + var states = new MockStateDelta().SetState(default, default(Text)); Assert.False(states.TryGetAvatarState(default, default, out _)); } @@ -97,7 +97,7 @@ public void TryGetAvatarStateInvalidCastException() [Fact] public void TryGetAvatarStateInvalidAddress() { - var states = new State().SetState(default, _avatarState.Serialize()); + var states = new MockStateDelta().SetState(default, _avatarState.Serialize()); Assert.False(states.TryGetAvatarState(Addresses.GameConfig, _avatarAddress, out _)); } @@ -105,8 +105,8 @@ public void TryGetAvatarStateInvalidAddress() [Fact] public void GetAvatarStateV2() { - var states = new State(); - states = (State)states + var states = new MockStateDelta(); + states = (MockStateDelta)states .SetState(_avatarAddress, _avatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), _avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), _avatarState.worldInformation.Serialize()) @@ -124,13 +124,13 @@ public void GetAvatarStateV2() [InlineData(LegacyQuestListKey)] public void GetAvatarStateV2_Throw_FailedLoadStateException(string key) { - var states = new State(); - states = (State)states + var states = new MockStateDelta(); + states = (MockStateDelta)states .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()); - states = (State)states.SetState(_avatarAddress.Derive(key), null); + states = (MockStateDelta)states.SetState(_avatarAddress.Derive(key), null); var exc = Assert.Throws(() => states.GetAvatarStateV2(_avatarAddress)); Assert.Contains(key, exc.Message); } @@ -140,15 +140,15 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string key) [InlineData(false)] public void TryGetAvatarStateV2(bool backward) { - var states = new State(); + var states = new MockStateDelta(); if (backward) { - states = (State)states + states = (MockStateDelta)states .SetState(_avatarAddress, _avatarState.Serialize()); } else { - states = (State)states + states = (MockStateDelta)states .SetState(_avatarAddress, _avatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), _avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), _avatarState.worldInformation.Serialize()) @@ -164,16 +164,16 @@ public void TryGetAvatarStateV2(bool backward) [InlineData(false)] public void TryGetAgentAvatarStatesV2(bool backward) { - var states = new State().SetState(_agentAddress, _agentState.Serialize()); + var states = new MockStateDelta().SetState(_agentAddress, _agentState.Serialize()); if (backward) { - states = (State)states + states = (MockStateDelta)states .SetState(_avatarAddress, _avatarState.Serialize()); } else { - states = (State)states + states = (MockStateDelta)states .SetState(_avatarAddress, _avatarState.SerializeV2()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), _avatarState.inventory.Serialize()) .SetState(_avatarAddress.Derive(LegacyWorldInformationKey), _avatarState.worldInformation.Serialize()) @@ -187,7 +187,7 @@ public void TryGetAgentAvatarStatesV2(bool backward) [Fact] public void GetStatesAsDict() { - IAccountStateDelta states = new State(); + IAccountStateDelta states = new MockStateDelta(); var dict = new Dictionary { { new PrivateKey().ToAddress(), Null.Value }, @@ -214,7 +214,7 @@ public void GetStatesAsDict() [Fact] public void GetSheets() { - IAccountStateDelta states = new State(); + IAccountStateDelta states = new MockStateDelta(); SheetsExtensionsTest.InitSheets( states, out _, @@ -241,7 +241,7 @@ public void GetSheets() [InlineData(true)] public void GetCrystalCostState(bool exist) { - IAccountStateDelta state = new State(); + IAccountStateDelta state = new MockStateDelta(); int expectedCount = exist ? 1 : 0; FungibleAssetValue expectedCrystal = exist ? 100 * CrystalCalculator.CRYSTAL @@ -274,7 +274,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 State() + IAccountStateDelta state = new MockStateDelta() .SetState(dailyCostAddress, crystalCostState.Serialize()) .SetState(weeklyCostAddress, crystalCostState.Serialize()) .SetState(previousCostAddress, crystalCostState.Serialize()) @@ -304,7 +304,7 @@ public void GetCrystalCostStates(long blockIndex, bool previousWeeklyExist) [Fact] public void GetCouponWallet() { - IAccountStateDelta states = new State(); + IAccountStateDelta 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/ActionContextExtensionsTest.cs b/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs index 25340a8a81..77e51e30c0 100644 --- a/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs +++ b/.Lib9c.Tests/Action/ActionContextExtensionsTest.cs @@ -142,7 +142,7 @@ public static IEnumerable IsPreviewNetTestcases() [MemberData(nameof(IsMainNetTestcases))] public void IsMainNet(GoldCurrencyState goldCurrencyState, bool expected) { - var state = new State().SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); + var state = new MockStateDelta().SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); IActionContext context = new ActionContext { PreviousState = state, diff --git a/.Lib9c.Tests/Action/ActionEvaluationTest.cs b/.Lib9c.Tests/Action/ActionEvaluationTest.cs index 5f09b12a60..3ee935c555 100644 --- a/.Lib9c.Tests/Action/ActionEvaluationTest.cs +++ b/.Lib9c.Tests/Action/ActionEvaluationTest.cs @@ -33,7 +33,7 @@ public ActionEvaluationTest() #pragma warning restore CS0618 _signer = new PrivateKey().ToAddress(); _sender = new PrivateKey().ToAddress(); - _states = new State() + _states = new MockStateDelta() .SetState(_signer, (Text)"ANYTHING") .SetState(default, Dictionary.Empty.Add("key", "value")) .MintAsset(context, _signer, _currency * 10000); diff --git a/.Lib9c.Tests/Action/ActivateAccount0Test.cs b/.Lib9c.Tests/Action/ActivateAccount0Test.cs index 908805f306..b771b91964 100644 --- a/.Lib9c.Tests/Action/ActivateAccount0Test.cs +++ b/.Lib9c.Tests/Action/ActivateAccount0Test.cs @@ -19,7 +19,7 @@ public void Execute() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) .Add(pendingActivation.address, pendingActivation.Serialize())); @@ -50,7 +50,7 @@ public void Rehearsal() ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -72,7 +72,7 @@ public void ExecuteWithInvalidSignature() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) .Add(pendingActivation.address, pendingActivation.Serialize()) ); @@ -99,7 +99,7 @@ public void ExecuteWithNonExistsPending() ActivationKey.Create(privateKey, nonce); // state에는 pendingActivation에 해당하는 대기가 없는 상태를 가정합니다. - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); @@ -123,7 +123,7 @@ public void ExecuteWithNonExistsAccounts() ActivationKey.Create(privateKey, nonce); // state가 올바르게 초기화되지 않은 상태를 가정합니다. - var state = new State(); + var state = new MockStateDelta(); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); Assert.Throws(() => @@ -144,7 +144,7 @@ public void ForbidReusingActivationKey() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) .Add(pendingActivation.address, pendingActivation.Serialize())); diff --git a/.Lib9c.Tests/Action/ActivateAccountTest.cs b/.Lib9c.Tests/Action/ActivateAccountTest.cs index 7b2432e5db..2fd01ed7f7 100644 --- a/.Lib9c.Tests/Action/ActivateAccountTest.cs +++ b/.Lib9c.Tests/Action/ActivateAccountTest.cs @@ -26,16 +26,16 @@ public void Execute(bool invalid, bool pendingExist, bool alreadyActivated, Type ActivationKey.Create(privateKey, nonce); Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey); - var state = new State(); + var state = new MockStateDelta(); if (pendingExist) { - state = (State)state.SetState(pendingActivation.address, pendingActivation.Serialize()); + state = (MockStateDelta)state.SetState(pendingActivation.address, pendingActivation.Serialize()); } if (alreadyActivated) { - state = (State)state.SetState(activatedAddress, true.Serialize()); + state = (MockStateDelta)state.SetState(activatedAddress, true.Serialize()); } ActivateAccount action = activationKey.CreateActivateAccount(invalid ? new byte[] { 0x00 } : nonce); @@ -75,7 +75,7 @@ public void Rehearsal() Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index 56dbf8f7ea..0e7078bae9 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -14,7 +14,7 @@ public class AddActivatedAccount0Test public void Execute() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State( + var state = new MockStateDelta( ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) @@ -44,7 +44,7 @@ public void Execute() public void Rehearsal() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State( + var state = new MockStateDelta( ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) @@ -75,7 +75,7 @@ public void Rehearsal() public void ExecuteWithNonExistsAccounts() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State(); + var state = new MockStateDelta(); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); @@ -95,7 +95,7 @@ public void ExecuteWithNonExistsAccounts() public void CheckPermission() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State( + var state = new MockStateDelta( ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) diff --git a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs index a8ef185cd7..6e056a4bf2 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs @@ -20,7 +20,7 @@ public class AddActivatedAccountTest public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type exc) { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State( + var state = new MockStateDelta( ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) ); @@ -28,7 +28,7 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e var activatedAddress = newComer.Derive(ActivationKey.DeriveKey); if (alreadyActivated) { - state = (State)state.SetState(activatedAddress, true.Serialize()); + state = (MockStateDelta)state.SetState(activatedAddress, true.Serialize()); } var action = new AddActivatedAccount(newComer); @@ -61,7 +61,7 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e public void Rehearsal() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State( + var state = new MockStateDelta( ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) ); diff --git a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs index 040f53181d..fc5bec5958 100644 --- a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs @@ -19,7 +19,7 @@ public void CheckPermission() var adminState = new AdminState(adminAddress, 100); var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()); - var state = new State(initStates); + var state = new MockStateDelta(initStates); var action = new AddRedeemCode { redeemCsv = "New Value", @@ -69,7 +69,7 @@ public void Execute() { Signer = adminAddress, BlockIndex = 0, - PreviousState = new State() + PreviousState = new MockStateDelta() .SetState(Addresses.Admin, adminState.Serialize()) .SetState(Addresses.RedeemCode, new RedeemCodeState(new RedeemCodeListSheet()).Serialize()), }); @@ -91,7 +91,7 @@ public void ExecuteThrowSheetRowValidateException() var sheet = new RedeemCodeListSheet(); sheet.Set(csv); - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.RedeemCode, new RedeemCodeState(sheet).Serialize()); var action = new AddRedeemCode @@ -118,7 +118,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Rehearsal = true, }); diff --git a/.Lib9c.Tests/Action/ApprovePledgeTest.cs b/.Lib9c.Tests/Action/ApprovePledgeTest.cs index 23b15e90dc..638b9a7548 100644 --- a/.Lib9c.Tests/Action/ApprovePledgeTest.cs +++ b/.Lib9c.Tests/Action/ApprovePledgeTest.cs @@ -21,7 +21,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 State() + IAccountStateDelta states = new MockStateDelta() .SetState( contractAddress, List.Empty.Add(patron.Serialize()).Add(false.Serialize()).Add(mead.Serialize()) @@ -63,7 +63,7 @@ public void Execute_Throw_Exception(bool invalidPatron, bool alreadyContract, Ty contract = List.Empty.Add(patron.Serialize()).Add(true.Serialize()); } - IAccountStateDelta states = new State().SetState(contractAddress, contract); + IAccountStateDelta 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 91d4034240..fa510e4d6b 100644 --- a/.Lib9c.Tests/Action/ArenahelperTest.cs +++ b/.Lib9c.Tests/Action/ArenahelperTest.cs @@ -35,7 +35,7 @@ public ArenaHelperTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(sheets); diff --git a/.Lib9c.Tests/Action/BattleArena10Test.cs b/.Lib9c.Tests/Action/BattleArena10Test.cs index 23b30f1a16..d7ab6259d8 100644 --- a/.Lib9c.Tests/Action/BattleArena10Test.cs +++ b/.Lib9c.Tests/Action/BattleArena10Test.cs @@ -47,7 +47,7 @@ public BattleArena10Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena11Test.cs b/.Lib9c.Tests/Action/BattleArena11Test.cs index 4b2247a291..0b26c0d751 100644 --- a/.Lib9c.Tests/Action/BattleArena11Test.cs +++ b/.Lib9c.Tests/Action/BattleArena11Test.cs @@ -47,7 +47,7 @@ public BattleArena11Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena12Test.cs b/.Lib9c.Tests/Action/BattleArena12Test.cs index 54f7c8c132..7b17c2420d 100644 --- a/.Lib9c.Tests/Action/BattleArena12Test.cs +++ b/.Lib9c.Tests/Action/BattleArena12Test.cs @@ -47,7 +47,7 @@ public BattleArena12Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena1Test.cs b/.Lib9c.Tests/Action/BattleArena1Test.cs index 2693738add..299f26643c 100644 --- a/.Lib9c.Tests/Action/BattleArena1Test.cs +++ b/.Lib9c.Tests/Action/BattleArena1Test.cs @@ -48,7 +48,7 @@ public BattleArena1Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(_sheets); diff --git a/.Lib9c.Tests/Action/BattleArena2Test.cs b/.Lib9c.Tests/Action/BattleArena2Test.cs index 1f52d9adc9..225acf091e 100644 --- a/.Lib9c.Tests/Action/BattleArena2Test.cs +++ b/.Lib9c.Tests/Action/BattleArena2Test.cs @@ -50,7 +50,7 @@ public BattleArena2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(_sheets); diff --git a/.Lib9c.Tests/Action/BattleArena3Test.cs b/.Lib9c.Tests/Action/BattleArena3Test.cs index 27936fadae..af89ebec8d 100644 --- a/.Lib9c.Tests/Action/BattleArena3Test.cs +++ b/.Lib9c.Tests/Action/BattleArena3Test.cs @@ -50,7 +50,7 @@ public BattleArena3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(_sheets); diff --git a/.Lib9c.Tests/Action/BattleArena4Test.cs b/.Lib9c.Tests/Action/BattleArena4Test.cs index dfc8226ddb..6a9cd955c1 100644 --- a/.Lib9c.Tests/Action/BattleArena4Test.cs +++ b/.Lib9c.Tests/Action/BattleArena4Test.cs @@ -50,7 +50,7 @@ public BattleArena4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(_sheets); diff --git a/.Lib9c.Tests/Action/BattleArena5Test.cs b/.Lib9c.Tests/Action/BattleArena5Test.cs index bb6eee0cda..ca4773cead 100644 --- a/.Lib9c.Tests/Action/BattleArena5Test.cs +++ b/.Lib9c.Tests/Action/BattleArena5Test.cs @@ -45,7 +45,7 @@ public BattleArena5Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena6Test.cs b/.Lib9c.Tests/Action/BattleArena6Test.cs index d269eaabed..3e515a98d8 100644 --- a/.Lib9c.Tests/Action/BattleArena6Test.cs +++ b/.Lib9c.Tests/Action/BattleArena6Test.cs @@ -46,7 +46,7 @@ public BattleArena6Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); _sheets.Remove(nameof(RuneOptionSheet)); diff --git a/.Lib9c.Tests/Action/BattleArena7Test.cs b/.Lib9c.Tests/Action/BattleArena7Test.cs index 7af91c4702..67319ef4a7 100644 --- a/.Lib9c.Tests/Action/BattleArena7Test.cs +++ b/.Lib9c.Tests/Action/BattleArena7Test.cs @@ -46,7 +46,7 @@ public BattleArena7Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena8Test.cs b/.Lib9c.Tests/Action/BattleArena8Test.cs index 28b4ecd60c..f3fcb616bf 100644 --- a/.Lib9c.Tests/Action/BattleArena8Test.cs +++ b/.Lib9c.Tests/Action/BattleArena8Test.cs @@ -47,7 +47,7 @@ public BattleArena8Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleArena9Test.cs b/.Lib9c.Tests/Action/BattleArena9Test.cs index a61ec0ba6f..ca475a55c6 100644 --- a/.Lib9c.Tests/Action/BattleArena9Test.cs +++ b/.Lib9c.Tests/Action/BattleArena9Test.cs @@ -47,7 +47,7 @@ public BattleArena9Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs index a4302e7c5c..37f8bd3f99 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale1Test.cs @@ -46,7 +46,7 @@ public BattleGrandFinale1Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs index 480fb2b3fa..46e5363d2b 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale2Test.cs @@ -46,7 +46,7 @@ public BattleGrandFinale2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs index 443c42faad..799bedc2a8 100644 --- a/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs +++ b/.Lib9c.Tests/Action/BattleGrandFinale3Test.cs @@ -46,7 +46,7 @@ public BattleGrandFinale3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialStates = new State(); + _initialStates = new MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in _sheets) diff --git a/.Lib9c.Tests/Action/Buy10Test.cs b/.Lib9c.Tests/Action/Buy10Test.cs index 5fbf10648e..cff87a6b1b 100644 --- a/.Lib9c.Tests/Action/Buy10Test.cs +++ b/.Lib9c.Tests/Action/Buy10Test.cs @@ -45,7 +45,7 @@ public Buy10Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -805,7 +805,7 @@ public void Rehearsal() OrderReceipt.DeriveAddress(_orderId), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Buy11Test.cs b/.Lib9c.Tests/Action/Buy11Test.cs index 88b5a592f0..61adfcfa94 100644 --- a/.Lib9c.Tests/Action/Buy11Test.cs +++ b/.Lib9c.Tests/Action/Buy11Test.cs @@ -47,7 +47,7 @@ public Buy11Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -811,7 +811,7 @@ public void Rehearsal() OrderReceipt.DeriveAddress(_orderId), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Buy2Test.cs b/.Lib9c.Tests/Action/Buy2Test.cs index 277c38c9b1..eb6739733e 100644 --- a/.Lib9c.Tests/Action/Buy2Test.cs +++ b/.Lib9c.Tests/Action/Buy2Test.cs @@ -36,7 +36,7 @@ public Buy2Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/Buy3Test.cs b/.Lib9c.Tests/Action/Buy3Test.cs index 35a191c62f..f879fe65eb 100644 --- a/.Lib9c.Tests/Action/Buy3Test.cs +++ b/.Lib9c.Tests/Action/Buy3Test.cs @@ -36,7 +36,7 @@ public Buy3Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -208,7 +208,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -229,7 +229,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy4Test.cs b/.Lib9c.Tests/Action/Buy4Test.cs index 8d4ffdc0e3..cc30426a90 100644 --- a/.Lib9c.Tests/Action/Buy4Test.cs +++ b/.Lib9c.Tests/Action/Buy4Test.cs @@ -38,7 +38,7 @@ public Buy4Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -232,7 +232,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -253,7 +253,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy5Test.cs b/.Lib9c.Tests/Action/Buy5Test.cs index 569f1e65e6..7283576508 100644 --- a/.Lib9c.Tests/Action/Buy5Test.cs +++ b/.Lib9c.Tests/Action/Buy5Test.cs @@ -39,7 +39,7 @@ public Buy5Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -366,7 +366,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy6Test.cs b/.Lib9c.Tests/Action/Buy6Test.cs index 6473ca1935..774caf1152 100644 --- a/.Lib9c.Tests/Action/Buy6Test.cs +++ b/.Lib9c.Tests/Action/Buy6Test.cs @@ -40,7 +40,7 @@ public Buy6Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -444,7 +444,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy7Test.cs b/.Lib9c.Tests/Action/Buy7Test.cs index 8404cdffff..29507030f0 100644 --- a/.Lib9c.Tests/Action/Buy7Test.cs +++ b/.Lib9c.Tests/Action/Buy7Test.cs @@ -40,7 +40,7 @@ public Buy7Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -445,7 +445,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/Buy8Test.cs b/.Lib9c.Tests/Action/Buy8Test.cs index 2d33969982..1a890c732b 100644 --- a/.Lib9c.Tests/Action/Buy8Test.cs +++ b/.Lib9c.Tests/Action/Buy8Test.cs @@ -42,7 +42,7 @@ public Buy8Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -587,7 +587,7 @@ public void Rehearsal() OrderReceipt.DeriveAddress(_orderId), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Buy9Test.cs b/.Lib9c.Tests/Action/Buy9Test.cs index cf6d11f757..83db8c3ff2 100644 --- a/.Lib9c.Tests/Action/Buy9Test.cs +++ b/.Lib9c.Tests/Action/Buy9Test.cs @@ -42,7 +42,7 @@ public Buy9Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -686,7 +686,7 @@ public void Rehearsal() OrderReceipt.DeriveAddress(_orderId), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index f486e7a4f4..35b0eabc12 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -37,7 +37,7 @@ public BuyMultipleTest(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -410,7 +410,7 @@ public void ExecuteThrowInvalidAddressException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) @@ -429,7 +429,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = _buyerAgentAddress, }) diff --git a/.Lib9c.Tests/Action/BuyProduct0Test.cs b/.Lib9c.Tests/Action/BuyProduct0Test.cs index f387e8f7ed..219cfc0061 100644 --- a/.Lib9c.Tests/Action/BuyProduct0Test.cs +++ b/.Lib9c.Tests/Action/BuyProduct0Test.cs @@ -46,7 +46,7 @@ public BuyProduct0Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index eeeba5cc94..9e01411776 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -46,7 +46,7 @@ public BuyProductTest(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index 64c78afc61..0aac0cd3d5 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -45,7 +45,7 @@ public BuyTest(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs index 3fce08f27c..c5ded9457f 100644 --- a/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/CancelMonsterCollectTest.cs @@ -22,7 +22,7 @@ public class CancelMonsterCollectTest public CancelMonsterCollectTest() { _signer = default; - _state = new State(); + _state = new MockStateDelta(); Dictionary sheets = TableSheetsImporter.ImportSheets(); _tableSheets = new TableSheets(sheets); var agentState = new AgentState(_signer); diff --git a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs index f14baefb02..ab9e7b6513 100644 --- a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs +++ b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs @@ -34,7 +34,7 @@ public CancelProductRegistrationTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs b/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs index 46cb038aff..e8c16294f5 100644 --- a/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs +++ b/.Lib9c.Tests/Action/ChargeActionPoint0Test.cs @@ -54,7 +54,7 @@ public void Execute() Assert.Equal(0, avatarState.actionPoint); - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.GameConfig, gameConfigState.Serialize()) .SetState(agentAddress, agent.Serialize()) .SetState(avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs index dbbae9e209..7d2939aaaa 100644 --- a/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs +++ b/.Lib9c.Tests/Action/ChargeActionPoint2Test.cs @@ -44,7 +44,7 @@ public ChargeActionPoint2Test() }; agent.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GameConfig, gameConfigState.Serialize()) .SetState(_agentAddress, agent.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()); @@ -111,7 +111,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Signer = default, }) diff --git a/.Lib9c.Tests/Action/ChargeActionPointTest.cs b/.Lib9c.Tests/Action/ChargeActionPointTest.cs index 11e2df6d23..e8a6e9d478 100644 --- a/.Lib9c.Tests/Action/ChargeActionPointTest.cs +++ b/.Lib9c.Tests/Action/ChargeActionPointTest.cs @@ -47,7 +47,7 @@ public ChargeActionPointTest() }; agent.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GameConfig, gameConfigState.Serialize()) .SetState(_agentAddress, agent.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()); @@ -186,7 +186,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs index b59762101f..cb64f9cc35 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward0Test.cs @@ -25,7 +25,7 @@ public ClaimMonsterCollectionReward0Test() { _signer = default; _avatarAddress = _signer.Derive("avatar"); - _state = new State(); + _state = new MockStateDelta(); Dictionary sheets = TableSheetsImporter.ImportSheets(); _tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().ToAddress(); diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs index 6ae2b7e6ac..d06edf77b5 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs @@ -36,7 +36,7 @@ public ClaimMonsterCollectionReward2Test(ITestOutputHelper outputHelper) _signer = default; _avatarAddress = _signer.Derive("avatar"); - _state = new State(); + _state = new MockStateDelta(); Dictionary sheets = TableSheetsImporter.ImportSheets(); _tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().ToAddress(); @@ -211,7 +211,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, BlockIndex = 0, Rehearsal = true, diff --git a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs index c38af8b78d..12082b5e3a 100644 --- a/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimMonsterCollectionRewardTest.cs @@ -36,7 +36,7 @@ public ClaimMonsterCollectionRewardTest(ITestOutputHelper outputHelper) _signer = default; _avatarAddress = _signer.Derive("avatar"); - _state = new State(); + _state = new MockStateDelta(); Dictionary sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().ToAddress(); @@ -188,7 +188,7 @@ public void Rehearsal() { IAccountStateDelta nextState = _action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, BlockIndex = 0, Rehearsal = true, diff --git a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs index 7b96725f0f..aab35eccf9 100644 --- a/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimRaidRewardTest.cs @@ -20,7 +20,7 @@ public ClaimRaidRewardTest() { var tableCsv = TableSheetsImporter.ImportSheets(); _tableSheets = new TableSheets(tableCsv); - _state = new State(); + _state = new MockStateDelta(); foreach (var kv in tableCsv) { _state = _state.SetState(Addresses.GetSheetAddress(kv.Key), kv.Value.Serialize()); diff --git a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs index 4474248615..9b2abd1707 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward1Test.cs @@ -31,7 +31,7 @@ public ClaimStakeReward1Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs index 951940671d..b22a09e645 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward2Test.cs @@ -32,7 +32,7 @@ public ClaimStakeReward2Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs index 76e02e8cb2..ea8d8bddf7 100644 --- a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs @@ -27,7 +27,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 State(); + IAccountStateDelta 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 9e52bce9d1..b8b358d228 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable0Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable0Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable0Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); @@ -119,7 +119,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 1, Random = _random, diff --git a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs index 33a66af8b2..b059df6cb1 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable2Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable2Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable2Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs index d7a0f58f72..f0c64b9b72 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable3Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable3Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable3Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs index 31c6d1f06d..c013b52243 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable4Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable4Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable4Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs index c616dc6c9a..985ab27e99 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable5Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable5Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable5Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs index f0679812fa..45ba7aa97c 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable6Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable6Test.cs @@ -53,7 +53,7 @@ public CombinationConsumable6Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs index e7bb05bc7c..4a8144a3ef 100644 --- a/.Lib9c.Tests/Action/CombinationConsumable7Test.cs +++ b/.Lib9c.Tests/Action/CombinationConsumable7Test.cs @@ -52,7 +52,7 @@ public CombinationConsumable7Test() default ); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationConsumableTest.cs b/.Lib9c.Tests/Action/CombinationConsumableTest.cs index 8c61a55536..239b763612 100644 --- a/.Lib9c.Tests/Action/CombinationConsumableTest.cs +++ b/.Lib9c.Tests/Action/CombinationConsumableTest.cs @@ -58,7 +58,7 @@ public CombinationConsumableTest() var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState( diff --git a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs index 7a073c0065..b88235a6bf 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment0Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment0Test.cs @@ -57,7 +57,7 @@ public CombinationEquipment0Test() #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( @@ -185,7 +185,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs index 20e3778265..f68a516d12 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment10Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment10Test.cs @@ -69,7 +69,7 @@ public CombinationEquipment10Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState( @@ -141,7 +141,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs index c2a7db0c67..8b0cf530a3 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment11Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment11Test.cs @@ -72,7 +72,7 @@ public CombinationEquipment11Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState( @@ -148,7 +148,7 @@ public void Rehearsal() ItemEnhancement10.GetFeeStoreAddress(), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs index 54a7e319ea..af0eb43273 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment12Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment12Test.cs @@ -82,7 +82,7 @@ public CombinationEquipment12Test(ITestOutputHelper outputHelper) _slotAddress, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_slotAddress, combinationSlotState.Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs index 7c53244f65..99453efe00 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment13Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment13Test.cs @@ -77,7 +77,7 @@ public CombinationEquipment13Test(ITestOutputHelper outputHelper) _slotAddress, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_slotAddress, combinationSlotState.Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs index 62f09d921f..8286a12bfb 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment14Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment14Test.cs @@ -78,7 +78,7 @@ public CombinationEquipment14Test(ITestOutputHelper outputHelper) _slotAddress, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_slotAddress, combinationSlotState.Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs index cb7f0fcc1f..1fe5c5aa14 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment15Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment15Test.cs @@ -78,7 +78,7 @@ public CombinationEquipment15Test(ITestOutputHelper outputHelper) _slotAddress, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_slotAddress, combinationSlotState.Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs index 96765f2ac7..24f7f02ccd 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment2Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment2Test.cs @@ -57,7 +57,7 @@ public CombinationEquipment2Test() #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( diff --git a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs index a4bd913f7e..83144d1e2c 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment3Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment3Test.cs @@ -62,7 +62,7 @@ public CombinationEquipment3Test(ITestOutputHelper outputHelper) #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( diff --git a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs index 360da2243d..3c106f8444 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment4Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment4Test.cs @@ -62,7 +62,7 @@ public CombinationEquipment4Test(ITestOutputHelper outputHelper) #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( diff --git a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs index 70ff103179..f70ab45fe7 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment5Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment5Test.cs @@ -62,7 +62,7 @@ public CombinationEquipment5Test(ITestOutputHelper outputHelper) #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( diff --git a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs index 8fb6a7c97a..0843a3163f 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment6Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment6Test.cs @@ -64,7 +64,7 @@ public CombinationEquipment6Test(ITestOutputHelper outputHelper) #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( @@ -254,7 +254,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs index 1df708dc1f..14062feed0 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment7Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment7Test.cs @@ -64,7 +64,7 @@ public CombinationEquipment7Test(ITestOutputHelper outputHelper) #pragma warning restore CS0618 var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState( @@ -253,7 +253,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs index 27042fbb16..b0e467ecad 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment8Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment8Test.cs @@ -68,7 +68,7 @@ public CombinationEquipment8Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState( @@ -140,7 +140,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs index 073b42e59e..c23642cb5e 100644 --- a/.Lib9c.Tests/Action/CombinationEquipment9Test.cs +++ b/.Lib9c.Tests/Action/CombinationEquipment9Test.cs @@ -68,7 +68,7 @@ public CombinationEquipment9Test(ITestOutputHelper outputHelper) var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState( @@ -140,7 +140,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs index c4bc27532b..e1c7c093b0 100644 --- a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs +++ b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs @@ -78,7 +78,7 @@ public CombinationEquipmentTest(ITestOutputHelper outputHelper) _slotAddress, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_slotAddress, combinationSlotState.Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs b/.Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs index b4eabefc01..d2ea34c5e7 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.State() + IAccountStateDelta 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 08f9808496..ab92518e86 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.State() + IAccountStateDelta 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 0d00c7a419..8942849c28 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.State(); + IAccountStateDelta state = new Lib9c.Tests.Action.MockStateDelta(); IRandom random = new TestRandom(); var coupon1 = new Coupon(CouponsFixture.Guid1, CouponsFixture.RewardSet1); diff --git a/.Lib9c.Tests/Action/CreateAvatar0Test.cs b/.Lib9c.Tests/Action/CreateAvatar0Test.cs index e40a67340e..b2ff4cd0e7 100644 --- a/.Lib9c.Tests/Action/CreateAvatar0Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar0Test.cs @@ -53,7 +53,7 @@ public void Execute() var sheets = TableSheetsImporter.ImportSheets(); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( Addresses.GoldDistribution, @@ -112,7 +112,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -146,7 +146,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(_avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(_avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -163,7 +163,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar0() { avatarAddress = _avatarAddress, @@ -192,7 +192,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) { var agentState = new AgentState(_agentAddress); agentState.avatarAddresses[index] = _avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar0() { @@ -254,7 +254,7 @@ public void Rehearsal() updatedAddresses.Add(slotAddress); } - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.Ranking, new RankingState0().Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CreateAvatar2Test.cs b/.Lib9c.Tests/Action/CreateAvatar2Test.cs index a7abf239ae..ac63630b1c 100644 --- a/.Lib9c.Tests/Action/CreateAvatar2Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar2Test.cs @@ -50,7 +50,7 @@ public void Execute() var sheets = TableSheetsImporter.ImportSheets(); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( Addresses.GoldDistribution, @@ -115,7 +115,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -156,7 +156,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -173,7 +173,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar2() { index = index, @@ -208,7 +208,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar2() { @@ -277,7 +277,7 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.Ranking, new RankingState0().Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CreateAvatar3Test.cs b/.Lib9c.Tests/Action/CreateAvatar3Test.cs index ac718284b9..61dc124be1 100644 --- a/.Lib9c.Tests/Action/CreateAvatar3Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar3Test.cs @@ -51,7 +51,7 @@ public void Execute() var sheets = TableSheetsImporter.ImportSheets(); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( Addresses.GoldDistribution, @@ -117,7 +117,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -158,7 +158,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -175,7 +175,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar3() { index = index, @@ -210,7 +210,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar3() { @@ -282,7 +282,7 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.Ranking, new RankingState0().Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CreateAvatar6Test.cs b/.Lib9c.Tests/Action/CreateAvatar6Test.cs index acca5bed8a..0fa5132623 100644 --- a/.Lib9c.Tests/Action/CreateAvatar6Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar6Test.cs @@ -51,7 +51,7 @@ public void Execute() var sheets = TableSheetsImporter.ImportSheets(); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( Addresses.GoldDistribution, @@ -117,7 +117,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -158,7 +158,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -175,7 +175,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar6() { index = index, @@ -210,7 +210,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar6() { @@ -282,7 +282,7 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State() + var state = new MockStateDelta() .SetState(Addresses.Ranking, new RankingState0().Serialize()) .SetState(GoldCurrencyState.Address, gold.Serialize()); diff --git a/.Lib9c.Tests/Action/CreateAvatar7Test.cs b/.Lib9c.Tests/Action/CreateAvatar7Test.cs index 4ba6d43537..2ea9ed7fa2 100644 --- a/.Lib9c.Tests/Action/CreateAvatar7Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar7Test.cs @@ -45,7 +45,7 @@ public void Execute() #pragma warning restore CS0618 var sheets = TableSheetsImporter.ImportSheets(); - var state = new State() + var state = new MockStateDelta() .SetState( Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() @@ -98,7 +98,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -139,7 +139,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -156,7 +156,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar7() { index = index, @@ -191,7 +191,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar7() { @@ -261,7 +261,7 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/CreateAvatarTest.cs b/.Lib9c.Tests/Action/CreateAvatarTest.cs index 621a851a6b..eb05486074 100644 --- a/.Lib9c.Tests/Action/CreateAvatarTest.cs +++ b/.Lib9c.Tests/Action/CreateAvatarTest.cs @@ -41,7 +41,7 @@ public void Execute() }; var sheets = TableSheetsImporter.ImportSheets(); - var state = new State() + var state = new MockStateDelta() .SetState( Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() @@ -97,7 +97,7 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { @@ -138,7 +138,7 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { @@ -155,7 +155,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar() { index = index, @@ -190,7 +190,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar() { @@ -260,7 +260,7 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs index 7737c8c1d2..8a371e91e3 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs @@ -24,7 +24,7 @@ public void Execute() var action = new CreatePendingActivation(pendingActivation); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) ); var actionContext = new ActionContext() @@ -52,7 +52,7 @@ public void CheckPermission() var action = new CreatePendingActivation(pendingActivation); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) ); @@ -90,7 +90,7 @@ public void Rehearsal() BlockIndex = 101, Signer = default, Rehearsal = true, - PreviousState = new State(), + PreviousState = new MockStateDelta(), } ); Assert.Equal( diff --git a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs index f26b858081..7c1a676497 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs @@ -28,7 +28,7 @@ PendingActivationState CreatePendingActivation() var action = new CreatePendingActivations(activations); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) ); var actionContext = new ActionContext() @@ -79,7 +79,7 @@ public void CheckPermission() var action = new CreatePendingActivations(); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) ); diff --git a/.Lib9c.Tests/Action/CreatePledgeTest.cs b/.Lib9c.Tests/Action/CreatePledgeTest.cs index e269a20bf4..c07b751e90 100644 --- a/.Lib9c.Tests/Action/CreatePledgeTest.cs +++ b/.Lib9c.Tests/Action/CreatePledgeTest.cs @@ -35,7 +35,7 @@ public void Execute(bool admin, Type exc) var agentAddress = new PrivateKey().ToAddress(); var pledgeAddress = agentAddress.GetPledgeAddress(); var context = new ActionContext(); - IAccountStateDelta states = new State() + IAccountStateDelta 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 4a3a250040..1da1539028 100644 --- a/.Lib9c.Tests/Action/DailyReward0Test.cs +++ b/.Lib9c.Tests/Action/DailyReward0Test.cs @@ -23,7 +23,7 @@ public DailyReward0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -85,7 +85,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward2Test.cs b/.Lib9c.Tests/Action/DailyReward2Test.cs index 65072cec81..1e0019ba65 100644 --- a/.Lib9c.Tests/Action/DailyReward2Test.cs +++ b/.Lib9c.Tests/Action/DailyReward2Test.cs @@ -25,7 +25,7 @@ public DailyReward2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -98,7 +98,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward3Test.cs b/.Lib9c.Tests/Action/DailyReward3Test.cs index 5a3d3ca8ae..5d560a0664 100644 --- a/.Lib9c.Tests/Action/DailyReward3Test.cs +++ b/.Lib9c.Tests/Action/DailyReward3Test.cs @@ -25,7 +25,7 @@ public DailyReward3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -98,7 +98,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) diff --git a/.Lib9c.Tests/Action/DailyReward4Test.cs b/.Lib9c.Tests/Action/DailyReward4Test.cs index 529280f8e2..cbfcc72b6a 100644 --- a/.Lib9c.Tests/Action/DailyReward4Test.cs +++ b/.Lib9c.Tests/Action/DailyReward4Test.cs @@ -28,7 +28,7 @@ public DailyReward4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -113,7 +113,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) @@ -131,7 +131,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, diff --git a/.Lib9c.Tests/Action/DailyReward5Test.cs b/.Lib9c.Tests/Action/DailyReward5Test.cs index c58fa24790..6e8314e85f 100644 --- a/.Lib9c.Tests/Action/DailyReward5Test.cs +++ b/.Lib9c.Tests/Action/DailyReward5Test.cs @@ -26,7 +26,7 @@ public DailyReward5Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -70,7 +70,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -119,7 +119,7 @@ public void Execute(int avatarStateSerializedVersion) [Fact] public void Execute_Throw_FailedLoadStateException() => - Assert.Throws(() => ExecuteInternal(new State())); + Assert.Throws(() => ExecuteInternal(new MockStateDelta())); [Theory] [InlineData(0, 0, true)] diff --git a/.Lib9c.Tests/Action/DailyReward6Test.cs b/.Lib9c.Tests/Action/DailyReward6Test.cs index 1f01d06695..8ed43783c0 100644 --- a/.Lib9c.Tests/Action/DailyReward6Test.cs +++ b/.Lib9c.Tests/Action/DailyReward6Test.cs @@ -28,7 +28,7 @@ public DailyReward6Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -72,7 +72,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -122,7 +122,7 @@ public void Execute(int avatarStateSerializedVersion) [Fact] public void Execute_Throw_FailedLoadStateException() => - Assert.Throws(() => ExecuteInternal(new State())); + Assert.Throws(() => ExecuteInternal(new MockStateDelta())); [Theory] [InlineData(0, 0, true)] diff --git a/.Lib9c.Tests/Action/DailyRewardTest.cs b/.Lib9c.Tests/Action/DailyRewardTest.cs index 2dd166a355..f89faaff80 100644 --- a/.Lib9c.Tests/Action/DailyRewardTest.cs +++ b/.Lib9c.Tests/Action/DailyRewardTest.cs @@ -26,7 +26,7 @@ public DailyRewardTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -70,7 +70,7 @@ public void Rehearsal() var nextState = action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Random = new TestRandom(), Rehearsal = true, Signer = _agentAddress, @@ -114,7 +114,7 @@ public void Execute(bool legacy) [Fact] public void Execute_Throw_FailedLoadStateException() => - Assert.Throws(() => ExecuteInternal(new State())); + Assert.Throws(() => ExecuteInternal(new MockStateDelta())); [Theory] [InlineData(0, 0, true)] diff --git a/.Lib9c.Tests/Action/EndPledgeTest.cs b/.Lib9c.Tests/Action/EndPledgeTest.cs index 9cb4b7de06..2e8df5e89a 100644 --- a/.Lib9c.Tests/Action/EndPledgeTest.cs +++ b/.Lib9c.Tests/Action/EndPledgeTest.cs @@ -20,7 +20,7 @@ public void Execute(int balance) var patron = new PrivateKey().ToAddress(); var agent = new PrivateKey().ToAddress(); var context = new ActionContext(); - IAccountStateDelta states = new State() + IAccountStateDelta states = new MockStateDelta() .SetState(agent.GetPledgeAddress(), List.Empty.Add(patron.Serialize()).Add(true.Serialize())); var mead = Currencies.Mead; if (balance > 0) @@ -53,7 +53,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 State().SetState(agent.GetPledgeAddress(), contract); + IAccountStateDelta 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 29fb65fc43..43c769d8d8 100644 --- a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs @@ -25,7 +25,7 @@ public class EventConsumableItemCraftsTest public EventConsumableItemCraftsTest() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs index bd0314b478..6e21056564 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV1Test.cs @@ -30,7 +30,7 @@ public class EventDungeonBattleV1Test public EventDungeonBattleV1Test() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs index 16ca596626..0337841826 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV2Test.cs @@ -30,7 +30,7 @@ public class EventDungeonBattleV2Test public EventDungeonBattleV2Test() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs index 9c952d5793..479a47a178 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV3Test.cs @@ -30,7 +30,7 @@ public class EventDungeonBattleV3Test public EventDungeonBattleV3Test() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs index c65500b7af..7a94f27761 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV4Test.cs @@ -31,7 +31,7 @@ public class EventDungeonBattleV4Test public EventDungeonBattleV4Test() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs index 06b3031652..90d09c5840 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleV5Test.cs @@ -32,7 +32,7 @@ public class EventDungeonBattleV5Test public EventDungeonBattleV5Test() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs index f4dcc9f187..01c91b6fbf 100644 --- a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs @@ -27,7 +27,7 @@ public class EventMaterialItemCraftsTest public EventMaterialItemCraftsTest() { - _initialStates = new State(); + _initialStates = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index faeeb3d95a..176cc0361a 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -61,7 +61,7 @@ public GrindingTest() #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(_ncgCurrency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState( Addresses.GetSheetAddress(), _tableSheets.CrystalMonsterCollectionMultiplierSheet.Serialize()) diff --git a/.Lib9c.Tests/Action/HackAndSlash0Test.cs b/.Lib9c.Tests/Action/HackAndSlash0Test.cs index 7825cb7aa4..710e9cf6e5 100644 --- a/.Lib9c.Tests/Action/HackAndSlash0Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash0Test.cs @@ -59,7 +59,7 @@ public HackAndSlash0Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -189,7 +189,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -591,7 +591,7 @@ public void Rehearsal() _rankingMapAddress, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash10Test.cs b/.Lib9c.Tests/Action/HackAndSlash10Test.cs index 72fb4462fc..15259b2b5d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash10Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash10Test.cs @@ -72,7 +72,7 @@ public HackAndSlash10Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -487,7 +487,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -1128,7 +1128,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash11Test.cs b/.Lib9c.Tests/Action/HackAndSlash11Test.cs index b5dbc9ca31..1121f87e62 100644 --- a/.Lib9c.Tests/Action/HackAndSlash11Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash11Test.cs @@ -72,7 +72,7 @@ public HackAndSlash11Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -445,7 +445,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -1072,7 +1072,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash12Test.cs b/.Lib9c.Tests/Action/HackAndSlash12Test.cs index 0c26db2355..e71e20f6f9 100644 --- a/.Lib9c.Tests/Action/HackAndSlash12Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash12Test.cs @@ -72,7 +72,7 @@ public HackAndSlash12Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -429,7 +429,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -1068,7 +1068,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/HackAndSlash13Test.cs b/.Lib9c.Tests/Action/HackAndSlash13Test.cs index 73c193cfed..0e3d5c2941 100644 --- a/.Lib9c.Tests/Action/HackAndSlash13Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash13Test.cs @@ -72,7 +72,7 @@ public HackAndSlash13Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -435,7 +435,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { @@ -1106,7 +1106,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/HackAndSlash15Test.cs b/.Lib9c.Tests/Action/HackAndSlash15Test.cs index 7a3dfdbac9..b5b8e209b8 100644 --- a/.Lib9c.Tests/Action/HackAndSlash15Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash15Test.cs @@ -71,7 +71,7 @@ public HackAndSlash15Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -431,7 +431,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash16Test.cs b/.Lib9c.Tests/Action/HackAndSlash16Test.cs index e4c17f998d..30c442311e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash16Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash16Test.cs @@ -72,7 +72,7 @@ public HackAndSlash16Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -432,7 +432,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash17Test.cs b/.Lib9c.Tests/Action/HackAndSlash17Test.cs index 15d4fa40e6..61d8f8089e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash17Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash17Test.cs @@ -72,7 +72,7 @@ public HackAndSlash17Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -432,7 +432,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash18Test.cs b/.Lib9c.Tests/Action/HackAndSlash18Test.cs index 8d07a23a86..b913c4c4b9 100644 --- a/.Lib9c.Tests/Action/HackAndSlash18Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash18Test.cs @@ -78,7 +78,7 @@ public HackAndSlash18Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) @@ -430,7 +430,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash19Test.cs b/.Lib9c.Tests/Action/HackAndSlash19Test.cs index 048ee555a2..861550298c 100644 --- a/.Lib9c.Tests/Action/HackAndSlash19Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash19Test.cs @@ -77,7 +77,7 @@ public HackAndSlash19Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) @@ -434,7 +434,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash20Test.cs b/.Lib9c.Tests/Action/HackAndSlash20Test.cs index 0f6c4c0954..1c1e937fc8 100644 --- a/.Lib9c.Tests/Action/HackAndSlash20Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash20Test.cs @@ -78,7 +78,7 @@ public HackAndSlash20Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) @@ -435,7 +435,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash21Test.cs b/.Lib9c.Tests/Action/HackAndSlash21Test.cs index dfb9668154..7e93b3481e 100644 --- a/.Lib9c.Tests/Action/HackAndSlash21Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash21Test.cs @@ -79,7 +79,7 @@ public HackAndSlash21Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) @@ -436,7 +436,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) AvatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlash2Test.cs b/.Lib9c.Tests/Action/HackAndSlash2Test.cs index 77b6306edf..94b88c0468 100644 --- a/.Lib9c.Tests/Action/HackAndSlash2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash2Test.cs @@ -61,7 +61,7 @@ public HackAndSlash2Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -198,7 +198,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, Random = new TestRandom(), })); @@ -600,7 +600,7 @@ public void Rehearsal() _rankingMapAddress, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash3Test.cs b/.Lib9c.Tests/Action/HackAndSlash3Test.cs index 85e2a377c4..5d73819aa9 100644 --- a/.Lib9c.Tests/Action/HackAndSlash3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash3Test.cs @@ -58,7 +58,7 @@ public HackAndSlash3Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) diff --git a/.Lib9c.Tests/Action/HackAndSlash4Test.cs b/.Lib9c.Tests/Action/HackAndSlash4Test.cs index a398eef5d2..cab895b2e3 100644 --- a/.Lib9c.Tests/Action/HackAndSlash4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash4Test.cs @@ -61,7 +61,7 @@ public HackAndSlash4Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -379,7 +379,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlash5Test.cs b/.Lib9c.Tests/Action/HackAndSlash5Test.cs index 2f9f1a5a2d..4ca528e9a7 100644 --- a/.Lib9c.Tests/Action/HackAndSlash5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash5Test.cs @@ -61,7 +61,7 @@ public HackAndSlash5Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -380,7 +380,7 @@ public void ExecuteThrowFailedLoadStateException() var exec = Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, Random = new TestRandom(), })); diff --git a/.Lib9c.Tests/Action/HackAndSlash6Test.cs b/.Lib9c.Tests/Action/HackAndSlash6Test.cs index 1f71609ac6..eb95090d7d 100644 --- a/.Lib9c.Tests/Action/HackAndSlash6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash6Test.cs @@ -63,7 +63,7 @@ public HackAndSlash6Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) @@ -396,7 +396,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) Assert.Null(action.Result); - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -813,7 +813,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash7Test.cs b/.Lib9c.Tests/Action/HackAndSlash7Test.cs index ed5c75663e..170155e229 100644 --- a/.Lib9c.Tests/Action/HackAndSlash7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash7Test.cs @@ -72,7 +72,7 @@ public HackAndSlash7Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -497,7 +497,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) WeeklyArenaAddress = _weeklyArenaState.address, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -876,7 +876,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash8Test.cs b/.Lib9c.Tests/Action/HackAndSlash8Test.cs index 40f4082726..295a8f1135 100644 --- a/.Lib9c.Tests/Action/HackAndSlash8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash8Test.cs @@ -72,7 +72,7 @@ public HackAndSlash8Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -490,7 +490,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -857,7 +857,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlash9Test.cs b/.Lib9c.Tests/Action/HackAndSlash9Test.cs index c11a857f0e..3c20057537 100644 --- a/.Lib9c.Tests/Action/HackAndSlash9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlash9Test.cs @@ -72,7 +72,7 @@ public HackAndSlash9Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -510,7 +510,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState @@ -1151,7 +1151,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs index 3dd020ebc7..1cb0228778 100644 --- a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs @@ -72,7 +72,7 @@ public HackAndSlashRandomBuffTest() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs index 85c3efed39..79d0fd77a8 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep1Test.cs @@ -67,7 +67,7 @@ public HackAndSlashSweep1Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -197,7 +197,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs index bcb460ce32..80fd82e004 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep2Test.cs @@ -67,7 +67,7 @@ public HackAndSlashSweep2Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -197,7 +197,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs index 249e044903..4feb3d6132 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep3Test.cs @@ -68,7 +68,7 @@ public HackAndSlashSweep3Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -227,7 +227,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs index 5f4fa393ca..1056ee86c0 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep4Test.cs @@ -68,7 +68,7 @@ public HackAndSlashSweep4Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -247,7 +247,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs index 0f201f7b69..04d6aa88ab 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep5Test.cs @@ -69,7 +69,7 @@ public HackAndSlashSweep5Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -250,7 +250,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs index 6fc7cd6a82..4b5acb2377 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep6Test.cs @@ -75,7 +75,7 @@ public HackAndSlashSweep6Test() #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -257,7 +257,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs index a77d4b50ff..bfa7b32f2b 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep7Test.cs @@ -75,7 +75,7 @@ public HackAndSlashSweep7Test() #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -260,7 +260,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs index 1079dfc082..ba0463b012 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep8Test.cs @@ -75,7 +75,7 @@ public HackAndSlashSweep8Test() #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -262,7 +262,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs index e4215a82e6..5a0f72cb5d 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweep9Test.cs @@ -76,7 +76,7 @@ public HackAndSlashSweep9Test() #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -263,7 +263,7 @@ public void Execute_FailedLoadStateException(bool backward) stageId = 1, }; - var state = backward ? new State() : _initialState; + var state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/HackAndSlashTest14.cs b/.Lib9c.Tests/Action/HackAndSlashTest14.cs index e551a92063..571cc2fdd8 100644 --- a/.Lib9c.Tests/Action/HackAndSlashTest14.cs +++ b/.Lib9c.Tests/Action/HackAndSlashTest14.cs @@ -71,7 +71,7 @@ public HackAndSlashTest14() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.SerializeV2()) .SetState(_avatarAddress, _avatarState.SerializeV2()) @@ -422,7 +422,7 @@ public void Execute_Throw_FailedLoadStateException(bool backward) avatarAddress = _avatarAddress, }; - IAccountStateDelta state = backward ? new State() : _initialState; + IAccountStateDelta state = backward ? new MockStateDelta() : _initialState; if (!backward) { state = _initialState diff --git a/.Lib9c.Tests/Action/InitializeStatesTest.cs b/.Lib9c.Tests/Action/InitializeStatesTest.cs index 7e1852b194..d6ff9fd6d0 100644 --- a/.Lib9c.Tests/Action/InitializeStatesTest.cs +++ b/.Lib9c.Tests/Action/InitializeStatesTest.cs @@ -61,7 +61,7 @@ public void Execute() { BlockIndex = 0, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), }); var addresses = new List
() @@ -127,7 +127,7 @@ public void ExecuteWithAuthorizedMinersState() { BlockIndex = 0, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), }); var fetchedState = new AuthorizedMinersState( @@ -175,7 +175,7 @@ public void ExecuteWithActivateAdminKey() { BlockIndex = 0, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), }); var fetchedState = new ActivatedAccountsState( @@ -226,7 +226,7 @@ public void ExecuteWithCredits() { BlockIndex = 0, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), }); var fetchedState = new CreditsState( @@ -271,7 +271,7 @@ public void ExecuteWithoutAdminState() { BlockIndex = 0, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), }); var fetchedState = new ActivatedAccountsState( diff --git a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs index 958d34b756..782ab3745e 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement0Test.cs @@ -58,7 +58,7 @@ public ItemEnhancement0Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -137,7 +137,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) @@ -505,7 +505,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()); var nextState = action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs index 25d0af6cac..49a8044a11 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement10Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement10Test.cs @@ -63,7 +63,7 @@ public ItemEnhancement10Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -227,7 +227,7 @@ public void Rehearsal() ItemEnhancement10.GetFeeStoreAddress(), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs index 2e73bc3f63..04053e6a01 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement2Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement2Test.cs @@ -57,7 +57,7 @@ public ItemEnhancement2Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -136,7 +136,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, BlockIndex = 0, }) @@ -470,7 +470,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State() + var state = new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()); var nextState = action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs index 66b2781e90..44ae80e3a3 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement3Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement3Test.cs @@ -57,7 +57,7 @@ public ItemEnhancement3Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) diff --git a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs index fb19885476..ee6a78854b 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement4Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement4Test.cs @@ -58,7 +58,7 @@ public ItemEnhancement4Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) diff --git a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs index 58f26c9f01..a14388f081 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement5Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement5Test.cs @@ -58,7 +58,7 @@ public ItemEnhancement5Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) diff --git a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs index 5ffd63b6ee..a9be9badd7 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement6Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement6Test.cs @@ -58,7 +58,7 @@ public ItemEnhancement6Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) diff --git a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs index 8aa0a2734b..2c0b98b41a 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement7Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement7Test.cs @@ -60,7 +60,7 @@ public ItemEnhancement7Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -196,7 +196,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs index b867526d99..1a367d4f45 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement8Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement8Test.cs @@ -60,7 +60,7 @@ public ItemEnhancement8Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -196,7 +196,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs index d7c77f884c..aa25ebe400 100644 --- a/.Lib9c.Tests/Action/ItemEnhancement9Test.cs +++ b/.Lib9c.Tests/Action/ItemEnhancement9Test.cs @@ -61,7 +61,7 @@ public ItemEnhancement9Test() _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize()) @@ -221,7 +221,7 @@ public void Rehearsal() Addresses.Blacksmith, }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index 9970c3ab39..60d2ef1aea 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -57,7 +57,7 @@ public ItemEnhancementTest() var slotAddress = _avatarAddress.Derive(string.Format(CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, 0)); var context = new ActionContext(); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()) .SetState(slotAddress, new CombinationSlotState(slotAddress, 0).Serialize()) diff --git a/.Lib9c.Tests/Action/JoinArena1Test.cs b/.Lib9c.Tests/Action/JoinArena1Test.cs index 4f68f7ddc3..43845a3e8a 100644 --- a/.Lib9c.Tests/Action/JoinArena1Test.cs +++ b/.Lib9c.Tests/Action/JoinArena1Test.cs @@ -46,7 +46,7 @@ public JoinArena1Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _signer = new PrivateKey().ToAddress(); _avatarAddress = _signer.Derive("avatar"); diff --git a/.Lib9c.Tests/Action/JoinArena2Test.cs b/.Lib9c.Tests/Action/JoinArena2Test.cs index 06c18b1a50..bbe38ddf50 100644 --- a/.Lib9c.Tests/Action/JoinArena2Test.cs +++ b/.Lib9c.Tests/Action/JoinArena2Test.cs @@ -46,7 +46,7 @@ public JoinArena2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _signer = new PrivateKey().ToAddress(); _avatarAddress = _signer.Derive("avatar"); diff --git a/.Lib9c.Tests/Action/JoinArena3Test.cs b/.Lib9c.Tests/Action/JoinArena3Test.cs index e720e28ab8..e2e98e943a 100644 --- a/.Lib9c.Tests/Action/JoinArena3Test.cs +++ b/.Lib9c.Tests/Action/JoinArena3Test.cs @@ -47,7 +47,7 @@ public JoinArena3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new State(); + _state = new MockStateDelta(); _signer = new PrivateKey().ToAddress(); _avatarAddress = _signer.Derive("avatar"); diff --git a/.Lib9c.Tests/Action/MarketValidationTest.cs b/.Lib9c.Tests/Action/MarketValidationTest.cs index ed0b4cc21d..df204a5701 100644 --- a/.Lib9c.Tests/Action/MarketValidationTest.cs +++ b/.Lib9c.Tests/Action/MarketValidationTest.cs @@ -24,7 +24,7 @@ public class MarketValidationTest public MarketValidationTest() { - _initialState = new State() + _initialState = new MockStateDelta() .SetState(GoldCurrencyState.Address, new GoldCurrencyState(Gold).Serialize()); } diff --git a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs index afcfacf166..279a2c8f97 100644 --- a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs +++ b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs @@ -32,7 +32,7 @@ public MigrateMonsterCollectionTest(ITestOutputHelper outputHelper) _signer = default; _avatarAddress = _signer.Derive("avatar"); - _state = new State(); + _state = new MockStateDelta(); Dictionary sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().ToAddress(); diff --git a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs index 26258fb032..4a96695023 100644 --- a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs @@ -17,7 +17,7 @@ public void Execute() { var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().AddAccount(default).Serialize()) ); diff --git a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs index 3ea7fb1611..8ab262b29c 100644 --- a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs @@ -34,7 +34,7 @@ public void Execute() ); var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new State(ImmutableDictionary.Empty + var state = new MockStateDelta(ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) .Add(avatarAddress, avatarState.SerializeV2()) ); diff --git a/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs b/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs index a2be908f98..d3beaae312 100644 --- a/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs +++ b/.Lib9c.Tests/Action/MigrationLegacyShopTest.cs @@ -28,7 +28,7 @@ public void Execute(bool isAdmin, bool expire, Type exc) { var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var states = new State().SetState(Addresses.Admin, adminState.Serialize()); + var states = new MockStateDelta().SetState(Addresses.Admin, adminState.Serialize()); var signer = isAdmin ? adminAddress : default; var blockIndex = expire ? 200 : 100; diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs index befd7f7ef1..fc3688ccce 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle0Test.cs @@ -57,7 +57,7 @@ public MimisbrunnrBattle0Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -284,7 +284,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs index 5cf056e708..998eb5542d 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle10Test.cs @@ -55,7 +55,7 @@ public MimisbrunnrBattle10Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -257,7 +257,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs index 3782e17c0c..6971cdccf8 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle11Test.cs @@ -53,7 +53,7 @@ public MimisbrunnrBattle11Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -258,7 +258,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs index 7c754a4c5e..627727bf6f 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle12Test.cs @@ -59,7 +59,7 @@ public MimisbrunnrBattle12Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -265,7 +265,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs index e7e0d8f7d8..c68795011b 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle13Test.cs @@ -60,7 +60,7 @@ public MimisbrunnrBattle13Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -266,7 +266,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs index f13bb436e9..d97bdd7559 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle2Test.cs @@ -57,7 +57,7 @@ public MimisbrunnrBattle2Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -284,7 +284,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs index 770835b632..662a9ec2ad 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle3Test.cs @@ -57,7 +57,7 @@ public MimisbrunnrBattle3Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -285,7 +285,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs index add4d9604a..67340e3337 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle4Test.cs @@ -58,7 +58,7 @@ public MimisbrunnrBattle4Test() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) @@ -294,7 +294,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -612,7 +612,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs index 449ace9afd..92de1f769c 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle5Test.cs @@ -55,7 +55,7 @@ public MimisbrunnrBattle5Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_rankingMapAddress, new RankingMapState(_rankingMapAddress).Serialize()); @@ -286,7 +286,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -596,7 +596,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs index e8c6093a3c..17c0b35a20 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle6Test.cs @@ -56,7 +56,7 @@ public MimisbrunnrBattle6Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -298,7 +298,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -755,7 +755,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs index 7fbe73cce5..55745a6d8a 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle7Test.cs @@ -56,7 +56,7 @@ public MimisbrunnrBattle7Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -298,7 +298,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -755,7 +755,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs index 83b44bb322..9a57bbec9e 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle8Test.cs @@ -53,7 +53,7 @@ public MimisbrunnrBattle8Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -281,7 +281,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -704,7 +704,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs index 59519d322d..06a5d18d17 100644 --- a/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs +++ b/.Lib9c.Tests/Action/MimisbrunnrBattle9Test.cs @@ -54,7 +54,7 @@ public MimisbrunnrBattle9Test() }; agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(_avatarAddress.Derive(LegacyInventoryKey), avatarState.inventory.Serialize()) @@ -256,7 +256,7 @@ public void ExecuteThrowFailedLoadStateException() { action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, }); }); @@ -755,7 +755,7 @@ public void Rehearsal() _avatarAddress.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/MockDelta.cs b/.Lib9c.Tests/Action/MockDelta.cs new file mode 100644 index 0000000000..2e2788b35e --- /dev/null +++ b/.Lib9c.Tests/Action/MockDelta.cs @@ -0,0 +1,72 @@ +#nullable enable + +namespace Lib9c.Tests.Action +{ + using System.Collections.Immutable; + using System.Linq; + using System.Numerics; + using Bencodex.Types; + using Libplanet; + using Libplanet.Assets; + using Libplanet.Consensus; + using Libplanet.State; + + /// + /// Almost a replica of https://github.com/planetarium/libplanet/blob/main/Libplanet/State/AccountDelta.cs + /// except this has its constructors exposed as public for testing. + /// + public class MockDelta : IAccountDelta + { + public MockDelta() + { + States = ImmutableDictionary.Empty; + Fungibles = ImmutableDictionary<(Address, Currency), BigInteger>.Empty; + TotalSupplies = ImmutableDictionary.Empty; + ValidatorSet = null; + } + + public MockDelta( + IImmutableDictionary statesDelta, + IImmutableDictionary<(Address, Currency), BigInteger> fungiblesDelta, + IImmutableDictionary totalSuppliesDelta, + ValidatorSet? validatorSetDelta) + { + States = statesDelta; + Fungibles = fungiblesDelta; + TotalSupplies = totalSuppliesDelta; + ValidatorSet = validatorSetDelta; + } + + /// + public IImmutableSet
UpdatedAddresses => + StateUpdatedAddresses.Union(FungibleUpdatedAddresses); + + /// + public IImmutableSet
StateUpdatedAddresses => + States.Keys.ToImmutableHashSet(); + + /// + public IImmutableDictionary States { get; } + + /// + public IImmutableSet
FungibleUpdatedAddresses => + Fungibles.Keys.Select(pair => pair.Item1).ToImmutableHashSet(); + + /// + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => + Fungibles.Keys.ToImmutableHashSet(); + + /// + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles { get; } + + /// + public IImmutableSet UpdatedTotalSupplyCurrencies => + TotalSupplies.Keys.ToImmutableHashSet(); + + /// + public IImmutableDictionary TotalSupplies { get; } + + /// + public ValidatorSet? ValidatorSet { get; } + } +} diff --git a/.Lib9c.Tests/Action/State.cs b/.Lib9c.Tests/Action/MockStateDelta.cs similarity index 69% rename from .Lib9c.Tests/Action/State.cs rename to .Lib9c.Tests/Action/MockStateDelta.cs index d01d735cc0..9056a4eff0 100644 --- a/.Lib9c.Tests/Action/State.cs +++ b/.Lib9c.Tests/Action/MockStateDelta.cs @@ -12,15 +12,15 @@ namespace Lib9c.Tests.Action using Libplanet.Consensus; using Libplanet.State; - public class State : IAccountStateDelta + public class MockStateDelta : IAccountStateDelta { - private readonly IImmutableDictionary _state; - private readonly IImmutableDictionary<(Address, Currency), BigInteger> _balance; + private readonly IImmutableDictionary _states; + private readonly IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; private readonly IImmutableDictionary _totalSupplies; private readonly ValidatorSet _validatorSet; private readonly IAccountDelta _delta; - public State() + public MockStateDelta() : this( ImmutableDictionary.Empty, ImmutableDictionary<(Address Address, Currency Currency), BigInteger>.Empty, @@ -32,14 +32,14 @@ public State() // Pretends all given arguments are part of the delta, i.e., have been modified // using appropriate methods such as Transfer/Mint/Burn to set the values. // Also convert to internal data types. - public State( - IImmutableDictionary state = null, - IImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue> balance = null, + public MockStateDelta( + IImmutableDictionary states = null, + IImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue> balances = null, IImmutableDictionary totalSupplies = null, ValidatorSet validatorSet = null) { - _state = state ?? ImmutableDictionary.Empty; - _balance = balance is { } b + _states = states ?? ImmutableDictionary.Empty; + _fungibles = balances is { } b ? b.ToImmutableDictionary(kv => kv.Key, kv => kv.Value.RawValue) : ImmutableDictionary<(Address, Currency), BigInteger>.Empty; _totalSupplies = totalSupplies is { } t @@ -48,22 +48,22 @@ public State( _validatorSet = validatorSet ?? new ValidatorSet(); - _delta = new Delta(_state, _balance, _totalSupplies, _validatorSet); + _delta = new MockDelta(_states, _fungibles, _totalSupplies, _validatorSet); } // For Transfer/Mint/Burn - private State( + private MockStateDelta( IImmutableDictionary state, IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, IImmutableDictionary totalSupplies, ValidatorSet validatorSet) { - _state = state; - _balance = balance; + _states = state; + _fungibles = balance; _totalSupplies = totalSupplies; _validatorSet = validatorSet; - _delta = new Delta(_state, _balance, _totalSupplies, _validatorSet); + _delta = new MockDelta(_states, _fungibles, _totalSupplies, _validatorSet); } public IAccountDelta Delta => _delta; @@ -86,9 +86,9 @@ public IReadOnlyList GetStates(IReadOnlyList
addresses) => addresses.Select(GetState).ToArray(); public IAccountStateDelta SetState(Address address, IValue state) => - new State( - _state.SetItem(address, state), - _balance, + new MockStateDelta( + _states.SetItem(address, state), + _fungibles, _totalSupplies, _validatorSet); @@ -122,9 +122,9 @@ public IAccountStateDelta MintAsset(IActionContext context, Address recipient, F value.Currency, (GetTotalSupply(value.Currency) + value).RawValue) : _totalSupplies; - return new State( - _state, - _balance.SetItem( + return new MockStateDelta( + _states, + _fungibles.SetItem( (recipient, value.Currency), (GetBalance(recipient, value.Currency) + value).RawValue), totalSupplies, @@ -140,9 +140,9 @@ public IAccountStateDelta BurnAsset(IActionContext context, Address owner, Fungi value.Currency, (GetTotalSupply(value.Currency) - value).RawValue) : _totalSupplies; - return new State( - _state, - _balance.SetItem( + return new MockStateDelta( + _states, + _fungibles.SetItem( (owner, value.Currency), (GetBalance(owner, value.Currency) - value).RawValue), totalSupplies, @@ -177,72 +177,17 @@ public IAccountStateDelta TransferAsset( throw new InsufficientBalanceException(msg, sender, senderBalance); } - IImmutableDictionary<(Address, Currency), BigInteger> newBalance = _balance + IImmutableDictionary<(Address, Currency), BigInteger> newBalance = _fungibles .SetItem((sender, currency), (senderBalance - value).RawValue) .SetItem((recipient, currency), (recipientBalance + value).RawValue); - return new State(_state, newBalance, _totalSupplies, _validatorSet); + return new MockStateDelta(_states, newBalance, _totalSupplies, _validatorSet); } public IAccountStateDelta SetValidator(Validator validator) { - return new State(_state, _balance, _totalSupplies, GetValidatorSet().Update(validator)); + return new MockStateDelta(_states, _fungibles, _totalSupplies, GetValidatorSet().Update(validator)); } public ValidatorSet GetValidatorSet() => _validatorSet; } - -#pragma warning disable SA1402 - public class Delta : IAccountDelta - { - private readonly IImmutableDictionary _state; - private readonly IImmutableDictionary<(Address, Currency), BigInteger> _balance; - private readonly IImmutableDictionary _totalSupplies; - private readonly ValidatorSet _validatorSet; - - public Delta() - : this( - ImmutableDictionary.Empty, - ImmutableDictionary<(Address, Currency), BigInteger>.Empty, - ImmutableDictionary.Empty, - null) - { - } - - public Delta( - IImmutableDictionary state, - IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, - IImmutableDictionary totalSupplies, - ValidatorSet validatorSet) - { - _state = state; - _balance = balance; - _totalSupplies = totalSupplies; - _validatorSet = validatorSet; - } - - public IImmutableSet
UpdatedAddresses => - StateUpdatedAddresses.Union(FungibleUpdatedAddresses); - - public IImmutableSet
StateUpdatedAddresses => _state.Keys.ToImmutableHashSet(); - - public IImmutableDictionary States => _state; - - public IImmutableSet
FungibleUpdatedAddresses => - UpdatedFungibleAssets.Select(pair => pair.Item1).ToImmutableHashSet(); - - public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => - Fungibles.Keys.ToImmutableHashSet(); - - public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => - _balance; - - public IImmutableSet UpdatedTotalSupplyCurrencies => - TotalSupplies.Keys.ToImmutableHashSet(); - - public IImmutableDictionary TotalSupplies => - _totalSupplies; - - public ValidatorSet ValidatorSet => _validatorSet; - } -#pragma warning restore SA1402 } diff --git a/.Lib9c.Tests/Action/MonsterCollect0Test.cs b/.Lib9c.Tests/Action/MonsterCollect0Test.cs index 7a417ec9c6..35553cf014 100644 --- a/.Lib9c.Tests/Action/MonsterCollect0Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect0Test.cs @@ -28,7 +28,7 @@ public MonsterCollect0Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); foreach ((string key, string value) in sheets) { @@ -111,7 +111,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, BlockIndex = 1, })); @@ -238,7 +238,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, Rehearsal = true, }); diff --git a/.Lib9c.Tests/Action/MonsterCollect2Test.cs b/.Lib9c.Tests/Action/MonsterCollect2Test.cs index 48170016df..e68f583b46 100644 --- a/.Lib9c.Tests/Action/MonsterCollect2Test.cs +++ b/.Lib9c.Tests/Action/MonsterCollect2Test.cs @@ -29,7 +29,7 @@ public MonsterCollect2Test() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); foreach ((string key, string value) in sheets) { @@ -133,7 +133,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, BlockIndex = 1, })); @@ -164,7 +164,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, Rehearsal = true, }); diff --git a/.Lib9c.Tests/Action/MonsterCollectTest.cs b/.Lib9c.Tests/Action/MonsterCollectTest.cs index 5d02d49ac7..3335da48ca 100644 --- a/.Lib9c.Tests/Action/MonsterCollectTest.cs +++ b/.Lib9c.Tests/Action/MonsterCollectTest.cs @@ -29,7 +29,7 @@ public MonsterCollectTest() var currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 var goldCurrencyState = new GoldCurrencyState(currency); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GoldCurrency, goldCurrencyState.Serialize()); foreach ((string key, string value) in sheets) { @@ -134,7 +134,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, BlockIndex = 1, })); @@ -185,7 +185,7 @@ public void Rehearsal() }; IAccountStateDelta nextState = action.Execute(new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _signer, Rehearsal = true, }); diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index c4334f35ce..05d969366b 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -25,7 +25,7 @@ public PatchTableSheetTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -89,7 +89,7 @@ public void CheckPermission() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); - var state = new State(initStates); + var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { TableName = tableName, @@ -132,7 +132,7 @@ public void ExecuteNewTable() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()) .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); - var state = new State(initStates); + var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { TableName = nameof(CostumeStatSheet), diff --git a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs index 9d24165999..6c3f171811 100644 --- a/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs +++ b/.Lib9c.Tests/Action/PrepareRewardAssetsTest.cs @@ -37,7 +37,7 @@ public void Execute(bool admin, bool includeNcg, Type exc) #pragma warning restore CS0618 } - IAccountStateDelta state = new State() + IAccountStateDelta 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 5f092de1a4..21e7669dde 100644 --- a/.Lib9c.Tests/Action/Raid1Test.cs +++ b/.Lib9c.Tests/Action/Raid1Test.cs @@ -114,7 +114,7 @@ long executeOffset var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -376,7 +376,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -528,7 +528,7 @@ public void Execute_Throw_ActionObsoletedException() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta 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 1d5ab5feba..f8002dc12d 100644 --- a/.Lib9c.Tests/Action/Raid2Test.cs +++ b/.Lib9c.Tests/Action/Raid2Test.cs @@ -117,7 +117,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -394,7 +394,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta 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 b75b23dae1..edc6921fb2 100644 --- a/.Lib9c.Tests/Action/Raid3Test.cs +++ b/.Lib9c.Tests/Action/Raid3Test.cs @@ -118,7 +118,7 @@ bool raiderListExist var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -396,7 +396,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta 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 704b3f4674..bfdcd584a7 100644 --- a/.Lib9c.Tests/Action/Raid4Test.cs +++ b/.Lib9c.Tests/Action/Raid4Test.cs @@ -137,7 +137,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -437,7 +437,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -589,7 +589,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Raid5Test.cs b/.Lib9c.Tests/Action/Raid5Test.cs index 5ca7c4298a..a12255f123 100644 --- a/.Lib9c.Tests/Action/Raid5Test.cs +++ b/.Lib9c.Tests/Action/Raid5Test.cs @@ -137,7 +137,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -437,7 +437,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -591,7 +591,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Raid6Test.cs b/.Lib9c.Tests/Action/Raid6Test.cs index 336a867fb9..6ea883fd01 100644 --- a/.Lib9c.Tests/Action/Raid6Test.cs +++ b/.Lib9c.Tests/Action/Raid6Test.cs @@ -137,7 +137,7 @@ int runeId2 var fee = _tableSheets.WorldBossListSheet[raidId].EntranceFee; var context = new ActionContext(); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -437,7 +437,7 @@ public void Execute_With_Reward() Address bossAddress = Addresses.GetWorldBossAddress(raidId); Address worldBossKillRewardRecordAddress = Addresses.GetWorldBossKillRewardRecordAddress(_avatarAddress, raidId); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); @@ -591,7 +591,7 @@ public void Execute_With_Free_Crystal_Fee() "1,900002,0,100,0,1,1,40"; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - IAccountStateDelta state = new State() + IAccountStateDelta state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(_agentAddress, new AgentState(_agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/RankingBattle0Test.cs b/.Lib9c.Tests/Action/RankingBattle0Test.cs index 0bea0db5fd..c26bb77cb4 100644 --- a/.Lib9c.Tests/Action/RankingBattle0Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle0Test.cs @@ -30,7 +30,7 @@ public class RankingBattle0Test public RankingBattle0Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RankingBattle10Test.cs b/.Lib9c.Tests/Action/RankingBattle10Test.cs index f922416f46..6ba3f2bc9d 100644 --- a/.Lib9c.Tests/Action/RankingBattle10Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle10Test.cs @@ -32,7 +32,7 @@ public class RankingBattle10Test public RankingBattle10Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var keys = new List { @@ -478,7 +478,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/RankingBattle11Test.cs b/.Lib9c.Tests/Action/RankingBattle11Test.cs index 32b669f776..36c7bfaed3 100644 --- a/.Lib9c.Tests/Action/RankingBattle11Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle11Test.cs @@ -35,7 +35,7 @@ public class RankingBattle11Test public RankingBattle11Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var keys = new List { @@ -680,7 +680,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext { diff --git a/.Lib9c.Tests/Action/RankingBattle2Test.cs b/.Lib9c.Tests/Action/RankingBattle2Test.cs index f600df95d2..933f2620d8 100644 --- a/.Lib9c.Tests/Action/RankingBattle2Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle2Test.cs @@ -30,7 +30,7 @@ public class RankingBattle2Test public RankingBattle2Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RankingBattle3Test.cs b/.Lib9c.Tests/Action/RankingBattle3Test.cs index cc7b77d60b..30763237fa 100644 --- a/.Lib9c.Tests/Action/RankingBattle3Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle3Test.cs @@ -30,7 +30,7 @@ public class RankingBattle3Test public RankingBattle3Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RankingBattle4Test.cs b/.Lib9c.Tests/Action/RankingBattle4Test.cs index ea224b0570..e50c26a67f 100644 --- a/.Lib9c.Tests/Action/RankingBattle4Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle4Test.cs @@ -31,7 +31,7 @@ public class RankingBattle4Test public RankingBattle4Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RankingBattle5Test.cs b/.Lib9c.Tests/Action/RankingBattle5Test.cs index 3530ef0a3c..2b89863240 100644 --- a/.Lib9c.Tests/Action/RankingBattle5Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle5Test.cs @@ -33,7 +33,7 @@ public class RankingBattle5Test public RankingBattle5Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -443,7 +443,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/RankingBattle6Test.cs b/.Lib9c.Tests/Action/RankingBattle6Test.cs index 3a6c937905..d33b32b4a3 100644 --- a/.Lib9c.Tests/Action/RankingBattle6Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle6Test.cs @@ -33,7 +33,7 @@ public class RankingBattle6Test public RankingBattle6Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -443,7 +443,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/RankingBattle7Test.cs b/.Lib9c.Tests/Action/RankingBattle7Test.cs index 73e182eec4..3e89fb2fa2 100644 --- a/.Lib9c.Tests/Action/RankingBattle7Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle7Test.cs @@ -33,7 +33,7 @@ public class RankingBattle7Test public RankingBattle7Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -443,7 +443,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/RankingBattle8Test.cs b/.Lib9c.Tests/Action/RankingBattle8Test.cs index c6f3d988de..5954e7a7f2 100644 --- a/.Lib9c.Tests/Action/RankingBattle8Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle8Test.cs @@ -34,7 +34,7 @@ public class RankingBattle8Test public RankingBattle8Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -480,7 +480,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/RankingBattle9Test.cs b/.Lib9c.Tests/Action/RankingBattle9Test.cs index 255cec7975..45c07ebb19 100644 --- a/.Lib9c.Tests/Action/RankingBattle9Test.cs +++ b/.Lib9c.Tests/Action/RankingBattle9Test.cs @@ -34,7 +34,7 @@ public class RankingBattle9Test public RankingBattle9Test(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -480,7 +480,7 @@ public void Rehearsal() _avatar1Address.Derive(LegacyQuestListKey), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/RankingBattleTest.cs b/.Lib9c.Tests/Action/RankingBattleTest.cs index ef4cb8b7f7..18cd0423fe 100644 --- a/.Lib9c.Tests/Action/RankingBattleTest.cs +++ b/.Lib9c.Tests/Action/RankingBattleTest.cs @@ -30,7 +30,7 @@ public class RankingBattleTest public RankingBattleTest(ITestOutputHelper outputHelper) { - _initialState = new State(); + _initialState = new MockStateDelta(); var keys = new List { diff --git a/.Lib9c.Tests/Action/RapidCombination0Test.cs b/.Lib9c.Tests/Action/RapidCombination0Test.cs index dbb1b5ee88..ad04995922 100644 --- a/.Lib9c.Tests/Action/RapidCombination0Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination0Test.cs @@ -28,7 +28,7 @@ public class RapidCombination0Test public RapidCombination0Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RapidCombination2Test.cs b/.Lib9c.Tests/Action/RapidCombination2Test.cs index 4f1d548c83..feeaa25f9e 100644 --- a/.Lib9c.Tests/Action/RapidCombination2Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination2Test.cs @@ -28,7 +28,7 @@ public class RapidCombination2Test public RapidCombination2Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RapidCombination3Test.cs b/.Lib9c.Tests/Action/RapidCombination3Test.cs index 9f92a515c5..14f066ca9a 100644 --- a/.Lib9c.Tests/Action/RapidCombination3Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination3Test.cs @@ -28,7 +28,7 @@ public class RapidCombination3Test public RapidCombination3Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/RapidCombination4Test.cs b/.Lib9c.Tests/Action/RapidCombination4Test.cs index 2d53e27c31..5cfb759490 100644 --- a/.Lib9c.Tests/Action/RapidCombination4Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination4Test.cs @@ -30,7 +30,7 @@ public class RapidCombination4Test public RapidCombination4Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -383,7 +383,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination4 { diff --git a/.Lib9c.Tests/Action/RapidCombination5Test.cs b/.Lib9c.Tests/Action/RapidCombination5Test.cs index 3eca37dd0a..eecfdffa6b 100644 --- a/.Lib9c.Tests/Action/RapidCombination5Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination5Test.cs @@ -30,7 +30,7 @@ public class RapidCombination5Test public RapidCombination5Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -383,7 +383,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination5 { diff --git a/.Lib9c.Tests/Action/RapidCombination6Test.cs b/.Lib9c.Tests/Action/RapidCombination6Test.cs index 8c9cb18cca..36ed8b4d84 100644 --- a/.Lib9c.Tests/Action/RapidCombination6Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination6Test.cs @@ -32,7 +32,7 @@ public class RapidCombination6Test public RapidCombination6Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -385,7 +385,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination6 { diff --git a/.Lib9c.Tests/Action/RapidCombination8Test.cs b/.Lib9c.Tests/Action/RapidCombination8Test.cs index bab26f22e2..11d86cec45 100644 --- a/.Lib9c.Tests/Action/RapidCombination8Test.cs +++ b/.Lib9c.Tests/Action/RapidCombination8Test.cs @@ -32,7 +32,7 @@ public class RapidCombination8Test public RapidCombination8Test() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -385,7 +385,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination8 { diff --git a/.Lib9c.Tests/Action/RapidCombinationTest.cs b/.Lib9c.Tests/Action/RapidCombinationTest.cs index 08c8a22dcf..6f48ebde2b 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest.cs @@ -32,7 +32,7 @@ public class RapidCombinationTest public RapidCombinationTest() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -385,7 +385,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination { diff --git a/.Lib9c.Tests/Action/RapidCombinationTest7.cs b/.Lib9c.Tests/Action/RapidCombinationTest7.cs index 1ba97cb9e5..00a76bfc3f 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest7.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest7.cs @@ -32,7 +32,7 @@ public class RapidCombinationTest7 public RapidCombinationTest7() { - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) @@ -385,7 +385,7 @@ public void Rehearsal() slotAddress, }; - var state = new State(); + var state = new MockStateDelta(); var action = new RapidCombination7 { diff --git a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs index 0537ddc379..c7d10c5fc5 100644 --- a/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/ReRegisterProduct0Test.cs @@ -40,7 +40,7 @@ public ReRegisterProduct0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index 58af0d2eaa..8188e2dbc2 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -40,7 +40,7 @@ public ReRegisterProductTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/RedeemCode0Test.cs b/.Lib9c.Tests/Action/RedeemCode0Test.cs index 0d4fe78005..ad94638ab9 100644 --- a/.Lib9c.Tests/Action/RedeemCode0Test.cs +++ b/.Lib9c.Tests/Action/RedeemCode0Test.cs @@ -68,7 +68,7 @@ public void Execute() #pragma warning restore CS0618 var context = new ActionContext(); - var initialState = new State() + var initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) .SetState(RedeemCodeState.Address, prevRedeemCodesState.Serialize()) @@ -125,7 +125,7 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Rehearsal = true, Signer = _agentAddress, }); diff --git a/.Lib9c.Tests/Action/RedeemCodeTest.cs b/.Lib9c.Tests/Action/RedeemCodeTest.cs index 23447b5fc8..e0c53ed887 100644 --- a/.Lib9c.Tests/Action/RedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/RedeemCodeTest.cs @@ -71,7 +71,7 @@ public void Execute(bool backward) #pragma warning restore CS0618 var context = new ActionContext(); - var initialState = new State() + var initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(RedeemCodeState.Address, prevRedeemCodesState.Serialize()) .SetState(GoldCurrencyState.Address, goldState.Serialize()) @@ -140,7 +140,7 @@ public void Rehearsal() { BlockIndex = 1, Miner = default, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Rehearsal = true, Signer = _agentAddress, }); diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index 70c06ddc1e..d6da256fa2 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -55,7 +55,7 @@ public RegisterProduct0Test() }; agentState.avatarAddresses[0] = AvatarAddress; - _initialState = new State() + _initialState = new MockStateDelta() .SetState(GoldCurrencyState.Address, new GoldCurrencyState(Gold).Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.MaterialItemSheet.Serialize()) .SetState(Addresses.GameConfig, _gameConfigState.Serialize()) diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 0116ac1052..00f2aa4f9a 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -55,7 +55,7 @@ public RegisterProductTest() }; agentState.avatarAddresses[0] = AvatarAddress; - _initialState = new State() + _initialState = new MockStateDelta() .SetState(GoldCurrencyState.Address, new GoldCurrencyState(Gold).Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.MaterialItemSheet.Serialize()) .SetState(Addresses.GameConfig, _gameConfigState.Serialize()) diff --git a/.Lib9c.Tests/Action/RenewAdminStateTest.cs b/.Lib9c.Tests/Action/RenewAdminStateTest.cs index 2d5d861ad8..bdba3ececc 100644 --- a/.Lib9c.Tests/Action/RenewAdminStateTest.cs +++ b/.Lib9c.Tests/Action/RenewAdminStateTest.cs @@ -24,7 +24,7 @@ public RenewAdminStateTest() _validUntil = 1_500_000L; _adminState = new AdminState(_adminPrivateKey.ToAddress(), _validUntil); _stateDelta = - new State(ImmutableDictionary.Empty.Add( + new MockStateDelta(ImmutableDictionary.Empty.Add( Addresses.Admin, _adminState.Serialize())); } diff --git a/.Lib9c.Tests/Action/RequestPledgeTest.cs b/.Lib9c.Tests/Action/RequestPledgeTest.cs index 5fd8f3b027..ef924c4dfc 100644 --- a/.Lib9c.Tests/Action/RequestPledgeTest.cs +++ b/.Lib9c.Tests/Action/RequestPledgeTest.cs @@ -21,7 +21,7 @@ public void Execute(int contractedMead) Currency mead = Currencies.Mead; Address patron = new PrivateKey().ToAddress(); var context = new ActionContext(); - IAccountStateDelta states = new State().MintAsset(context, patron, 2 * mead); + IAccountStateDelta states = new MockStateDelta().MintAsset(context, patron, 2 * mead); var address = new PrivateKey().ToAddress(); var action = new RequestPledge { @@ -52,7 +52,7 @@ public void Execute_Throw_AlreadyContractedException() Address patron = new PrivateKey().ToAddress(); var address = new PrivateKey().ToAddress(); Address contractAddress = address.GetPledgeAddress(); - IAccountStateDelta states = new State().SetState(contractAddress, List.Empty); + IAccountStateDelta 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 cf01f11de9..c0635c4d14 100644 --- a/.Lib9c.Tests/Action/RewardGoldTest.cs +++ b/.Lib9c.Tests/Action/RewardGoldTest.cs @@ -37,7 +37,7 @@ public class RewardGoldTest { private readonly AvatarState _avatarState; private readonly AvatarState _avatarState2; - private readonly State _baseState; + private readonly MockStateDelta _baseState; private readonly TableSheets _tableSheets; public RewardGoldTest() @@ -77,7 +77,7 @@ public RewardGoldTest() var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); #pragma warning restore CS0618 IActionContext context = new ActionContext(); - _baseState = (State)new State() + _baseState = (MockStateDelta)new MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState(Addresses.GoldDistribution, GoldDistributionTest.Fixture.Select(v => v.Serialize()).Serialize()) .MintAsset(context, GoldCurrencyState.Address, gold.Currency * 100000000000); @@ -573,7 +573,7 @@ public void TransferMead(int patronMead, int balance) var patronAddress = new PrivateKey().ToAddress(); var contractAddress = agentAddress.GetPledgeAddress(); IActionContext context = new ActionContext(); - IAccountStateDelta states = new State() + IAccountStateDelta 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/RuneEnhancement0Test.cs b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs index 5ba311a434..cda8340fee 100644 --- a/.Lib9c.Tests/Action/RuneEnhancement0Test.cs +++ b/.Lib9c.Tests/Action/RuneEnhancement0Test.cs @@ -40,7 +40,7 @@ public void Execute(int seed) var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -170,7 +170,7 @@ public void Execute_RuneCostNotFoundException() .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -223,7 +223,7 @@ public void Execute_RuneCostDataNotFoundException() .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -292,7 +292,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); @@ -405,7 +405,7 @@ public void Execute_TryCountIsZeroException() .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/RuneEnhancementTest.cs b/.Lib9c.Tests/Action/RuneEnhancementTest.cs index d1db93ea0c..a8597a8063 100644 --- a/.Lib9c.Tests/Action/RuneEnhancementTest.cs +++ b/.Lib9c.Tests/Action/RuneEnhancementTest.cs @@ -55,7 +55,7 @@ public void Execute(int seed) ); agentState.avatarAddresses.Add(0, avatarAddress); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -194,7 +194,7 @@ public void Execute_RuneCostNotFoundException() rankingMapAddress ); agentState.avatarAddresses.Add(0, avatarAddress); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -256,7 +256,7 @@ public void Execute_RuneCostDataNotFoundException() rankingMapAddress ); agentState.avatarAddresses.Add(0, avatarAddress); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -334,7 +334,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, ); agentState.avatarAddresses.Add(0, avatarAddress); var context = new ActionContext(); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -456,7 +456,7 @@ public void Execute_TryCountIsZeroException() rankingMapAddress ); agentState.avatarAddresses.Add(0, avatarAddress); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, agentState.SerializeV2()) .SetState(avatarAddress, avatarState.SerializeV2()) @@ -505,7 +505,7 @@ public void Execute_FailedLoadStateException() .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs index d6fd27d15e..2fbb1c4e6e 100644 --- a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs @@ -38,7 +38,7 @@ public ArenaScenarioTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _state = new Tests.Action.State(); + _state = new Tests.Action.MockStateDelta(); _sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(_sheets); diff --git a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs index 1b080d3348..dc3d71aa6a 100644 --- a/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/Scenario/CombinationAndRapidCombinationTest.cs @@ -80,7 +80,7 @@ public CombinationAndRapidCombinationTest(ITestOutputHelper outputHelper) _worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey); _questListAddress = _avatarAddress.Derive(LegacyQuestListKey); - _initialState = new Tests.Action.State() + _initialState = new Tests.Action.MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState(gameConfigState.address, gameConfigState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index e3bfeb56eb..a505bd1059 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -103,7 +103,7 @@ public MarketScenarioTest(ITestOutputHelper outputHelper) agentState3.avatarAddresses[0] = _buyerAvatarAddress; _currency = Currency.Legacy("NCG", 2, minters: null); - _initialState = new Tests.Action.State() + _initialState = new Tests.Action.MockStateDelta() .SetState(GoldCurrencyState.Address, new GoldCurrencyState(_currency).Serialize()) .SetState(Addresses.GameConfig, _gameConfigState.Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.MaterialItemSheet.Serialize()) diff --git a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs index 04933ee60d..13cf75d84f 100644 --- a/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MeadScenarioTest.cs @@ -21,7 +21,7 @@ public void Contract() Currency mead = Currencies.Mead; var patron = new PrivateKey().ToAddress(); IActionContext context = new ActionContext(); - IAccountStateDelta states = new State().MintAsset(context, patron, 10 * mead); + IAccountStateDelta states = new MockStateDelta().MintAsset(context, patron, 10 * mead); var agentAddress = new PrivateKey().ToAddress(); var requestPledge = new RequestPledge @@ -86,7 +86,7 @@ bool IsTarget(Type type) var action = (IAction)Activator.CreateInstance(typeId)!; var actionContext = new ActionContext { - PreviousState = new State(), + PreviousState = new MockStateDelta(), }; try { diff --git a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs index eaf8fe287a..5035219b5f 100644 --- a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs @@ -40,7 +40,7 @@ public void Craft_And_Equip() ); var context = new ActionContext(); - IAccountStateDelta initialState = new Tests.Action.State() + IAccountStateDelta 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 3c24132ba3..6d402baa7b 100644 --- a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs +++ b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs @@ -60,7 +60,7 @@ public SellAndCancellationAndSellTest(ITestOutputHelper outputHelper) GameConfig.RequireClearedStageLevel.ActionsInShop), }; - _initialState = new Tests.Action.State() + _initialState = new Tests.Action.MockStateDelta() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState(gameConfigState.address, gameConfigState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) diff --git a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs index 3c216744e0..4bc39be44d 100644 --- a/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/StakeAndClaimStakeReward2ScenarioTest.cs @@ -15,7 +15,7 @@ namespace Lib9c.Tests.Action.Scenario using Xunit; using Xunit.Abstractions; using static Lib9c.SerializeKeys; - using State = Lib9c.Tests.Action.State; + using State = Lib9c.Tests.Action.MockStateDelta; public class StakeAndClaimStakeReward2ScenarioTest { diff --git a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs index 8a360f38a0..0bfaadb01e 100644 --- a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs @@ -50,7 +50,7 @@ public WorldUnlockScenarioTest() _weeklyArenaState = new WeeklyArenaState(0); - _initialState = new Lib9c.Tests.Action.State() + _initialState = new Lib9c.Tests.Action.MockStateDelta() .SetState(_weeklyArenaState.address, _weeklyArenaState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, avatarState.Serialize()) diff --git a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs index a4e9491292..e1007cc502 100644 --- a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs +++ b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs @@ -34,11 +34,11 @@ public class SecureMiningRewardTest new Address("636d187B4d434244A92B65B06B5e7da14b3810A9"), }.ToImmutableList(); - private static readonly State _previousState = new State( - state: ImmutableDictionary.Empty + private static readonly MockStateDelta _previousState = new MockStateDelta( + states: ImmutableDictionary.Empty .Add(AdminState.Address, new AdminState(_admin, 100).Serialize()) .Add(GoldCurrencyState.Address, new GoldCurrencyState(NCG).Serialize()), - balance: ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty + balances: ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_authMiners[0], NCG), NCG * 1000) .Add((_authMiners[1], NCG), NCG * 2000) .Add((_authMiners[2], NCG), NCG * 3000) diff --git a/.Lib9c.Tests/Action/Sell0Test.cs b/.Lib9c.Tests/Action/Sell0Test.cs index 4599fd5457..43d00320fd 100644 --- a/.Lib9c.Tests/Action/Sell0Test.cs +++ b/.Lib9c.Tests/Action/Sell0Test.cs @@ -31,7 +31,7 @@ public Sell0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -155,7 +155,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell10Test.cs b/.Lib9c.Tests/Action/Sell10Test.cs index e1ee81f5b0..df9650a455 100644 --- a/.Lib9c.Tests/Action/Sell10Test.cs +++ b/.Lib9c.Tests/Action/Sell10Test.cs @@ -39,7 +39,7 @@ public Sell10Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -256,7 +256,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -443,7 +443,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Sell11Test.cs b/.Lib9c.Tests/Action/Sell11Test.cs index 48ea71557c..4cb0c7888e 100644 --- a/.Lib9c.Tests/Action/Sell11Test.cs +++ b/.Lib9c.Tests/Action/Sell11Test.cs @@ -39,7 +39,7 @@ public Sell11Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -304,7 +304,7 @@ public void Execute_Throw_InvalidOperationException_DueTo_EmptyState() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -491,7 +491,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Sell2Test.cs b/.Lib9c.Tests/Action/Sell2Test.cs index 32d1cc3591..dd5c539063 100644 --- a/.Lib9c.Tests/Action/Sell2Test.cs +++ b/.Lib9c.Tests/Action/Sell2Test.cs @@ -31,7 +31,7 @@ public Sell2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -192,7 +192,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell3Test.cs b/.Lib9c.Tests/Action/Sell3Test.cs index c19399622c..18f3b1c0fe 100644 --- a/.Lib9c.Tests/Action/Sell3Test.cs +++ b/.Lib9c.Tests/Action/Sell3Test.cs @@ -33,7 +33,7 @@ public Sell3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -193,7 +193,7 @@ public void ExecuteThrowFailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell4Test.cs b/.Lib9c.Tests/Action/Sell4Test.cs index e2fbe84d55..1d4230b123 100644 --- a/.Lib9c.Tests/Action/Sell4Test.cs +++ b/.Lib9c.Tests/Action/Sell4Test.cs @@ -36,7 +36,7 @@ public Sell4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -224,7 +224,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell5Test.cs b/.Lib9c.Tests/Action/Sell5Test.cs index 1c136070eb..b4488c4b67 100644 --- a/.Lib9c.Tests/Action/Sell5Test.cs +++ b/.Lib9c.Tests/Action/Sell5Test.cs @@ -35,7 +35,7 @@ public Sell5Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -300,7 +300,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell6Test.cs b/.Lib9c.Tests/Action/Sell6Test.cs index 0d1674482a..bed6dd8dca 100644 --- a/.Lib9c.Tests/Action/Sell6Test.cs +++ b/.Lib9c.Tests/Action/Sell6Test.cs @@ -35,7 +35,7 @@ public Sell6Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -603,7 +603,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/Sell7Test.cs b/.Lib9c.Tests/Action/Sell7Test.cs index 6348104fce..23969f995f 100644 --- a/.Lib9c.Tests/Action/Sell7Test.cs +++ b/.Lib9c.Tests/Action/Sell7Test.cs @@ -39,7 +39,7 @@ public Sell7Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -297,7 +297,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -466,7 +466,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Sell8Test.cs b/.Lib9c.Tests/Action/Sell8Test.cs index 3df907d76f..cb3d5a831e 100644 --- a/.Lib9c.Tests/Action/Sell8Test.cs +++ b/.Lib9c.Tests/Action/Sell8Test.cs @@ -39,7 +39,7 @@ public Sell8Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -290,7 +290,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -459,7 +459,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Sell9Test.cs b/.Lib9c.Tests/Action/Sell9Test.cs index 055937acdf..ad90294b8b 100644 --- a/.Lib9c.Tests/Action/Sell9Test.cs +++ b/.Lib9c.Tests/Action/Sell9Test.cs @@ -39,7 +39,7 @@ public Sell9Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -256,7 +256,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -443,7 +443,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/SellCancellation0Test.cs b/.Lib9c.Tests/Action/SellCancellation0Test.cs index a94e708c58..3cc640cc98 100644 --- a/.Lib9c.Tests/Action/SellCancellation0Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation0Test.cs @@ -28,7 +28,7 @@ public SellCancellation0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation2Test.cs b/.Lib9c.Tests/Action/SellCancellation2Test.cs index 784d4f65a4..a13d176e7e 100644 --- a/.Lib9c.Tests/Action/SellCancellation2Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation2Test.cs @@ -30,7 +30,7 @@ public SellCancellation2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation3Test.cs b/.Lib9c.Tests/Action/SellCancellation3Test.cs index 0685f25274..0dba1bc63b 100644 --- a/.Lib9c.Tests/Action/SellCancellation3Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation3Test.cs @@ -28,7 +28,7 @@ public SellCancellation3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation4Test.cs b/.Lib9c.Tests/Action/SellCancellation4Test.cs index 2421ecca8e..85156dbafb 100644 --- a/.Lib9c.Tests/Action/SellCancellation4Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation4Test.cs @@ -28,7 +28,7 @@ public SellCancellation4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation5Test.cs b/.Lib9c.Tests/Action/SellCancellation5Test.cs index 6f2592aee6..97d368aa00 100644 --- a/.Lib9c.Tests/Action/SellCancellation5Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation5Test.cs @@ -32,7 +32,7 @@ public SellCancellation5Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation6Test.cs b/.Lib9c.Tests/Action/SellCancellation6Test.cs index 47dda389d6..562b94325e 100644 --- a/.Lib9c.Tests/Action/SellCancellation6Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation6Test.cs @@ -34,7 +34,7 @@ public SellCancellation6Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { diff --git a/.Lib9c.Tests/Action/SellCancellation7Test.cs b/.Lib9c.Tests/Action/SellCancellation7Test.cs index 4a5bf18951..2fb8427f01 100644 --- a/.Lib9c.Tests/Action/SellCancellation7Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation7Test.cs @@ -37,7 +37,7 @@ public SellCancellation7Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -475,7 +475,7 @@ public void Rehearsal() Addresses.GetItemAddress(default), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/SellCancellation8Test.cs b/.Lib9c.Tests/Action/SellCancellation8Test.cs index 9a043ebc28..804123c697 100644 --- a/.Lib9c.Tests/Action/SellCancellation8Test.cs +++ b/.Lib9c.Tests/Action/SellCancellation8Test.cs @@ -37,7 +37,7 @@ public SellCancellation8Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -496,7 +496,7 @@ public void Rehearsal() Addresses.GetItemAddress(default), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/SellCancellationTest.cs b/.Lib9c.Tests/Action/SellCancellationTest.cs index 3ab9c0a2c2..8db512cba4 100644 --- a/.Lib9c.Tests/Action/SellCancellationTest.cs +++ b/.Lib9c.Tests/Action/SellCancellationTest.cs @@ -39,7 +39,7 @@ public SellCancellationTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -531,7 +531,7 @@ public void Rehearsal() Addresses.GetItemAddress(default), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/SellTest.cs b/.Lib9c.Tests/Action/SellTest.cs index 8d734ea0bd..b8e2d6c141 100644 --- a/.Lib9c.Tests/Action/SellTest.cs +++ b/.Lib9c.Tests/Action/SellTest.cs @@ -38,7 +38,7 @@ public SellTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -303,7 +303,7 @@ public void Execute_Throw_InvalidOperationException_DueTo_EmptyState() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -490,7 +490,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs b/.Lib9c.Tests/Action/Snapshot/TransferAsset0SnapshotTest.cs index a9b0ec1204..f10cb1f4bb 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 State().MintAsset(context, senderAddress, crystal * 100); + IAccountStateDelta state = new MockStateDelta().MintAsset(context, senderAddress, crystal * 100); var actionContext = new ActionContext { Signer = senderAddress, @@ -88,7 +88,7 @@ public Task TransferWithMemo() var recipientAddress = recipientPrivateKey.ToAddress(); var crystal = CrystalCalculator.CRYSTAL; var context = new ActionContext(); - var state = new State().MintAsset(context, senderAddress, crystal * 100); + var 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 9a0d3b89e3..b5db636ff6 100644 --- a/.Lib9c.Tests/Action/Stake0Test.cs +++ b/.Lib9c.Tests/Action/Stake0Test.cs @@ -29,7 +29,7 @@ public Stake0Test(ITestOutputHelper outputHelper) .CreateLogger(); var context = new ActionContext(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/StakeTest.cs b/.Lib9c.Tests/Action/StakeTest.cs index f8c42eae2b..9898564941 100644 --- a/.Lib9c.Tests/Action/StakeTest.cs +++ b/.Lib9c.Tests/Action/StakeTest.cs @@ -28,7 +28,7 @@ public StakeTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index 06dd85f0cc..2daa5a0b2b 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -53,9 +53,9 @@ public void Execute() .Add((_recipient, _currency), _currency * 10); var state = ImmutableDictionary.Empty .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -80,8 +80,8 @@ public void ExecuteWithInvalidSigner() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -111,8 +111,8 @@ public void ExecuteWithInvalidRecipient() { var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset2 with same sender and recipient. var action = new TransferAsset2( @@ -151,8 +151,8 @@ public void ExecuteWithInsufficientBalance() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -182,8 +182,8 @@ public void ExecuteWithMinterAsSender() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -216,8 +216,8 @@ public void ExecuteWithMinterAsRecipient() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyByRecipient), _currency * 1000) .Add((_recipient, currencyByRecipient), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -250,9 +250,9 @@ public void ExecuteWithUnactivatedRecipient() var state = ImmutableDictionary.Empty .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset2( sender: _sender, @@ -284,7 +284,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -394,7 +394,7 @@ public void CheckObsolete() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _sender, Rehearsal = false, BlockIndex = TransferAsset3.CrystalTransferringRestrictionStartIndex, diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index a9d7111475..e199816630 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -78,9 +78,9 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) state = state.Add(_recipient, new AgentState(_recipient).Serialize()); } - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset3( sender: _sender, @@ -105,8 +105,8 @@ public void ExecuteWithInvalidSigner() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset3( sender: _sender, @@ -136,8 +136,8 @@ public void ExecuteWithInvalidRecipient() { var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAsset3( @@ -167,8 +167,8 @@ public void ExecuteWithInsufficientBalance() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset3( sender: _sender, @@ -198,8 +198,8 @@ public void ExecuteWithMinterAsSender() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset3( sender: _sender, @@ -232,8 +232,8 @@ public void ExecuteWithMinterAsRecipient() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyByRecipient), _currency * 1000) .Add((_recipient, currencyByRecipient), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset3( sender: _sender, @@ -266,9 +266,9 @@ public void ExecuteWithUnactivatedRecipient() var state = ImmutableDictionary.Empty .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset3( sender: _sender, @@ -300,7 +300,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -374,9 +374,9 @@ public void Execute_Throw_InvalidTransferCurrencyException() var state = ImmutableDictionary.Empty .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset3( sender: _sender, diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index 9d58c01bd2..309fdee706 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -56,9 +56,9 @@ public void Execute() .Add((_recipient, _currency), _currency * 10); var state = ImmutableDictionary.Empty; - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset( sender: _sender, @@ -84,8 +84,8 @@ public void Execute_Throw_InvalidTransferSignerException() .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10) .Add((_sender, Currencies.Mead), Currencies.Mead * 1); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset( sender: _sender, @@ -116,8 +116,8 @@ public void Execute_Throw_InvalidTransferRecipientException() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_sender, Currencies.Mead), Currencies.Mead * 1); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAsset( @@ -148,8 +148,8 @@ public void Execute_Throw_InsufficientBalanceException() .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset( sender: _sender, @@ -186,8 +186,8 @@ public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10) .Add((_sender, Currencies.Mead), Currencies.Mead * 1); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset( sender: _sender, @@ -222,7 +222,7 @@ public void Rehearsal() var context = new ActionContext(); IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State().MintAsset(context, _sender, Currencies.Mead * 1), + PreviousState = new MockStateDelta().MintAsset(context, _sender, Currencies.Mead * 1), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -297,9 +297,9 @@ public void Execute_Throw_InvalidTransferCurrencyException() var state = ImmutableDictionary.Empty .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAsset( sender: _sender, diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 72044efcda..8be009e55f 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -49,8 +49,8 @@ public void Execute() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset0( sender: _sender, @@ -75,8 +75,8 @@ public void ExecuteWithInvalidSigner() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset0( sender: _sender, @@ -106,8 +106,8 @@ public void ExecuteWithInvalidRecipient() { var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAsset0( @@ -146,8 +146,8 @@ public void ExecuteWithInsufficientBalance() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset0( sender: _sender, @@ -177,8 +177,8 @@ public void ExecuteWithMinterAsSender() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset0( sender: _sender, @@ -211,8 +211,8 @@ public void ExecuteWithMinterAsRecipient() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyByRecipient), _currency * 1000) .Add((_recipient, currencyByRecipient), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAsset0( sender: _sender, @@ -246,7 +246,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index ca6b6b556b..17856d17de 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -100,9 +100,9 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) .Add(_recipient2, new AgentState(_recipient2).Serialize()); } - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAssets0( sender: _sender, @@ -131,8 +131,8 @@ public void ExecuteWithInvalidSigner() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAssets0( sender: _sender, @@ -164,8 +164,8 @@ public void ExecuteWithInvalidRecipient() { var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAssets0( @@ -197,8 +197,8 @@ public void ExecuteWithInsufficientBalance() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAssets0( sender: _sender, @@ -230,8 +230,8 @@ public void ExecuteWithMinterAsSender() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAssets0( sender: _sender, @@ -266,8 +266,8 @@ public void ExecuteWithMinterAsRecipient() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyByRecipient), _currency * 1000) .Add((_recipient, currencyByRecipient), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAssets0( sender: _sender, @@ -302,9 +302,9 @@ public void ExecuteWithUnactivatedRecipient() var state = ImmutableDictionary.Empty .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAssets0( sender: _sender, @@ -340,7 +340,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -472,7 +472,7 @@ public void Execute_Throw_ArgumentOutOfRangeException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -489,9 +489,9 @@ public void Execute_Throw_InvalidTransferCurrencyException() var state = ImmutableDictionary.Empty .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAssets0( sender: _sender, diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 313bd83d64..0957e9aaee 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -72,9 +72,9 @@ public void Execute() .Add((_recipient, _currency), _currency * 10); var state = ImmutableDictionary.Empty; - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAssets( sender: _sender, @@ -105,8 +105,8 @@ public void Execute_Throw_InvalidTransferSignerException() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); var action = new TransferAssets( sender: _sender, @@ -138,8 +138,8 @@ public void Execute_Throw_InvalidTransferRecipientException() { var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAssets( @@ -172,8 +172,8 @@ public void Execute_Throw_InsufficientBalanceException() .Add((_sender, _currency), _currency * 1000) .Add((_recipient, _currency), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAssets( sender: _sender, @@ -208,8 +208,8 @@ public void Execute_Throw_InvalidTransferMinterException() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, currencyBySender), _currency * 1000) .Add((_recipient, currencyBySender), _currency * 10); - var prevState = new State( - balance: balance + var prevState = new MockStateDelta( + balances: balance ).SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAssets( sender: _sender, @@ -247,7 +247,7 @@ public void Rehearsal() IAccountStateDelta nextState = action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = default, Rehearsal = true, BlockIndex = 1, @@ -379,7 +379,7 @@ public void Execute_Throw_ArgumentOutOfRangeException() { action.Execute(new ActionContext() { - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _sender, Rehearsal = false, BlockIndex = 1, @@ -396,9 +396,9 @@ public void Execute_Throw_InvalidTransferCurrencyException() var state = ImmutableDictionary.Empty .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new State( - state: state, - balance: balance + var prevState = new MockStateDelta( + states: state, + balances: balance ); var action = new TransferAssets( sender: _sender, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs index 8a59f1e7db..dac2fc93ae 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipe1Test.cs @@ -52,7 +52,7 @@ public UnlockEquipmentRecipe1Test() agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.EquipmentItemSheet.Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.EquipmentItemRecipeSheet.Serialize()) diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs index be1396455f..84d2536441 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs @@ -52,7 +52,7 @@ public UnlockEquipmentRecipeTest() agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(_agentAddress, agentState.Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.EquipmentItemSheet.Serialize()) .SetState(Addresses.GetSheetAddress(), _tableSheets.EquipmentItemRecipeSheet.Serialize()) diff --git a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs index 6902af9ffe..102c28f05f 100644 --- a/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs +++ b/.Lib9c.Tests/Action/UnlockRuneSlotTest.cs @@ -35,7 +35,7 @@ public IAccountStateDelta Init(out Address agentAddress, out Address avatarAddre .StartedBlockIndex; var goldCurrencyState = new GoldCurrencyState(_goldCurrency); - var state = new State() + var state = new MockStateDelta() .SetState(goldCurrencyState.address, goldCurrencyState.Serialize()) .SetState(agentAddress, new AgentState(agentAddress).Serialize()); diff --git a/.Lib9c.Tests/Action/UnlockWorld1Test.cs b/.Lib9c.Tests/Action/UnlockWorld1Test.cs index a509e939cc..86bc0080e5 100644 --- a/.Lib9c.Tests/Action/UnlockWorld1Test.cs +++ b/.Lib9c.Tests/Action/UnlockWorld1Test.cs @@ -50,7 +50,7 @@ public UnlockWorld1Test() agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GetSheetAddress(), _tableSheets.WorldUnlockSheet.Serialize()) .SetState(Addresses.GameConfig, gameConfigState.Serialize()); } diff --git a/.Lib9c.Tests/Action/UnlockWorldTest.cs b/.Lib9c.Tests/Action/UnlockWorldTest.cs index f5d62ae2ef..08dd435e5c 100644 --- a/.Lib9c.Tests/Action/UnlockWorldTest.cs +++ b/.Lib9c.Tests/Action/UnlockWorldTest.cs @@ -50,7 +50,7 @@ public UnlockWorldTest() agentState.avatarAddresses.Add(0, _avatarAddress); - _initialState = new State() + _initialState = new MockStateDelta() .SetState(Addresses.GetSheetAddress(), _tableSheets.WorldUnlockSheet.Serialize()) .SetState(Addresses.GameConfig, gameConfigState.Serialize()); } diff --git a/.Lib9c.Tests/Action/UpdateSell0Test.cs b/.Lib9c.Tests/Action/UpdateSell0Test.cs index ce45a4c9b3..cb81413b2a 100644 --- a/.Lib9c.Tests/Action/UpdateSell0Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell0Test.cs @@ -38,7 +38,7 @@ public UpdateSell0Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -276,7 +276,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -367,7 +367,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/UpdateSell2Test.cs b/.Lib9c.Tests/Action/UpdateSell2Test.cs index 617f262a27..a3169bf68f 100644 --- a/.Lib9c.Tests/Action/UpdateSell2Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell2Test.cs @@ -38,7 +38,7 @@ public UpdateSell2Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -257,7 +257,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -348,7 +348,7 @@ public void Rehearsal() OrderDigestListState.DeriveAddress(_avatarAddress), }; - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { diff --git a/.Lib9c.Tests/Action/UpdateSell3Test.cs b/.Lib9c.Tests/Action/UpdateSell3Test.cs index aab0dd612d..1c28ef76f5 100644 --- a/.Lib9c.Tests/Action/UpdateSell3Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell3Test.cs @@ -38,7 +38,7 @@ public UpdateSell3Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/UpdateSell4Test.cs b/.Lib9c.Tests/Action/UpdateSell4Test.cs index 8bc42dd880..a75c09c4d5 100644 --- a/.Lib9c.Tests/Action/UpdateSell4Test.cs +++ b/.Lib9c.Tests/Action/UpdateSell4Test.cs @@ -38,7 +38,7 @@ public UpdateSell4Test(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/UpdateSellTest.cs b/.Lib9c.Tests/Action/UpdateSellTest.cs index b7477ca764..403d2a520e 100644 --- a/.Lib9c.Tests/Action/UpdateSellTest.cs +++ b/.Lib9c.Tests/Action/UpdateSellTest.cs @@ -38,7 +38,7 @@ public UpdateSellTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var (key, value) in sheets) { @@ -258,7 +258,7 @@ public void Execute_Throw_ListEmptyException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } @@ -283,7 +283,7 @@ public void Execute_Throw_FailedLoadStateException() Assert.Throws(() => action.Execute(new ActionContext { BlockIndex = 0, - PreviousState = new State(), + PreviousState = new MockStateDelta(), Signer = _agentAddress, })); } diff --git a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs index 38d583d0d3..e067471efa 100644 --- a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs +++ b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs @@ -27,7 +27,7 @@ public ValidatorSetOperateTest(ITestOutputHelper outputHelper) .WriteTo.TestOutput(outputHelper) .CreateLogger(); - _initialState = new State(); + _initialState = new MockStateDelta(); _validator = new Validator(new PrivateKey().PublicKey, BigInteger.One); var sheets = TableSheetsImporter.ImportSheets(); @@ -47,7 +47,7 @@ public void CheckPermission() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()); - var state = new State( + var state = new MockStateDelta( initStates, validatorSet: new ValidatorSet()); var action = ValidatorSetOperate.Append(_validator); @@ -71,7 +71,7 @@ public void CheckPermission_Throws_PermissionDenied() var initStates = ImmutableDictionary.Empty .Add(AdminState.Address, adminState.Serialize()); - var state = new State( + var state = new MockStateDelta( initStates, validatorSet: new ValidatorSet()); var action = ValidatorSetOperate.Append(_validator); @@ -107,7 +107,7 @@ public void Append_Throws_WhenAlreadyExistValidator() [Fact] public void Update_Throws_WhenDoNotExistValidator() { - var state = new State(); + var state = new MockStateDelta(); var action = ValidatorSetOperate.Update(_validator); InvalidOperationException exc = Assert.Throws(() => action.Execute(new ActionContext @@ -122,7 +122,7 @@ public void Update_Throws_WhenDoNotExistValidator() [Fact] public void Remove_Throws_WhenDoNotExistValidator() { - var state = new State(); + var state = new MockStateDelta(); var action = ValidatorSetOperate.Remove(_validator); InvalidOperationException exc = Assert.Throws(() => action.Execute(new ActionContext diff --git a/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs b/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs index 911ad0431b..d5a419cbd1 100644 --- a/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs +++ b/.Lib9c.Tests/Extensions/SheetsExtensionsTest.cs @@ -24,7 +24,7 @@ public class SheetsExtensionsTest public SheetsExtensionsTest() { - _states = new Tests.Action.State(); + _states = new Tests.Action.MockStateDelta(); InitSheets( _states, out _sheetNameAndFiles, diff --git a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs index eb7bd69be9..b5e8a8b530 100644 --- a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs +++ b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs @@ -99,7 +99,7 @@ public static MakeInitialStateResult MakeInitialState() var sheets = TableSheetsImporter.ImportSheets(); var weeklyArenaAddress = WeeklyArenaState.DeriveAddress(0); var context = new ActionContext(); - var initialState = new Tests.Action.State() + var initialState = new Tests.Action.MockStateDelta() .SetState(GoldCurrencyState.Address, goldCurrencyState.Serialize()) .SetState( Addresses.GoldDistribution, diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index 3337742b1c..d5f12b65ee 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -11,7 +11,7 @@ namespace Lib9c.Tests.Util using Nekoyume.Action; using Nekoyume.Model.State; using Nekoyume.TableData; - using State = Lib9c.Tests.Action.State; + using State = Lib9c.Tests.Action.MockStateDelta; using StateExtensions = Nekoyume.Model.State.StateExtensions; public static class InitializeUtil From c889d66b296dfb5f94a194a287f41bc275199b39 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 15:52:47 +0900 Subject: [PATCH 39/68] Introduce MockState --- .Lib9c.Tests/Action/MockState.cs | 189 +++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 .Lib9c.Tests/Action/MockState.cs diff --git a/.Lib9c.Tests/Action/MockState.cs b/.Lib9c.Tests/Action/MockState.cs new file mode 100644 index 0000000000..7a3927a11a --- /dev/null +++ b/.Lib9c.Tests/Action/MockState.cs @@ -0,0 +1,189 @@ +#nullable enable + +namespace Lib9c.Tests.Action +{ + using System; + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Linq; + using System.Numerics; + using Bencodex.Types; + using Libplanet; + using Libplanet.Assets; + using Libplanet.Consensus; + using Libplanet.State; + + /// + /// A mock implementation of with various overloaded methods for + /// improving QoL. + /// + /// + /// All methods are pretty self-explanatory with no side-effects. There are some caveats: + /// + /// + /// Every balance related operation can accept a negative amount. Each behave as expected. + /// That is, adding negative amount would decrease the balance. + /// + /// + /// Negative balance is allowed for all cases. This includes total supply. + /// + /// + /// Total supply is not automatically tracked. That is, changing the balance associated + /// with an does not change the total supply in any way. + /// Total supply must be explicitly set if needed. + /// + /// + /// There are only few restrictions that apply for manipulating this object, mostly + /// pertaining to total supplies: + /// + /// + /// It is not possible to set a total supply amount for a currency that is + /// not trackable. + /// + /// + /// It is not possible to set a total supply amount that is over the currency's + /// capped maximum total supply. + /// + /// + /// + /// + /// + public class MockState : IAccountState + { + private readonly IImmutableDictionary _states; + private readonly IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; + private readonly IImmutableDictionary _totalSupplies; + private readonly ValidatorSet _validatorSet; + + public MockState() + : this( + ImmutableDictionary.Empty, + ImmutableDictionary<(Address Address, Currency Currency), BigInteger>.Empty, + ImmutableDictionary.Empty, + new ValidatorSet()) + { + } + + private MockState( + IImmutableDictionary state, + IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, + IImmutableDictionary totalSupplies, + ValidatorSet validatorSet) + { + _states = state; + _fungibles = balance; + _totalSupplies = totalSupplies; + _validatorSet = validatorSet; + } + + public IValue? GetState(Address address) => _states.TryGetValue(address, out IValue? value) + ? value + : null; + + public IReadOnlyList GetStates(IReadOnlyList
addresses) => + addresses.Select(GetState).ToArray(); + + public FungibleAssetValue GetBalance(Address address, Currency currency) => + _fungibles.TryGetValue((address, currency), out BigInteger rawValue) + ? FungibleAssetValue.FromRawValue(currency, rawValue) + : FungibleAssetValue.FromRawValue(currency, 0); + + public FungibleAssetValue GetTotalSupply(Currency currency) + { + if (!currency.TotalSupplyTrackable) + { + var msg = + $"The total supply value of the currency {currency} is not trackable" + + " because it is a legacy untracked currency which might have been" + + " established before the introduction of total supply tracking support."; + throw new TotalSupplyNotTrackableException(msg, currency); + } + + return _totalSupplies.TryGetValue(currency, out var rawValue) + ? FungibleAssetValue.FromRawValue(currency, rawValue) + : FungibleAssetValue.FromRawValue(currency, 0); + } + + public ValidatorSet GetValidatorSet() => _validatorSet; + + public MockState SetState(Address address, IValue state) => + new MockState( + _states.SetItem(address, state), + _fungibles, + _totalSupplies, + _validatorSet); + + public MockState SetBalance(Address address, FungibleAssetValue amount) => + SetBalance((address, amount.Currency), amount.RawValue); + + public MockState SetBalance(Address address, Currency currency, BigInteger rawAmount) => + SetBalance((address, currency), rawAmount); + + public MockState SetBalance((Address Address, Currency Currency) pair, BigInteger rawAmount) => + new MockState( + _states, + _fungibles.SetItem(pair, rawAmount), + _totalSupplies, + _validatorSet); + + public MockState AddBalance(Address address, FungibleAssetValue amount) => + AddBalance((address, amount.Currency), amount.RawValue); + + public MockState AddBalance(Address address, Currency currency, BigInteger rawAmount) => + AddBalance((address, currency), rawAmount); + + public MockState AddBalance((Address Address, Currency Currency) pair, BigInteger rawAmount) => + SetBalance(pair, (_fungibles.TryGetValue(pair, out BigInteger amount) ? amount : 0) + rawAmount); + + public MockState SubtractBalance(Address address, FungibleAssetValue amount) => + SubtractBalance((address, amount.Currency), amount.RawValue); + + public MockState SubtractBalance(Address address, Currency currency, BigInteger rawAmount) => + SubtractBalance((address, currency), rawAmount); + + public MockState SubtractBalance((Address Address, Currency Currency) pair, BigInteger rawAmount) => + SetBalance(pair, (_fungibles.TryGetValue(pair, out BigInteger amount) ? amount : 0) - rawAmount); + + public MockState TransferBalance(Address sender, Address recipient, FungibleAssetValue amount) => + TransferBalance(sender, recipient, amount.Currency, amount.RawValue); + + public MockState TransferBalance(Address sender, Address recipient, Currency currency, BigInteger rawAmount) => + SubtractBalance(sender, currency, rawAmount).AddBalance(recipient, currency, rawAmount); + + public MockState SetTotalSupply(FungibleAssetValue amount) => + SetTotalSupply(amount.Currency, amount.RawValue); + + public MockState SetTotalSupply(Currency currency, BigInteger rawAmount) => + currency.TotalSupplyTrackable + ? !(currency.MaximumSupply is { } maximumSupply) || rawAmount <= maximumSupply.RawValue + ? new MockState( + _states, + _fungibles, + _totalSupplies.SetItem(currency, rawAmount), + _validatorSet) + : throw new ArgumentException( + $"Given {currency}'s total supply is capped at {maximumSupply.RawValue} and " + + $"cannot be set to {rawAmount}.") + : throw new ArgumentException( + $"Given {currency} is not trackable."); + + public MockState AddTotalSupply(FungibleAssetValue amount) => + AddTotalSupply(amount.Currency, amount.RawValue); + + public MockState AddTotalSupply(Currency currency, BigInteger rawAmount) => + SetTotalSupply(currency, (_totalSupplies.TryGetValue(currency, out BigInteger amount) ? amount : 0) + rawAmount); + + public MockState SubtractTotalSupply(FungibleAssetValue amount) => + SubtractTotalSupply(amount.Currency, amount.RawValue); + + public MockState SubtractTotalSupply(Currency currency, BigInteger rawAmount) => + SetTotalSupply(currency, (_totalSupplies.TryGetValue(currency, out BigInteger amount) ? amount : 0) - rawAmount); + + public MockState SetValidator(Validator validator) => + new MockState( + _states, + _fungibles, + _totalSupplies, + _validatorSet.Update(validator)); + } +} From d3f254e91fa91b0c7e279281164b39db5a38c8df Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 17:03:47 +0900 Subject: [PATCH 40/68] Expose more properties for migration --- .Lib9c.Tests/Action/MockState.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.Lib9c.Tests/Action/MockState.cs b/.Lib9c.Tests/Action/MockState.cs index 7a3927a11a..c12d2117b6 100644 --- a/.Lib9c.Tests/Action/MockState.cs +++ b/.Lib9c.Tests/Action/MockState.cs @@ -185,5 +185,13 @@ public MockState SetValidator(Validator validator) => _fungibles, _totalSupplies, _validatorSet.Update(validator)); + + public IImmutableDictionary States => _states; + + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => _fungibles; + + public IImmutableDictionary TotalSupplies => _totalSupplies; + + public ValidatorSet ValidatorSet => _validatorSet; } } From 429bf148e02a24291764233c33b9bbd507b0307e Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 17:53:25 +0900 Subject: [PATCH 41/68] Use MockState for tests --- .../Action/FaucetCurrencyTest.cs | 7 +- .Lib9c.Tests/Action/ActivateAccount0Test.cs | 27 +++--- .../Action/AddActivatedAccount0Test.cs | 21 ++--- .../Action/AddActivatedAccountTest.cs | 10 +- .Lib9c.Tests/Action/AddRedeemCodeTest.cs | 4 +- .../Action/CreatePendingActivationTest.cs | 12 +-- .../Action/CreatePendingActivationsTest.cs | 12 +-- .../MigrationActivatedAccountsStateTest.cs | 8 +- .../Action/MigrationAvatarStateTest.cs | 8 +- .Lib9c.Tests/Action/MockState.cs | 21 +++-- .Lib9c.Tests/Action/MockStateDelta.cs | 13 ++- .Lib9c.Tests/Action/PatchTableSheetTest.cs | 12 +-- .Lib9c.Tests/Action/RenewAdminStateTest.cs | 7 +- .Lib9c.Tests/Action/SecureMiningRewardTest.cs | 16 ++-- .Lib9c.Tests/Action/TransferAsset2Test.cs | 64 +++++-------- .Lib9c.Tests/Action/TransferAsset3Test.cs | 84 +++++++---------- .Lib9c.Tests/Action/TransferAssetTest.cs | 63 +++++-------- .Lib9c.Tests/Action/TransferAssetTest0.cs | 46 ++++------ .Lib9c.Tests/Action/TransferAssets0Test.cs | 92 ++++++++----------- .Lib9c.Tests/Action/TransferAssetsTest.cs | 55 ++++------- .../Action/ValidatorSetOperateTest.cs | 18 ++-- 21 files changed, 248 insertions(+), 352 deletions(-) diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs index 4c6ca5d9cc..e92dd6912a 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetCurrencyTest.cs @@ -32,10 +32,9 @@ public FaucetCurrencyTest(ITestOutputHelper outputHelper) _crystal = Currency.Legacy("CRYSTAL", 18, null); #pragma warning restore CS0618 - var balance = - ImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue>.Empty - .Add((GoldCurrencyState.Address, _ncg), _ncg * int.MaxValue); - _initialState = new Lib9c.Tests.Action.MockStateDelta(balances: balance); + _initialState = new MockStateDelta( + MockState.Empty + .AddBalance(GoldCurrencyState.Address, _ncg * int.MaxValue)); var goldCurrencyState = new GoldCurrencyState(_ncg); _agentAddress = new PrivateKey().ToAddress(); diff --git a/.Lib9c.Tests/Action/ActivateAccount0Test.cs b/.Lib9c.Tests/Action/ActivateAccount0Test.cs index b771b91964..345e04105c 100644 --- a/.Lib9c.Tests/Action/ActivateAccount0Test.cs +++ b/.Lib9c.Tests/Action/ActivateAccount0Test.cs @@ -19,9 +19,10 @@ public void Execute() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - .Add(pendingActivation.address, pendingActivation.Serialize())); + var state = new MockStateDelta( + MockState.Empty + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) + .SetState(pendingActivation.address, pendingActivation.Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() @@ -72,10 +73,10 @@ public void ExecuteWithInvalidSignature() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - .Add(pendingActivation.address, pendingActivation.Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) + .SetState(pendingActivation.address, pendingActivation.Serialize())); // 잘못된 논스를 넣습니다. ActivateAccount0 action = activationKey.CreateActivateAccount0(new byte[] { 0x00, }); @@ -99,8 +100,9 @@ public void ExecuteWithNonExistsPending() ActivationKey.Create(privateKey, nonce); // state에는 pendingActivation에 해당하는 대기가 없는 상태를 가정합니다. - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); + var state = new MockStateDelta( + MockState.Empty + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); Assert.Throws(() => @@ -144,9 +146,10 @@ public void ForbidReusingActivationKey() var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - .Add(pendingActivation.address, pendingActivation.Serialize())); + var state = new MockStateDelta( + MockState.Empty + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) + .SetState(pendingActivation.address, pendingActivation.Serialize())); ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce); IAccountStateDelta nextState = action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index 0e7078bae9..da193f5666 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -15,10 +15,9 @@ public void Execute() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); var state = new MockStateDelta( - ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize()) + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); @@ -45,10 +44,9 @@ public void Rehearsal() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); var state = new MockStateDelta( - ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize()) + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); @@ -96,10 +94,9 @@ public void CheckPermission() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); var state = new MockStateDelta( - ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize()) + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize())); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount0(newComer); diff --git a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs index 6e056a4bf2..a51eef78e1 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs @@ -21,9 +21,8 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); var state = new MockStateDelta( - ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize())); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var activatedAddress = newComer.Derive(ActivationKey.DeriveKey); if (alreadyActivated) @@ -62,9 +61,8 @@ public void Rehearsal() { var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); var state = new MockStateDelta( - ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize())); var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var action = new AddActivatedAccount(newComer); diff --git a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs index fc5bec5958..a97adb41a1 100644 --- a/.Lib9c.Tests/Action/AddRedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/AddRedeemCodeTest.cs @@ -17,8 +17,8 @@ public void CheckPermission() { var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var initStates = ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()); + var initStates = MockState.Empty + .SetState(AdminState.Address, adminState.Serialize()); var state = new MockStateDelta(initStates); var action = new AddRedeemCode { diff --git a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs index 8a371e91e3..9653954de4 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationTest.cs @@ -24,9 +24,9 @@ public void Execute() var action = new CreatePendingActivation(pendingActivation); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, adminState.Serialize())); var actionContext = new ActionContext() { BlockIndex = 1, @@ -52,9 +52,9 @@ public void CheckPermission() var action = new CreatePendingActivation(pendingActivation); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, adminState.Serialize())); Assert.Throws( () => action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs index 7c1a676497..209484aead 100644 --- a/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs +++ b/.Lib9c.Tests/Action/CreatePendingActivationsTest.cs @@ -28,9 +28,9 @@ PendingActivationState CreatePendingActivation() var action = new CreatePendingActivations(activations); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, adminState.Serialize())); var actionContext = new ActionContext() { BlockIndex = 1, @@ -79,9 +79,9 @@ public void CheckPermission() var action = new CreatePendingActivations(); var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, adminState.Serialize())); Assert.Throws( () => action.Execute(new ActionContext() diff --git a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs index 4a96695023..79bb17a33e 100644 --- a/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationActivatedAccountsStateTest.cs @@ -17,10 +17,10 @@ public void Execute() { var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - .Add(ActivatedAccountsState.Address, new ActivatedAccountsState().AddAccount(default).Serialize()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize()) + .SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().AddAccount(default).Serialize())); var action = new MigrationActivatedAccountsState(); diff --git a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs index 8ab262b29c..50c9b6be89 100644 --- a/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs +++ b/.Lib9c.Tests/Action/MigrationAvatarStateTest.cs @@ -34,10 +34,10 @@ public void Execute() ); var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7"); - var state = new MockStateDelta(ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(admin, 100).Serialize()) - .Add(avatarAddress, avatarState.SerializeV2()) - ); + var state = new MockStateDelta( + MockState.Empty + .SetState(AdminState.Address, new AdminState(admin, 100).Serialize()) + .SetState(avatarAddress, avatarState.SerializeV2())); var action = new MigrationAvatarState { diff --git a/.Lib9c.Tests/Action/MockState.cs b/.Lib9c.Tests/Action/MockState.cs index c12d2117b6..b97cc986f9 100644 --- a/.Lib9c.Tests/Action/MockState.cs +++ b/.Lib9c.Tests/Action/MockState.cs @@ -50,12 +50,13 @@ namespace Lib9c.Tests.Action /// public class MockState : IAccountState { + private static readonly MockState _empty = new MockState(); private readonly IImmutableDictionary _states; private readonly IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; private readonly IImmutableDictionary _totalSupplies; private readonly ValidatorSet _validatorSet; - public MockState() + private MockState() : this( ImmutableDictionary.Empty, ImmutableDictionary<(Address Address, Currency Currency), BigInteger>.Empty, @@ -76,6 +77,16 @@ private MockState( _validatorSet = validatorSet; } + public static MockState Empty => _empty; + + public IImmutableDictionary States => _states; + + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => _fungibles; + + public IImmutableDictionary TotalSupplies => _totalSupplies; + + public ValidatorSet ValidatorSet => _validatorSet; + public IValue? GetState(Address address) => _states.TryGetValue(address, out IValue? value) ? value : null; @@ -185,13 +196,5 @@ public MockState SetValidator(Validator validator) => _fungibles, _totalSupplies, _validatorSet.Update(validator)); - - public IImmutableDictionary States => _states; - - public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => _fungibles; - - public IImmutableDictionary TotalSupplies => _totalSupplies; - - public ValidatorSet ValidatorSet => _validatorSet; } } diff --git a/.Lib9c.Tests/Action/MockStateDelta.cs b/.Lib9c.Tests/Action/MockStateDelta.cs index 9056a4eff0..f50c303e58 100644 --- a/.Lib9c.Tests/Action/MockStateDelta.cs +++ b/.Lib9c.Tests/Action/MockStateDelta.cs @@ -21,11 +21,16 @@ public class MockStateDelta : IAccountStateDelta private readonly IAccountDelta _delta; public MockStateDelta() + : this(MockState.Empty) + { + } + + public MockStateDelta(MockState mockState) : this( - ImmutableDictionary.Empty, - ImmutableDictionary<(Address Address, Currency Currency), BigInteger>.Empty, - ImmutableDictionary.Empty, - new ValidatorSet()) + mockState.States, + mockState.Fungibles, + mockState.TotalSupplies, + mockState.ValidatorSet) { } diff --git a/.Lib9c.Tests/Action/PatchTableSheetTest.cs b/.Lib9c.Tests/Action/PatchTableSheetTest.cs index 05d969366b..82e9d13191 100644 --- a/.Lib9c.Tests/Action/PatchTableSheetTest.cs +++ b/.Lib9c.Tests/Action/PatchTableSheetTest.cs @@ -86,9 +86,9 @@ public void CheckPermission() var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); const string tableName = "TestTable"; - var initStates = ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); + var initStates = MockState.Empty + .SetState(AdminState.Address, adminState.Serialize()) + .SetState(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { @@ -129,9 +129,9 @@ public void ExecuteNewTable() var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); const string tableName = "TestTable"; - var initStates = ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()) - .Add(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); + var initStates = MockState.Empty + .SetState(AdminState.Address, adminState.Serialize()) + .SetState(Addresses.TableSheet.Derive(tableName), Dictionary.Empty.Add(tableName, "Initial")); var state = new MockStateDelta(initStates); var action = new PatchTableSheet() { diff --git a/.Lib9c.Tests/Action/RenewAdminStateTest.cs b/.Lib9c.Tests/Action/RenewAdminStateTest.cs index bdba3ececc..e39425586b 100644 --- a/.Lib9c.Tests/Action/RenewAdminStateTest.cs +++ b/.Lib9c.Tests/Action/RenewAdminStateTest.cs @@ -23,10 +23,9 @@ public RenewAdminStateTest() _adminPrivateKey = new PrivateKey(); _validUntil = 1_500_000L; _adminState = new AdminState(_adminPrivateKey.ToAddress(), _validUntil); - _stateDelta = - new MockStateDelta(ImmutableDictionary.Empty.Add( - Addresses.Admin, - _adminState.Serialize())); + _stateDelta = new MockStateDelta( + MockState.Empty + .SetState(Addresses.Admin, _adminState.Serialize())); } [Fact] diff --git a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs index e1007cc502..25138740ad 100644 --- a/.Lib9c.Tests/Action/SecureMiningRewardTest.cs +++ b/.Lib9c.Tests/Action/SecureMiningRewardTest.cs @@ -35,15 +35,13 @@ public class SecureMiningRewardTest }.ToImmutableList(); private static readonly MockStateDelta _previousState = new MockStateDelta( - states: ImmutableDictionary.Empty - .Add(AdminState.Address, new AdminState(_admin, 100).Serialize()) - .Add(GoldCurrencyState.Address, new GoldCurrencyState(NCG).Serialize()), - balances: ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_authMiners[0], NCG), NCG * 1000) - .Add((_authMiners[1], NCG), NCG * 2000) - .Add((_authMiners[2], NCG), NCG * 3000) - .Add((_authMiners[3], NCG), NCG * 4000) - ); + MockState.Empty + .SetState(AdminState.Address, new AdminState(_admin, 100).Serialize()) + .SetState(GoldCurrencyState.Address, new GoldCurrencyState(NCG).Serialize()) + .SetBalance(_authMiners[0], NCG * 1000) + .SetBalance(_authMiners[1], NCG * 2000) + .SetBalance(_authMiners[2], NCG * 3000) + .SetBalance(_authMiners[3], NCG * 4000)); [Fact] public void Execute() diff --git a/.Lib9c.Tests/Action/TransferAsset2Test.cs b/.Lib9c.Tests/Action/TransferAsset2Test.cs index 2daa5a0b2b..d19187dbef 100644 --- a/.Lib9c.Tests/Action/TransferAsset2Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset2Test.cs @@ -48,15 +48,11 @@ public void Constructor_ThrowsMemoLengthOverflowException() [Fact] public void Execute() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, @@ -77,12 +73,10 @@ public void Execute() [Fact] public void ExecuteWithInvalidSigner() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, @@ -109,11 +103,9 @@ public void ExecuteWithInvalidSigner() [Fact] public void ExecuteWithInvalidRecipient() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000)); // Should not allow TransferAsset2 with same sender and recipient. var action = new TransferAsset2( sender: _sender, @@ -148,12 +140,10 @@ public void ExecuteWithInvalidRecipient() [Fact] public void ExecuteWithInsufficientBalance() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, @@ -179,12 +169,10 @@ public void ExecuteWithMinterAsSender() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyBySender = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, @@ -213,12 +201,10 @@ public void ExecuteWithMinterAsRecipient() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyByRecipient = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyByRecipient), _currency * 1000) - .Add((_recipient, currencyByRecipient), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, currencyByRecipient * 1000) + .SetBalance(_sender, currencyByRecipient * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, @@ -244,16 +230,12 @@ public void ExecuteWithMinterAsRecipient() public void ExecuteWithUnactivatedRecipient() { var activatedAddress = new ActivatedAccountsState().AddAccount(new PrivateKey().ToAddress()); - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty - .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) - .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetState(Addresses.ActivatedAccount, activatedAddress.Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset2( sender: _sender, recipient: _recipient, diff --git a/.Lib9c.Tests/Action/TransferAsset3Test.cs b/.Lib9c.Tests/Action/TransferAsset3Test.cs index e199816630..5f3a883d35 100644 --- a/.Lib9c.Tests/Action/TransferAsset3Test.cs +++ b/.Lib9c.Tests/Action/TransferAsset3Test.cs @@ -57,31 +57,28 @@ public void Constructor_ThrowsMemoLengthOverflowException() [InlineData(false, false, true)] public void Execute(bool activate, bool legacyActivate, bool stateExist) { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty; + var mockState = MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10); + if (activate) { - state = state.Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); + mockState = mockState.SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); } if (legacyActivate) { var activatedAccountState = new ActivatedAccountsState(); activatedAccountState = activatedAccountState.AddAccount(_recipient); - state = state.Add(activatedAccountState.address, activatedAccountState.Serialize()); + mockState = mockState.SetState(activatedAccountState.address, activatedAccountState.Serialize()); } if (stateExist) { - state = state.Add(_recipient, new AgentState(_recipient).Serialize()); + mockState = mockState.SetState(_recipient, new AgentState(_recipient).Serialize()); } - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + var prevState = new MockStateDelta(mockState); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -102,12 +99,10 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) [Fact] public void ExecuteWithInvalidSigner() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -137,8 +132,9 @@ public void ExecuteWithInvalidRecipient() var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty .Add((_sender, _currency), _currency * 1000); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000)); + // Should not allow TransferAsset with same sender and recipient. var action = new TransferAsset3( sender: _sender, @@ -164,12 +160,11 @@ public void ExecuteWithInvalidRecipient() [Fact] public void ExecuteWithInsufficientBalance() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)) + .SetState(_recipient, new AgentState(_recipient).Serialize()); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -195,12 +190,11 @@ public void ExecuteWithMinterAsSender() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyBySender = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10)); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -229,12 +223,11 @@ public void ExecuteWithMinterAsRecipient() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyByRecipient = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyByRecipient), _currency * 1000) - .Add((_recipient, currencyByRecipient), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetBalance(_sender, currencyByRecipient * 1000) + .SetBalance(_recipient, currencyByRecipient * 10) + .SetState(_recipient, new AgentState(_recipient).Serialize())); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -260,16 +253,12 @@ public void ExecuteWithMinterAsRecipient() public void ExecuteWithUnactivatedRecipient() { var activatedAddress = new ActivatedAccountsState().AddAccount(new PrivateKey().ToAddress()); - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty - .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) - .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetState(Addresses.ActivatedAccount, activatedAddress.Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset3( sender: _sender, recipient: _recipient, @@ -369,15 +358,10 @@ public void LoadPlainValue(string memo) public void Execute_Throw_InvalidTransferCurrencyException() { var crystal = CrystalCalculator.CRYSTAL; - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, crystal), crystal * 1000); - var state = ImmutableDictionary.Empty - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetBalance(_sender, crystal * 1000)); var action = new TransferAsset3( sender: _sender, recipient: _recipient, diff --git a/.Lib9c.Tests/Action/TransferAssetTest.cs b/.Lib9c.Tests/Action/TransferAssetTest.cs index 309fdee706..5afe13a202 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest.cs @@ -51,15 +51,10 @@ public void Execute() { var contractAddress = _sender.Derive(nameof(RequestPledge)); var patronAddress = new PrivateKey().ToAddress(); - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty; - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset( sender: _sender, recipient: _recipient, @@ -80,13 +75,11 @@ public void Execute() [Fact] public void Execute_Throw_InvalidTransferSignerException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10) - .Add((_sender, Currencies.Mead), Currencies.Mead * 1); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10) + .SetBalance(_sender, Currencies.Mead * 1)); var action = new TransferAsset( sender: _sender, recipient: _recipient, @@ -113,12 +106,10 @@ public void Execute_Throw_InvalidTransferSignerException() [Fact] public void Execute_Throw_InvalidTransferRecipientException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_sender, Currencies.Mead), Currencies.Mead * 1); var prevState = new MockStateDelta( - balances: balance - ); + 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, @@ -144,13 +135,11 @@ public void Execute_Throw_InvalidTransferRecipientException() [Fact] public void Execute_Throw_InsufficientBalanceException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset( sender: _sender, recipient: _recipient, @@ -182,13 +171,12 @@ public void Execute_Throw_InvalidTransferMinterException(bool minterAsSender) // 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 balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10) - .Add((_sender, Currencies.Mead), Currencies.Mead * 1); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + 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, @@ -291,16 +279,11 @@ public void LoadPlainValue(string memo) public void Execute_Throw_InvalidTransferCurrencyException() { var crystal = CrystalCalculator.CRYSTAL; - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, crystal), crystal * 1000) - .Add((_sender, Currencies.Mead), Currencies.Mead * 1); - var state = ImmutableDictionary.Empty - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + 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, diff --git a/.Lib9c.Tests/Action/TransferAssetTest0.cs b/.Lib9c.Tests/Action/TransferAssetTest0.cs index 8be009e55f..85f6a33328 100644 --- a/.Lib9c.Tests/Action/TransferAssetTest0.cs +++ b/.Lib9c.Tests/Action/TransferAssetTest0.cs @@ -46,12 +46,10 @@ public void Constructor_ThrowsMemoLengthOverflowException() [Fact] public void Execute() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset0( sender: _sender, recipient: _recipient, @@ -72,12 +70,10 @@ public void Execute() [Fact] public void ExecuteWithInvalidSigner() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset0( sender: _sender, recipient: _recipient, @@ -104,11 +100,9 @@ public void ExecuteWithInvalidSigner() [Fact] public void ExecuteWithInvalidRecipient() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000)); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAsset0( sender: _sender, @@ -143,12 +137,10 @@ public void ExecuteWithInvalidRecipient() [Fact] public void ExecuteWithInsufficientBalance() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAsset0( sender: _sender, recipient: _recipient, @@ -174,12 +166,10 @@ public void ExecuteWithMinterAsSender() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyBySender = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10)); var action = new TransferAsset0( sender: _sender, recipient: _recipient, @@ -208,12 +198,10 @@ public void ExecuteWithMinterAsRecipient() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyByRecipient = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyByRecipient), _currency * 1000) - .Add((_recipient, currencyByRecipient), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, currencyByRecipient * 1000) + .SetBalance(_recipient, currencyByRecipient * 10)); var action = new TransferAsset0( sender: _sender, recipient: _recipient, diff --git a/.Lib9c.Tests/Action/TransferAssets0Test.cs b/.Lib9c.Tests/Action/TransferAssets0Test.cs index 17856d17de..bef3f642d0 100644 --- a/.Lib9c.Tests/Action/TransferAssets0Test.cs +++ b/.Lib9c.Tests/Action/TransferAssets0Test.cs @@ -73,15 +73,14 @@ public void Constructor_ThrowsMemoLengthOverflowException() [InlineData(false, false, true)] public void Execute(bool activate, bool legacyActivate, bool stateExist) { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty; + var mockState = MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10); if (activate) { - state = state - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) - .Add(_recipient2.Derive(ActivationKey.DeriveKey), true.Serialize()); + mockState = mockState + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetState(_recipient2.Derive(ActivationKey.DeriveKey), true.Serialize()); } if (legacyActivate) @@ -90,20 +89,17 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) activatedAccountState = activatedAccountState .AddAccount(_recipient) .AddAccount(_recipient2); - state = state.Add(activatedAccountState.address, activatedAccountState.Serialize()); + mockState = mockState.SetState(activatedAccountState.address, activatedAccountState.Serialize()); } if (stateExist) { - state = state - .Add(_recipient, new AgentState(_recipient).Serialize()) - .Add(_recipient2, new AgentState(_recipient2).Serialize()); + mockState = mockState + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetState(_recipient2, new AgentState(_recipient2).Serialize()); } - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + var prevState = new MockStateDelta(mockState); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -128,12 +124,10 @@ public void Execute(bool activate, bool legacyActivate, bool stateExist) [Fact] public void ExecuteWithInvalidSigner() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -162,11 +156,9 @@ public void ExecuteWithInvalidSigner() [Fact] public void ExecuteWithInvalidRecipient() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000)); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAssets0( sender: _sender, @@ -194,12 +186,11 @@ public void ExecuteWithInvalidRecipient() [Fact] public void ExecuteWithInsufficientBalance() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -227,12 +218,11 @@ public void ExecuteWithMinterAsSender() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyBySender = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10)); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -263,12 +253,11 @@ public void ExecuteWithMinterAsRecipient() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyByRecipient = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyByRecipient), _currency * 1000) - .Add((_recipient, currencyByRecipient), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, currencyByRecipient * 1000) + .SetBalance(_recipient, currencyByRecipient * 10)); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -296,16 +285,12 @@ public void ExecuteWithMinterAsRecipient() public void ExecuteWithUnactivatedRecipient() { var activatedAddress = new ActivatedAccountsState().AddAccount(new PrivateKey().ToAddress()); - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty - .Add(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) - .Add(Addresses.ActivatedAccount, activatedAddress.Serialize()); var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_sender.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetState(Addresses.ActivatedAccount, activatedAddress.Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets0( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -484,15 +469,10 @@ public void Execute_Throw_ArgumentOutOfRangeException() public void Execute_Throw_InvalidTransferCurrencyException() { var crystal = CrystalCalculator.CRYSTAL; - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, crystal), crystal * 1000); - var state = ImmutableDictionary.Empty - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetBalance(_sender, crystal * 1000)); var action = new TransferAssets0( sender: _sender, recipients: new List<(Address, FungibleAssetValue)> diff --git a/.Lib9c.Tests/Action/TransferAssetsTest.cs b/.Lib9c.Tests/Action/TransferAssetsTest.cs index 0957e9aaee..c5ea63e106 100644 --- a/.Lib9c.Tests/Action/TransferAssetsTest.cs +++ b/.Lib9c.Tests/Action/TransferAssetsTest.cs @@ -67,15 +67,10 @@ public void Execute() { var contractAddress = _sender.Derive(nameof(RequestPledge)); var patronAddress = new PrivateKey().ToAddress(); - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var state = ImmutableDictionary.Empty; - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -102,12 +97,10 @@ public void Execute() [Fact] public void Execute_Throw_InvalidTransferSignerException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -136,11 +129,9 @@ public void Execute_Throw_InvalidTransferSignerException() [Fact] public void Execute_Throw_InvalidTransferRecipientException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000); var prevState = new MockStateDelta( - balances: balance - ); + MockState.Empty + .SetBalance(_sender, _currency * 1000)); // Should not allow TransferAsset with same sender and recipient. var action = new TransferAssets( sender: _sender, @@ -168,13 +159,11 @@ public void Execute_Throw_InvalidTransferRecipientException() [Fact] public void Execute_Throw_InsufficientBalanceException() { - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, _currency), _currency * 1000) - .Add((_recipient, _currency), _currency * 10); - var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, _currency * 1000) + .SetBalance(_recipient, _currency * 10)); var action = new TransferAssets( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -205,12 +194,11 @@ public void Execute_Throw_InvalidTransferMinterException() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 var currencyBySender = Currency.Legacy("NCG", 2, _sender); #pragma warning restore CS0618 - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, currencyBySender), _currency * 1000) - .Add((_recipient, currencyBySender), _currency * 10); var prevState = new MockStateDelta( - balances: balance - ).SetState(_recipient, new AgentState(_recipient).Serialize()); + MockState.Empty + .SetState(_recipient, new AgentState(_recipient).Serialize()) + .SetBalance(_sender, currencyBySender * 1000) + .SetBalance(_recipient, currencyBySender * 10)); var action = new TransferAssets( sender: _sender, new List<(Address, FungibleAssetValue)> @@ -391,15 +379,10 @@ public void Execute_Throw_ArgumentOutOfRangeException() public void Execute_Throw_InvalidTransferCurrencyException() { var crystal = CrystalCalculator.CRYSTAL; - var balance = ImmutableDictionary<(Address, Currency), FungibleAssetValue>.Empty - .Add((_sender, crystal), crystal * 1000); - var state = ImmutableDictionary.Empty - .Add(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()); - var prevState = new MockStateDelta( - states: state, - balances: balance - ); + MockState.Empty + .SetState(_recipient.Derive(ActivationKey.DeriveKey), true.Serialize()) + .SetBalance(_sender, crystal * 1000)); var action = new TransferAssets( sender: _sender, recipients: new List<(Address, FungibleAssetValue)> diff --git a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs index e067471efa..abeaec3373 100644 --- a/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs +++ b/.Lib9c.Tests/Action/ValidatorSetOperateTest.cs @@ -44,12 +44,9 @@ public void CheckPermission() { var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var initStates = - ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()); - var state = new MockStateDelta( - initStates, - validatorSet: new ValidatorSet()); + var initStates = MockState.Empty + .SetState(AdminState.Address, adminState.Serialize()); + var state = new MockStateDelta(initStates); var action = ValidatorSetOperate.Append(_validator); var nextState = action.Execute( new ActionContext() @@ -68,12 +65,9 @@ public void CheckPermission_Throws_PermissionDenied() { var adminAddress = new Address("399bddF9F7B6d902ea27037B907B2486C9910730"); var adminState = new AdminState(adminAddress, 100); - var initStates = - ImmutableDictionary.Empty - .Add(AdminState.Address, adminState.Serialize()); - var state = new MockStateDelta( - initStates, - validatorSet: new ValidatorSet()); + var initStates = MockState.Empty + .SetState(AdminState.Address, adminState.Serialize()); + var state = new MockStateDelta(initStates); var action = ValidatorSetOperate.Append(_validator); PermissionDeniedException exc1 = Assert.Throws(() => From dd9c1b2cb32920aa5f0fb36e5ced315f403a5eb8 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 4 Jul 2023 18:04:53 +0900 Subject: [PATCH 42/68] Make `ITradableFungibleItem` to `IFungibleItem` on `UnloadFromMyGarages` action --- .../Action/Garages/UnloadFromMyGaragesTest.cs | 43 +++++-------------- Lib9c/Action/Garages/UnloadFromMyGarages.cs | 4 +- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index 1e7467fc92..76391fe380 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -36,7 +36,7 @@ public class UnloadFromMyGaragesTest private readonly Address _recipientAvatarAddr; private readonly (Address balanceAddr, FungibleAssetValue value)[] _fungibleAssetValues; private readonly (HashDigest fungibleId, int count)[] _fungibleIdAndCounts; - private readonly ITradableFungibleItem[] _tradableFungibleItems; + private readonly IFungibleItem[] _fungibleItems; private readonly IAccountStateDelta _previousStates; public UnloadFromMyGaragesTest() @@ -56,7 +56,7 @@ public UnloadFromMyGaragesTest() _recipientAvatarAddr, _fungibleAssetValues, _fungibleIdAndCounts, - _tradableFungibleItems, + _fungibleItems, _previousStates ) = GetSuccessfulPreviousStatesWithPlainValue(); } @@ -167,9 +167,8 @@ public void Execute_Success() AgentAddr, fungibleId); Assert.True(nextStates.GetState(garageAddr) is Null); - Assert.True(inventory.HasTradableFungibleItem( + Assert.True(inventory.HasFungibleItem( fungibleId, - requiredBlockIndex: null, blockIndex: 0, count)); } @@ -335,24 +334,6 @@ public void Execute_Throws_Exception() _fungibleIdAndCounts)); } } - - // Inventory can be overflowed. - for (var i = 0; i < _fungibleIdAndCounts.Length; i++) - { - var item = _tradableFungibleItems[i]; - var inventory = _previousStates.GetInventory(inventoryAddr); - inventory.AddTradableFungibleItem(item, int.MaxValue); - var previousStatesWithInvalidGarageState = - _previousStates.SetState(inventoryAddr, inventory.Serialize()); - Assert.Throws(() => Execute( - AgentAddr, - 0, - previousStatesWithInvalidGarageState, - new TestRandom(), - _recipientAvatarAddr, - null, - _fungibleIdAndCounts)); - } } private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execute( @@ -407,7 +388,7 @@ private static (Address balanceAddr, FungibleAssetValue value)[] Address recipientAvatarAddr, (Address balanceAddr, FungibleAssetValue value)[] fungibleAssetValues, (HashDigest fungibleId, int count)[] fungibleIdAndCounts, - ITradableFungibleItem[] _tradableFungibleItems, + IFungibleItem[] _fungibleItems, IAccountStateDelta previousStates) GetSuccessfulPreviousStatesWithPlainValue() { @@ -437,29 +418,27 @@ private static (Address balanceAddr, FungibleAssetValue value)[] var fungibleItemAndCounts = _tableSheets.MaterialItemSheet.OrderedList! .Take(3) - .Select(ItemFactory.CreateTradableMaterial) - .Select((tradableMaterial, index) => + .Select(ItemFactory.CreateMaterial) + .Select((material, index) => { var garageAddr = Addresses.GetGarageAddress( AgentAddr, - tradableMaterial.FungibleId); + material.FungibleId); var count = index + 1; - var garage = new FungibleItemGarage(tradableMaterial, count); + var garage = new FungibleItemGarage(material, count); previousStates = previousStates.SetState( garageAddr, garage.Serialize()); - return ( - tradableFungibleItem: (ITradableFungibleItem)tradableMaterial, - count); + return (fungibleItem: (IFungibleItem)material, count); }).ToArray(); return ( recipientAvatarAddr: AvatarAddr, fungibleAssetValues, fungibleItemAndCounts - .Select(tuple => (tuple.tradableFungibleItem.FungibleId, tuple.count)) + .Select(tuple => (tuple.fungibleItem.FungibleId, tuple.count)) .ToArray(), - fungibleItemAndCounts.Select(tuple => tuple.tradableFungibleItem).ToArray(), + fungibleItemAndCounts.Select(tuple => tuple.fungibleItem).ToArray(), previousStates ); } diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index 991a1f82d8..8bb072e261 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -207,9 +207,7 @@ private IAccountStateDelta TransferFungibleItems( foreach (var (_, count, garageAddr, garage) in fungibleItemTuples) { garage.Unload(count); - inventory.AddTradableFungibleItem( - (ITradableFungibleItem)garage.Item, - count); + inventory.AddFungibleItem((ItemBase)garage.Item, count); states = states.SetState(garageAddr, garage.Serialize()); } From f2e1c339c3208d36b2ba67f9430873f9ed7b356c Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 3 Jul 2023 15:33:25 +0900 Subject: [PATCH 43/68] Backup CreateAvatar8 --- .Lib9c.Tests/Action/CreateAvatar8Test.cs | 307 +++++++++++++++++++++++ Lib9c/Action/CreateAvatar8.cs | 273 ++++++++++++++++++++ 2 files changed, 580 insertions(+) create mode 100644 .Lib9c.Tests/Action/CreateAvatar8Test.cs create mode 100644 Lib9c/Action/CreateAvatar8.cs diff --git a/.Lib9c.Tests/Action/CreateAvatar8Test.cs b/.Lib9c.Tests/Action/CreateAvatar8Test.cs new file mode 100644 index 0000000000..997c93b62a --- /dev/null +++ b/.Lib9c.Tests/Action/CreateAvatar8Test.cs @@ -0,0 +1,307 @@ +namespace Lib9c.Tests.Action +{ + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Runtime.Serialization.Formatters.Binary; + using Libplanet; + using Libplanet.Assets; + using Nekoyume; + using Nekoyume.Action; + using Nekoyume.Helper; + using Nekoyume.Model.State; + using Nekoyume.TableData; + using Xunit; + using static Lib9c.SerializeKeys; + + public class CreateAvatar8Test + { + private readonly Address _agentAddress; + private readonly TableSheets _tableSheets; + + public CreateAvatar8Test() + { + _agentAddress = default; + _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); + } + + [Fact] + public void Execute() + { + var action = new CreateAvatar8() + { + index = 0, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = "test", + }; + + var sheets = TableSheetsImporter.ImportSheets(); + var state = new State() + .SetState( + Addresses.GameConfig, + new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() + ); + + foreach (var (key, value) in sheets) + { + state = state.SetState(Addresses.TableSheet.Derive(key), value.Serialize()); + } + + Assert.Equal(0 * CrystalCalculator.CRYSTAL, state.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); + + var nextState = action.Execute(new ActionContext() + { + PreviousStates = state, + Signer = _agentAddress, + BlockIndex = 0, + }); + + var avatarAddress = _agentAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CreateAvatar2.DeriveFormat, + 0 + ) + ); + Assert.True(nextState.TryGetAgentAvatarStatesV2( + default, + avatarAddress, + out var agentState, + out var nextAvatarState, + out _) + ); + Assert.True(agentState.avatarAddresses.Any()); + Assert.Equal("test", nextAvatarState.name); + Assert.Equal(50 * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); + } + + [Theory] + [InlineData("홍길동")] + [InlineData("山田太郎")] + public void ExecuteThrowInvalidNamePatterException(string nickName) + { + var agentAddress = default(Address); + + var action = new CreateAvatar8() + { + index = 0, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = nickName, + }; + + var state = new State(); + + Assert.Throws(() => action.Execute(new ActionContext() + { + PreviousStates = state, + Signer = agentAddress, + BlockIndex = 0, + }) + ); + } + + [Fact] + public void ExecuteThrowInvalidAddressException() + { + var avatarAddress = _agentAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CreateAvatar2.DeriveFormat, + 0 + ) + ); + + var avatarState = new AvatarState( + avatarAddress, + _agentAddress, + 0, + _tableSheets.GetAvatarSheets(), + new GameConfigState(), + default + ); + + var action = new CreateAvatar8() + { + index = 0, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = "test", + }; + + var state = new State().SetState(avatarAddress, avatarState.Serialize()); + + Assert.Throws(() => action.Execute(new ActionContext() + { + PreviousStates = state, + Signer = _agentAddress, + BlockIndex = 0, + }) + ); + } + + [Theory] + [InlineData(-1)] + [InlineData(3)] + public void ExecuteThrowAvatarIndexOutOfRangeException(int index) + { + var agentState = new AgentState(_agentAddress); + var state = new State().SetState(_agentAddress, agentState.Serialize()); + var action = new CreateAvatar8() + { + index = index, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = "test", + }; + + Assert.Throws(() => action.Execute(new ActionContext + { + PreviousStates = state, + Signer = _agentAddress, + BlockIndex = 0, + }) + ); + } + + [Theory] + [InlineData(0)] + [InlineData(1)] + [InlineData(2)] + public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) + { + var agentState = new AgentState(_agentAddress); + var avatarAddress = _agentAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CreateAvatar2.DeriveFormat, + 0 + ) + ); + agentState.avatarAddresses[index] = avatarAddress; + var state = new State().SetState(_agentAddress, agentState.Serialize()); + + var action = new CreateAvatar8() + { + index = index, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = "test", + }; + + Assert.Throws(() => action.Execute(new ActionContext() + { + PreviousStates = state, + Signer = _agentAddress, + BlockIndex = 0, + }) + ); + } + + [Theory] + [InlineData(0)] + [InlineData(1)] + [InlineData(2)] + public void Rehearsal(int index) + { + var agentAddress = default(Address); + var avatarAddress = _agentAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CreateAvatar2.DeriveFormat, + index + ) + ); + + var action = new CreateAvatar8() + { + index = index, + hair = 0, + ear = 0, + lens = 0, + tail = 0, + name = "test", + }; + +#pragma warning disable CS0618 + // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 + var gold = new GoldCurrencyState(Currency.Legacy("NCG", 2, null)); +#pragma warning restore CS0618 + var updatedAddresses = new List
() + { + agentAddress, + avatarAddress, + avatarAddress.Derive(LegacyInventoryKey), + avatarAddress.Derive(LegacyQuestListKey), + avatarAddress.Derive(LegacyWorldInformationKey), + }; + for (var i = 0; i < AvatarState.CombinationSlotCapacity; i++) + { + var slotAddress = avatarAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CombinationSlotState.DeriveFormat, + i + ) + ); + updatedAddresses.Add(slotAddress); + } + + var state = new State(); + + var nextState = action.Execute(new ActionContext() + { + PreviousStates = state, + Signer = agentAddress, + BlockIndex = 0, + Rehearsal = true, + }); + + Assert.Equal( + updatedAddresses.ToImmutableHashSet(), + nextState.UpdatedAddresses + ); + } + + [Fact] + public void Serialize_With_DotnetAPI() + { + var formatter = new BinaryFormatter(); + var action = new CreateAvatar8() + { + index = 2, + hair = 1, + ear = 4, + lens = 5, + tail = 7, + name = "test", + }; + + using var ms = new MemoryStream(); + formatter.Serialize(ms, action); + + ms.Seek(0, SeekOrigin.Begin); + var deserialized = (CreateAvatar8)formatter.Deserialize(ms); + + Assert.Equal(2, deserialized.index); + Assert.Equal(1, deserialized.hair); + Assert.Equal(4, deserialized.ear); + Assert.Equal(5, deserialized.lens); + Assert.Equal(7, deserialized.tail); + Assert.Equal("test", deserialized.name); + } + } +} diff --git a/Lib9c/Action/CreateAvatar8.cs b/Lib9c/Action/CreateAvatar8.cs new file mode 100644 index 0000000000..dfdea25640 --- /dev/null +++ b/Lib9c/Action/CreateAvatar8.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; +using Bencodex.Types; +using Lib9c.Abstractions; +using Libplanet.Action; +using Libplanet.State; +using Nekoyume.Helper; +using Nekoyume.Model.Item; +using Nekoyume.Model.Skill; +using Nekoyume.Model.Stat; +using Nekoyume.Model.State; +using Nekoyume.TableData; +using Nekoyume.TableData.Pet; +using Serilog; +using static Lib9c.SerializeKeys; + +namespace Nekoyume.Action +{ + /// + /// Hard forked at https://github.com/planetarium/lib9c/pull/1158 + /// Updated at https://github.com/planetarium/lib9c/pull/1158 + /// + [Serializable] + [ActionType("create_avatar8")] + public class CreateAvatar8 : GameAction, ICreateAvatarV2 + { + public const string DeriveFormat = "avatar-state-{0}"; + + public int index; + public int hair; + public int lens; + public int ear; + public int tail; + public string name; + + int ICreateAvatarV2.Index => index; + int ICreateAvatarV2.Hair => hair; + int ICreateAvatarV2.Lens => lens; + int ICreateAvatarV2.Ear => ear; + int ICreateAvatarV2.Tail => tail; + string ICreateAvatarV2.Name => name; + + protected override IImmutableDictionary PlainValueInternal => new Dictionary() + { + ["index"] = (Integer) index, + ["hair"] = (Integer) hair, + ["lens"] = (Integer) lens, + ["ear"] = (Integer) ear, + ["tail"] = (Integer) tail, + ["name"] = (Text) name, + }.ToImmutableDictionary(); + + protected override void LoadPlainValueInternal(IImmutableDictionary plainValue) + { + index = (int) ((Integer) plainValue["index"]).Value; + hair = (int) ((Integer) plainValue["hair"]).Value; + lens = (int) ((Integer) plainValue["lens"]).Value; + ear = (int) ((Integer) plainValue["ear"]).Value; + tail = (int) ((Integer) plainValue["tail"]).Value; + name = (Text) plainValue["name"]; + } + + public override IAccountStateDelta Execute(IActionContext context) + { + context.UseGas(1); + IActionContext ctx = context; + var signer = ctx.Signer; + var states = ctx.PreviousStates; + var avatarAddress = signer.Derive( + string.Format( + CultureInfo.InvariantCulture, + DeriveFormat, + index + ) + ); + var inventoryAddress = avatarAddress.Derive(LegacyInventoryKey); + var worldInformationAddress = avatarAddress.Derive(LegacyWorldInformationKey); + var questListAddress = avatarAddress.Derive(LegacyQuestListKey); + if (ctx.Rehearsal) + { + states = states.SetState(signer, MarkChanged); + for (var i = 0; i < AvatarState.CombinationSlotCapacity; i++) + { + var slotAddress = avatarAddress.Derive( + string.Format( + CultureInfo.InvariantCulture, + CombinationSlotState.DeriveFormat, + i + ) + ); + states = states.SetState(slotAddress, MarkChanged); + } + + return states + .SetState(avatarAddress, MarkChanged) + .SetState(inventoryAddress, MarkChanged) + .SetState(worldInformationAddress, MarkChanged) + .SetState(questListAddress, MarkChanged) + .MarkBalanceChanged(ctx, GoldCurrencyMock, signer); + } + + var addressesHex = GetSignerAndOtherAddressesHex(context, avatarAddress); + + if (!Regex.IsMatch(name, GameConfig.AvatarNickNamePattern)) + { + throw new InvalidNamePatternException( + $"{addressesHex}Aborted as the input name {name} does not follow the allowed name pattern."); + } + + var sw = new Stopwatch(); + sw.Start(); + var started = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}CreateAvatar exec started", addressesHex); + AgentState existingAgentState = states.GetAgentState(signer); + var agentState = existingAgentState ?? new AgentState(signer); + var avatarState = states.GetAvatarState(avatarAddress); + if (!(avatarState is null)) + { + throw new InvalidAddressException( + $"{addressesHex}Aborted as there is already an avatar at {avatarAddress}."); + } + + if (!(0 <= index && index < GameConfig.SlotCount)) + { + throw new AvatarIndexOutOfRangeException( + $"{addressesHex}Aborted as the index is out of range #{index}."); + } + + if (agentState.avatarAddresses.ContainsKey(index)) + { + throw new AvatarIndexAlreadyUsedException( + $"{addressesHex}Aborted as the signer already has an avatar at index #{index}."); + } + sw.Stop(); + Log.Verbose("{AddressesHex}CreateAvatar Get AgentAvatarStates: {Elapsed}", addressesHex, sw.Elapsed); + sw.Restart(); + + Log.Verbose("{AddressesHex}Execute CreateAvatar; player: {AvatarAddress}", addressesHex, avatarAddress); + + agentState.avatarAddresses.Add(index, avatarAddress); + + // Avoid NullReferenceException in test + var materialItemSheet = ctx.PreviousStates.GetSheet(); + + avatarState = CreateAvatar0.CreateAvatarState(name, avatarAddress, ctx, materialItemSheet, default); + + if (hair < 0) hair = 0; + if (lens < 0) lens = 0; + if (ear < 0) ear = 0; + if (tail < 0) tail = 0; + + avatarState.Customize(hair, lens, ear, tail); + + foreach (var address in avatarState.combinationSlotAddresses) + { + var slotState = + new CombinationSlotState(address, GameConfig.RequireClearedStageLevel.CombinationEquipmentAction); + states = states.SetState(address, slotState.Serialize()); + } + + avatarState.UpdateQuestRewards(materialItemSheet); + + // Add Runes when executing on editor mode. +#if LIB9C_DEV_EXTENSIONS || UNITY_EDITOR + states = CreateAvatar0.AddRunesForTest(avatarAddress, states); + + // Add pets for test + if (states.TryGetSheet(out PetSheet petSheet)) + { + foreach (var row in petSheet) + { + var petState = new PetState(row.Id); + petState.LevelUp(); + var petStateAddress = PetState.DeriveAddress(avatarAddress, row.Id); + states = states.SetState(petStateAddress, petState.Serialize()); + } + } + + var recipeIds = new int[] { + 21, + 62, + 103, + 128, + 148, + 152, + }; + var equipmentSheet = states.GetSheet(); + var recipeSheet = states.GetSheet(); + var subRecipeSheet = states.GetSheet(); + var optionSheet = states.GetSheet(); + var skillSheet = states.GetSheet(); + var characterLevelSheet = states.GetSheet(); + var enhancementCostSheet = states.GetSheet(); + + avatarState.level = 300; + avatarState.exp = characterLevelSheet[300].Exp; + + // prepare equipments for test + foreach (var recipeId in recipeIds) + { + var recipeRow = recipeSheet[recipeId]; + var subRecipeId = recipeRow.SubRecipeIds[1]; + var subRecipeRow = subRecipeSheet[subRecipeId]; + var equipmentRow = equipmentSheet[recipeRow.ResultEquipmentId]; + + var equipment = (Equipment)ItemFactory.CreateItemUsable( + equipmentRow, + context.Random.GenerateRandomGuid(), + 0L, + madeWithMimisbrunnrRecipe: subRecipeRow.IsMimisbrunnrSubRecipe ?? false); + + foreach (var option in subRecipeRow.Options) + { + var optionRow = optionSheet[option.Id]; + // Add stats. + if (optionRow.StatType != StatType.NONE) + { + var statMap = new DecimalStat(optionRow.StatType, optionRow.StatMax); + equipment.StatsMap.AddStatAdditionalValue(statMap.StatType, statMap.TotalValue); + equipment.optionCountFromCombination++; + } + // Add skills. + else + { + var skillRow = skillSheet.OrderedList.First(r => r.Id == optionRow.SkillId); + var skill = SkillFactory.Get( + skillRow, + optionRow.SkillDamageMax, + optionRow.SkillChanceMax, + optionRow.StatDamageRatioMax, + optionRow.ReferencedStatType); + if (skill != null) + { + equipment.Skills.Add(skill); + equipment.optionCountFromCombination++; + } + } + } + + for (int i = 1; i <= 20; ++i) + { + var subType = equipment.ItemSubType; + var grade = equipment.Grade; + var costRow = enhancementCostSheet.Values + .First(x => x.ItemSubType == subType && + x.Grade == grade && + x.Level == i); + equipment.LevelUp(ctx.Random, costRow, true); + } + + avatarState.inventory.AddItem(equipment); + } +#endif + + sw.Stop(); + Log.Verbose("{AddressesHex}CreateAvatar CreateAvatarState: {Elapsed}", addressesHex, sw.Elapsed); + var ended = DateTimeOffset.UtcNow; + Log.Debug("{AddressesHex}CreateAvatar Total Executed Time: {Elapsed}", addressesHex, ended - started); + return states + .SetState(signer, agentState.Serialize()) + .SetState(inventoryAddress, avatarState.inventory.Serialize()) + .SetState(worldInformationAddress, avatarState.worldInformation.Serialize()) + .SetState(questListAddress, avatarState.questList.Serialize()) + .SetState(avatarAddress, avatarState.SerializeV2()) + .MintAsset(ctx, signer, 50 * CrystalCalculator.CRYSTAL); + } + } +} From 1f69041e0605fd1008803139fb8275165ac3798f Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 3 Jul 2023 15:51:16 +0900 Subject: [PATCH 44/68] Increase mint crystal 50 -> 600_000 --- .Lib9c.Tests/Action/CreateAvatarTest.cs | 2 +- Lib9c/Action/CreateAvatar.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.Lib9c.Tests/Action/CreateAvatarTest.cs b/.Lib9c.Tests/Action/CreateAvatarTest.cs index eb05486074..6488b3c24f 100644 --- a/.Lib9c.Tests/Action/CreateAvatarTest.cs +++ b/.Lib9c.Tests/Action/CreateAvatarTest.cs @@ -77,7 +77,7 @@ public void Execute() ); Assert.True(agentState.avatarAddresses.Any()); Assert.Equal("test", nextAvatarState.name); - Assert.Equal(50 * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); + Assert.Equal(600_000 * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); } [Theory] diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 0770e2010f..8211f94bd2 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -22,11 +22,11 @@ namespace Nekoyume.Action { /// - /// Hard forked at https://github.com/planetarium/lib9c/pull/1158 - /// Updated at https://github.com/planetarium/lib9c/pull/1158 + /// Hard forked at https://github.com/planetarium/lib9c/pull/1991 + /// Updated at https://github.com/planetarium/lib9c/pull/1991 /// [Serializable] - [ActionType("create_avatar8")] + [ActionType("create_avatar9")] public class CreateAvatar : GameAction, ICreateAvatarV2 { public const string DeriveFormat = "avatar-state-{0}"; @@ -267,7 +267,7 @@ public override IAccountStateDelta Execute(IActionContext context) .SetState(worldInformationAddress, avatarState.worldInformation.Serialize()) .SetState(questListAddress, avatarState.questList.Serialize()) .SetState(avatarAddress, avatarState.SerializeV2()) - .MintAsset(ctx, signer, 50 * CrystalCalculator.CRYSTAL); + .MintAsset(ctx, signer, 600_000 * CrystalCalculator.CRYSTAL); } } } From 1095da272ab6acd49bfe9f3f071f674c0b63cc11 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 6 Jul 2023 11:47:55 +0900 Subject: [PATCH 45/68] Fix broken build --- .Lib9c.Tests/Action/CreateAvatar8Test.cs | 26 ++++++++++++------------ Lib9c/Action/CreateAvatar8.cs | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.Lib9c.Tests/Action/CreateAvatar8Test.cs b/.Lib9c.Tests/Action/CreateAvatar8Test.cs index 997c93b62a..ada0b0c010 100644 --- a/.Lib9c.Tests/Action/CreateAvatar8Test.cs +++ b/.Lib9c.Tests/Action/CreateAvatar8Test.cs @@ -41,7 +41,7 @@ public void Execute() }; var sheets = TableSheetsImporter.ImportSheets(); - var state = new State() + var state = new MockStateDelta() .SetState( Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() @@ -56,7 +56,7 @@ public void Execute() var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }); @@ -97,11 +97,11 @@ public void ExecuteThrowInvalidNamePatterException(string nickName) name = nickName, }; - var state = new State(); + var state = new MockStateDelta(); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, }) @@ -138,11 +138,11 @@ public void ExecuteThrowInvalidAddressException() name = "test", }; - var state = new State().SetState(avatarAddress, avatarState.Serialize()); + var state = new MockStateDelta().SetState(avatarAddress, avatarState.Serialize()); Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -155,7 +155,7 @@ public void ExecuteThrowInvalidAddressException() public void ExecuteThrowAvatarIndexOutOfRangeException(int index) { var agentState = new AgentState(_agentAddress); - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar8() { index = index, @@ -168,7 +168,7 @@ public void ExecuteThrowAvatarIndexOutOfRangeException(int index) Assert.Throws(() => action.Execute(new ActionContext { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -190,7 +190,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) ) ); agentState.avatarAddresses[index] = avatarAddress; - var state = new State().SetState(_agentAddress, agentState.Serialize()); + var state = new MockStateDelta().SetState(_agentAddress, agentState.Serialize()); var action = new CreateAvatar8() { @@ -204,7 +204,7 @@ public void ExecuteThrowAvatarIndexAlreadyUsedException(int index) Assert.Throws(() => action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = _agentAddress, BlockIndex = 0, }) @@ -260,11 +260,11 @@ public void Rehearsal(int index) updatedAddresses.Add(slotAddress); } - var state = new State(); + var state = new MockStateDelta(); var nextState = action.Execute(new ActionContext() { - PreviousStates = state, + PreviousState = state, Signer = agentAddress, BlockIndex = 0, Rehearsal = true, @@ -272,7 +272,7 @@ public void Rehearsal(int index) Assert.Equal( updatedAddresses.ToImmutableHashSet(), - nextState.UpdatedAddresses + nextState.Delta.UpdatedAddresses ); } diff --git a/Lib9c/Action/CreateAvatar8.cs b/Lib9c/Action/CreateAvatar8.cs index dfdea25640..25b22810d2 100644 --- a/Lib9c/Action/CreateAvatar8.cs +++ b/Lib9c/Action/CreateAvatar8.cs @@ -70,7 +70,7 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); IActionContext ctx = context; var signer = ctx.Signer; - var states = ctx.PreviousStates; + var states = ctx.PreviousState; var avatarAddress = signer.Derive( string.Format( CultureInfo.InvariantCulture, @@ -145,7 +145,7 @@ public override IAccountStateDelta Execute(IActionContext context) agentState.avatarAddresses.Add(index, avatarAddress); // Avoid NullReferenceException in test - var materialItemSheet = ctx.PreviousStates.GetSheet(); + var materialItemSheet = ctx.PreviousState.GetSheet(); avatarState = CreateAvatar0.CreateAvatarState(name, avatarAddress, ctx, materialItemSheet, default); From 9cb41279860a46fd602c0d31230c5205a7a04347 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 4 Jul 2023 20:53:23 +0900 Subject: [PATCH 46/68] Modernize MockStateDelta --- .../Action/AddActivatedAccount0Test.cs | 1 - .../Action/AddActivatedAccountTest.cs | 1 - .Lib9c.Tests/Action/MockStateDelta.cs | 427 +++++++++++++----- ...asset.TransferCrystal.summary.verified.txt | 11 +- ...sset.TransferWithMemo.summary.verified.txt | 11 +- 5 files changed, 320 insertions(+), 131 deletions(-) diff --git a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs index da193f5666..94d6aa4662 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccount0Test.cs @@ -62,7 +62,6 @@ public void Rehearsal() Assert.Equal( new[] { - AdminState.Address, ActivatedAccountsState.Address, }.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses diff --git a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs index a51eef78e1..d0d8365ffe 100644 --- a/.Lib9c.Tests/Action/AddActivatedAccountTest.cs +++ b/.Lib9c.Tests/Action/AddActivatedAccountTest.cs @@ -78,7 +78,6 @@ public void Rehearsal() Assert.Equal( new[] { - AdminState.Address, newComer.Derive(ActivationKey.DeriveKey), }.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses diff --git a/.Lib9c.Tests/Action/MockStateDelta.cs b/.Lib9c.Tests/Action/MockStateDelta.cs index f50c303e58..dd7a78ef79 100644 --- a/.Lib9c.Tests/Action/MockStateDelta.cs +++ b/.Lib9c.Tests/Action/MockStateDelta.cs @@ -1,8 +1,11 @@ +#nullable enable + namespace Lib9c.Tests.Action { using System; using System.Collections.Generic; using System.Collections.Immutable; + using System.Diagnostics.Contracts; using System.Linq; using System.Numerics; using Bencodex.Types; @@ -12,157 +15,316 @@ namespace Lib9c.Tests.Action using Libplanet.Consensus; using Libplanet.State; + /// + /// + /// A rough replica of https://github.com/planetarium/libplanet/blob/main/Libplanet/State/AccountStateDelta.cs + /// except this has its constructors exposed as public for testing with many of + /// checks removed. + /// + /// + /// Notable differences from the original are: + /// + /// + /// There is no authority check for and , + /// i.e. any can mint and burn. + /// + /// + /// There is no amount check for , , + /// i.e. 0 or even a negative amount is allowed. + /// + /// + /// The behaves as if any given + /// has value equal to 0. + /// + /// + /// + /// + [Pure] public class MockStateDelta : IAccountStateDelta { - private readonly IImmutableDictionary _states; - private readonly IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; - private readonly IImmutableDictionary _totalSupplies; - private readonly ValidatorSet _validatorSet; - private readonly IAccountDelta _delta; - public MockStateDelta() : this(MockState.Empty) { } - public MockStateDelta(MockState mockState) + public MockStateDelta(IAccountState mockState) : this( - mockState.States, - mockState.Fungibles, - mockState.TotalSupplies, - mockState.ValidatorSet) + mockState.GetStates, + mockState.GetBalance, + mockState.GetTotalSupply, + mockState.GetValidatorSet) { } - // Pretends all given arguments are part of the delta, i.e., have been modified - // using appropriate methods such as Transfer/Mint/Burn to set the values. - // Also convert to internal data types. - public MockStateDelta( - IImmutableDictionary states = null, - IImmutableDictionary<(Address Address, Currency Currency), FungibleAssetValue> balances = null, - IImmutableDictionary totalSupplies = null, - ValidatorSet validatorSet = null) + private MockStateDelta( + AccountStateGetter accountStateGetter, + AccountBalanceGetter accountBalanceGetter, + TotalSupplyGetter totalSupplyGetter, + ValidatorSetGetter validatorSetGetter) { - _states = states ?? ImmutableDictionary.Empty; - _fungibles = balances is { } b - ? b.ToImmutableDictionary(kv => kv.Key, kv => kv.Value.RawValue) - : ImmutableDictionary<(Address, Currency), BigInteger>.Empty; - _totalSupplies = totalSupplies is { } t - ? t.ToImmutableDictionary(kv => kv.Key, kv => kv.Value.RawValue) - : ImmutableDictionary.Empty; - _validatorSet = - validatorSet ?? new ValidatorSet(); - - _delta = new MockDelta(_states, _fungibles, _totalSupplies, _validatorSet); + Delta = new MockDelta(); + StateGetter = accountStateGetter; + BalanceGetter = accountBalanceGetter; + TotalSupplyGetter = totalSupplyGetter; + ValidatorSetGetter = validatorSetGetter; + TotalUpdatedFungibles = ImmutableDictionary<(Address, Currency), BigInteger>.Empty; } - // For Transfer/Mint/Burn - private MockStateDelta( - IImmutableDictionary state, - IImmutableDictionary<(Address Address, Currency Currency), BigInteger> balance, - IImmutableDictionary totalSupplies, - ValidatorSet validatorSet) - { - _states = state; - _fungibles = balance; - _totalSupplies = totalSupplies; - _validatorSet = validatorSet; + /// + public IAccountDelta Delta { get; private set; } - _delta = new MockDelta(_states, _fungibles, _totalSupplies, _validatorSet); - } + /// + public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => + TotalUpdatedFungibles.Keys.ToImmutableHashSet(); - public IAccountDelta Delta => _delta; + public IImmutableDictionary<(Address, Currency), BigInteger> TotalUpdatedFungibles + { get; protected set; } - public IImmutableSet
UpdatedAddresses => _delta.UpdatedAddresses; + private AccountStateGetter StateGetter { get; set; } - public IImmutableSet
StateUpdatedAddresses => _delta.StateUpdatedAddresses; + private AccountBalanceGetter BalanceGetter { get; set; } - public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => _delta.UpdatedFungibleAssets; + private TotalSupplyGetter TotalSupplyGetter { get; set; } - public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => _delta.UpdatedFungibleAssets; + private ValidatorSetGetter ValidatorSetGetter { get; set; } - public IImmutableSet UpdatedTotalSupplyCurrencies => _delta.UpdatedTotalSupplyCurrencies; + /// + [Pure] + public IValue? GetState(Address address) + { + IValue? state = GetStates(new[] { address })[0]; + return state; + } - public IValue GetState(Address address) => _delta.States.TryGetValue(address, out IValue value) - ? value - : null; + /// + [Pure] + public IReadOnlyList GetStates(IReadOnlyList
addresses) + { + int length = addresses.Count; + IValue?[] values = new IValue?[length]; + var notFoundIndices = new List(length); + for (int i = 0; i < length; i++) + { + Address address = addresses[i]; + if (Delta.States.TryGetValue(address, out IValue? updatedValue)) + { + values[i] = updatedValue; + } + else + { + notFoundIndices.Add(i); + } + } - public IReadOnlyList GetStates(IReadOnlyList
addresses) => - addresses.Select(GetState).ToArray(); + if (notFoundIndices.Count > 0) + { + IReadOnlyList restValues = StateGetter( + notFoundIndices.Select(index => addresses[index]).ToArray()); + foreach ((var v, var i) in notFoundIndices.Select((v, i) => (v, i))) + { + values[v] = restValues[i]; + } + } + return values; + } + + /// + [Pure] public IAccountStateDelta SetState(Address address, IValue state) => - new MockStateDelta( - _states.SetItem(address, state), - _fungibles, - _totalSupplies, - _validatorSet); + UpdateStates(Delta.States.SetItem(address, state)); + /// + [Pure] public FungibleAssetValue GetBalance(Address address, Currency currency) => - _delta.Fungibles.TryGetValue((address, currency), out BigInteger rawValue) - ? FungibleAssetValue.FromRawValue(currency, rawValue) - : FungibleAssetValue.FromRawValue(currency, 0); + GetBalance(address, currency, Delta.Fungibles); + /// + [Pure] public FungibleAssetValue GetTotalSupply(Currency currency) { if (!currency.TotalSupplyTrackable) { - var msg = - $"The total supply value of the currency {currency} is not trackable" - + " because it is a legacy untracked currency which might have been" - + " established before the introduction of total supply tracking support."; - throw new TotalSupplyNotTrackableException(msg, currency); + throw new TotalSupplyNotTrackableException( + $"The total supply value of the currency {currency} is not trackable " + + "because it is a legacy untracked currency which might have been " + + "established before the introduction of total supply tracking support.", + currency); } // Return dirty state if it exists. - return _delta.TotalSupplies.TryGetValue(currency, out var rawValue) - ? FungibleAssetValue.FromRawValue(currency, rawValue) - : FungibleAssetValue.FromRawValue(currency, 0); + if (Delta.TotalSupplies.TryGetValue(currency, out BigInteger totalSupplyValue)) + { + return FungibleAssetValue.FromRawValue(currency, totalSupplyValue); + } + + return TotalSupplyGetter(currency); } - public IAccountStateDelta MintAsset(IActionContext context, Address recipient, FungibleAssetValue value) + /// + [Pure] + public ValidatorSet GetValidatorSet() => + Delta.ValidatorSet ?? ValidatorSetGetter(); + + /// + [Pure] + public IAccountStateDelta MintAsset( + IActionContext context, Address recipient, FungibleAssetValue value) { - var totalSupplies = - value.Currency.TotalSupplyTrackable - ? _totalSupplies.SetItem( - value.Currency, - (GetTotalSupply(value.Currency) + value).RawValue) - : _totalSupplies; - return new MockStateDelta( - _states, - _fungibles.SetItem( - (recipient, value.Currency), - (GetBalance(recipient, value.Currency) + value).RawValue), - totalSupplies, - _validatorSet + Currency currency = value.Currency; + FungibleAssetValue balance = GetBalance(recipient, currency); + (Address, Currency) assetKey = (recipient, currency); + BigInteger rawBalance = (balance + value).RawValue; + + if (currency.TotalSupplyTrackable) + { + var currentTotalSupply = GetTotalSupply(currency); + if (currency.MaximumSupply < currentTotalSupply + value) + { + var msg = $"The amount {value} attempted to be minted added to the current" + + $" total supply of {currentTotalSupply} exceeds the" + + $" maximum allowed supply of {currency.MaximumSupply}."; + throw new SupplyOverflowException(msg, value); + } + + return UpdateFungibleAssets( + Delta.Fungibles.SetItem(assetKey, rawBalance), + TotalUpdatedFungibles.SetItem(assetKey, rawBalance), + Delta.TotalSupplies.SetItem(currency, (currentTotalSupply + value).RawValue) + ); + } + + return UpdateFungibleAssets( + Delta.Fungibles.SetItem(assetKey, rawBalance), + TotalUpdatedFungibles.SetItem(assetKey, rawBalance) ); } - public IAccountStateDelta BurnAsset(IActionContext context, Address owner, FungibleAssetValue value) + /// + [Pure] + public IAccountStateDelta TransferAsset( + IActionContext context, + Address sender, + Address recipient, + FungibleAssetValue value, + bool allowNegativeBalance = false) => + TransferAssetV0(sender, recipient, value, allowNegativeBalance); + + /// + [Pure] + public IAccountStateDelta BurnAsset( + IActionContext context, Address owner, FungibleAssetValue value) { - var totalSupplies = - value.Currency.TotalSupplyTrackable - ? _totalSupplies.SetItem( - value.Currency, - (GetTotalSupply(value.Currency) - value).RawValue) - : _totalSupplies; - return new MockStateDelta( - _states, - _fungibles.SetItem( - (owner, value.Currency), - (GetBalance(owner, value.Currency) - value).RawValue), - totalSupplies, - _validatorSet); + Currency currency = value.Currency; + FungibleAssetValue balance = GetBalance(owner, currency); + (Address, Currency) assetKey = (owner, currency); + BigInteger rawBalance = (balance - value).RawValue; + if (currency.TotalSupplyTrackable) + { + return UpdateFungibleAssets( + Delta.Fungibles.SetItem(assetKey, rawBalance), + TotalUpdatedFungibles.SetItem(assetKey, rawBalance), + Delta.TotalSupplies.SetItem( + currency, + (GetTotalSupply(currency) - value).RawValue) + ); + } + + return UpdateFungibleAssets( + Delta.Fungibles.SetItem(assetKey, rawBalance), + TotalUpdatedFungibles.SetItem(assetKey, rawBalance) + ); } - public IAccountStateDelta TransferAsset( - IActionContext context, + /// + [Pure] + public IAccountStateDelta SetValidator(Validator validator) + { + return UpdateValidatorSet(GetValidatorSet().Update(validator)); + } + + [Pure] + private FungibleAssetValue GetBalance( + Address address, + Currency currency, + IImmutableDictionary<(Address, Currency), BigInteger> balances) => + balances.TryGetValue((address, currency), out BigInteger balance) + ? FungibleAssetValue.FromRawValue(currency, balance) + : BalanceGetter(address, currency); + + [Pure] + private IAccountStateDelta UpdateStates( + IImmutableDictionary updatedStates + ) => + new MockStateDelta( + StateGetter, + BalanceGetter, + TotalSupplyGetter, + ValidatorSetGetter) + { + Delta = new MockDelta( + updatedStates, + Delta.Fungibles, + Delta.TotalSupplies, + Delta.ValidatorSet), + TotalUpdatedFungibles = TotalUpdatedFungibles, + }; + + [Pure] + private IAccountStateDelta UpdateFungibleAssets( + IImmutableDictionary<(Address, Currency), BigInteger> updatedFungibleAssets, + IImmutableDictionary<(Address, Currency), BigInteger> totalUpdatedFungibles + ) => + UpdateFungibleAssets( + updatedFungibleAssets, + totalUpdatedFungibles, + Delta.TotalSupplies); + + [Pure] + private IAccountStateDelta UpdateFungibleAssets( + IImmutableDictionary<(Address, Currency), BigInteger> updatedFungibleAssets, + IImmutableDictionary<(Address, Currency), BigInteger> totalUpdatedFungibles, + IImmutableDictionary updatedTotalSupply + ) => + new MockStateDelta( + StateGetter, + BalanceGetter, + TotalSupplyGetter, + ValidatorSetGetter) + { + Delta = new MockDelta( + Delta.States, + updatedFungibleAssets, + updatedTotalSupply, + Delta.ValidatorSet), + TotalUpdatedFungibles = totalUpdatedFungibles, + }; + + [Pure] + private IAccountStateDelta UpdateValidatorSet( + ValidatorSet updatedValidatorSet + ) => + new MockStateDelta( + StateGetter, + BalanceGetter, + TotalSupplyGetter, + ValidatorSetGetter) + { + Delta = new MockDelta( + Delta.States, + Delta.Fungibles, + Delta.TotalSupplies, + updatedValidatorSet), + TotalUpdatedFungibles = TotalUpdatedFungibles, + }; + + [Pure] + private IAccountStateDelta TransferAssetV0( Address sender, Address recipient, FungibleAssetValue value, - bool allowNegativeBalance = false - ) + bool allowNegativeBalance = false) { - // Copy from Libplanet (AccountStateDeltaImpl.cs@66104588af35afbd18a41bb7857eacd9da190019) if (value.Sign <= 0) { throw new ArgumentOutOfRangeException( @@ -182,17 +344,60 @@ public IAccountStateDelta TransferAsset( throw new InsufficientBalanceException(msg, sender, senderBalance); } - IImmutableDictionary<(Address, Currency), BigInteger> newBalance = _fungibles - .SetItem((sender, currency), (senderBalance - value).RawValue) - .SetItem((recipient, currency), (recipientBalance + value).RawValue); - return new MockStateDelta(_states, newBalance, _totalSupplies, _validatorSet); + return UpdateFungibleAssets( + Delta.Fungibles + .SetItem((sender, currency), (senderBalance - value).RawValue) + .SetItem((recipient, currency), (recipientBalance + value).RawValue), + TotalUpdatedFungibles + .SetItem((sender, currency), (senderBalance - value).RawValue) + .SetItem((recipient, currency), (recipientBalance + value).RawValue) + ); } - public IAccountStateDelta SetValidator(Validator validator) + [Pure] + private IAccountStateDelta TransferAssetV1( + Address sender, + Address recipient, + FungibleAssetValue value, + bool allowNegativeBalance = false) { - return new MockStateDelta(_states, _fungibles, _totalSupplies, GetValidatorSet().Update(validator)); - } + if (value.Sign <= 0) + { + throw new ArgumentOutOfRangeException( + nameof(value), + "The value to transfer has to be greater than zero." + ); + } - public ValidatorSet GetValidatorSet() => _validatorSet; + Currency currency = value.Currency; + FungibleAssetValue senderBalance = GetBalance(sender, currency); + + if (!allowNegativeBalance && senderBalance < value) + { + var msg = $"The account {sender}'s balance of {currency} is insufficient to " + + $"transfer: {senderBalance} < {value}."; + throw new InsufficientBalanceException(msg, sender, senderBalance); + } + + (Address, Currency) senderAssetKey = (sender, currency); + BigInteger senderRawBalance = (senderBalance - value).RawValue; + + IImmutableDictionary<(Address, Currency), BigInteger> updatedFungibleAssets = + Delta.Fungibles.SetItem(senderAssetKey, senderRawBalance); + IImmutableDictionary<(Address, Currency), BigInteger> totalUpdatedFungibles = + TotalUpdatedFungibles.SetItem(senderAssetKey, senderRawBalance); + + FungibleAssetValue recipientBalance = GetBalance( + recipient, + currency, + updatedFungibleAssets); + (Address, Currency) recipientAssetKey = (recipient, currency); + BigInteger recipientRawBalance = (recipientBalance + value).RawValue; + + return UpdateFungibleAssets( + updatedFungibleAssets.SetItem(recipientAssetKey, recipientRawBalance), + totalUpdatedFungibles.SetItem(recipientAssetKey, recipientRawBalance) + ); + } } } diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt index 5d35a221d9..1a74723cb7 100644 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferCrystal.summary.verified.txt @@ -7,13 +7,6 @@ UpdatedAddresses: [ 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - ValidatorSet: { - Bencoded: [] - } - }, - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ] + ] + } } \ No newline at end of file diff --git a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt index 5d35a221d9..1a74723cb7 100644 --- a/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt +++ b/.Lib9c.Tests/Action/Snapshot/transfer_asset.TransferWithMemo.summary.verified.txt @@ -7,13 +7,6 @@ UpdatedAddresses: [ 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ], - ValidatorSet: { - Bencoded: [] - } - }, - UpdatedAddresses: [ - 99A06c2Bd71f0EAa8196fE45BE5ca424eE809733, - C61C376693E6B26717C9ee9aCA5A2453028f6ffA - ] + ] + } } \ No newline at end of file From 390ca4e62ba4082147097cb8d38fe6634c3e7cec Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 7 Jul 2023 11:28:50 +0900 Subject: [PATCH 47/68] Do not wipe out empty garage to null --- .../Garages/DeliverToOthersGaragesTest.cs | 36 +++++++------------ .../Action/Garages/UnloadFromMyGaragesTest.cs | 33 ++++++----------- .../Model/Garages/FungibleItemGarageTest.cs | 6 ---- Lib9c/Model/Garages/FungibleItemGarage.cs | 4 +-- 4 files changed, 23 insertions(+), 56 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs index 6567da6562..546ec2e646 100644 --- a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -162,8 +162,9 @@ public void Execute_Success() SenderAgentAddr, fungibleId); Assert.Equal( - Null.Value, - nextStates.GetState(senderGarageAddr)); + 0, + new FungibleItemGarage(nextStates.GetState(senderGarageAddr)).Count + ); var recipientGarageAddr = Addresses.GetGarageAddress( _recipientAgentAddr, fungibleId); @@ -284,28 +285,15 @@ public void Execute_Throws_Exception() garage.Unload(1); var previousStatesWithNotEnoughCountOfGarageState = _previousStates.SetState(garageAddr, garage.Serialize()); - if (garage.Count == 0) - { - Assert.Throws(() => Execute( - SenderAgentAddr, - 0, - previousStatesWithNotEnoughCountOfGarageState, - new TestRandom(), - _recipientAgentAddr, - null, - _fungibleIdAndCounts)); - } - else - { - Assert.Throws(() => Execute( - SenderAgentAddr, - 0, - previousStatesWithNotEnoughCountOfGarageState, - new TestRandom(), - _recipientAgentAddr, - null, - _fungibleIdAndCounts)); - } + + Assert.Throws(() => Execute( + SenderAgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + _recipientAgentAddr, + null, + _fungibleIdAndCounts)); } // Recipient's fungible item Garages can be overflowed. diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index 76391fe380..b232a1a3b8 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -166,7 +166,7 @@ public void Execute_Success() var garageAddr = Addresses.GetGarageAddress( AgentAddr, fungibleId); - Assert.True(nextStates.GetState(garageAddr) is Null); + Assert.Equal(0, new FungibleItemGarage(nextStates.GetState(garageAddr)).Count); Assert.True(inventory.HasFungibleItem( fungibleId, blockIndex: 0, @@ -311,28 +311,15 @@ public void Execute_Throws_Exception() garage.Unload(1); var previousStatesWithNotEnoughCountOfGarageState = _previousStates.SetState(garageAddr, garage.Serialize()); - if (garage.Count == 0) - { - Assert.Throws(() => Execute( - AgentAddr, - 0, - previousStatesWithNotEnoughCountOfGarageState, - new TestRandom(), - _recipientAvatarAddr, - null, - _fungibleIdAndCounts)); - } - else - { - Assert.Throws(() => Execute( - AgentAddr, - 0, - previousStatesWithNotEnoughCountOfGarageState, - new TestRandom(), - _recipientAvatarAddr, - null, - _fungibleIdAndCounts)); - } + + Assert.Throws(() => Execute( + AgentAddr, + 0, + previousStatesWithNotEnoughCountOfGarageState, + new TestRandom(), + _recipientAvatarAddr, + null, + _fungibleIdAndCounts)); } } diff --git a/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs b/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs index e615976a2b..7f68960c43 100644 --- a/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs +++ b/.Lib9c.Tests/Model/Garages/FungibleItemGarageTest.cs @@ -161,12 +161,6 @@ public void Unload_Failure(int count1, int count2) private static void AssertSerialization(FungibleItemGarage garage) { var serialized = garage.Serialize(); - if (garage.Count == 0) - { - Assert.Equal(Null.Value, serialized); - return; - } - var deserialized = new FungibleItemGarage(serialized); Assert.Equal(garage.Item, deserialized.Item); Assert.Equal(garage.Count, deserialized.Count); diff --git a/Lib9c/Model/Garages/FungibleItemGarage.cs b/Lib9c/Model/Garages/FungibleItemGarage.cs index cef5f80e25..1704555f58 100644 --- a/Lib9c/Model/Garages/FungibleItemGarage.cs +++ b/Lib9c/Model/Garages/FungibleItemGarage.cs @@ -40,9 +40,7 @@ public FungibleItemGarage(IValue? serialized) Count = (Integer)list[1]; } - public IValue Serialize() => Count == 0 - ? (IValue)Null.Value - : new List( + public IValue Serialize() => new List( Item?.Serialize() ?? Null.Value, (Integer)Count); From 7668b4b3253b37e2a2a4d466051d4580d875c73e Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Fri, 7 Jul 2023 13:36:12 +0900 Subject: [PATCH 48/68] fix: delete `CostKind` column --- .../Garages/LoadIntoMyGaragesCostSheetTest.cs | 37 +++++------------ .../Garages/LoadIntoMyGaragesCostSheet.csv | 13 +++--- .../Garages/LoadIntoMyGaragesCostSheet.cs | 40 ++++--------------- 3 files changed, 24 insertions(+), 66 deletions(-) diff --git a/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs b/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs index b6d9e68c64..4c52804512 100644 --- a/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs +++ b/.Lib9c.Tests/TableData/Garages/LoadIntoMyGaragesCostSheetTest.cs @@ -17,16 +17,16 @@ public class LoadIntoMyGaragesCostSheetTest public LoadIntoMyGaragesCostSheetTest() { var sb = new StringBuilder(); - sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine("id,currency_ticker,fungible_id,garage_cost_per_unit"); sb.AppendLine( - "1,ITEM,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16"); + "1,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16"); sb.AppendLine( - "2,ITEM,,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016"); + "2,,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016"); sb.AppendLine( - "3,ITEM,,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1"); + "3,,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1"); sb.AppendLine( - "4,ITEM,,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10"); - sb.AppendLine("5,CURRENCY,RUNE_GOLDENLEAF,,10"); + "4,,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10"); + sb.AppendLine("5,RUNE_GOLDENLEAF,,10"); _sheet = new LoadIntoMyGaragesCostSheet(); _sheet.Set(sb.ToString()); } @@ -38,7 +38,6 @@ public void Set() Assert.Equal(5, _sheet.Count); var row = _sheet.OrderedList[0]; Assert.Equal(1, row.Id); - Assert.Equal("ITEM", row.CostKind); Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); Assert.Equal( "00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe", @@ -46,7 +45,6 @@ public void Set() Assert.Equal(0.16m, row.GarageCostPerUnit); row = _sheet.OrderedList[1]; Assert.Equal(2, row.Id); - Assert.Equal("ITEM", row.CostKind); Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); Assert.Equal( "3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a", @@ -54,7 +52,6 @@ public void Set() Assert.Equal(0.0016m, row.GarageCostPerUnit); row = _sheet.OrderedList[2]; Assert.Equal(3, row.Id); - Assert.Equal("ITEM", row.CostKind); Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); Assert.Equal( "1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820", @@ -62,7 +59,6 @@ public void Set() Assert.Equal(1m, row.GarageCostPerUnit); row = _sheet.OrderedList[3]; Assert.Equal(4, row.Id); - Assert.Equal("ITEM", row.CostKind); Assert.True(string.IsNullOrEmpty(row.CurrencyTicker)); Assert.Equal( "f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0", @@ -70,31 +66,18 @@ public void Set() Assert.Equal(10m, row.GarageCostPerUnit); row = _sheet.OrderedList[4]; Assert.Equal(5, row.Id); - Assert.Equal("CURRENCY", row.CostKind); Assert.Equal("RUNE_GOLDENLEAF", row.CurrencyTicker); Assert.Null(row.FungibleId); Assert.Equal(10m, row.GarageCostPerUnit); } - [Fact] - public void Set_InvalidCostKind() - { - var sb = new StringBuilder(); - sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); - sb.AppendLine( - "1,INVALID,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16"); - - var sheet = new LoadIntoMyGaragesCostSheet(); - Assert.Throws(() => sheet.Set(sb.ToString())); - } - [Fact] public void Set_InvalidFungibleId() { var sb = new StringBuilder(); - sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine("id,currency_ticker,fungible_id,garage_cost_per_unit"); sb.AppendLine( - "1,ITEM,,INVALID,0.16"); + "1,,INVALID,0.16"); var sheet = new LoadIntoMyGaragesCostSheet(); Assert.Throws(() => sheet.Set(sb.ToString())); @@ -104,9 +87,9 @@ public void Set_InvalidFungibleId() public void Set_InvalidGarageCostPerUnit() { var sb = new StringBuilder(); - sb.AppendLine("id,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit"); + sb.AppendLine("id,currency_ticker,fungible_id,garage_cost_per_unit"); sb.AppendLine( - "1,ITEM,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,INVALID"); + "1,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,INVALID"); var sheet = new LoadIntoMyGaragesCostSheet(); Assert.Throws(() => sheet.Set(sb.ToString())); diff --git a/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv index 7c90a90288..aa5706e461 100644 --- a/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv +++ b/Lib9c/TableCSV/Garages/LoadIntoMyGaragesCostSheet.csv @@ -1,11 +1,10 @@ -id,_memo,cost_kind,currency_ticker,fungible_id,garage_cost_per_unit +id,_memo,currency_ticker,fungible_id,garage_cost_per_unit _id,int -_cost_kind,CURRENCY|ITEM _currency_ticker,(empty)|NCG|CRYSTAL... _fungible_id,(empty)|3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a|00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe... _garage_cost_per_unit,1|100|0.001... -1,ap portion(500000),Item,,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16 -2,hourglass(400000),Item,,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016 -3,golden meat(800201),Item,,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1 -4,golden dust(600201),Item,,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10 -5,golden leaf runestone,Currency,RUNE_GOLDENLEAF,,10 +1,ap portion(500000),,00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe,0.16 +2,hourglass(400000),,3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a,0.0016 +3,golden meat(800201),,1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820,1 +4,golden dust(600201),,f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0,10 +5,golden leaf runestone,RUNE_GOLDENLEAF,,10 diff --git a/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs b/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs index 125bd4774f..588257c7bb 100644 --- a/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs +++ b/Lib9c/TableData/Garages/LoadIntoMyGaragesCostSheet.cs @@ -20,11 +20,6 @@ public class Row : SheetRow public int Id { get; private set; } - /// - /// CURRENCY | ITEM - /// - public string CostKind { get; private set; } - public string CurrencyTicker { get; private set; } public HashDigest? FungibleId { get; private set; } @@ -34,22 +29,11 @@ public class Row : SheetRow public override void Set(IReadOnlyList fields) { Id = ParseInt(fields[0]); - CostKind = string.IsNullOrEmpty(fields[1]) - ? null - : fields[1].ToUpperInvariant(); - if (CostKind != "CURRENCY" && - CostKind != "ITEM") - { - throw new ArgumentException( - $"CostKind must be CURRENCY or ITEM but {CostKind}.", - nameof(fields)); - } - - CurrencyTicker = fields[2]; - FungibleId = string.IsNullOrEmpty(fields[3]) + CurrencyTicker = fields[1]; + FungibleId = string.IsNullOrEmpty(fields[2]) ? (HashDigest?)null - : HashDigest.FromString(fields[3]); - GarageCostPerUnit = ParseDecimal(fields[4]); + : HashDigest.FromString(fields[2]); + GarageCostPerUnit = ParseDecimal(fields[3]); } } @@ -59,17 +43,13 @@ public LoadIntoMyGaragesCostSheet() : base(nameof(LoadIntoMyGaragesCostSheet)) public decimal GetGarageCostPerUnit(string currencyTicker) { - var row = OrderedList!.First(r => - r.CostKind == "CURRENCY" && - r.CurrencyTicker == currencyTicker); + var row = OrderedList!.First(r => r.CurrencyTicker == currencyTicker); return row.GarageCostPerUnit; } public decimal GetGarageCostPerUnit(HashDigest fungibleId) { - var row = OrderedList!.First(r => - r.CostKind == "ITEM" && - r.FungibleId.Equals(fungibleId)); + var row = OrderedList!.First(r => r.FungibleId?.Equals(fungibleId) ?? false); return row.GarageCostPerUnit; } @@ -131,16 +111,12 @@ public FungibleAssetValue GetGarageCost( public bool HasCost(string currencyTicker) { - return OrderedList!.Any(r => - r.CostKind == "CURRENCY" && - r.CurrencyTicker == currencyTicker); + return OrderedList!.Any(r => r.CurrencyTicker == currencyTicker); } public bool HasCost(HashDigest fungibleId) { - return OrderedList!.Any(r => - r.CostKind == "ITEM" && - r.FungibleId.Equals(fungibleId)); + return OrderedList!.Any(r => r.FungibleId?.Equals(fungibleId) ?? false); } } } From 279314a6d52ee10d76a48ffd1b518dd072eb43a0 Mon Sep 17 00:00:00 2001 From: hyeon Date: Mon, 10 Jul 2023 12:10:38 +0900 Subject: [PATCH 49/68] Apply Libplanet changes - `IAccountStateView` is changed to `IAccountState` - `IActionContext.PreviousStates` is changed to `IActionContext.PreviousState` --- .../Action/Garages/DeliverToOthersGaragesTest.cs | 4 ++-- .Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs | 4 ++-- .../Action/Garages/UnloadFromMyGaragesTest.cs | 4 ++-- Lib9c/Action/AccountStateExtensions.cs | 4 ++-- Lib9c/Action/Garages/DeliverToOthersGarages.cs | 8 ++++---- Lib9c/Action/Garages/GarageUtils.cs | 6 +++--- Lib9c/Action/Garages/LoadIntoMyGarages.cs | 12 ++++++------ Lib9c/Action/Garages/UnloadFromMyGarages.cs | 10 +++++----- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs index 546ec2e646..fd45836d68 100644 --- a/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs @@ -318,7 +318,7 @@ public void Execute_Throws_Exception() private static (DeliverToOthersGarages action, IAccountStateDelta nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousStates, + IAccountStateDelta previousState, IRandom random, Address recipientAgentAddr, IEnumerable? fungibleAssetValues, @@ -337,7 +337,7 @@ private static (DeliverToOthersGarages action, IAccountStateDelta nextStates) Ex Signer = signer, BlockIndex = blockIndex, Rehearsal = false, - PreviousStates = previousStates, + PreviousState = previousState, Random = random, })); } diff --git a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs index e0229470fa..a127ded665 100644 --- a/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs @@ -398,7 +398,7 @@ public void Execute_Throws_Exception() private static (LoadIntoMyGarages action, IAccountStateDelta nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousStates, + IAccountStateDelta previousState, IRandom random, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, Address? inventoryAddr, @@ -415,7 +415,7 @@ private static (LoadIntoMyGarages action, IAccountStateDelta nextStates) Execute Signer = signer, BlockIndex = blockIndex, Rehearsal = false, - PreviousStates = previousStates, + PreviousState = previousState, Random = random, }; return (action, action.Execute(context)); diff --git a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs index b232a1a3b8..3f293ec340 100644 --- a/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs +++ b/.Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs @@ -326,7 +326,7 @@ public void Execute_Throws_Exception() private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execute( Address signer, long blockIndex, - IAccountStateDelta previousStates, + IAccountStateDelta previousState, IRandom random, Address recipientAvatarAddr, IEnumerable<(Address balanceAddr, FungibleAssetValue value)>? fungibleAssetValues, @@ -345,7 +345,7 @@ private static (UnloadFromMyGarages action, IAccountStateDelta nextStates) Execu Signer = signer, BlockIndex = blockIndex, Rehearsal = false, - PreviousStates = previousStates, + PreviousState = previousState, Random = random, })); } diff --git a/Lib9c/Action/AccountStateExtensions.cs b/Lib9c/Action/AccountStateExtensions.cs index f783992c68..1f552bc854 100644 --- a/Lib9c/Action/AccountStateExtensions.cs +++ b/Lib9c/Action/AccountStateExtensions.cs @@ -1338,7 +1338,7 @@ public static RaiderState GetRaiderState(this IAccountState states, } public static IValue GetInventoryState( - this IAccountStateView accountStateView, + this IAccountState accountStateView, Address inventoryAddr) { var inventoryState = accountStateView.GetState(inventoryAddr); @@ -1351,7 +1351,7 @@ public static IValue GetInventoryState( } public static Inventory GetInventory( - this IAccountStateView accountStateView, + this IAccountState accountStateView, Address inventoryAddr) { var inventoryState = GetInventoryState(accountStateView, inventoryAddr); diff --git a/Lib9c/Action/Garages/DeliverToOthersGarages.cs b/Lib9c/Action/Garages/DeliverToOthersGarages.cs index 3141d4330c..41db85b57f 100644 --- a/Lib9c/Action/Garages/DeliverToOthersGarages.cs +++ b/Lib9c/Action/Garages/DeliverToOthersGarages.cs @@ -163,16 +163,16 @@ private void SetInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var state = context.PreviousState; if (context.Rehearsal) { - return states; + return state; } var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(addressesHex); - states = SendBalances(context, states); - return SendFungibleItems(context.Signer, states); + state = SendBalances(context, state); + return SendFungibleItems(context.Signer, state); } private void ValidateFields(string addressesHex) diff --git a/Lib9c/Action/Garages/GarageUtils.cs b/Lib9c/Action/Garages/GarageUtils.cs index 2791c31143..94625227e6 100644 --- a/Lib9c/Action/Garages/GarageUtils.cs +++ b/Lib9c/Action/Garages/GarageUtils.cs @@ -106,7 +106,7 @@ public static class GarageUtils Address garageAddr, IValue? garageState)> WithGarageStateTuples( Address agentAddr, - IAccountStateView states, + IAccountState states, IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) { var withGarageAddr = fungibleIdAndCounts @@ -137,7 +137,7 @@ public static class GarageUtils IValue? recipientGarageState)> WithGarageStateTuples( Address senderAgentAddr, Address recipientAgentAddr, - IAccountStateView states, + IAccountState states, IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) { var withGarageAddr = fungibleIdAndCounts @@ -192,7 +192,7 @@ public static class GarageUtils Address garageAddr, FungibleItemGarage garage)> WithGarageTuples( Address agentAddr, - IAccountStateView states, + IAccountState states, IEnumerable<(HashDigest fungibleId, int count)> fungibleIdAndCounts) { return WithGarageStateTuples(agentAddr, states, fungibleIdAndCounts) diff --git a/Lib9c/Action/Garages/LoadIntoMyGarages.cs b/Lib9c/Action/Garages/LoadIntoMyGarages.cs index 8881096cc1..978f7770c8 100644 --- a/Lib9c/Action/Garages/LoadIntoMyGarages.cs +++ b/Lib9c/Action/Garages/LoadIntoMyGarages.cs @@ -125,27 +125,27 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var state = context.PreviousState; if (context.Rehearsal) { - return states; + return state; } var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(context.Signer, addressesHex); - var sheet = states.GetSheet(); + var sheet = state.GetSheet(); var garageCost = sheet.GetGarageCost( FungibleAssetValues?.Select(tuple => tuple.value), FungibleIdAndCounts); - states = states.TransferAsset( + state = state.TransferAsset( context, context.Signer, Addresses.GarageWallet, garageCost); - states = TransferFungibleAssetValues(context, states); - return TransferFungibleItems(context.Signer, context.BlockIndex, states); + state = TransferFungibleAssetValues(context, state); + return TransferFungibleItems(context.Signer, context.BlockIndex, state); } private void ValidateFields( diff --git a/Lib9c/Action/Garages/UnloadFromMyGarages.cs b/Lib9c/Action/Garages/UnloadFromMyGarages.cs index 8bb072e261..eba0354a38 100644 --- a/Lib9c/Action/Garages/UnloadFromMyGarages.cs +++ b/Lib9c/Action/Garages/UnloadFromMyGarages.cs @@ -120,17 +120,17 @@ protected override void LoadPlainValueInternal( public override IAccountStateDelta Execute(IActionContext context) { context.UseGas(1); - var states = context.PreviousStates; + var state = context.PreviousState; if (context.Rehearsal) { - return states; + return state; } var addressesHex = GetSignerAndOtherAddressesHex(context); ValidateFields(addressesHex); - states = TransferFungibleAssetValues(context, states); - states = TransferFungibleItems(context.Signer, states); - return SendMail(context.BlockIndex, context.Random, states); + state = TransferFungibleAssetValues(context, state); + state = TransferFungibleItems(context.Signer, state); + return SendMail(context.BlockIndex, context.Random, state); } private void ValidateFields(string addressesHex) From 3f2bf5c250e751009ce2b5586ce42832ab3e2e7a Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Mon, 10 Jul 2023 16:50:15 +0900 Subject: [PATCH 50/68] fix: apply Libplanet changes inside of `UNITY_EDITOR` constants --- Lib9c/Action/CreateAvatar8.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/Action/CreateAvatar8.cs b/Lib9c/Action/CreateAvatar8.cs index 25b22810d2..b7665f8c4f 100644 --- a/Lib9c/Action/CreateAvatar8.cs +++ b/Lib9c/Action/CreateAvatar8.cs @@ -167,7 +167,7 @@ public override IAccountStateDelta Execute(IActionContext context) // Add Runes when executing on editor mode. #if LIB9C_DEV_EXTENSIONS || UNITY_EDITOR - states = CreateAvatar0.AddRunesForTest(avatarAddress, states); + states = CreateAvatar0.AddRunesForTest(context, avatarAddress, states); // Add pets for test if (states.TryGetSheet(out PetSheet petSheet)) From 2e2f283bae0a71ed707b0951a16bac8ca82c2a6f Mon Sep 17 00:00:00 2001 From: Atralupus Date: Mon, 10 Jul 2023 17:39:24 +0900 Subject: [PATCH 51/68] ci: Apply auto find options --- .github/workflows/main.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2f648fec0..01959b674e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -96,15 +96,6 @@ jobs: fi env: WEB_FLOW_KEY_URL: https://github.com/web-flow.gpg - - name: Update other repos referring lib9c as submodules - uses: planetarium/submodule-updater@main - with: - token: ${{ secrets.SUBMODULE_UPDATER_GH_TOKEN }} - committer: > - Submodule Updater - targets: | - ${{ github.repository_owner }}/NineChronicles:rc-${{ github.ref_name }}? - ${{ github.repository_owner }}/NineChronicles.Headless:rc-${{ github.ref_name }}? - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: @@ -121,7 +112,7 @@ jobs: destination_dir: ${{ github.ref_name }} update-submodule: - if: ${{ (github.ref_type == 'branch' && startsWith(github.ref_name, 'rc-v')) || github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} + if: github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} runs-on: ubuntu-latest steps: - name: Update other repos referring lib9c as submodules @@ -131,5 +122,5 @@ jobs: committer: > Submodule Updater targets: | - ${{ github.repository_owner }}/NineChronicles:${{ github.ref_name }}? - ${{ github.repository_owner }}/NineChronicles.Headless:${{ github.ref_name }}? + ${{ github.repository_owner }}/NineChronicles:refs/heads/release/* + ${{ github.repository_owner }}/NineChronicles.Headless:refs/heads/release/* From 1614fa19fbd3bf610f828cced12688254437ad1b Mon Sep 17 00:00:00 2001 From: Atralupus Date: Mon, 10 Jul 2023 17:41:40 +0900 Subject: [PATCH 52/68] fix typo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01959b674e..9ebbf13ae7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -112,7 +112,7 @@ jobs: destination_dir: ${{ github.ref_name }} update-submodule: - if: github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} + if: github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') runs-on: ubuntu-latest steps: - name: Update other repos referring lib9c as submodules From 366507d69f4d64f05ad190c07323e2d19eec5159 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 6 Jul 2023 20:22:21 +0900 Subject: [PATCH 53/68] Optimize serialize --- Lib9c/Model/Quest/CollectQuest.cs | 10 +++------- Lib9c/Model/Quest/CombinationEquipmentQuest.cs | 11 +++-------- Lib9c/Model/Quest/CombinationQuest.cs | 13 ++++--------- Lib9c/Model/Quest/GeneralQuest.cs | 8 ++------ Lib9c/Model/Quest/GoldQuest.cs | 9 ++------- Lib9c/Model/Quest/ItemEnhancementQuest.cs | 13 ++++--------- Lib9c/Model/Quest/ItemGradeQuest.cs | 12 ++++-------- Lib9c/Model/Quest/ItemTypeCollectQuest.cs | 12 ++++-------- Lib9c/Model/Quest/MonsterQuest.cs | 10 +++------- Lib9c/Model/Quest/Quest.cs | 18 ++++++++---------- Lib9c/Model/Quest/TradeQuest.cs | 10 +++------- Lib9c/Model/State/RedeemCodeState.cs | 12 +++++------- 12 files changed, 45 insertions(+), 93 deletions(-) diff --git a/Lib9c/Model/Quest/CollectQuest.cs b/Lib9c/Model/Quest/CollectQuest.cs index ed00acf407..7f0b550a6b 100644 --- a/Lib9c/Model/Quest/CollectQuest.cs +++ b/Lib9c/Model/Quest/CollectQuest.cs @@ -14,7 +14,7 @@ public class CollectQuest : Quest public readonly int ItemId; - public CollectQuest(CollectQuestSheet.Row data, QuestReward reward) + public CollectQuest(CollectQuestSheet.Row data, QuestReward reward) : base(data, reward) { ItemId = data.ItemId; @@ -54,11 +54,7 @@ public void Update(CollectionMap itemMap) } public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"itemId"] = (Integer)ItemId, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary) base.Serialize()) + .Add("itemId", ItemId); } } diff --git a/Lib9c/Model/Quest/CombinationEquipmentQuest.cs b/Lib9c/Model/Quest/CombinationEquipmentQuest.cs index 405840357b..6868333bb0 100644 --- a/Lib9c/Model/Quest/CombinationEquipmentQuest.cs +++ b/Lib9c/Model/Quest/CombinationEquipmentQuest.cs @@ -58,14 +58,9 @@ public void Update(int recipeId) public override IValue Serialize() { - var dict = new Dictionary - { - [(Text) "recipe_id"] = RecipeId.Serialize(), - [(Text) "stage_id"] = StageId.Serialize(), - }; -#pragma warning disable LAA1002 - return new Dictionary(dict.Union((Dictionary) base.Serialize())); -#pragma warning restore LAA1002 + return ((Dictionary) base.Serialize()) + .Add("recipe_id", RecipeId.Serialize()) + .Add("stage_id", StageId.Serialize()); } } } diff --git a/Lib9c/Model/Quest/CombinationQuest.cs b/Lib9c/Model/Quest/CombinationQuest.cs index 236e5a8ab5..fbe9bbbc78 100644 --- a/Lib9c/Model/Quest/CombinationQuest.cs +++ b/Lib9c/Model/Quest/CombinationQuest.cs @@ -16,7 +16,7 @@ public class CombinationQuest : Quest public override QuestType QuestType => QuestType.Craft; - public CombinationQuest(CombinationQuestSheet.Row data, QuestReward reward) + public CombinationQuest(CombinationQuestSheet.Row data, QuestReward reward) : base(data, reward) { ItemType = data.ItemType; @@ -58,13 +58,8 @@ public void Update(List items) } public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"itemType"] = (Integer)(int)ItemType, - [(Text)"itemSubType"] = (Integer)(int)ItemSubType, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 - + ((Dictionary) base.Serialize()) + .Add("itemType", (int) ItemType) + .Add("itemSubType", (int) ItemSubType); } } diff --git a/Lib9c/Model/Quest/GeneralQuest.cs b/Lib9c/Model/Quest/GeneralQuest.cs index 466b532a9d..f8f26999c3 100644 --- a/Lib9c/Model/Quest/GeneralQuest.cs +++ b/Lib9c/Model/Quest/GeneralQuest.cs @@ -74,12 +74,8 @@ public void Update(CollectionMap eventMap) } public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"event"] = (Integer)(int)Event, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary) base.Serialize()) + .Add("event", (int) Event); } } diff --git a/Lib9c/Model/Quest/GoldQuest.cs b/Lib9c/Model/Quest/GoldQuest.cs index 8bdba842d4..890622a352 100644 --- a/Lib9c/Model/Quest/GoldQuest.cs +++ b/Lib9c/Model/Quest/GoldQuest.cs @@ -62,12 +62,7 @@ public void Update(FungibleAssetValue gold) } public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"type"] = (Integer)(int)Type, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 - + ((Dictionary) base.Serialize()) + .Add("type", (int) Type); } } diff --git a/Lib9c/Model/Quest/ItemEnhancementQuest.cs b/Lib9c/Model/Quest/ItemEnhancementQuest.cs index 926bc1cb2a..b93a56f240 100644 --- a/Lib9c/Model/Quest/ItemEnhancementQuest.cs +++ b/Lib9c/Model/Quest/ItemEnhancementQuest.cs @@ -16,7 +16,7 @@ public class ItemEnhancementQuest : Quest public int Count => _count; public override float Progress => (float) _current / _count; - public ItemEnhancementQuest(ItemEnhancementQuestSheet.Row data, QuestReward reward) + public ItemEnhancementQuest(ItemEnhancementQuestSheet.Row data, QuestReward reward) : base(data, reward) { _count = data.Count; @@ -63,13 +63,8 @@ public void Update(Equipment equipment) protected override string TypeId => "itemEnhancementQuest"; public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"grade"] = (Integer)Grade, - [(Text)"count"] = (Integer)_count, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 - + ((Dictionary) base.Serialize()) + .Add("grade", Grade) + .Add("count", _count); } } diff --git a/Lib9c/Model/Quest/ItemGradeQuest.cs b/Lib9c/Model/Quest/ItemGradeQuest.cs index e123f13b22..5ad5d7c31a 100644 --- a/Lib9c/Model/Quest/ItemGradeQuest.cs +++ b/Lib9c/Model/Quest/ItemGradeQuest.cs @@ -14,7 +14,7 @@ public class ItemGradeQuest : Quest { public readonly int Grade; public readonly List ItemIds = new List(); - public ItemGradeQuest(ItemGradeQuestSheet.Row data, QuestReward reward) + public ItemGradeQuest(ItemGradeQuestSheet.Row data, QuestReward reward) : base(data, reward) { Grade = data.Grade; @@ -62,13 +62,9 @@ public void Update(ItemUsable itemUsable) protected override string TypeId => "itemGradeQuest"; public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"grade"] = Grade.Serialize(), - [(Text)"itemIds"] = new List(ItemIds.OrderBy(i => i).Select(i => i.Serialize())), - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary)base.Serialize()) + .Add("grade", Grade.Serialize()) + .Add("itemIds", new List(ItemIds.OrderBy(i => i).Select(i => i.Serialize()))); } } diff --git a/Lib9c/Model/Quest/ItemTypeCollectQuest.cs b/Lib9c/Model/Quest/ItemTypeCollectQuest.cs index 64a8ed7d79..ca8a46acbe 100644 --- a/Lib9c/Model/Quest/ItemTypeCollectQuest.cs +++ b/Lib9c/Model/Quest/ItemTypeCollectQuest.cs @@ -15,7 +15,7 @@ public class ItemTypeCollectQuest : Quest public readonly ItemType ItemType; public readonly List ItemIds = new List(); - public ItemTypeCollectQuest(ItemTypeCollectQuestSheet.Row data, QuestReward reward) + public ItemTypeCollectQuest(ItemTypeCollectQuestSheet.Row data, QuestReward reward) : base(data, reward) { ItemType = data.ItemType; @@ -64,13 +64,9 @@ public override string GetProgressText() => protected override string TypeId => "itemTypeCollectQuest"; public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"itemType"] = ItemType.Serialize(), - [(Text)"itemIds"] = new List(ItemIds.OrderBy(i => i).Select(i => i.Serialize())), - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary) base.Serialize()) + .Add("itemType", ItemType.Serialize()) + .Add("itemIds", new List(ItemIds.OrderBy(i => i).Select(i => i.Serialize()))); } } diff --git a/Lib9c/Model/Quest/MonsterQuest.cs b/Lib9c/Model/Quest/MonsterQuest.cs index b053d2c2e1..60b7818469 100644 --- a/Lib9c/Model/Quest/MonsterQuest.cs +++ b/Lib9c/Model/Quest/MonsterQuest.cs @@ -12,7 +12,7 @@ public class MonsterQuest : Quest { public readonly int MonsterId; - public MonsterQuest(MonsterQuestSheet.Row data, QuestReward reward) + public MonsterQuest(MonsterQuestSheet.Row data, QuestReward reward) : base(data, reward) { MonsterId = data.MonsterId; @@ -54,11 +54,7 @@ public void Update(CollectionMap monsterMap) } public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"monsterId"] = (Integer)MonsterId, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary) base.Serialize()) + .Add("monsterId", MonsterId); } } diff --git a/Lib9c/Model/Quest/Quest.cs b/Lib9c/Model/Quest/Quest.cs index 55c378ca02..2d30d98972 100644 --- a/Lib9c/Model/Quest/Quest.cs +++ b/Lib9c/Model/Quest/Quest.cs @@ -82,16 +82,14 @@ protected Quest(Dictionary serialized) public abstract string GetProgressText(); public virtual IValue Serialize() => - new Dictionary(new Dictionary - { - [(Text) "typeId"] = (Text) TypeId, - [(Text) "complete"] = new Bencodex.Types.Boolean(Complete), - [(Text) "goal"] = (Integer) Goal, - [(Text) "current"] = (Integer) _current, - [(Text) "id"] = (Integer) Id, - [(Text) "reward"] = Reward.Serialize(), - [(Text) "isPaidInAction"] = new Bencodex.Types.Boolean(IsPaidInAction), - }); + Dictionary.Empty + .Add("typeId", (Text) TypeId) + .Add("complete", new Bencodex.Types.Boolean(Complete)) + .Add("goal", (Integer) Goal) + .Add("current", (Integer) _current) + .Add("id", (Integer) Id) + .Add("reward", Reward.Serialize()) + .Add("isPaidInAction", new Bencodex.Types.Boolean(IsPaidInAction)); public static Quest Deserialize(Dictionary serialized) { diff --git a/Lib9c/Model/Quest/TradeQuest.cs b/Lib9c/Model/Quest/TradeQuest.cs index acb5bc6323..206697b9ca 100644 --- a/Lib9c/Model/Quest/TradeQuest.cs +++ b/Lib9c/Model/Quest/TradeQuest.cs @@ -14,7 +14,7 @@ public class TradeQuest : Quest public override QuestType QuestType => QuestType.Exchange; public readonly TradeType Type; - public TradeQuest(TradeQuestSheet.Row data, QuestReward reward) + public TradeQuest(TradeQuestSheet.Row data, QuestReward reward) : base(data, reward) { Type = data.Type; @@ -45,11 +45,7 @@ public override string GetProgressText() => protected override string TypeId => "tradeQuest"; public override IValue Serialize() => -#pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text)"type"] = (Integer)(int)Type, - }.Union((Dictionary)base.Serialize())); -#pragma warning restore LAA1002 + ((Dictionary) base.Serialize()) + .Add("type", (int) Type); } } diff --git a/Lib9c/Model/State/RedeemCodeState.cs b/Lib9c/Model/State/RedeemCodeState.cs index d9b761faa4..7554b36461 100644 --- a/Lib9c/Model/State/RedeemCodeState.cs +++ b/Lib9c/Model/State/RedeemCodeState.cs @@ -79,14 +79,12 @@ public RedeemCodeState(Dictionary rewardMap) } public override IValue Serialize() => + ((Dictionary) base.Serialize()) #pragma warning disable LAA1002 - new Dictionary(new Dictionary - { - [(Text) "map"] = new Dictionary(_map.Select(kv => new KeyValuePair( - kv.Key, - kv.Value.Serialize() - ))) - }.Union((Dictionary) base.Serialize())); + .Add("map", new Dictionary(_map.Select(kv => new KeyValuePair( + kv.Key, + kv.Value.Serialize() + )))); #pragma warning restore LAA1002 public int Redeem(string code, Address userAddress) From 62cc93d06c214c071f1a99bb4d86c70a0b317a53 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 6 Jul 2023 20:22:59 +0900 Subject: [PATCH 54/68] Disable log --- Lib9c/Battle/StageSimulator.cs | 22 ++++++++++++---------- Lib9c/Battle/Wave.cs | 6 +++--- Lib9c/Model/Character/CharacterBase.cs | 14 +++++++------- Lib9c/Model/Character/Player.cs | 8 ++++---- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Lib9c/Battle/StageSimulator.cs b/Lib9c/Battle/StageSimulator.cs index 16b43b70b2..ec93e0a26a 100644 --- a/Lib9c/Battle/StageSimulator.cs +++ b/Lib9c/Battle/StageSimulator.cs @@ -99,7 +99,7 @@ public static List GetWaveRewards( return waveRewards; } - public Player Simulate() + public Player Simulate(bool log = false) { Log.worldId = WorldId; Log.stageId = StageId; @@ -128,8 +128,7 @@ public Player Simulate() ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs); - Log.Add(usedSkill); + skill.Use(Player, 0, buffs); } while (true) @@ -142,7 +141,7 @@ public Player Simulate() Result = BattleLog.Result.Lose; if (Exp > 0) { - Player.GetExp((int)(Exp * 0.3m), true); + Player.GetExp((int)(Exp * 0.3m), log); } } else @@ -169,7 +168,7 @@ public Player Simulate() Result = BattleLog.Result.Lose; if (Exp > 0) { - Player.GetExp((int)(Exp * 0.3m), true); + Player.GetExp((int)(Exp * 0.3m), log); } } else @@ -192,7 +191,7 @@ public Player Simulate() { if (Exp > 0) { - Player.GetExp(Exp, true); + Player.GetExp(Exp, log); } break; @@ -200,10 +199,13 @@ public Player Simulate() case 2: { ItemMap = Player.GetRewards(_waveRewards); - var dropBox = new DropBox(null, _waveRewards); - Log.Add(dropBox); - var getReward = new GetReward(null, _waveRewards); - Log.Add(getReward); + if (log) + { + var dropBox = new DropBox(null, _waveRewards); + Log.Add(dropBox); + var getReward = new GetReward(null, _waveRewards); + Log.Add(getReward); + } break; } default: diff --git a/Lib9c/Battle/Wave.cs b/Lib9c/Battle/Wave.cs index a938356c14..615051057b 100644 --- a/Lib9c/Battle/Wave.cs +++ b/Lib9c/Battle/Wave.cs @@ -25,9 +25,9 @@ public void Spawn(ISimulator simulator) enemy.InitAI(); } - var enemies = _enemies.Select(enemy => new Enemy(enemy)).ToList(); - var spawnWave = new SpawnWave(null, simulator.WaveNumber, simulator.WaveTurn, enemies, HasBoss); - simulator.Log.Add(spawnWave); + // var enemies = _enemies.Select(enemy => new Enemy(enemy)).ToList(); + // var spawnWave = new SpawnWave(null, simulator.WaveNumber, simulator.WaveTurn, enemies, HasBoss); + // simulator.Log.Add(spawnWave); } [Obsolete("Use Spawn")] diff --git a/Lib9c/Model/Character/CharacterBase.cs b/Lib9c/Model/Character/CharacterBase.cs index b338688b7c..abbf0808c5 100644 --- a/Lib9c/Model/Character/CharacterBase.cs +++ b/Lib9c/Model/Character/CharacterBase.cs @@ -225,7 +225,7 @@ private void ReduceDurationOfBuffs() pair.Value.RemainedDuration--; } } - + protected virtual void ReduceSkillCooldown() { Skills.ReduceCooldown(); @@ -259,7 +259,7 @@ protected virtual BattleStatus.Skill UseSkill() } Skills.SetCooldown(selectedSkill.SkillRow.Id, sheetSkill.Cooldown); - Simulator.Log.Add(usedSkill); + // Simulator.Log.Add(usedSkill); return usedSkill; } @@ -328,7 +328,7 @@ private void RemoveBuffs() return; Stats.SetBuffs(StatBuffs); - Simulator.Log.Add(new RemoveBuffs((CharacterBase) Clone())); + // Simulator.Log.Add(new RemoveBuffs((CharacterBase) Clone())); } protected virtual void EndTurn() @@ -465,8 +465,8 @@ public void Die() protected virtual void OnDead() { - var dead = new Dead((CharacterBase) Clone()); - Simulator.Log.Add(dead); + // var dead = new Dead((CharacterBase) Clone()); + // Simulator.Log.Add(dead); } public void Heal(int heal) @@ -554,7 +554,7 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) foreach (var bleed in bleeds) { var effect = bleed.GiveEffect(this, Simulator.WaveTurn); - Simulator.Log.Add(effect); + // Simulator.Log.Add(effect); } // Apply thorn damage if target has thorn @@ -569,7 +569,7 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) if (isAttackSkill && skillInfo.Target.Thorn > 0) { var effect = GiveThornDamage(skillInfo.Target.Thorn); - Simulator.Log.Add(effect); + // Simulator.Log.Add(effect); } } diff --git a/Lib9c/Model/Character/Player.cs b/Lib9c/Model/Character/Player.cs index 44abc2ee4e..94eab4af5e 100644 --- a/Lib9c/Model/Character/Player.cs +++ b/Lib9c/Model/Character/Player.cs @@ -449,8 +449,8 @@ public CollectionMap GetRewards2(List items) public virtual void Spawn() { InitAI(); - var spawn = new SpawnPlayer((CharacterBase)Clone()); - Simulator.Log.Add(spawn); + // var spawn = new SpawnPlayer((CharacterBase)Clone()); + // Simulator.Log.Add(spawn); } [Obsolete("Use Spawn")] @@ -527,7 +527,7 @@ protected override BattleStatus.Skill UseSkill() var cooldown = RuneSkillCooldownMap[selectedSkill.SkillRow.Id]; RuneSkills.SetCooldown(selectedSkill.SkillRow.Id, cooldown); - Simulator.Log.Add(usedSkill); + // Simulator.Log.Add(usedSkill); return usedSkill; } @@ -672,7 +672,7 @@ protected override void EndTurn() Simulator.TurnNumber++; Simulator.WaveTurn++; - Simulator.Log.Add(new WaveTurnEnd(this, Simulator.TurnNumber, Simulator.WaveTurn)); + // Simulator.Log.Add(new WaveTurnEnd(this, Simulator.TurnNumber, Simulator.WaveTurn)); } } } From 0bb4c649cd777545c5aeac2534a0dc0b1899392e Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 6 Jul 2023 20:27:09 +0900 Subject: [PATCH 55/68] Optimize loop --- Lib9c/Action/HackAndSlash.cs | 39 +++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/Lib9c/Action/HackAndSlash.cs b/Lib9c/Action/HackAndSlash.cs index 58e5dd762e..08e8ed1f6b 100644 --- a/Lib9c/Action/HackAndSlash.cs +++ b/Lib9c/Action/HackAndSlash.cs @@ -439,8 +439,14 @@ public IAccountStateDelta Execute( } } + var stageWaveRow = sheets.GetSheet()[StageId]; + var enemySkillSheet = sheets.GetSheet(); + var costumeStatSheet = sheets.GetSheet(); + var stageCleared = !isNotClearedStage; + var starCount = 0; for (var i = 0; i < TotalPlayCount; i++) { + var rewards = StageSimulator.GetWaveRewards(random, stageRow, materialItemSheet); sw.Restart(); // First simulating will use Foods and Random Skills. // Remainder simulating will not use Foods. @@ -453,13 +459,13 @@ public IAccountStateDelta Execute( WorldId, StageId, stageRow, - sheets.GetSheet()[StageId], - avatarState.worldInformation.IsStageCleared(StageId), + stageWaveRow, + stageCleared, StageRewardExpHelper.GetExp(avatarState.level, StageId), simulatorSheets, - sheets.GetSheet(), - sheets.GetSheet(), - StageSimulator.GetWaveRewards(random, stageRow, materialItemSheet)); + enemySkillSheet, + costumeStatSheet, + rewards); sw.Stop(); Log.Verbose("{AddressesHex}HAS Initialize Simulator: {Elapsed}", addressesHex, sw.Elapsed); @@ -471,13 +477,17 @@ public IAccountStateDelta Execute( sw.Restart(); if (simulator.Log.IsClear) { - simulator.Player.worldInformation.ClearStage( - WorldId, - StageId, - blockIndex, - worldSheet, - worldUnlockSheet - ); + if (!stageCleared) + { + avatarState.worldInformation.ClearStage( + WorldId, + StageId, + blockIndex, + worldSheet, + worldUnlockSheet + ); + stageCleared = true; + } sw.Stop(); Log.Verbose("{AddressesHex}HAS ClearStage: {Elapsed}", addressesHex, sw.Elapsed); } @@ -504,9 +514,8 @@ public IAccountStateDelta Execute( player.eventMapForBeforeV100310.Clear(); } + starCount += simulator.Log.clearedWaveNumber; avatarState.Update(simulator); - // Update CrystalRandomSkillState.Stars by clearedWaveNumber. (add) - skillState?.Update(simulator.Log.clearedWaveNumber, crystalStageBuffSheet); sw.Stop(); Log.Verbose( @@ -526,6 +535,8 @@ public IAccountStateDelta Execute( Log.Verbose("{AddressesHex}HAS loop Simulate: {Elapsed}, Count: {PlayCount}", addressesHex, sw.Elapsed, TotalPlayCount); + // Update CrystalRandomSkillState.Stars by clearedWaveNumber. (add) + skillState?.Update(starCount, crystalStageBuffSheet); sw.Restart(); avatarState.UpdateQuestRewards(materialItemSheet); avatarState.updatedAt = blockIndex; From 852aba97fbe273bdf5bd09ea58fae674b77e0130 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 17:53:41 +0900 Subject: [PATCH 56/68] clean: replace to explicit class --- .Lib9c.Tests/Util/InitializeUtil.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index d5f12b65ee..6aa872f4aa 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -11,8 +11,6 @@ namespace Lib9c.Tests.Util using Nekoyume.Action; using Nekoyume.Model.State; using Nekoyume.TableData; - using State = Lib9c.Tests.Action.MockStateDelta; - using StateExtensions = Nekoyume.Model.State.StateExtensions; public static class InitializeUtil { @@ -31,7 +29,7 @@ IAccountStateDelta initialStatesWithAvatarStateV2 { adminAddr ??= new PrivateKey().ToAddress(); var context = new ActionContext(); - var states = new State().SetState( + var states = new MockStateDelta().SetState( Addresses.Admin, new AdminState(adminAddr.Value, long.MaxValue).Serialize()); var sheets = TableSheetsImporter.ImportSheets( From ea9648cf2515a740cb050889504098034ee7bc13 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 17:53:59 +0900 Subject: [PATCH 57/68] fix: apply new interface --- .Lib9c.Tests/Action/ClaimStakeReward4Test.cs | 4 ++-- Lib9c/Action/ClaimStakeReward4.cs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs b/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs index 22d531453b..c3946289ab 100644 --- a/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs +++ b/.Lib9c.Tests/Action/ClaimStakeReward4Test.cs @@ -244,12 +244,12 @@ private void Execute( prevState = prevState .SetState(stakeStateAddr, initialStakeState.Serialize()) - .MintAsset(stakeStateAddr, _ncg * stakeAmount); + .MintAsset(new ActionContext(), stakeStateAddr, _ncg * stakeAmount); var action = new ClaimStakeReward4(avatarAddr); var states = action.Execute(new ActionContext { - PreviousStates = prevState, + PreviousState = prevState, Signer = agentAddr, BlockIndex = blockIndex, }); diff --git a/Lib9c/Action/ClaimStakeReward4.cs b/Lib9c/Action/ClaimStakeReward4.cs index 776ae611eb..9709d7a548 100644 --- a/Lib9c/Action/ClaimStakeReward4.cs +++ b/Lib9c/Action/ClaimStakeReward4.cs @@ -129,10 +129,10 @@ public override IAccountStateDelta Execute(IActionContext context) context.UseGas(1); if (context.Rehearsal) { - return context.PreviousStates; + return context.PreviousState; } - var states = context.PreviousStates; + var states = context.PreviousState; var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); if (!states.TryGetStakeState(context.Signer, out var stakeState)) { @@ -291,7 +291,7 @@ private IAccountStateDelta ProcessReward( continue; } - states = states.MintAsset(AvatarAddress, runeReward); + states = states.MintAsset(context, AvatarAddress, runeReward); break; case StakeRegularRewardSheet.StakeRewardType.Currency: if (string.IsNullOrEmpty(reward.CurrencyTicker)) @@ -309,6 +309,7 @@ private IAccountStateDelta ProcessReward( } states = states.MintAsset( + context, context.Signer, rewardCurrencyQuantity * currencyRewardStep * rewardCurrency); break; From e44722b1e9f07b351370b459f06b086dbf0b4301 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Wed, 12 Jul 2023 15:33:18 +0900 Subject: [PATCH 58/68] Implement delta --- Lib9c.MessagePack/AccountStateDelta.cs | 68 ++++++++++++-------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/Lib9c.MessagePack/AccountStateDelta.cs b/Lib9c.MessagePack/AccountStateDelta.cs index 4377506037..79e91262c8 100644 --- a/Lib9c.MessagePack/AccountStateDelta.cs +++ b/Lib9c.MessagePack/AccountStateDelta.cs @@ -18,49 +18,35 @@ public struct AccountStateDelta : IAccountStateDelta private IImmutableDictionary _states; private IImmutableDictionary<(Address, Currency), BigInteger> _balances; private IImmutableDictionary _totalSupplies; - - public IImmutableSet
UpdatedAddresses => _states.Keys.ToImmutableHashSet(); - - public IImmutableSet
StateUpdatedAddresses => _states.Keys.ToImmutableHashSet(); - - public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => - _balances.Keys.ToImmutableHashSet(); + private MockAccountDelta _delta; public IImmutableSet<(Address, Currency)> TotalUpdatedFungibleAssets => ImmutableHashSet<(Address, Currency)>.Empty; - public IImmutableSet UpdatedTotalSupplyCurrencies => - _totalSupplies.Keys.ToImmutableHashSet(); - public AccountStateDelta( IImmutableDictionary states, IImmutableDictionary<(Address, Currency), BigInteger> balances, IImmutableDictionary totalSupplies ) { + _delta = new MockAccountDelta(states, balances, totalSupplies); _states = states; _balances = balances; _totalSupplies = totalSupplies; } public AccountStateDelta(Dictionary states, List balances, Dictionary totalSupplies) + : this( + states.ToImmutableDictionary( + kv => new Address(kv.Key), + kv => kv.Value), + balances.Cast().ToImmutableDictionary( + record => (new Address(((Binary)record["address"]).ByteArray), new Currency((Dictionary)record["currency"])), + record => (BigInteger)(Integer)record["amount"]), + totalSupplies.ToImmutableDictionary( + kv => new Currency(new Codec().Decode((Binary)kv.Key)), + kv => (BigInteger)(Integer)kv.Value)) { - // This assumes `states` consists of only Binary keys: - _states = states.ToImmutableDictionary( - kv => new Address(kv.Key), - kv => kv.Value - ); - - _balances = balances.Cast().ToImmutableDictionary( - record => (new Address(((Binary)record["address"]).ByteArray), new Currency((Dictionary)record["currency"])), - record => (BigInteger)(Integer)record["amount"] - ); - - // This assumes `totalSupplies` consists of only Binary keys: - _totalSupplies = totalSupplies.ToImmutableDictionary( - kv => new Currency(new Codec().Decode((Binary)kv.Key)), - kv => (BigInteger)(Integer)kv.Value - ); } public AccountStateDelta(IValue serialized) @@ -77,7 +63,7 @@ public AccountStateDelta(byte[] bytes) { } - public IAccountDelta Delta => new MockAccountDelta(); + public IAccountDelta Delta => _delta; public IValue? GetState(Address address) => _states.ContainsKey(address) @@ -245,18 +231,28 @@ public ValidatorSet GetValidatorSet() private class MockAccountDelta : IAccountDelta { - public MockAccountDelta() + private IImmutableDictionary _states; + private IImmutableDictionary<(Address, Currency), BigInteger> _fungibles; + private IImmutableDictionary _totalSupplies; + + public MockAccountDelta( + IImmutableDictionary states, + IImmutableDictionary<(Address, Currency), BigInteger> balances, + IImmutableDictionary totalSupplies) { + _states = states; + _fungibles = balances; + _totalSupplies = totalSupplies; } - public IImmutableSet
UpdatedAddresses => ImmutableHashSet
.Empty; - public IImmutableSet
StateUpdatedAddresses => ImmutableHashSet
.Empty; - public IImmutableDictionary States => ImmutableDictionary.Empty; - public IImmutableSet
FungibleUpdatedAddresses => ImmutableHashSet
.Empty; - public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => ImmutableHashSet<(Address, Currency)>.Empty; - public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => ImmutableDictionary<(Address, Currency), BigInteger>.Empty; - public IImmutableSet UpdatedTotalSupplyCurrencies => ImmutableHashSet.Empty; - public IImmutableDictionary TotalSupplies => ImmutableDictionary.Empty; + public IImmutableSet
UpdatedAddresses => StateUpdatedAddresses.Union(FungibleUpdatedAddresses); + public IImmutableSet
StateUpdatedAddresses => _states.Keys.ToImmutableHashSet(); + public IImmutableDictionary States => _states; + public IImmutableSet
FungibleUpdatedAddresses => _fungibles.Keys.Select(pair => pair.Item1).ToImmutableHashSet(); + public IImmutableSet<(Address, Currency)> UpdatedFungibleAssets => _fungibles.Keys.ToImmutableHashSet(); + public IImmutableDictionary<(Address, Currency), BigInteger> Fungibles => _fungibles; + public IImmutableSet UpdatedTotalSupplyCurrencies => _totalSupplies.Keys.ToImmutableHashSet(); + public IImmutableDictionary TotalSupplies => _totalSupplies; public ValidatorSet? ValidatorSet => null; } } From 94468db6c77da282b561108b25947aa6961f34c5 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 13 Jul 2023 10:32:10 +0900 Subject: [PATCH 59/68] Fix crystal mint --- .Lib9c.Tests/Action/CreateAvatarTest.cs | 11 +++++++---- Lib9c/Action/CreateAvatar.cs | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.Lib9c.Tests/Action/CreateAvatarTest.cs b/.Lib9c.Tests/Action/CreateAvatarTest.cs index 6488b3c24f..2d8b0b3f80 100644 --- a/.Lib9c.Tests/Action/CreateAvatarTest.cs +++ b/.Lib9c.Tests/Action/CreateAvatarTest.cs @@ -27,8 +27,11 @@ public CreateAvatarTest() _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); } - [Fact] - public void Execute() + [Theory] + [InlineData(0L, 600_000)] + [InlineData(7_210_000L, 600_000)] + [InlineData(7_210_001L, 200_000)] + public void Execute(long blockIndex, int expected) { var action = new CreateAvatar() { @@ -58,7 +61,7 @@ public void Execute() { PreviousState = state, Signer = _agentAddress, - BlockIndex = 0, + BlockIndex = blockIndex, }); var avatarAddress = _agentAddress.Derive( @@ -77,7 +80,7 @@ public void Execute() ); Assert.True(agentState.avatarAddresses.Any()); Assert.Equal("test", nextAvatarState.name); - Assert.Equal(600_000 * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); + Assert.Equal(expected * CrystalCalculator.CRYSTAL, nextState.GetBalance(_agentAddress, CrystalCalculator.CRYSTAL)); } [Theory] diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index 1b55f6c950..f2a2a9f54e 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -261,13 +261,16 @@ public override IAccountStateDelta Execute(IActionContext context) Log.Verbose("{AddressesHex}CreateAvatar CreateAvatarState: {Elapsed}", addressesHex, sw.Elapsed); var ended = DateTimeOffset.UtcNow; Log.Debug("{AddressesHex}CreateAvatar Total Executed Time: {Elapsed}", addressesHex, ended - started); + // TODO delete check blockIndex hard-fork this action + // Fix invalid mint crystal balance in internal network. main-net always mint 200_000 + var mintingValue = context.BlockIndex > 7_210_000L ? 200_000 : 600_000; return states .SetState(signer, agentState.Serialize()) .SetState(inventoryAddress, avatarState.inventory.Serialize()) .SetState(worldInformationAddress, avatarState.worldInformation.Serialize()) .SetState(questListAddress, avatarState.questList.Serialize()) .SetState(avatarAddress, avatarState.SerializeV2()) - .MintAsset(ctx, signer, 600_000 * CrystalCalculator.CRYSTAL); + .MintAsset(ctx, signer, mintingValue * CrystalCalculator.CRYSTAL); } } } From c6beb70868dada10a45ed678592a59c55683fb93 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 12 Jul 2023 16:12:42 +0900 Subject: [PATCH 60/68] Skip clone CharacterBase --- Lib9c/Battle/RaidBoss.cs | 10 +++-- Lib9c/Battle/StageSimulator.cs | 2 +- Lib9c/Battle/StageSimulatorV1.cs | 4 +- Lib9c/Battle/StageSimulatorV2.cs | 2 +- Lib9c/Battle/StageSimulatorV3.cs | 2 +- Lib9c/Model/BattleStatus/Skill.cs | 14 ++++--- Lib9c/Model/Buff/Bleed.cs | 2 +- Lib9c/Model/Character/CharacterBase.cs | 55 ++++++++++++-------------- Lib9c/Model/Character/Player.cs | 3 +- Lib9c/Model/Skill/AreaAttack.cs | 9 ++--- Lib9c/Model/Skill/AttackSkill.cs | 5 ++- Lib9c/Model/Skill/BlowAttack.cs | 7 ++-- Lib9c/Model/Skill/BuffRemovalAttack.cs | 7 ++-- Lib9c/Model/Skill/BuffSkill.cs | 4 +- Lib9c/Model/Skill/DoubleAttack.cs | 7 ++-- Lib9c/Model/Skill/HealSkill.cs | 11 +++--- Lib9c/Model/Skill/NormalAttack.cs | 7 ++-- Lib9c/Model/Skill/Skill.cs | 8 ++-- 18 files changed, 77 insertions(+), 82 deletions(-) diff --git a/Lib9c/Battle/RaidBoss.cs b/Lib9c/Battle/RaidBoss.cs index 3ab518802f..dca8e7657f 100644 --- a/Lib9c/Battle/RaidBoss.cs +++ b/Lib9c/Battle/RaidBoss.cs @@ -104,7 +104,8 @@ protected override BattleStatus.Skill UseSkill() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); Simulator.Log.Add(usedSkill); @@ -145,16 +146,17 @@ public void Enrage() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); Simulator.Log.Add(usedSkill); foreach (var info in usedSkill.SkillInfos) { - if (!info.Target.IsDead) + if (!info.IsDead) continue; - var target = Targets.FirstOrDefault(i => i.Id == info.Target.Id); + var target = Targets.FirstOrDefault(i => i.Id == info.Id); target?.Die(); } } diff --git a/Lib9c/Battle/StageSimulator.cs b/Lib9c/Battle/StageSimulator.cs index ec93e0a26a..6726e10c35 100644 --- a/Lib9c/Battle/StageSimulator.cs +++ b/Lib9c/Battle/StageSimulator.cs @@ -128,7 +128,7 @@ public Player Simulate(bool log = false) ActionBuffSheet ); - skill.Use(Player, 0, buffs); + skill.Use(Player, 0, buffs, log); } while (true) diff --git a/Lib9c/Battle/StageSimulatorV1.cs b/Lib9c/Battle/StageSimulatorV1.cs index 66e386f255..1ad0e2cbc2 100644 --- a/Lib9c/Battle/StageSimulatorV1.cs +++ b/Lib9c/Battle/StageSimulatorV1.cs @@ -301,7 +301,7 @@ CostumeStatSheet costumeStatSheet { Player.SetCostumeStat(costumeStatSheet); } - + public Player Simulate(int playCount) { Log.worldId = WorldId; @@ -331,7 +331,7 @@ public Player Simulate(int playCount) ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs); + var usedSkill = skill.Use(Player, 0, buffs, false); Log.Add(usedSkill); } diff --git a/Lib9c/Battle/StageSimulatorV2.cs b/Lib9c/Battle/StageSimulatorV2.cs index 12845f69ee..28a2511ff9 100644 --- a/Lib9c/Battle/StageSimulatorV2.cs +++ b/Lib9c/Battle/StageSimulatorV2.cs @@ -122,7 +122,7 @@ public Player Simulate() ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs); + var usedSkill = skill.Use(Player, 0, buffs, false); Log.Add(usedSkill); } diff --git a/Lib9c/Battle/StageSimulatorV3.cs b/Lib9c/Battle/StageSimulatorV3.cs index 253327ea37..98ec1bcfc7 100644 --- a/Lib9c/Battle/StageSimulatorV3.cs +++ b/Lib9c/Battle/StageSimulatorV3.cs @@ -128,7 +128,7 @@ public Player Simulate() ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs); + var usedSkill = skill.Use(Player, 0, buffs, false); Log.Add(usedSkill); } diff --git a/Lib9c/Model/BattleStatus/Skill.cs b/Lib9c/Model/BattleStatus/Skill.cs index 3c7f3bcf29..930ce6442e 100644 --- a/Lib9c/Model/BattleStatus/Skill.cs +++ b/Lib9c/Model/BattleStatus/Skill.cs @@ -12,22 +12,26 @@ public abstract class Skill : EventBase [Serializable] public class SkillInfo { - public readonly CharacterBase Target; public readonly int Effect; public readonly bool Critical; public readonly SkillCategory SkillCategory; public readonly ElementalType ElementalType; public readonly SkillTargetType SkillTargetType; public readonly int WaveTurn; + public readonly int Thorn; + public readonly bool IsDead; + public readonly Guid Id; + - public readonly Model.Buff.Buff? Buff; - public SkillInfo(CharacterBase character, int effect, bool critical, SkillCategory skillCategory, + public SkillInfo(Guid id, bool isDead, int thorn, int effect, bool critical, SkillCategory skillCategory, int waveTurn, ElementalType elementalType = ElementalType.Normal, SkillTargetType targetType = SkillTargetType.Enemy, Model.Buff.Buff? buff = null) { - Target = character; + Id = id; + IsDead = isDead; + Thorn = thorn; Effect = effect; Critical = critical; SkillCategory = skillCategory; @@ -42,7 +46,7 @@ public SkillInfo(CharacterBase character, int effect, bool critical, SkillCatego public readonly IEnumerable SkillInfos; - + public readonly IEnumerable? BuffInfos; protected Skill(int skillId, CharacterBase character, IEnumerable skillInfos, diff --git a/Lib9c/Model/Buff/Bleed.cs b/Lib9c/Model/Buff/Bleed.cs index 5011703514..3589acec71 100644 --- a/Lib9c/Model/Buff/Bleed.cs +++ b/Lib9c/Model/Buff/Bleed.cs @@ -41,7 +41,7 @@ public override BattleStatus.Skill GiveEffect( var damageInfos = new List { - new BattleStatus.Skill.SkillInfo((CharacterBase)affectedCharacter.Clone(), damage, false, + new BattleStatus.Skill.SkillInfo(affectedCharacter.Id, affectedCharacter.IsDead, affectedCharacter.Thorn, damage, false, SkillCategory.Debuff, simulatorWaveTurn, RowData.ElementalType, RowData.TargetType) }; diff --git a/Lib9c/Model/Character/CharacterBase.cs b/Lib9c/Model/Character/CharacterBase.cs index abbf0808c5..014e946380 100644 --- a/Lib9c/Model/Character/CharacterBase.cs +++ b/Lib9c/Model/Character/CharacterBase.cs @@ -250,7 +250,8 @@ protected virtual BattleStatus.Skill UseSkill() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); if (!Simulator.SkillSheet.TryGetValue(selectedSkill.SkillRow.Id, out var sheetSkill)) @@ -278,7 +279,8 @@ private BattleStatus.Skill UseSkillV1() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); Skills.SetCooldown(selectedSkill.SkillRow.Id, selectedSkill.SkillRow.Cooldown); @@ -301,7 +303,8 @@ private BattleStatus.Skill UseSkillV2() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); Skills.SetCooldown(selectedSkill.SkillRow.Id, selectedSkill.SkillRow.Cooldown); @@ -566,9 +569,9 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) skillInfo.SkillCategory == SkillCategory.DoubleAttack || skillInfo.SkillCategory == SkillCategory.AreaAttack || skillInfo.SkillCategory == SkillCategory.BuffRemovalAttack; - if (isAttackSkill && skillInfo.Target.Thorn > 0) + if (isAttackSkill && skillInfo.Thorn > 0) { - var effect = GiveThornDamage(skillInfo.Target.Thorn); + GiveThornDamage(skillInfo.Thorn); // Simulator.Log.Add(effect); } } @@ -582,31 +585,23 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) FinishTargetIfKilled(usedSkill); } - private BattleStatus.Skill GiveThornDamage(int targetThorn) + private void GiveThornDamage(int targetThorn) { - var clone = (CharacterBase)Clone(); + // var clone = (CharacterBase)Clone(); // minimum 1 damage var thornDamage = Math.Max(1, targetThorn - DEF); CurrentHP -= thornDamage; - var damageInfos = new List() - { - new BattleStatus.Skill.SkillInfo( - (CharacterBase)Clone(), - thornDamage, - false, - SkillCategory.TickDamage, - Simulator.WaveTurn, - ElementalType.Normal, - SkillTargetType.Enemy) - }; - - var tickDamage = new TickDamage( - default, - clone, - damageInfos, - null); - - return tickDamage; + // var damageInfos = new List() + // { + // new BattleStatus.Skill.SkillInfo( + // (CharacterBase)Clone(), + // thornDamage, + // false, + // SkillCategory.TickDamage, + // Simulator.WaveTurn, + // ElementalType.Normal, + // SkillTargetType.Enemy) + // }; } private void FinishTargetIfKilledForBeforeV100310(BattleStatus.Skill usedSkill) @@ -614,7 +609,7 @@ private void FinishTargetIfKilledForBeforeV100310(BattleStatus.Skill usedSkill) var isFirst = true; foreach (var info in usedSkill.SkillInfos) { - if (!info.Target.IsDead) + if (!info.IsDead) { continue; } @@ -626,7 +621,7 @@ private void FinishTargetIfKilledForBeforeV100310(BattleStatus.Skill usedSkill) } var target = Targets.FirstOrDefault(i => - i.Id == info.Target.Id); + i.Id == info.Id); switch (target) { case Player player: @@ -655,12 +650,12 @@ private void FinishTargetIfKilled(BattleStatus.Skill usedSkill) var killedTargets = new List(); foreach (var info in usedSkill.SkillInfos) { - if (!info.Target.IsDead) + if (!info.IsDead) { continue; } - var target = Targets.FirstOrDefault(i => i.Id == info.Target.Id); + var target = Targets.FirstOrDefault(i => i.Id == info.Id); if (!killedTargets.Contains(target)) { killedTargets.Add(target); diff --git a/Lib9c/Model/Character/Player.cs b/Lib9c/Model/Character/Player.cs index 94eab4af5e..6d44793e1f 100644 --- a/Lib9c/Model/Character/Player.cs +++ b/Lib9c/Model/Character/Player.cs @@ -522,7 +522,8 @@ protected override BattleStatus.Skill UseSkill() Simulator.StatBuffSheet, Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet - ) + ), + false ); var cooldown = RuneSkillCooldownMap[selectedSkill.SkillRow.Id]; diff --git a/Lib9c/Model/Skill/AreaAttack.cs b/Lib9c/Model/Skill/AreaAttack.cs index c49774e492..d5009806ac 100644 --- a/Lib9c/Model/Skill/AreaAttack.cs +++ b/Lib9c/Model/Skill/AreaAttack.cs @@ -17,12 +17,11 @@ public AreaAttack( { } - public override Model.BattleStatus.Skill Use( - CharacterBase caster, - int simulatorWaveTurn, - IEnumerable buffs) + public override BattleStatus.Skill Use(CharacterBase caster, + int simulatorWaveTurn, + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/AttackSkill.cs b/Lib9c/Model/Skill/AttackSkill.cs index b5c392ab28..a676c9eabe 100644 --- a/Lib9c/Model/Skill/AttackSkill.cs +++ b/Lib9c/Model/Skill/AttackSkill.cs @@ -29,7 +29,7 @@ protected AttackSkill( /// /// protected IEnumerable ProcessDamage(CharacterBase caster, int simulatorWaveTurn, - bool isNormalAttack = false) + bool isNormalAttack = false, bool b = false) { var infos = new List(); var targets = SkillRow.SkillTargetType.GetTarget(caster).ToList(); @@ -86,7 +86,8 @@ protected AttackSkill( target.CurrentHP -= damage; } - infos.Add(new BattleStatus.Skill.SkillInfo((CharacterBase) target.Clone(), damage, isCritical, + var clone = b ? (CharacterBase) target.Clone() : null; + infos.Add(new BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, damage, isCritical, SkillRow.SkillCategory, simulatorWaveTurn, SkillRow.ElementalType, SkillRow.SkillTargetType)); } diff --git a/Lib9c/Model/Skill/BlowAttack.cs b/Lib9c/Model/Skill/BlowAttack.cs index 6d0eb29ba8..fa6b724a02 100644 --- a/Lib9c/Model/Skill/BlowAttack.cs +++ b/Lib9c/Model/Skill/BlowAttack.cs @@ -17,12 +17,11 @@ public BlowAttack( { } - public override BattleStatus.Skill Use( - CharacterBase caster, + public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/BuffRemovalAttack.cs b/Lib9c/Model/Skill/BuffRemovalAttack.cs index be103e777d..fd04ff37bc 100644 --- a/Lib9c/Model/Skill/BuffRemovalAttack.cs +++ b/Lib9c/Model/Skill/BuffRemovalAttack.cs @@ -17,12 +17,11 @@ public BuffRemovalAttack( { } - public override BattleStatus.Skill Use( - CharacterBase caster, + public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); var targets = SkillRow.SkillTargetType.GetTarget(caster); diff --git a/Lib9c/Model/Skill/BuffSkill.cs b/Lib9c/Model/Skill/BuffSkill.cs index a6d61f8c0d..524f9b65d9 100644 --- a/Lib9c/Model/Skill/BuffSkill.cs +++ b/Lib9c/Model/Skill/BuffSkill.cs @@ -18,9 +18,9 @@ public BuffSkill( } public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new BattleStatus.Buff(SkillRow.Id, clone, buff); diff --git a/Lib9c/Model/Skill/DoubleAttack.cs b/Lib9c/Model/Skill/DoubleAttack.cs index 35f0038128..fe75c2b115 100644 --- a/Lib9c/Model/Skill/DoubleAttack.cs +++ b/Lib9c/Model/Skill/DoubleAttack.cs @@ -17,12 +17,11 @@ public DoubleAttack( { } - public override BattleStatus.Skill Use( - CharacterBase caster, + public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/HealSkill.cs b/Lib9c/Model/Skill/HealSkill.cs index f7bbd5cf4b..9bfab1ed7d 100644 --- a/Lib9c/Model/Skill/HealSkill.cs +++ b/Lib9c/Model/Skill/HealSkill.cs @@ -17,15 +17,14 @@ public HealSkill( { } - public override BattleStatus.Skill Use( - CharacterBase caster, + public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var heal = ProcessHeal(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); - + return new BattleStatus.HealSkill(SkillRow.Id, clone, heal, buff); } @@ -42,7 +41,7 @@ public override BattleStatus.Skill Use( foreach (var target in SkillRow.SkillTargetType.GetTarget(caster)) { target.Heal(healPoint); - infos.Add(new BattleStatus.Skill.SkillInfo((CharacterBase)target.Clone(), healPoint, caster.IsCritical(false), + infos.Add(new BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, healPoint, caster.IsCritical(false), SkillRow.SkillCategory, simulatorWaveTurn)); } diff --git a/Lib9c/Model/Skill/NormalAttack.cs b/Lib9c/Model/Skill/NormalAttack.cs index 96facc11c9..11329ba690 100644 --- a/Lib9c/Model/Skill/NormalAttack.cs +++ b/Lib9c/Model/Skill/NormalAttack.cs @@ -17,12 +17,11 @@ public NormalAttack( { } - public override Model.BattleStatus.Skill Use( - CharacterBase caster, + public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs) + IEnumerable buffs, bool b) { - var clone = (CharacterBase) caster.Clone(); + var clone = b ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn, true); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/Skill.cs b/Lib9c/Model/Skill/Skill.cs index 6985aa7e57..ce99003587 100644 --- a/Lib9c/Model/Skill/Skill.cs +++ b/Lib9c/Model/Skill/Skill.cs @@ -36,11 +36,9 @@ protected Skill( ReferencedStatType = referencedStatType; } - public abstract BattleStatus.Skill Use( - CharacterBase caster, + public abstract BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs - ); + IEnumerable buffs, bool b); protected bool Equals(Skill other) { @@ -83,7 +81,7 @@ public override int GetHashCode() foreach (var target in targets.Where(target => target.GetChance(buff.BuffInfo.Chance))) { target.AddBuff(buff); - infos.Add(new Model.BattleStatus.Skill.SkillInfo((CharacterBase) target.Clone(), 0, false, + infos.Add(new Model.BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, 0, false, SkillRow.SkillCategory, simulatorWaveTurn, ElementalType.Normal, SkillRow.SkillTargetType, buff)); } From f11925f6cf1eb9ed64b20ec73ead6ae3a694cbd0 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 13 Jul 2023 15:52:19 +0900 Subject: [PATCH 61/68] Improve HitHelper - simplify hitstep1 - remove type casting hitstep2 --- Lib9c/Battle/HitHelper.cs | 113 +++++++++++--------------------------- 1 file changed, 32 insertions(+), 81 deletions(-) diff --git a/Lib9c/Battle/HitHelper.cs b/Lib9c/Battle/HitHelper.cs index f2d9c2caaa..1efbde5a6a 100644 --- a/Lib9c/Battle/HitHelper.cs +++ b/Lib9c/Battle/HitHelper.cs @@ -64,101 +64,52 @@ public static bool IsHitWithoutLevelCorrection( public static int GetHitStep1(int attackerLevel, int defenderLevel) { - var correction = 0; var diff = attackerLevel - defenderLevel; if (diff <= GetHitStep1LevelDiffMin) { - correction = GetHitStep1CorrectionMin; + return GetHitStep1CorrectionMin; } - else if (diff >= GetHitStep1LevelDiffMax) - { - correction = GetHitStep1CorrectionMax; - } - else + + if (diff >= GetHitStep1LevelDiffMax) { - switch (diff) - { - case -13: - correction = -4; - break; - case -12: - correction = -3; - break; - case -11: - correction = -2; - break; - case -10: - correction = -1; - break; - case -9: - correction = 0; - break; - case -8: - correction = 1; - break; - case -7: - correction = 2; - break; - case -6: - correction = 4; - break; - case -5: - correction = 6; - break; - case -4: - correction = 8; - break; - case -3: - correction = 13; - break; - case -2: - correction = 20; - break; - case -1: - correction = 28; - break; - case 0: - correction = 40; - break; - case 1: - correction = 41; - break; - case 2: - correction = 42; - break; - case 3: - correction = 43; - break; - case 4: - correction = 44; - break; - case 5: - correction = 45; - break; - case 6: - correction = 46; - break; - case 7: - correction = 47; - break; - case 8: - correction = 48; - break; - case 9: - correction = 49; - break; - } + return GetHitStep1CorrectionMax; } - return correction; + return diff switch + { + -13 => -4, + -12 => -3, + -11 => -2, + -10 => -1, + -9 => 0, + -8 => 1, + -7 => 2, + -6 => 4, + -5 => 6, + -4 => 8, + -3 => 13, + -2 => 20, + -1 => 28, + 0 => 40, + 1 => 41, + 2 => 42, + 3 => 43, + 4 => 44, + 5 => 45, + 6 => 46, + 7 => 47, + 8 => 48, + 9 => 49, + _ => 0 + }; } public static int GetHitStep2(int attackerHit, int defenderHit) { attackerHit = Math.Max(1, attackerHit); defenderHit = Math.Max(1, defenderHit); - var additionalCorrection = (int) ((attackerHit - defenderHit / 3m) / defenderHit * 100); + var additionalCorrection = (attackerHit * 100 - defenderHit * 100 / 3) / defenderHit; return Math.Min(Math.Max(additionalCorrection, GetHitStep2AdditionalCorrectionMin), GetHitStep2AdditionalCorrectionMax); } From cce76925a7162a96897672788a287d1c8e4d9b98 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 13 Jul 2023 16:53:53 +0900 Subject: [PATCH 62/68] Improve AttackCountHelper - Delete dictionary - Delete type convert --- Lib9c/Battle/AttackCountHelper.cs | 127 ++++++++++-------------- Lib9c/Model/Character/ArenaCharacter.cs | 4 +- Lib9c/Model/Character/CharacterBase.cs | 4 +- 3 files changed, 55 insertions(+), 80 deletions(-) diff --git a/Lib9c/Battle/AttackCountHelper.cs b/Lib9c/Battle/AttackCountHelper.cs index 89dc520f94..7fffe6ff73 100644 --- a/Lib9c/Battle/AttackCountHelper.cs +++ b/Lib9c/Battle/AttackCountHelper.cs @@ -1,68 +1,14 @@ using System; using System.Collections.Generic; +using System.Diagnostics; namespace Nekoyume.Battle { public static class AttackCountHelper { - public struct Info - { - public decimal DamageMultiplier; - public decimal AdditionalCriticalChance; - } - public const int CountMaxLowerLimit = 2; public const int CountMaxUpperLimit = 5; - /// - /// key: attack count max - /// value: attack count, info - /// - public static readonly IReadOnlyDictionary> CachedInfo = - new Dictionary> - { - { - 1, new Dictionary - { - {1, new Info {DamageMultiplier = 1m, AdditionalCriticalChance = 0m}} - } - }, - { - 2, new Dictionary - { - {1, new Info {DamageMultiplier = 1m, AdditionalCriticalChance = 0m}}, - {2, new Info {DamageMultiplier = 2m, AdditionalCriticalChance = 25m}} - } - }, - { - 3, new Dictionary - { - {1, new Info {DamageMultiplier = 1m, AdditionalCriticalChance = 0m}}, - {2, new Info {DamageMultiplier = 2m, AdditionalCriticalChance = 10m}}, - {3, new Info {DamageMultiplier = 3m, AdditionalCriticalChance = 35m}} - } - }, - { - 4, new Dictionary - { - {1, new Info {DamageMultiplier = 1m, AdditionalCriticalChance = 0m}}, - {2, new Info {DamageMultiplier = 2m, AdditionalCriticalChance = 10m}}, - {3, new Info {DamageMultiplier = 3m, AdditionalCriticalChance = 20m}}, - {4, new Info {DamageMultiplier = 4m, AdditionalCriticalChance = 45m}} - } - }, - { - 5, new Dictionary - { - {1, new Info {DamageMultiplier = 1m, AdditionalCriticalChance = 0m}}, - {2, new Info {DamageMultiplier = 2m, AdditionalCriticalChance = 10m}}, - {3, new Info {DamageMultiplier = 3m, AdditionalCriticalChance = 20m}}, - {4, new Info {DamageMultiplier = 4m, AdditionalCriticalChance = 30m}}, - {5, new Info {DamageMultiplier = 5m, AdditionalCriticalChance = 55m}} - } - } - }; - public static int GetCountMax(int level) { if (level < 11) @@ -76,40 +22,69 @@ public static int GetCountMax(int level) : CountMaxUpperLimit; } - public static decimal GetDamageMultiplier(int attackCount, int attackCountMax) + public static int GetDamageMultiplier(int attackCount, int attackCountMax) { if (attackCount > attackCountMax) throw new ArgumentOutOfRangeException( $"{nameof(attackCount)}: {attackCount} / {nameof(attackCountMax)}: {attackCountMax}"); - var info = GetInfo(attackCount, attackCountMax); - return info.DamageMultiplier; - } - - public static decimal GetAdditionalCriticalChance(int attackCount, int attackCountMax) - { - if (attackCount > attackCountMax) - throw new ArgumentOutOfRangeException( - $"{nameof(attackCount)}: {attackCount} / {nameof(attackCountMax)}: {attackCountMax}"); + if (attackCountMax <= 5) + { + return Math.Max(1, attackCount); + } - var info = GetInfo(attackCount, attackCountMax); - return info.AdditionalCriticalChance; + throw new ArgumentOutOfRangeException(); } - private static Info GetInfo(int attackCount, int attackCountMax) + public static int GetAdditionalCriticalChance(int attackCount, int attackCountMax) { if (attackCount > attackCountMax) throw new ArgumentOutOfRangeException( $"{nameof(attackCount)}: {attackCount} / {nameof(attackCountMax)}: {attackCountMax}"); + switch (attackCount) + { + case 1: + return 0; + case 2: + switch (attackCountMax) + { + case 2: + return 25; + case 3: + case 4: + case 5: + return 10; + } + break; + case 3: + switch (attackCountMax) + { + case 3: + return 35; + case 4: + case 5: + return 20; + } + break; + case 4: + switch (attackCountMax) + { + case 4: + return 45; + case 5: + return 30; + } + break; + case 5: + switch (attackCountMax) + { + case 5: + return 55; + } + break; + } - if (!CachedInfo.ContainsKey(attackCountMax)) - throw new ArgumentOutOfRangeException($"{nameof(attackCountMax)}: {attackCountMax}"); - - if (!CachedInfo[attackCountMax].ContainsKey(attackCount)) - throw new ArgumentOutOfRangeException( - $"{nameof(attackCountMax)}: {attackCountMax} / {nameof(attackCount)}: {attackCount}"); - - return CachedInfo[attackCountMax][attackCount]; + throw new ArgumentOutOfRangeException(); } } } diff --git a/Lib9c/Model/Character/ArenaCharacter.cs b/Lib9c/Model/Character/ArenaCharacter.cs index 2ec210f0dd..d487336ea3 100644 --- a/Lib9c/Model/Character/ArenaCharacter.cs +++ b/Lib9c/Model/Character/ArenaCharacter.cs @@ -819,7 +819,7 @@ public bool IsCritical(bool considerAttackCount = true) return CRI >= chance; var additionalCriticalChance = - (int) AttackCountHelper.GetAdditionalCriticalChance(_attackCount, _attackCountMax); + AttackCountHelper.GetAdditionalCriticalChance(_attackCount, _attackCountMax); return CRI + additionalCriticalChance >= chance; } @@ -850,7 +850,7 @@ public int GetDamage(int damage, bool considerAttackCount = true) _attackCount = 1; } - var damageMultiplier = (int) AttackCountHelper.GetDamageMultiplier(_attackCount, _attackCountMax); + var damageMultiplier = AttackCountHelper.GetDamageMultiplier(_attackCount, _attackCountMax); damage *= damageMultiplier; return damage; } diff --git a/Lib9c/Model/Character/CharacterBase.cs b/Lib9c/Model/Character/CharacterBase.cs index 014e946380..5293ea55f0 100644 --- a/Lib9c/Model/Character/CharacterBase.cs +++ b/Lib9c/Model/Character/CharacterBase.cs @@ -413,7 +413,7 @@ public bool IsCritical(bool considerAttackCount = true) return CRI >= chance; var additionalCriticalChance = - (int) AttackCountHelper.GetAdditionalCriticalChance(AttackCount, AttackCountMax); + AttackCountHelper.GetAdditionalCriticalChance(AttackCount, AttackCountMax); return CRI + additionalCriticalChance >= chance; } @@ -446,7 +446,7 @@ public int GetDamage(int damage, bool considerAttackCount = true) AttackCount = 1; } - var damageMultiplier = (int) AttackCountHelper.GetDamageMultiplier(AttackCount, AttackCountMax); + var damageMultiplier = AttackCountHelper.GetDamageMultiplier(AttackCount, AttackCountMax); damage *= damageMultiplier; #if TEST_LOG From cd81e23c0e88128163b2e681cb8f5bf08206a458 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 14 Jul 2023 16:37:58 +0900 Subject: [PATCH 63/68] Enable replay log by Simulator.LogEvent --- .Lib9c.Tests/Model/Skill/CombatTest.cs | 34 +++++++- .Lib9c.Tests/Model/Skill/NormalAttackTest.cs | 5 +- Lib9c/Action/HackAndSlash.cs | 3 +- Lib9c/Battle/ISimulator.cs | 1 + Lib9c/Battle/RaidBoss.cs | 6 +- Lib9c/Battle/Simulator.cs | 8 +- Lib9c/Battle/StageSimulator.cs | 24 +++--- Lib9c/Battle/StageSimulatorV1.cs | 2 +- Lib9c/Battle/StageSimulatorV2.cs | 2 +- Lib9c/Battle/StageSimulatorV3.cs | 2 +- Lib9c/Battle/Wave.cs | 9 ++- Lib9c/Model/BattleStatus/Skill.cs | 10 ++- Lib9c/Model/Buff/Bleed.cs | 3 +- Lib9c/Model/Character/CharacterBase.cs | 82 ++++++++++++++------ Lib9c/Model/Character/Player.cs | 21 +++-- Lib9c/Model/Skill/AreaAttack.cs | 4 +- Lib9c/Model/Skill/AttackSkill.cs | 7 +- Lib9c/Model/Skill/BlowAttack.cs | 4 +- Lib9c/Model/Skill/BuffRemovalAttack.cs | 4 +- Lib9c/Model/Skill/BuffSkill.cs | 4 +- Lib9c/Model/Skill/DoubleAttack.cs | 4 +- Lib9c/Model/Skill/HealSkill.cs | 6 +- Lib9c/Model/Skill/NormalAttack.cs | 4 +- Lib9c/Model/Skill/Skill.cs | 4 +- 24 files changed, 169 insertions(+), 84 deletions(-) diff --git a/.Lib9c.Tests/Model/Skill/CombatTest.cs b/.Lib9c.Tests/Model/Skill/CombatTest.cs index fb8f8c05f7..1622761013 100644 --- a/.Lib9c.Tests/Model/Skill/CombatTest.cs +++ b/.Lib9c.Tests/Model/Skill/CombatTest.cs @@ -75,7 +75,7 @@ public void CalculateDEFAndDamageReduction(int def, int drv, int drr, int enemyA var normalAttack = new NormalAttack(skillRow, 0, 100, default, StatType.NONE); var prevHP = _player.CurrentHP; - normalAttack.Use(_enemy, 1, new List()); + normalAttack.Use(_enemy, 1, new List(), false); var currentHP = _player.CurrentHP; var damage = prevHP - currentHP; @@ -100,11 +100,41 @@ public void CalculateCritDamage(int cdmg, int atk, int expectedDamage) var normalAttack = new NormalAttack(skillRow, 0, 100, default, StatType.NONE); var prevHP = _player.CurrentHP; - normalAttack.Use(_enemy, 1, new List()); + normalAttack.Use(_enemy, 1, new List(), false); var currentHP = _player.CurrentHP; var damage = prevHP - currentHP; Assert.Equal(expectedDamage, damage); } + + [Fact] + public void Thorn() + { + var prevHP = _enemy.CurrentHP; + var skill = _enemy.GiveThornDamage(1); + var currentHP = _enemy.CurrentHP; + // get 1dmg from thorn + Assert.Equal(prevHP - 1, currentHP); + Assert.Equal(prevHP, skill.Character.CurrentHP); + var skillInfo = Assert.Single(skill.SkillInfos); + Assert.Equal(currentHP, skillInfo.Target!.CurrentHP); + } + + [Fact] + public void Bleed() + { + var actionBuffSheet = _tableSheets.ActionBuffSheet; + var row = actionBuffSheet.Values.First(); + var bleed = Assert.IsType(BuffFactory.GetActionBuff(_enemy.Stats, row)); + var dmg = bleed.Power; + var prevHP = _player.CurrentHP; + var skill = bleed.GiveEffect(_player, 1); + var currentHP = _player.CurrentHP; + // get dmg from bleed + Assert.Equal(prevHP - dmg, currentHP); + Assert.Equal(prevHP, skill.Character.CurrentHP); + var skillInfo = Assert.Single(skill.SkillInfos); + Assert.Equal(currentHP, skillInfo.Target!.CurrentHP); + } } } diff --git a/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs b/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs index e6a8c843cd..125bfe47f5 100644 --- a/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs @@ -79,13 +79,14 @@ public void Use() var battleStatusSkill = normalAttack.Use( player, 0, - new List()); + new List(), + true); Assert.NotNull(battleStatusSkill); Assert.Single(battleStatusSkill.SkillInfos); var skillInfo = battleStatusSkill.SkillInfos.FirstOrDefault(); Assert.NotNull(skillInfo); - Assert.Equal(enemy.Id, skillInfo.Target.Id); + Assert.Equal(enemy.Id, skillInfo.CharacterId); } } } diff --git a/Lib9c/Action/HackAndSlash.cs b/Lib9c/Action/HackAndSlash.cs index 08e8ed1f6b..90563404e2 100644 --- a/Lib9c/Action/HackAndSlash.cs +++ b/Lib9c/Action/HackAndSlash.cs @@ -465,7 +465,8 @@ public IAccountStateDelta Execute( simulatorSheets, enemySkillSheet, costumeStatSheet, - rewards); + rewards, + false); sw.Stop(); Log.Verbose("{AddressesHex}HAS Initialize Simulator: {Elapsed}", addressesHex, sw.Elapsed); diff --git a/Lib9c/Battle/ISimulator.cs b/Lib9c/Battle/ISimulator.cs index d68c70b410..00f45d4eef 100644 --- a/Lib9c/Battle/ISimulator.cs +++ b/Lib9c/Battle/ISimulator.cs @@ -14,5 +14,6 @@ public interface ISimulator IEnumerable Reward { get; } int WaveNumber { get; } int WaveTurn { get; } + bool LogEvent { get; } } } diff --git a/Lib9c/Battle/RaidBoss.cs b/Lib9c/Battle/RaidBoss.cs index dca8e7657f..ce8b9231dc 100644 --- a/Lib9c/Battle/RaidBoss.cs +++ b/Lib9c/Battle/RaidBoss.cs @@ -105,7 +105,7 @@ protected override BattleStatus.Skill UseSkill() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + Simulator.LogEvent ); Simulator.Log.Add(usedSkill); @@ -147,7 +147,7 @@ public void Enrage() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + Simulator.LogEvent ); Simulator.Log.Add(usedSkill); @@ -156,7 +156,7 @@ public void Enrage() if (!info.IsDead) continue; - var target = Targets.FirstOrDefault(i => i.Id == info.Id); + var target = Targets.FirstOrDefault(i => i.Id == info.CharacterId); target?.Die(); } } diff --git a/Lib9c/Battle/Simulator.cs b/Lib9c/Battle/Simulator.cs index 70b4d69c62..7d43a46bcd 100644 --- a/Lib9c/Battle/Simulator.cs +++ b/Lib9c/Battle/Simulator.cs @@ -33,14 +33,14 @@ public abstract class Simulator : ISimulator public int WaveNumber { get; protected set; } public int WaveTurn { get; set; } public abstract IEnumerable Reward { get; } + public bool LogEvent { get; protected set; } - protected Simulator( - IRandom random, + protected Simulator(IRandom random, AvatarState avatarState, List foods, - SimulatorSheetsV1 simulatorSheets - ) : this(random, new Player(avatarState, simulatorSheets), foods, simulatorSheets) + SimulatorSheetsV1 simulatorSheets, bool logEvent = true) : this(random, new Player(avatarState, simulatorSheets), foods, simulatorSheets) { + LogEvent = logEvent; } protected Simulator( diff --git a/Lib9c/Battle/StageSimulator.cs b/Lib9c/Battle/StageSimulator.cs index 6726e10c35..e01122b6b5 100644 --- a/Lib9c/Battle/StageSimulator.cs +++ b/Lib9c/Battle/StageSimulator.cs @@ -13,6 +13,7 @@ using Nekoyume.Model.Buff; using Nekoyume.TableData; using Priority_Queue; +using Skill = Nekoyume.Model.Skill.Skill; namespace Nekoyume.Battle { @@ -32,12 +33,11 @@ public class StageSimulator : Simulator, IStageSimulator private int TurnLimit { get; } public override IEnumerable Reward => _waveRewards; - public StageSimulator( - IRandom random, + public StageSimulator(IRandom random, AvatarState avatarState, List foods, List runeStates, - List skillsOnWaveStart, + List skillsOnWaveStart, int worldId, int stageId, StageSheet.Row stageRow, @@ -47,12 +47,14 @@ public StageSimulator( SimulatorSheets simulatorSheets, EnemySkillSheet enemySkillSheet, CostumeStatSheet costumeStatSheet, - List waveRewards) + List waveRewards, + bool logEvent = true) : base( random, avatarState, foods, - simulatorSheets) + simulatorSheets, + logEvent) { Player.SetCostumeStat(costumeStatSheet); if (runeStates != null) @@ -99,7 +101,7 @@ public static List GetWaveRewards( return waveRewards; } - public Player Simulate(bool log = false) + public Player Simulate() { Log.worldId = WorldId; Log.stageId = StageId; @@ -128,7 +130,7 @@ public Player Simulate(bool log = false) ActionBuffSheet ); - skill.Use(Player, 0, buffs, log); + skill.Use(Player, 0, buffs, LogEvent); } while (true) @@ -141,7 +143,7 @@ public Player Simulate(bool log = false) Result = BattleLog.Result.Lose; if (Exp > 0) { - Player.GetExp((int)(Exp * 0.3m), log); + Player.GetExp((int)(Exp * 0.3m), LogEvent); } } else @@ -168,7 +170,7 @@ public Player Simulate(bool log = false) Result = BattleLog.Result.Lose; if (Exp > 0) { - Player.GetExp((int)(Exp * 0.3m), log); + Player.GetExp((int)(Exp * 0.3m), LogEvent); } } else @@ -191,7 +193,7 @@ public Player Simulate(bool log = false) { if (Exp > 0) { - Player.GetExp(Exp, log); + Player.GetExp(Exp, LogEvent); } break; @@ -199,7 +201,7 @@ public Player Simulate(bool log = false) case 2: { ItemMap = Player.GetRewards(_waveRewards); - if (log) + if (LogEvent) { var dropBox = new DropBox(null, _waveRewards); Log.Add(dropBox); diff --git a/Lib9c/Battle/StageSimulatorV1.cs b/Lib9c/Battle/StageSimulatorV1.cs index 1ad0e2cbc2..bafcaf03e7 100644 --- a/Lib9c/Battle/StageSimulatorV1.cs +++ b/Lib9c/Battle/StageSimulatorV1.cs @@ -331,7 +331,7 @@ public Player Simulate(int playCount) ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs, false); + var usedSkill = skill.Use(Player, 0, buffs, LogEvent); Log.Add(usedSkill); } diff --git a/Lib9c/Battle/StageSimulatorV2.cs b/Lib9c/Battle/StageSimulatorV2.cs index 28a2511ff9..08aed9dc75 100644 --- a/Lib9c/Battle/StageSimulatorV2.cs +++ b/Lib9c/Battle/StageSimulatorV2.cs @@ -122,7 +122,7 @@ public Player Simulate() ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs, false); + var usedSkill = skill.Use(Player, 0, buffs, LogEvent); Log.Add(usedSkill); } diff --git a/Lib9c/Battle/StageSimulatorV3.cs b/Lib9c/Battle/StageSimulatorV3.cs index 98ec1bcfc7..5d47a62482 100644 --- a/Lib9c/Battle/StageSimulatorV3.cs +++ b/Lib9c/Battle/StageSimulatorV3.cs @@ -128,7 +128,7 @@ public Player Simulate() ActionBuffSheet ); - var usedSkill = skill.Use(Player, 0, buffs, false); + var usedSkill = skill.Use(Player, 0, buffs, LogEvent); Log.Add(usedSkill); } diff --git a/Lib9c/Battle/Wave.cs b/Lib9c/Battle/Wave.cs index 615051057b..99bd2faf12 100644 --- a/Lib9c/Battle/Wave.cs +++ b/Lib9c/Battle/Wave.cs @@ -25,9 +25,12 @@ public void Spawn(ISimulator simulator) enemy.InitAI(); } - // var enemies = _enemies.Select(enemy => new Enemy(enemy)).ToList(); - // var spawnWave = new SpawnWave(null, simulator.WaveNumber, simulator.WaveTurn, enemies, HasBoss); - // simulator.Log.Add(spawnWave); + if (simulator.LogEvent) + { + var enemies = _enemies.Select(enemy => new Enemy(enemy)).ToList(); + var spawnWave = new SpawnWave(null, simulator.WaveNumber, simulator.WaveTurn, enemies, HasBoss); + simulator.Log.Add(spawnWave); + } } [Obsolete("Use Spawn")] diff --git a/Lib9c/Model/BattleStatus/Skill.cs b/Lib9c/Model/BattleStatus/Skill.cs index 930ce6442e..48149d5a4d 100644 --- a/Lib9c/Model/BattleStatus/Skill.cs +++ b/Lib9c/Model/BattleStatus/Skill.cs @@ -12,6 +12,7 @@ public abstract class Skill : EventBase [Serializable] public class SkillInfo { + public readonly CharacterBase? Target; public readonly int Effect; public readonly bool Critical; public readonly SkillCategory SkillCategory; @@ -20,16 +21,16 @@ public class SkillInfo public readonly int WaveTurn; public readonly int Thorn; public readonly bool IsDead; - public readonly Guid Id; + public readonly Guid CharacterId; public readonly Model.Buff.Buff? Buff; - public SkillInfo(Guid id, bool isDead, int thorn, int effect, bool critical, SkillCategory skillCategory, + public SkillInfo(Guid characterId, bool isDead, int thorn, int effect, bool critical, SkillCategory skillCategory, int waveTurn, ElementalType elementalType = ElementalType.Normal, - SkillTargetType targetType = SkillTargetType.Enemy, Model.Buff.Buff? buff = null) + SkillTargetType targetType = SkillTargetType.Enemy, Model.Buff.Buff? buff = null, CharacterBase? target = null) { - Id = id; + CharacterId = characterId; IsDead = isDead; Thorn = thorn; Effect = effect; @@ -39,6 +40,7 @@ public SkillInfo(Guid id, bool isDead, int thorn, int effect, bool critical, Ski SkillTargetType = targetType; Buff = buff; WaveTurn = waveTurn; + Target = target; } } diff --git a/Lib9c/Model/Buff/Bleed.cs b/Lib9c/Model/Buff/Bleed.cs index 3589acec71..800f9bd779 100644 --- a/Lib9c/Model/Buff/Bleed.cs +++ b/Lib9c/Model/Buff/Bleed.cs @@ -41,9 +41,10 @@ public override BattleStatus.Skill GiveEffect( var damageInfos = new List { + // Copy new Character with damaged. new BattleStatus.Skill.SkillInfo(affectedCharacter.Id, affectedCharacter.IsDead, affectedCharacter.Thorn, damage, false, SkillCategory.Debuff, simulatorWaveTurn, RowData.ElementalType, - RowData.TargetType) + RowData.TargetType, target: (CharacterBase)affectedCharacter.Clone()) }; return new Model.BattleStatus.TickDamage( diff --git a/Lib9c/Model/Character/CharacterBase.cs b/Lib9c/Model/Character/CharacterBase.cs index 5293ea55f0..e60c085174 100644 --- a/Lib9c/Model/Character/CharacterBase.cs +++ b/Lib9c/Model/Character/CharacterBase.cs @@ -240,6 +240,7 @@ private void ReduceSkillCooldownV1() protected virtual BattleStatus.Skill UseSkill() { var selectedSkill = Skills.Select(Simulator.Random); + bool log = Simulator.LogEvent; var usedSkill = selectedSkill.Use( this, Simulator.WaveTurn, @@ -251,7 +252,7 @@ protected virtual BattleStatus.Skill UseSkill() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + log ); if (!Simulator.SkillSheet.TryGetValue(selectedSkill.SkillRow.Id, out var sheetSkill)) @@ -260,7 +261,10 @@ protected virtual BattleStatus.Skill UseSkill() } Skills.SetCooldown(selectedSkill.SkillRow.Id, sheetSkill.Cooldown); - // Simulator.Log.Add(usedSkill); + if (log) + { + Simulator.Log.Add(usedSkill); + } return usedSkill; } @@ -280,7 +284,7 @@ private BattleStatus.Skill UseSkillV1() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + Simulator.LogEvent ); Skills.SetCooldown(selectedSkill.SkillRow.Id, selectedSkill.SkillRow.Cooldown); @@ -304,7 +308,7 @@ private BattleStatus.Skill UseSkillV2() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + Simulator.LogEvent ); Skills.SetCooldown(selectedSkill.SkillRow.Id, selectedSkill.SkillRow.Cooldown); @@ -331,7 +335,10 @@ private void RemoveBuffs() return; Stats.SetBuffs(StatBuffs); - // Simulator.Log.Add(new RemoveBuffs((CharacterBase) Clone())); + if (Simulator.LogEvent) + { + Simulator.Log.Add(new RemoveBuffs((CharacterBase) Clone())); + } } protected virtual void EndTurn() @@ -468,8 +475,11 @@ public void Die() protected virtual void OnDead() { - // var dead = new Dead((CharacterBase) Clone()); - // Simulator.Log.Add(dead); + if (Simulator.LogEvent) + { + var dead = new Dead((CharacterBase) Clone()); + Simulator.Log.Add(dead); + } } public void Heal(int heal) @@ -554,10 +564,14 @@ protected virtual void OnPreSkill() protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) { var bleeds = Buffs.Values.OfType().OrderBy(x => x.BuffInfo.Id); + bool log = Simulator.LogEvent; foreach (var bleed in bleeds) { var effect = bleed.GiveEffect(this, Simulator.WaveTurn); - // Simulator.Log.Add(effect); + if (log) + { + Simulator.Log.Add(effect); + } } // Apply thorn damage if target has thorn @@ -571,8 +585,11 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) skillInfo.SkillCategory == SkillCategory.BuffRemovalAttack; if (isAttackSkill && skillInfo.Thorn > 0) { - GiveThornDamage(skillInfo.Thorn); - // Simulator.Log.Add(effect); + var effect = GiveThornDamage(skillInfo.Thorn); + if (log) + { + Simulator.Log.Add(effect); + } } } @@ -585,23 +602,38 @@ protected virtual void OnPostSkill(BattleStatus.Skill usedSkill) FinishTargetIfKilled(usedSkill); } - private void GiveThornDamage(int targetThorn) + internal BattleStatus.Skill GiveThornDamage(int targetThorn) { - // var clone = (CharacterBase)Clone(); + bool log = Simulator.LogEvent; + // Copy not damaged character + var clone = log ? (CharacterBase)Clone() : null; // minimum 1 damage var thornDamage = Math.Max(1, targetThorn - DEF); CurrentHP -= thornDamage; - // var damageInfos = new List() - // { - // new BattleStatus.Skill.SkillInfo( - // (CharacterBase)Clone(), - // thornDamage, - // false, - // SkillCategory.TickDamage, - // Simulator.WaveTurn, - // ElementalType.Normal, - // SkillTargetType.Enemy) - // }; + if (log) + { + // Copy new damaged character + var damageInfos = new List() + { + new BattleStatus.Skill.SkillInfo( + Id, + IsDead, + thornDamage, + thornDamage, + false, + SkillCategory.TickDamage, + Simulator.WaveTurn, + target: (CharacterBase)Clone()) + }; + var tickDamage = new TickDamage( + default, + clone, + damageInfos, + null); + return tickDamage; + } + + return null; } private void FinishTargetIfKilledForBeforeV100310(BattleStatus.Skill usedSkill) @@ -621,7 +653,7 @@ private void FinishTargetIfKilledForBeforeV100310(BattleStatus.Skill usedSkill) } var target = Targets.FirstOrDefault(i => - i.Id == info.Id); + i.Id == info.CharacterId); switch (target) { case Player player: @@ -655,7 +687,7 @@ private void FinishTargetIfKilled(BattleStatus.Skill usedSkill) continue; } - var target = Targets.FirstOrDefault(i => i.Id == info.Id); + var target = Targets.FirstOrDefault(i => i.Id == info.CharacterId); if (!killedTargets.Contains(target)) { killedTargets.Add(target); diff --git a/Lib9c/Model/Character/Player.cs b/Lib9c/Model/Character/Player.cs index 6d44793e1f..f66bda838a 100644 --- a/Lib9c/Model/Character/Player.cs +++ b/Lib9c/Model/Character/Player.cs @@ -449,8 +449,11 @@ public CollectionMap GetRewards2(List items) public virtual void Spawn() { InitAI(); - // var spawn = new SpawnPlayer((CharacterBase)Clone()); - // Simulator.Log.Add(spawn); + if (Simulator.LogEvent) + { + var spawn = new SpawnPlayer((CharacterBase)Clone()); + Simulator.Log.Add(spawn); + } } [Obsolete("Use Spawn")] @@ -512,6 +515,8 @@ protected override BattleStatus.Skill UseSkill() return base.UseSkill(); } + bool log = Simulator.LogEvent; + var usedSkill = selectedSkill.Use( this, Simulator.WaveTurn, @@ -523,12 +528,15 @@ protected override BattleStatus.Skill UseSkill() Simulator.SkillActionBuffSheet, Simulator.ActionBuffSheet ), - false + log ); var cooldown = RuneSkillCooldownMap[selectedSkill.SkillRow.Id]; RuneSkills.SetCooldown(selectedSkill.SkillRow.Id, cooldown); - // Simulator.Log.Add(usedSkill); + if (log) + { + Simulator.Log.Add(usedSkill); + } return usedSkill; } @@ -673,7 +681,10 @@ protected override void EndTurn() Simulator.TurnNumber++; Simulator.WaveTurn++; - // Simulator.Log.Add(new WaveTurnEnd(this, Simulator.TurnNumber, Simulator.WaveTurn)); + if (Simulator.LogEvent) + { + Simulator.Log.Add(new WaveTurnEnd(this, Simulator.TurnNumber, Simulator.WaveTurn)); + } } } } diff --git a/Lib9c/Model/Skill/AreaAttack.cs b/Lib9c/Model/Skill/AreaAttack.cs index d5009806ac..4f23a61eda 100644 --- a/Lib9c/Model/Skill/AreaAttack.cs +++ b/Lib9c/Model/Skill/AreaAttack.cs @@ -19,9 +19,9 @@ public AreaAttack( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/AttackSkill.cs b/Lib9c/Model/Skill/AttackSkill.cs index a676c9eabe..6a2370d6ae 100644 --- a/Lib9c/Model/Skill/AttackSkill.cs +++ b/Lib9c/Model/Skill/AttackSkill.cs @@ -27,9 +27,10 @@ protected AttackSkill( /// /// /// + /// /// protected IEnumerable ProcessDamage(CharacterBase caster, int simulatorWaveTurn, - bool isNormalAttack = false, bool b = false) + bool isNormalAttack = false, bool copyCharacter = true) { var infos = new List(); var targets = SkillRow.SkillTargetType.GetTarget(caster).ToList(); @@ -86,10 +87,10 @@ protected AttackSkill( target.CurrentHP -= damage; } - var clone = b ? (CharacterBase) target.Clone() : null; + var clone = copyCharacter ? (CharacterBase) target.Clone() : null; infos.Add(new BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, damage, isCritical, SkillRow.SkillCategory, simulatorWaveTurn, SkillRow.ElementalType, - SkillRow.SkillTargetType)); + SkillRow.SkillTargetType, target: clone)); } } diff --git a/Lib9c/Model/Skill/BlowAttack.cs b/Lib9c/Model/Skill/BlowAttack.cs index fa6b724a02..c4fdae7a40 100644 --- a/Lib9c/Model/Skill/BlowAttack.cs +++ b/Lib9c/Model/Skill/BlowAttack.cs @@ -19,9 +19,9 @@ public BlowAttack( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/BuffRemovalAttack.cs b/Lib9c/Model/Skill/BuffRemovalAttack.cs index fd04ff37bc..bc930314c1 100644 --- a/Lib9c/Model/Skill/BuffRemovalAttack.cs +++ b/Lib9c/Model/Skill/BuffRemovalAttack.cs @@ -19,9 +19,9 @@ public BuffRemovalAttack( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); var targets = SkillRow.SkillTargetType.GetTarget(caster); diff --git a/Lib9c/Model/Skill/BuffSkill.cs b/Lib9c/Model/Skill/BuffSkill.cs index 524f9b65d9..674ad3239d 100644 --- a/Lib9c/Model/Skill/BuffSkill.cs +++ b/Lib9c/Model/Skill/BuffSkill.cs @@ -18,9 +18,9 @@ public BuffSkill( } public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new BattleStatus.Buff(SkillRow.Id, clone, buff); diff --git a/Lib9c/Model/Skill/DoubleAttack.cs b/Lib9c/Model/Skill/DoubleAttack.cs index fe75c2b115..3b919354bf 100644 --- a/Lib9c/Model/Skill/DoubleAttack.cs +++ b/Lib9c/Model/Skill/DoubleAttack.cs @@ -19,9 +19,9 @@ public DoubleAttack( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/HealSkill.cs b/Lib9c/Model/Skill/HealSkill.cs index 9bfab1ed7d..17c87aabe2 100644 --- a/Lib9c/Model/Skill/HealSkill.cs +++ b/Lib9c/Model/Skill/HealSkill.cs @@ -19,9 +19,9 @@ public HealSkill( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var heal = ProcessHeal(caster, simulatorWaveTurn); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); @@ -42,7 +42,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, { target.Heal(healPoint); infos.Add(new BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, healPoint, caster.IsCritical(false), - SkillRow.SkillCategory, simulatorWaveTurn)); + SkillRow.SkillCategory, simulatorWaveTurn, target: target)); } return infos; diff --git a/Lib9c/Model/Skill/NormalAttack.cs b/Lib9c/Model/Skill/NormalAttack.cs index 11329ba690..b9e6d26223 100644 --- a/Lib9c/Model/Skill/NormalAttack.cs +++ b/Lib9c/Model/Skill/NormalAttack.cs @@ -19,9 +19,9 @@ public NormalAttack( public override BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b) + IEnumerable buffs, bool copyCharacter) { - var clone = b ? (CharacterBase) caster.Clone() : null; + var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; var damage = ProcessDamage(caster, simulatorWaveTurn, true); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); diff --git a/Lib9c/Model/Skill/Skill.cs b/Lib9c/Model/Skill/Skill.cs index ce99003587..f75297fd7e 100644 --- a/Lib9c/Model/Skill/Skill.cs +++ b/Lib9c/Model/Skill/Skill.cs @@ -38,7 +38,7 @@ protected Skill( public abstract BattleStatus.Skill Use(CharacterBase caster, int simulatorWaveTurn, - IEnumerable buffs, bool b); + IEnumerable buffs, bool copyCharacter); protected bool Equals(Skill other) { @@ -83,7 +83,7 @@ public override int GetHashCode() target.AddBuff(buff); infos.Add(new Model.BattleStatus.Skill.SkillInfo(target.Id, target.IsDead, target.Thorn, 0, false, SkillRow.SkillCategory, simulatorWaveTurn, ElementalType.Normal, SkillRow.SkillTargetType, - buff)); + buff, target)); } } From 6488222f5a5e3e3c34f725999d0548a5ebf64928 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Fri, 14 Jul 2023 19:03:17 +0900 Subject: [PATCH 64/68] Fix decimal point case --- .Lib9c.Tests/Action/HitHelperTest.cs | 34 ++++++++++++++++++++++++++++ Lib9c/Battle/HitHelper.cs | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .Lib9c.Tests/Action/HitHelperTest.cs diff --git a/.Lib9c.Tests/Action/HitHelperTest.cs b/.Lib9c.Tests/Action/HitHelperTest.cs new file mode 100644 index 0000000000..1b53168ffe --- /dev/null +++ b/.Lib9c.Tests/Action/HitHelperTest.cs @@ -0,0 +1,34 @@ +namespace Lib9c.Tests.Action +{ + using System; + using Nekoyume.Battle; + using Xunit; + + public class HitHelperTest + { + [Fact] + public void GetHitStep2() + { + // copy from previous logic + int GetHitStep2Legacy(int attackerHit, int defenderHit) + { + attackerHit = Math.Max(1, attackerHit); + defenderHit = Math.Max(1, defenderHit); + var additionalCorrection = (int)((attackerHit - defenderHit / 3m) / defenderHit * 100); + return Math.Min( + Math.Max(additionalCorrection, HitHelper.GetHitStep2AdditionalCorrectionMin), + HitHelper.GetHitStep2AdditionalCorrectionMax); + } + + for (int i = 0; i < 9; i++) + { + for (int j = 0; j < 9; j++) + { + var legacy = GetHitStep2Legacy(i, j); + var current = HitHelper.GetHitStep2(i, j); + Assert.True(legacy == current, $"{i}, {j}, {legacy}, {current}"); + } + } + } + } +} diff --git a/Lib9c/Battle/HitHelper.cs b/Lib9c/Battle/HitHelper.cs index 1efbde5a6a..49cb4932fc 100644 --- a/Lib9c/Battle/HitHelper.cs +++ b/Lib9c/Battle/HitHelper.cs @@ -109,7 +109,7 @@ public static int GetHitStep2(int attackerHit, int defenderHit) { attackerHit = Math.Max(1, attackerHit); defenderHit = Math.Max(1, defenderHit); - var additionalCorrection = (attackerHit * 100 - defenderHit * 100 / 3) / defenderHit; + var additionalCorrection = (attackerHit * 10000 - defenderHit * 10000 / 3) / defenderHit / 100; return Math.Min(Math.Max(additionalCorrection, GetHitStep2AdditionalCorrectionMin), GetHitStep2AdditionalCorrectionMax); } From 97476b37733b67f3790664514eabc3d203f8871e Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 14 Jul 2023 22:47:23 +0900 Subject: [PATCH 65/68] Bump libplanet to 2.4.1 --- .Libplanet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Libplanet b/.Libplanet index 720e0364ff..1d74e3706c 160000 --- a/.Libplanet +++ b/.Libplanet @@ -1 +1 @@ -Subproject commit 720e0364ffcdaeac1460d530348447674b3391f3 +Subproject commit 1d74e3706ce2ef6607e142969c5dfa3ec41f1076 From 8f4aef5b1f5c58253636482088ea5b80ccee123b Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 17 Jul 2023 11:29:28 +0900 Subject: [PATCH 66/68] Fix SkillInfo.Target clone --- .Lib9c.Tests/Model/Skill/NormalAttackTest.cs | 18 ++++++++++-------- Lib9c/Model/Skill/AreaAttack.cs | 2 +- Lib9c/Model/Skill/BlowAttack.cs | 2 +- Lib9c/Model/Skill/BuffRemovalAttack.cs | 2 +- Lib9c/Model/Skill/DoubleAttack.cs | 2 +- Lib9c/Model/Skill/NormalAttack.cs | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs b/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs index 125bfe47f5..42e53cb772 100644 --- a/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/NormalAttackTest.cs @@ -26,8 +26,10 @@ public NormalAttackTest(ITestOutputHelper outputHelper) .CreateLogger(); } - [Fact] - public void Use() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Use(bool copyCharacter) { var sheets = TableSheetsImporter.ImportSheets(); var tableSheets = new TableSheets(sheets); @@ -65,7 +67,8 @@ public void Use() StageSimulator.GetWaveRewards( random, tableSheets.StageSheet[1], - tableSheets.MaterialItemSheet) + tableSheets.MaterialItemSheet), + copyCharacter ); var player = new Player(avatarState, simulator); @@ -80,13 +83,12 @@ public void Use() player, 0, new List(), - true); + copyCharacter); Assert.NotNull(battleStatusSkill); - Assert.Single(battleStatusSkill.SkillInfos); - - var skillInfo = battleStatusSkill.SkillInfos.FirstOrDefault(); - Assert.NotNull(skillInfo); + Assert.Equal(!copyCharacter, battleStatusSkill.Character is null); + var skillInfo = Assert.Single(battleStatusSkill.SkillInfos); Assert.Equal(enemy.Id, skillInfo.CharacterId); + Assert.Equal(!copyCharacter, skillInfo.Target is null); } } } diff --git a/Lib9c/Model/Skill/AreaAttack.cs b/Lib9c/Model/Skill/AreaAttack.cs index 4f23a61eda..d115d7fcec 100644 --- a/Lib9c/Model/Skill/AreaAttack.cs +++ b/Lib9c/Model/Skill/AreaAttack.cs @@ -22,7 +22,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, IEnumerable buffs, bool copyCharacter) { var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; - var damage = ProcessDamage(caster, simulatorWaveTurn); + var damage = ProcessDamage(caster, simulatorWaveTurn, copyCharacter: copyCharacter); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new Model.BattleStatus.AreaAttack(SkillRow.Id, clone, damage, buff); diff --git a/Lib9c/Model/Skill/BlowAttack.cs b/Lib9c/Model/Skill/BlowAttack.cs index c4fdae7a40..854380f93d 100644 --- a/Lib9c/Model/Skill/BlowAttack.cs +++ b/Lib9c/Model/Skill/BlowAttack.cs @@ -22,7 +22,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, IEnumerable buffs, bool copyCharacter) { var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; - var damage = ProcessDamage(caster, simulatorWaveTurn); + var damage = ProcessDamage(caster, simulatorWaveTurn, copyCharacter: copyCharacter); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new Model.BattleStatus.BlowAttack(SkillRow.Id, clone, damage, buff); diff --git a/Lib9c/Model/Skill/BuffRemovalAttack.cs b/Lib9c/Model/Skill/BuffRemovalAttack.cs index bc930314c1..f770ad95fc 100644 --- a/Lib9c/Model/Skill/BuffRemovalAttack.cs +++ b/Lib9c/Model/Skill/BuffRemovalAttack.cs @@ -22,7 +22,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, IEnumerable buffs, bool copyCharacter) { var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; - var damage = ProcessDamage(caster, simulatorWaveTurn); + var damage = ProcessDamage(caster, simulatorWaveTurn, copyCharacter: copyCharacter); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); var targets = SkillRow.SkillTargetType.GetTarget(caster); foreach (var target in targets) diff --git a/Lib9c/Model/Skill/DoubleAttack.cs b/Lib9c/Model/Skill/DoubleAttack.cs index 3b919354bf..cab0ff6439 100644 --- a/Lib9c/Model/Skill/DoubleAttack.cs +++ b/Lib9c/Model/Skill/DoubleAttack.cs @@ -22,7 +22,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, IEnumerable buffs, bool copyCharacter) { var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; - var damage = ProcessDamage(caster, simulatorWaveTurn); + var damage = ProcessDamage(caster, simulatorWaveTurn, copyCharacter: copyCharacter); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new Model.BattleStatus.DoubleAttack(SkillRow.Id, clone, damage, buff); diff --git a/Lib9c/Model/Skill/NormalAttack.cs b/Lib9c/Model/Skill/NormalAttack.cs index b9e6d26223..e50205ba7d 100644 --- a/Lib9c/Model/Skill/NormalAttack.cs +++ b/Lib9c/Model/Skill/NormalAttack.cs @@ -22,7 +22,7 @@ public override BattleStatus.Skill Use(CharacterBase caster, IEnumerable buffs, bool copyCharacter) { var clone = copyCharacter ? (CharacterBase) caster.Clone() : null; - var damage = ProcessDamage(caster, simulatorWaveTurn, true); + var damage = ProcessDamage(caster, simulatorWaveTurn, true, copyCharacter); var buff = ProcessBuff(caster, simulatorWaveTurn, buffs); return new Model.BattleStatus.NormalAttack(SkillRow.Id, clone, damage, buff); From 991be3947e96c2a7dfcdb3dc04cd00c4412d0c7a Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 17 Jul 2023 18:19:44 +0900 Subject: [PATCH 67/68] Set obsolete create_avatar8 --- Lib9c/Action/CreateAvatar8.cs | 2 ++ Lib9c/ActionObsoleteConfig.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Lib9c/Action/CreateAvatar8.cs b/Lib9c/Action/CreateAvatar8.cs index b7665f8c4f..75c06c215c 100644 --- a/Lib9c/Action/CreateAvatar8.cs +++ b/Lib9c/Action/CreateAvatar8.cs @@ -27,6 +27,7 @@ namespace Nekoyume.Action /// [Serializable] [ActionType("create_avatar8")] + [ActionObsolete(ActionObsoleteConfig.V200040ObsoleteIndex)] public class CreateAvatar8 : GameAction, ICreateAvatarV2 { public const string DeriveFormat = "avatar-state-{0}"; @@ -68,6 +69,7 @@ protected override void LoadPlainValueInternal(IImmutableDictionary Date: Mon, 17 Jul 2023 19:18:16 +0900 Subject: [PATCH 68/68] fix: mail type of `UnloadFromMyGaragesRecipientMail` to `Auction` --- Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs b/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs index d1d2f0f5f9..67db42c33b 100644 --- a/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs +++ b/Lib9c/Model/Mail/UnloadFromMyGaragesRecipientMail.cs @@ -15,7 +15,7 @@ namespace Nekoyume.Model.Mail public class UnloadFromMyGaragesRecipientMail : Mail { protected override string TypeId => nameof(UnloadFromMyGaragesRecipientMail); - public override MailType MailType => MailType.System; + public override MailType MailType => MailType.Auction; public readonly IOrderedEnumerable<(Address balanceAddr, FungibleAssetValue value)>? FungibleAssetValues;