From 1c8be44c610b1f4669f14700f75ffb44edb11fed Mon Sep 17 00:00:00 2001 From: theodore Date: Fri, 19 Jul 2024 14:20:29 +0800 Subject: [PATCH] feat: modify GetTotalEffectiveListedNFTAmount --- contract/Forest/ForestContract_Sellers.cs | 5 ++++- test/Forest.Tests/ForestContractTests_Views.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/contract/Forest/ForestContract_Sellers.cs b/contract/Forest/ForestContract_Sellers.cs index b0cbf62..e9904e6 100644 --- a/contract/Forest/ForestContract_Sellers.cs +++ b/contract/Forest/ForestContract_Sellers.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using AElf; using AElf.Contracts.MultiToken; @@ -120,11 +121,13 @@ public override Empty ListWithFixedPrice(ListWithFixedPriceInput input) Quantity = input.Quantity, WhitelistId = whitelistId }); + var allowance = GetAllowance(Context.Sender, input.Symbol); var collectionSymbol = TransferCollectionSymbol(input.Symbol); var collectionAllowance = State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender]; if (collectionAllowance == null || collectionAllowance == "") { - State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = input.Quantity.ToString(); + State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = + Math.Max(allowance, input.Quantity).ToString(); } else { diff --git a/test/Forest.Tests/ForestContractTests_Views.cs b/test/Forest.Tests/ForestContractTests_Views.cs index 9e065af..a9d6213 100644 --- a/test/Forest.Tests/ForestContractTests_Views.cs +++ b/test/Forest.Tests/ForestContractTests_Views.cs @@ -1185,7 +1185,7 @@ await BuyerForestContractStub.MakeOffer.SendAsync(new MakeOfferInput() Address = User1Address })); getTotalEffectiveListedNftAmount.Allowance.ShouldBe(0); - getTotalEffectiveListedNftAmount.TotalAmount.ShouldBe(sellQuantity); + getTotalEffectiveListedNftAmount.TotalAmount.ShouldBe(sellQuantity*2); } #endregion