Skip to content

Add support for PolygonScan #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Add support for PolygonScan #20

wants to merge 4 commits into from

Conversation

guggio
Copy link
Contributor

@guggio guggio commented Mar 19, 2022

With the emergence of side chains and layer 2s, etherscan expanded its offerings and supports block explorer APIs for other networks as well. Since the API requests and responses are fairly similar between the networks, the extension should not be too difficult.

Changes

I created a BaseApi class for the setup and a Network interface to get the correct API-URL. I added the Polygonscan implementation as the first alternative API. I left the EthNetwork enum in the module as before, but I think it might be better to place it in the network submodule.

Todos

Since some requests and responses are different between Polygonscan and Etherscan (especially for the stats APIs), more specifications regarding the setup of the specific endpoints might be required (e.g. protected initialization methods for endpoint APIs with default implementation such as IStatisticApi createStatisticsApi() { return new PolygonStatisticsApi()}).

Testing

I added some basic account and contract api tests with random addresses. I am not sure how to best integrate specific endpoint api tests into the current testing architecture. Do you have any suggestions?

Looking forward to your thoughts and ideas.

@GoodforGod
Copy link
Owner

Hello! Thanks for such PR, I will look into it deeply when have more time!

As for tests that's maybe the best to rewrite all tests (if they use all same endpoints / APIs) to parameterized tests and pass different APIs with different addresses to test all cases, thats may be the best way

@GoodforGod GoodforGod added the enhancement New feature or request label Mar 22, 2022
@GoodforGod GoodforGod self-assigned this Mar 22, 2022
@GoodforGod GoodforGod added this to the v2.0.0 milestone Mar 27, 2022
@guggio
Copy link
Contributor Author

guggio commented May 7, 2022

Hi Anton,

I mistakenly added my changes for "making the log-api usage bug free" in the same PR since I did not revert my branch to your master. Since I am more used to SVN, I don't know how to make a dedicated PR for my second commit.

However, for my project, I need to use Logs and the previous implementation of the Log-Api did not offer all the opportunities that were possible. Additionally, the usage seemed difficult and it was easy to run into run-time errors, since everything looked fine during compilation but would not work in the end. Thus, I made some adaptations to make the usage basically bug free. This needed a lot more (simple) classes to ensure type safety.

I wonder what you think about it?

@GoodforGod
Copy link
Owner

I didn't forget about your PR, I just trying to rearrange and finish other projects and then will back to this one

guggio added 2 commits July 12, 2022 15:51
- Inclusion of tokenID in Erc721 transfers
- Support for Erc1155 transfers
@GoodforGod
Copy link
Owner

I was kinda out of the grid for quite a time, will take a look into it, this will probably go into 2.0 so I have to make preparations for 2.0 refactoring to include this one in there

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@GoodforGod GoodforGod changed the base branch from master to dev May 13, 2023 17:45
@GoodforGod GoodforGod removed this from the v2.0.0 milestone May 15, 2023
@phil3k3
Copy link

phil3k3 commented Jan 8, 2024

@GoodforGod do you have plans to merge this one?

@GoodforGod
Copy link
Owner

GoodforGod commented Jan 15, 2024

Hello @phil3k3 , current API supports all methods that are included in this PR, for polygon URL usage please create API with the following syntax:

EtherScanAPI api = EtherScanAPI.builder()
        .withNetwork(() -> URI.create("https://api-my-custom.etherscan.io/api"))
        .build();

So there is no need in this PR anymore cause everything is already supported, it will be closed

@GoodforGod GoodforGod closed this Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
3 participants