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

Support parsing full path contract name from block explorers #1771

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

0237h
Copy link
Collaborator

@0237h 0237h commented Nov 25, 2024

Some explorers like ZkSync will return the ContractName with a full path like so:

{
  ...
  "ContractName": "contracts/SyncSwapRouter.sol:SyncSwapRouter",
  ...
}

This PR adds support for parsing the contract name for this format (e.g. SyncSwapRouter).

Copy link

changeset-bot bot commented Nov 25, 2024

🦋 Changeset detected

Latest commit: 87e1334

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphprotocol/graph-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@0237h 0237h requested a review from YaroShkvorets November 25, 2024 16:52
@YaroShkvorets
Copy link
Collaborator

Looks like there are issues with openzeppelin contracts, i.e. 0xF77bd7c05598E094bc06e34bB81C07Bd3B091dB1

image

Copy link
Collaborator

@YaroShkvorets YaroShkvorets left a comment

Choose a reason for hiding this comment

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

see comment

@0237h
Copy link
Collaborator Author

0237h commented Nov 25, 2024

@YaroShkvorets Good catch thanks, I've simplified the regex 👍

In case name of the file doesn't match the actual contract name,
the regex would not be valid.

Instead, we just pick the contract name following colon.
@0237h
Copy link
Collaborator Author

0237h commented Nov 25, 2024

Simplified further without regex for cases like yyy.sol:xxx where the file name (yyy) doesn't match the actual contract class name (xxx).

Not sure if it's even possible but we don't know what the explorer can return so to be safe, this just takes whatever is after the last colon (:) character.

@0237h 0237h merged commit 93271b0 into graphprotocol:main Nov 25, 2024
9 checks passed
@0237h 0237h deleted the fix/contract-name-parsing branch November 25, 2024 22:37
@0237h 0237h mentioned this pull request Nov 27, 2024
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.

2 participants