From 246bc3d475fe73fadbfc14c4ef7b24c2b08dc969 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 1 Jun 2017 14:40:59 +0200 Subject: [PATCH] solidity_names() recognizes interface 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. --- ethereum/_solidity.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ethereum/_solidity.py b/ethereum/_solidity.py index 6b1001466..81ff22ddf 100644 --- a/ethereum/_solidity.py +++ b/ethereum/_solidity.py @@ -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:])