From f900e40534ad514a912245e4c03e689028302586 Mon Sep 17 00:00:00 2001 From: tyrosine1153 <tyrosine1153@gmail.com> Date: Tue, 26 Nov 2024 17:25:15 +0900 Subject: [PATCH] fix duplicate guid NonFungibleItem in Claimitems --- Lib9c/Action/ClaimItems.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Lib9c/Action/ClaimItems.cs b/Lib9c/Action/ClaimItems.cs index 4a9cf52196..990e2b2e90 100644 --- a/Lib9c/Action/ClaimItems.cs +++ b/Lib9c/Action/ClaimItems.cs @@ -127,31 +127,30 @@ public override IWorld Execute(IActionContext context) { (bool tradable, int itemId) = Currencies.ParseItemCurrency(tokenCurrency); states = states.BurnAsset(context, context.Signer, fungibleAssetValue); - var item = itemSheet[itemId] switch - { - MaterialItemSheet.Row materialRow => tradable - ? ItemFactory.CreateTradableMaterial(materialRow) - : ItemFactory.CreateMaterial(materialRow), - var itemRow => ItemFactory.CreateItem(itemRow, random) - }; // FIXME: This is an implementation bug in the Inventory class, // but we'll deal with it temporarily here. // If Pluggable AEV ever becomes a reality, // it's only right that this is fixed in Inventory. + var itemRow = itemSheet[itemId]; var itemCount = (int)fungibleAssetValue.RawValue; - if (item is INonFungibleItem) + if (itemRow is MaterialItemSheet.Row materialRow) { - foreach (var _ in Enumerable.Range(0, itemCount)) - { - avatarState.inventory.AddItem(item, 1); - } + var item = tradable + ? ItemFactory.CreateTradableMaterial(materialRow) + : ItemFactory.CreateMaterial(materialRow); + avatarState.inventory.AddItem(item, itemCount); } else { - avatarState.inventory.AddItem(item, itemCount); + foreach (var _ in Enumerable.Range(0, itemCount)) + { + var item = ItemFactory.CreateItem(itemRow, random); + avatarState.inventory.AddItem(item); + } } - items.Add((item.Id, itemCount)); + + items.Add((itemRow.Id, itemCount)); } }