Skip to content

Commit

Permalink
Merge branch 'master' into feature/royalty
Browse files Browse the repository at this point in the history
  • Loading branch information
fyannch committed Jul 25, 2024
2 parents c7e626b + d9b2fed commit ea93d33
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion contract/Forest/ForestContractConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ 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;
}
10 changes: 6 additions & 4 deletions contract/Forest/ForestContract_Sellers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions contract/Forest/ForestContract_Views.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public override GetTotalEffectiveListedNFTAmountOutput GetTotalEffectiveListedNF
{
Symbol = input.Symbol,
Allowance = allowance,
TotalAmount = Math.Max(allowance,totalAmount)
TotalAmount = (allowance >= MaxApproveAllowance) ? totalAmount : Math.Max(allowance,totalAmount)
};
}

var getTotalEffectiveListedNftAmountOutput = new GetTotalEffectiveListedNFTAmountOutput()
{
Symbol = input.Symbol,
Allowance = allowance,
TotalAmount = long.Parse(collectionAllowance)
TotalAmount = (long.Parse(collectionAllowance) >= MaxApproveAllowance) ? DefaultApproveAllowance : long.Parse(collectionAllowance)
};

return getTotalEffectiveListedNftAmountOutput;
Expand Down

0 comments on commit ea93d33

Please sign in to comment.