Skip to content

Commit

Permalink
fix: show only nfts and grc1155 owner has, because there could be who…
Browse files Browse the repository at this point in the history
… knows how many of those he does not
  • Loading branch information
matijamarjanovic committed Jan 17, 2025
1 parent 8ab9a26 commit b107e7d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/gno.land/r/matijamarjanovic/tokenhub/tokenhub.gno
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,20 @@ func getBalances(addr std.Address) string {
registeredNFTs.Iterate("", "", func(key string, value interface{}) bool {
nftGetter := value.(grc721.NFTGetter)
nft := nftGetter()
balance, _ := nft.BalanceOf(addr)
balances.Set("nft:"+key, balance)
key_parts := strings.Split(key, ".")
if addr == nft.OwnerOf(grc721.TokenID(key_parts[len(key_parts)-1])) { // show only the nfts owner owns
balances.Set("nft:"+key)
}
return false
})

grc20reg.Iterate(func(key string, tokenGetter grc20.TokenGetter) bool {
token := tokenGetter()
balance := token.BalanceOf(addr)
balances.Set("token:"+key, balance)
balance := token.BalanceOf(addr)
if balance > 0 {
balances.Set("token:"+key, balance)
}
return false
})

Expand Down Expand Up @@ -455,9 +460,9 @@ func getNonZeroBalances(addr std.Address) string {
registeredNFTs.Iterate("", "", func(key string, value interface{}) bool {
nftGetter := value.(grc721.NFTGetter)
nft := nftGetter()
balance, _ := nft.BalanceOf(addr)
if balance > 0 {
balances.Set("nft:"+key, balance)
key_parts := strings.Split(key, ".")
if addr == nft.OwnerOf(grc721.TokenID(key_parts[len(key_parts)-1])) { // show only the nfts owner owns
balances.Set("nft:"+key)
}
return false
})
Expand Down

0 comments on commit b107e7d

Please sign in to comment.