Skip to content

Commit 3c9f17a

Browse files
committed
fix test check negative token id
1 parent 29601c8 commit 3c9f17a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Thirdweb/Thirdweb.Extensions/ThirdwebExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,13 +1220,19 @@ public static async Task<BigInteger> ERC1155_TotalSupply(this ThirdwebContract c
12201220
/// <param name="fillOwner">A boolean indicating whether to fill the owner details. Defaults to true.</param>
12211221
/// <returns>A task representing the asynchronous operation, with an NFT result containing the token details.</returns>
12221222
/// <exception cref="ArgumentNullException">Thrown when the contract is null.</exception>
1223+
/// <exception cref="ArgumentOutOfRangeException">Thrown when the token ID is less than 0.</exception>
12231224
public static async Task<NFT> ERC721_GetNFT(this ThirdwebContract contract, BigInteger tokenId, bool fillOwner = true)
12241225
{
12251226
if (contract == null)
12261227
{
12271228
throw new ArgumentNullException(nameof(contract));
12281229
}
12291230

1231+
if (tokenId < 0)
1232+
{
1233+
throw new ArgumentOutOfRangeException(nameof(tokenId), "Token ID must be equal or greater than 0");
1234+
}
1235+
12301236
var nft = new NFT
12311237
{
12321238
Owner = Constants.ADDRESS_ZERO,
@@ -1379,13 +1385,19 @@ public static async Task<List<NFT>> ERC721_GetOwnedNFTs(this ThirdwebContract co
13791385
/// <param name="fillSupply">A boolean indicating whether to fill the supply. Defaults to true if not specified.</param>
13801386
/// <returns>A task representing the asynchronous operation, with an NFT result containing the token details.</returns>
13811387
/// <exception cref="ArgumentNullException">Thrown when the contract is null.</exception>
1388+
/// <exception cref="ArgumentOutOfRangeException">Thrown when the token ID is less than 0.</exception>
13821389
public static async Task<NFT> ERC1155_GetNFT(this ThirdwebContract contract, BigInteger tokenId, bool fillSupply = true)
13831390
{
13841391
if (contract == null)
13851392
{
13861393
throw new ArgumentNullException(nameof(contract));
13871394
}
13881395

1396+
if (tokenId < 0)
1397+
{
1398+
throw new ArgumentOutOfRangeException(nameof(tokenId), "Token ID must be equal or greater than 0");
1399+
}
1400+
13891401
var uri = await contract.ERC1155_URI(tokenId).ConfigureAwait(false);
13901402
NFTMetadata metadata;
13911403
try

0 commit comments

Comments
 (0)