From d1bdcc744bd7f2437e46fb713ff2cd5aa585e31f 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/tools/_solidity.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ethereum/tools/_solidity.py b/ethereum/tools/_solidity.py index 8eb47f055..b1b1d979c 100644 --- a/ethereum/tools/_solidity.py +++ b/ethereum/tools/_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:])