Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
solidity_names() recognizes interface
Browse files Browse the repository at this point in the history
Based directly on top of pyethereum v1.6.1

This is a hack. Solidity 0.4.11 introduces the interface keyword and
breaks the solidity_names() function. This simply tweaks the function
so that it also treats interfaces like contracts and does not break.

I don't believe pyethereum should attempt to parse solidity files on its
own as compatibility issues like this are almost certain to arise also in the
future. For more long-term a different solution should be found where
pyethereum queries solidity itself and does not parse anything on its own.
  • Loading branch information
LefterisJP committed Jun 1, 2017
1 parent ddaac54 commit 246bc3d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ethereum/_solidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def solidity_names(code): # pylint: disable=too-many-branches
if result:
names.append(('contract', result.groups()[0]))

if char == 'i' and code[pos: pos + 9] == 'interface':
result = re.match('^interface[^_$a-zA-Z]+([_$a-zA-Z][_$a-zA-Z0-9]*)', code[pos:])

if result:
names.append(('contract', result.groups()[0]))


if char == 'l' and code[pos: pos + 7] == 'library':
result = re.match('^library[^_$a-zA-Z]+([_$a-zA-Z][_$a-zA-Z0-9]*)', code[pos:])

Expand Down

0 comments on commit 246bc3d

Please sign in to comment.