File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
Assets/Thirdweb/Core/Scripts Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,6 @@ public async Task<List<NFT>> GetAll(QueryAllParams queryParams = null)
9292 start = 0 ;
9393 end = totalCount - 1 ;
9494 }
95- // TODO: Add Multicall
9695 List < NFT > allNfts = new List < NFT > ( ) ;
9796 for ( int i = start ; i <= end ; i ++ )
9897 allNfts . Add ( await Get ( i . ToString ( ) ) ) ;
@@ -113,7 +112,6 @@ public async Task<List<NFT>> GetOwned(string address = null)
113112 else
114113 {
115114 string owner = address == null ? await ThirdwebManager . Instance . SDK . wallet . GetAddress ( ) : address ;
116- // TODO: Add Multicall
117115 int totalCount = await TotalCount ( ) ;
118116 List < NFT > ownedNfts = new List < NFT > ( ) ;
119117 for ( int i = 0 ; i < totalCount ; i ++ )
Original file line number Diff line number Diff line change @@ -113,12 +113,12 @@ public async Task<List<NFT>> GetOwned(string address = null)
113113 else
114114 {
115115 string owner = address == null ? await ThirdwebManager . Instance . SDK . wallet . GetAddress ( ) : address ;
116+ var balanceOfOwner = int . Parse ( await BalanceOf ( owner ) ) ;
117+ List < NFT > ownedNfts = new List < NFT > ( ) ;
116118
117119 try
118120 {
119121 // ERC721Enumerable
120- var balanceOfOwner = int . Parse ( await BalanceOf ( owner ) ) ;
121- List < NFT > ownedNfts = new List < NFT > ( ) ;
122122 for ( int i = 0 ; i < balanceOfOwner ; i ++ )
123123 {
124124 var tokenId = await TransactionManager . ThirdwebRead < TokenERC721Contract . TokenOfOwnerByIndexFunction , TokenERC721Contract . TokenOfOwnerByIndexOutputDTO > (
@@ -129,16 +129,17 @@ public async Task<List<NFT>> GetOwned(string address = null)
129129 }
130130 return ownedNfts ;
131131 }
132- catch ( System . Exception )
132+ catch
133133 {
134134 // ERC721 totalSupply
135135 var count = await TotalCount ( ) ;
136- List < NFT > ownedNfts = new List < NFT > ( ) ;
137136 for ( int i = 0 ; i < count ; i ++ )
138137 {
139138 if ( await OwnerOf ( i . ToString ( ) ) == owner )
140139 {
141140 ownedNfts . Add ( await Get ( i . ToString ( ) ) ) ;
141+ if ( ownedNfts . Count == balanceOfOwner )
142+ break ;
142143 }
143144 }
144145 return ownedNfts ;
You can’t perform that action at this time.
0 commit comments