Skip to content
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

Add new client for Etherscan API v2 #1407

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

falvaradorodriguez
Copy link
Contributor

@falvaradorodriguez falvaradorodriguez commented Oct 31, 2024

@coveralls
Copy link

coveralls commented Oct 31, 2024

Pull Request Test Coverage Report for Build 11614341087

Details

  • 59 of 64 (92.19%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 93.545%

Changes Missing Coverage Covered Lines Changed/Added Lines %
safe_eth/eth/clients/etherscan_client_v2.py 27 28 96.43%
safe_eth/eth/tests/clients/test_etherscan_client_v2.py 30 34 88.24%
Totals Coverage Status
Change from base Build 11571197837: -0.01%
Covered Lines: 8985
Relevant Lines: 9605

💛 - Coveralls

@falvaradorodriguez falvaradorodriguez marked this pull request as ready for review October 31, 2024 10:30
@falvaradorodriguez falvaradorodriguez requested a review from a team as a code owner October 31, 2024 10:30
self.base_api_url = self.BASE_API_V2_URL

@classmethod
def _get_supported_networks(cls) -> List[Dict[str, Any]]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be cached, and also it shouldn't be a private method

Copy link
Contributor Author

@falvaradorodriguez falvaradorodriguez Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this method will be called rarely times and may even add a new chain along the way. It should have no problems without being cached.

It is updated as public method here

item.get("chainid") == str(network.value) for item in supported_networks
)

def build_url(self, path: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be at the top of the class, just for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here

@@ -320,7 +320,7 @@ def __init__(
self.request_timeout = request_timeout

def build_url(self, path: str):
url = urljoin(self.base_api_url, path)
url = urljoin(self.base_api_url, f"api?{path}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why api is out of the path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the problem is the name of the parameter. I updated it as query here

)

def build_url(self, path: str) -> str:
url = urljoin(self.base_api_url, f"v2/api?chainid={self.network.value}&{path}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2/api should be path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the path. I already updated the name of the parameter.

@falvaradorodriguez falvaradorodriguez merged commit 7969813 into main Nov 4, 2024
6 checks passed
@falvaradorodriguez falvaradorodriguez deleted the support-etherscan-v2-api branch November 4, 2024 19:11
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Etherscan V2 API
4 participants