Skip to content

Comments

Init etherscan client#8280

Merged
mslipper merged 3 commits intodevelopfrom
wyatt/bindgen/init-etherscan-client
Dec 14, 2023
Merged

Init etherscan client#8280
mslipper merged 3 commits intodevelopfrom
wyatt/bindgen/init-etherscan-client

Conversation

@Spacesai1or
Copy link
Contributor

@Spacesai1or Spacesai1or commented Nov 27, 2023

This PR introduces an Etherscan API wrapper to be used by #8281 to sourced information about contracts to create Go bindings

@Spacesai1or
Copy link
Contributor Author

Spacesai1or commented Nov 27, 2023

@semgrep-app
Copy link
Contributor

semgrep-app bot commented Nov 27, 2023

Semgrep found 1 import-text-template finding:

  • op-bindings/bindgen/generator_local.go: L12

When working with web applications that involve rendering user-generated content, it's important to properly escape any HTML content to prevent Cross-Site Scripting (XSS) attacks. In Go, the text/template package does not automatically escape HTML content, which can leave your application vulnerable to these types of attacks. To mitigate this risk, it's recommended to use the html/template package instead, which provides built-in functionality for HTML escaping. By using html/template to render your HTML content, you can help to ensure that your web application is more secure and less susceptible to XSS vulnerabilities.

Ignore this finding from import-text-template.

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from f183f17 to 0e04b92 Compare November 27, 2023 20:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from 5a1e484 to 9f68969 Compare November 27, 2023 20:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from 0e04b92 to 9c7ad44 Compare November 27, 2023 20:33
@Spacesai1or Spacesai1or marked this pull request as draft November 27, 2023 21:33
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from 9c7ad44 to e858407 Compare November 27, 2023 21:36
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from b9aed79 to a36df5d Compare November 27, 2023 22:28
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from e858407 to e30e909 Compare November 27, 2023 22:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2023

Walkthrough

Walkthrough

The update to the Etherscan client in Go introduces enhanced functionality and error handling. It incorporates a retry mechanism for API calls, extends the client with new types and functions for fetching ABI, bytecode, and transaction information, and adjusts its initialization to require an API key. The changes aim to improve the robustness of interactions with Etherscan's API and RPC endpoints by handling rate limits and retries.

Changes

File Path Change Summary
.../etherscan/client.go Added op-service/retry import, new types (apiResponse, rpcResponse, TxInfo), constants for retries and rate limit errors, apiKey parameter in NewClient, and new functions for fetching ABI, bytecode, and transactions.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from e30e909 to 7dbf9c5 Compare November 27, 2023 22:40
@Spacesai1or Spacesai1or marked this pull request as ready for review November 28, 2023 21:10
Copy link
Contributor

@hamdiallam hamdiallam left a comment

Choose a reason for hiding this comment

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

Looks good! Any unit tests you can add? Can hardcode some sample responses in the unit tests themselves to mock out the actual rpc call

nw if you'd just want to leverage manual tests

@Spacesai1or Spacesai1or marked this pull request as draft December 1, 2023 19:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from a36df5d to c35ad82 Compare December 2, 2023 01:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from 7dbf9c5 to 42d11e0 Compare December 2, 2023 01:29
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from c35ad82 to d380971 Compare December 2, 2023 02:20
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from 42d11e0 to a9c7e2a Compare December 2, 2023 02:20
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from d380971 to 4c3a3a8 Compare December 2, 2023 03:21
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from a9c7e2a to 820e623 Compare December 2, 2023 03:21
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/local-contract-refactor branch from 08e676f to e4536f9 Compare December 8, 2023 03:25
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from f33e298 to 276121d Compare December 8, 2023 03:25
Copy link
Collaborator

@mslipper mslipper left a comment

Choose a reason for hiding this comment

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

A couple of things I suggest fixing here before merge. In addition - have you looked at https://github.com/nanmu42/etherscan-api? Could be useful to pull that in as a dep and not have to maintain this at all.

Base automatically changed from wyatt/bindgen/local-contract-refactor to develop December 13, 2023 23:09
@Spacesai1or
Copy link
Contributor Author

...have you looked at nanmu42/etherscan-api? Could be useful to pull that in as a dep and not have to maintain this at all.

@mslipper I hadn't considered using a third-party package. I think the wrapper this PR introduces is pretty minimal, providing just what we need and should be low effort to maintain if Etherscan makes an API change (most likely just requiring a route change). The package you linked had it's last code update a year ago (with most of the code not being touched in 2 - 5 years, and the author doesn't seem very active on Github), and I'm concerned with introducing a dependency that isn't actively being developed and appears to have low usage. I also looked for alternative packages, but didn't find anything better

Unless you feel strongly about replacing this PR with the linked package, I prefer we keep the API wrapper as is, and reconsider replacing it with the linked package if a future situation calls for it

@mslipper
Copy link
Collaborator

Ok let's keep the API wrapper as-is.

@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from 276121d to a102c19 Compare December 14, 2023 06:02
@Spacesai1or Spacesai1or requested a review from mslipper December 14, 2023 06:03
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from a102c19 to d19211d Compare December 14, 2023 06:35
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch 3 times, most recently from cce302e to f203a03 Compare December 14, 2023 07:03
@Spacesai1or Spacesai1or force-pushed the wyatt/bindgen/init-etherscan-client branch from f203a03 to b4629be Compare December 14, 2023 07:11
@mslipper mslipper enabled auto-merge December 14, 2023 15:57
@mslipper mslipper added this pull request to the merge queue Dec 14, 2023
Merged via the queue into develop with commit a1a30a0 Dec 14, 2023
@mslipper mslipper deleted the wyatt/bindgen/init-etherscan-client branch December 14, 2023 16:47
This was referenced Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants