AlphaWallet / AlphaWallet/alpha-wallet-android

Use ERC721Enumerable Interface if available

Đang mở
#2,560 2 bình luận 0 reaction 1 người được giao Được @asif-finimble nhận Xem trên GitHub
Ngôn ngữ chính
Java
Star
646
Fork
579
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

- Create a new ERC721 type, ERC721_Enumerable (in ```ContractType```).
- Check if the ERC721 contract has the Enumerable interface (```TokenRepository```, find the correct value for ```INTERFACE_ERC721ENUMERABLE```). ```bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;```
- Label the ERC721 which we now know is an Enumerable as ERC721_Enumerable, when we do the ```determineCommonType()```
- ~~Inherit the ```ERC721Token``` class and override the ```updateBalance``` method to create the class.~~

Instead of needing to trawl event history we can fetch full TokenId balance with only two calls.

First calling the ```balanceOf(address)``` - which is already done by the default ERC721 balance update before ```updateBalance``` is called, then crawling the indices {0 -> balance count} up to the balance count by calling the contract function:

```uint256 tokenOfOwnerByIndex({wallet address}, index)```

This function returns the TokenId at the index eg.

Balance of NFT is 3 tokens, check tokenOfOwnerByIndex for 0,1,2 ->

0 -> 2556
1 -> 3456
2 -> 4431

Then we have all the TokenIds owned by the wallet without needing to trawl the event list, in only 1 extra call.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.