Skip to content

Commit 7a95564

Browse files
authored
ERC721Queryable / NFT Pagination Support (#68)
1 parent b0648f1 commit 7a95564

File tree

3 files changed

+214
-46
lines changed

3 files changed

+214
-46
lines changed

Thirdweb.Tests/Thirdweb.Extensions/Thirdweb.Extensions.Tests.cs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class ExtensionsTests : BaseTests
1111
private readonly string _dropErc20ContractAddress = "0xEBB8a39D865465F289fa349A67B3391d8f910da9";
1212
private readonly string _dropErc721ContractAddress = "0xD811CB13169C175b64bf8897e2Fd6a69C6343f5C";
1313
private readonly string _dropErc1155ContractAddress = "0x6A7a26c9a595E6893C255C9dF0b593e77518e0c3";
14+
private readonly string _erc721AContractAddressTaiko = "0xCA99F9DbF4A13D4de05B41a68041dcE7929cb5e0";
1415

1516
private readonly BigInteger _chainId = 421614;
1617

@@ -53,6 +54,11 @@ private async Task<ThirdwebContract> GetDrop1155Contract()
5354
return await ThirdwebContract.Create(this.Client, this._dropErc1155ContractAddress, this._chainId);
5455
}
5556

57+
private async Task<ThirdwebContract> GetERC721AContract()
58+
{
59+
return await ThirdwebContract.Create(this.Client, this._erc721AContractAddressTaiko, 167000);
60+
}
61+
5662
#region Common
5763

5864
[Fact(Timeout = 120000)]
@@ -793,7 +799,6 @@ public async Task GetAllNFTs_721_WithRange()
793799
var nfts = await contract.ERC721_GetAllNFTs(1, 2);
794800
Assert.NotNull(nfts);
795801
Assert.NotEmpty(nfts);
796-
Assert.True(nfts.Count == 1);
797802
}
798803

799804
[Fact(Timeout = 120000)]
@@ -805,6 +810,39 @@ public async Task GetOwnedNFTs_721()
805810
Assert.NotNull(nfts);
806811
}
807812

813+
[Fact(Timeout = 120000)]
814+
public async Task GetOwnedNFTs_721_WithRange()
815+
{
816+
var contract = await this.GetTokenERC721Contract();
817+
var ownerAddress = contract.Address;
818+
var nfts = await contract.ERC721_GetOwnedNFTs(ownerAddress, 1, 2);
819+
Assert.NotNull(nfts);
820+
}
821+
822+
[Fact(Timeout = 120000)]
823+
public async Task GetOwnedNFTs_721A()
824+
{
825+
var contract = await this.GetERC721AContract();
826+
var ownerAddress = "0x10a798EC43A776c39BA19978EDb6e4a7706326FA";
827+
var nfts = await contract.ERC721_GetOwnedNFTs(ownerAddress);
828+
Assert.NotNull(nfts);
829+
Assert.True(nfts.Count > 0);
830+
}
831+
832+
[Fact(Timeout = 120000)]
833+
public async Task GetOwnedNFTs_721A_WithRange()
834+
{
835+
var contract = await this.GetERC721AContract();
836+
var ownerAddress = "0x10a798EC43A776c39BA19978EDb6e4a7706326FA";
837+
var nfts = await contract.ERC721_GetOwnedNFTs(ownerAddress, 0, 280);
838+
Assert.NotNull(nfts);
839+
Assert.True(nfts.Count == 2);
840+
841+
nfts = await contract.ERC721_GetOwnedNFTs(ownerAddress, 0, 1);
842+
Assert.NotNull(nfts);
843+
Assert.True(nfts.Count == 1);
844+
}
845+
808846
[Fact(Timeout = 120000)]
809847
public async Task GetNFT_1155()
810848
{
@@ -830,7 +868,6 @@ public async Task GetAllNFTs_1155_WithRange()
830868
var nfts = await contract.ERC1155_GetAllNFTs(1, 2);
831869
Assert.NotNull(nfts);
832870
Assert.NotEmpty(nfts);
833-
Assert.True(nfts.Count == 1);
834871
}
835872

836873
[Fact(Timeout = 120000)]
@@ -842,6 +879,15 @@ public async Task GetOwnedNFTs_1155()
842879
Assert.NotNull(nfts);
843880
}
844881

882+
[Fact(Timeout = 120000)]
883+
public async Task GetOwnedNFTs_1155_WithRange()
884+
{
885+
var contract = await this.GetTokenERC1155Contract();
886+
var ownerAddress = contract.Address;
887+
var nfts = await contract.ERC1155_GetOwnedNFTs(ownerAddress, 1, 2);
888+
Assert.NotNull(nfts);
889+
}
890+
845891
#endregion
846892

847893
#region DropERC20

Thirdweb.Tests/Thirdweb.RPC/Thirdweb.RPC.Tests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ public async Task TestRpcError()
7474
public async Task TestCache()
7575
{
7676
var client = ThirdwebClient.Create(secretKey: this.SecretKey);
77-
var rpc = ThirdwebRPC.GetRpcInstance(client, 1);
77+
var rpc = ThirdwebRPC.GetRpcInstance(client, 421614);
7878
var blockNumber1 = await rpc.SendRequestAsync<string>("eth_blockNumber");
79-
await ThirdwebTask.Delay(100);
79+
await ThirdwebTask.Delay(1);
8080
var blockNumber2 = await rpc.SendRequestAsync<string>("eth_blockNumber");
8181
Assert.Equal(blockNumber1, blockNumber2);
82+
await ThirdwebTask.Delay(100);
83+
var blockNumber3 = await rpc.SendRequestAsync<string>("eth_blockNumber");
84+
Assert.NotEqual(blockNumber1, blockNumber3);
8285
}
8386
}

0 commit comments

Comments
 (0)