GoodforGod / java-etherscan-api

🔗 Polished Java library for EtherScan.io API
https://etherscan.io
MIT License
58 stars 47 forks source link

Add support for ERC-721 (NFT) Tokens #13

Closed NGuggs closed 2 years ago

NGuggs commented 2 years ago

I noticed there was currently only support for ERC-20 tokens and that Ertherscan used a different endpoint to get ERC-721 (NFT) Tokens.

Changes

I followed the same paradigm used for the ERC-20 tokens and just duplicated and changed for the new endpoint.

Considerations

With how similar the tokens are in requests, the methods could be combined into a single set with an enum or parameter (or similar in function) that determines which token type your are intending and reduces nearly duplicate code. Though it would take extra work to support backwards compatible upgrades to the new version.

Testing

Manually tested against a random account (0x51b1501420C50aDdA1C4942720bC0e7e8C6D768e) which includes both ERC-20 and ERC-721 tokens.

Still need to add test cases for this. But... was curious how you chose the account for the initial set of test cases. I noticed that account did not have ERC-721 tokens and I would be hesitant to use a random account knowing there could be additional tokens in the future and break the tests.

Let me know your throughts.

GoodforGod commented 2 years ago

Hello, Nathan

Thanks for your PR!

Everything looks good! You are correct, only test cases are needed for regression testing of such API. Thats a good question actually, I can't remember like proper strategy I was using at that time, something like "found unused account that barely move assets (probably forgotten) and reinforce tests as mush as possible".

I think such strategy is applicable here also, will be waiting test cases for your changes and they will be ready to go!

GoodforGod commented 2 years ago

Looks like rate limit wasn't expecting PR and API key is not propagated and API is rate limited, I'll merge and release it in 1.2.0

GoodforGod commented 2 years ago

Thanks for your contribution @NGuggs !