graphprotocol / graph-tooling

Monorepo for various tools used by subgraph developers.
https://thegraph.com/docs
Apache License 2.0
392 stars 209 forks source link

Support parsing full path contract name from block explorers #1771

Closed 0237h closed 21 hours ago

0237h commented 1 day ago

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).

changeset-bot[bot] commented 1 day ago

🦋 Changeset detected

Latest commit: 87e1334322aeea75346a7b567db9961398e7486d

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

YaroShkvorets commented 23 hours ago

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

image
0237h commented 23 hours ago

@YaroShkvorets Good catch thanks, I've simplified the regex :+1:

0237h commented 22 hours ago

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.