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
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 010e6b2 commit 82e7896
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ethereum/_solidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ 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 82e7896

Please sign in to comment.