diff --git a/contract/Forest/ForestContractConstants.cs b/contract/Forest/ForestContractConstants.cs index db5de96..fa17ac7 100644 --- a/contract/Forest/ForestContractConstants.cs +++ b/contract/Forest/ForestContractConstants.cs @@ -26,5 +26,8 @@ public partial class ForestContract public const int DefaultMaxBatchCancelListCount= 20; public const string CollectionSymbolSuffix = "0"; public const string SymbolSeparator = "-"; - + public const long DefaultApproveAllowance = 10000; + public const long MaxApproveAllowance = 9223372000000000000; + + } \ No newline at end of file diff --git a/contract/Forest/ForestContract_Sellers.cs b/contract/Forest/ForestContract_Sellers.cs index e9904e6..3e5cd01 100644 --- a/contract/Forest/ForestContract_Sellers.cs +++ b/contract/Forest/ForestContract_Sellers.cs @@ -126,12 +126,14 @@ public override Empty ListWithFixedPrice(ListWithFixedPriceInput input) var collectionAllowance = State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender]; if (collectionAllowance == null || collectionAllowance == "") { - State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = - Math.Max(allowance, input.Quantity).ToString(); + var listedNFTTotalAmount = (allowance >= MaxApproveAllowance) ? input.Quantity : Math.Max(allowance, input.Quantity); + State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = listedNFTTotalAmount.ToString(); } else { - var originQuantity = long.Parse(collectionAllowance); + var originQuantity = (long.Parse(collectionAllowance) >= MaxApproveAllowance) + ? DefaultApproveAllowance + : long.Parse(collectionAllowance); State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = (input.Quantity + originQuantity).ToString(); } @@ -238,7 +240,7 @@ private Empty SingleDelist(DelistInput input) var originQuantity = long.Parse(collectionAllowance); var resultQuantity = originQuantity - input.Quantity; State.ListedNFTTotalAmountMap[collectionSymbol][Context.Sender] = - (resultQuantity >= 0 ? resultQuantity.ToString() : ""); + (resultQuantity >= 0 ? resultQuantity.ToString() : "0"); } return new Empty(); diff --git a/contract/Forest/ForestContract_Views.cs b/contract/Forest/ForestContract_Views.cs index 383756f..31a6089 100644 --- a/contract/Forest/ForestContract_Views.cs +++ b/contract/Forest/ForestContract_Views.cs @@ -129,7 +129,7 @@ public override GetTotalEffectiveListedNFTAmountOutput GetTotalEffectiveListedNF { Symbol = input.Symbol, Allowance = allowance, - TotalAmount = Math.Max(allowance,totalAmount) + TotalAmount = (allowance >= MaxApproveAllowance) ? totalAmount : Math.Max(allowance,totalAmount) }; } @@ -137,7 +137,7 @@ public override GetTotalEffectiveListedNFTAmountOutput GetTotalEffectiveListedNF { Symbol = input.Symbol, Allowance = allowance, - TotalAmount = long.Parse(collectionAllowance) + TotalAmount = (long.Parse(collectionAllowance) >= MaxApproveAllowance) ? DefaultApproveAllowance : long.Parse(collectionAllowance) }; return getTotalEffectiveListedNftAmountOutput;