|
|
|
@ -1,20 +1,21 @@ |
|
|
|
|
import re |
|
|
|
|
from ethereum import utils |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_signatures_from_file(file, sigs={}): |
|
|
|
|
|
|
|
|
|
funcs = [] |
|
|
|
|
|
|
|
|
|
with open(file, encoding="utf-8") as f: |
|
|
|
|
for line in f: |
|
|
|
|
|
|
|
|
|
m = re.search(r'function\s+(.*\))', line) |
|
|
|
|
code = f.read() |
|
|
|
|
|
|
|
|
|
if m: |
|
|
|
|
funcs.append(m.group(1)) |
|
|
|
|
funcs = re.findall(r'function[\s]+(.*?\))', code, re.DOTALL) |
|
|
|
|
|
|
|
|
|
for f in funcs: |
|
|
|
|
|
|
|
|
|
f = re.sub(r'[\n]', '', f) |
|
|
|
|
|
|
|
|
|
m = re.search(r'^([A-Za-z0-9_]+)', f) |
|
|
|
|
|
|
|
|
|
if (m): |
|
|
|
@ -38,4 +39,6 @@ def add_signatures_from_file(file, sigs={}): |
|
|
|
|
typelist = ",".join(types) |
|
|
|
|
signature += "(" + typelist + ")" |
|
|
|
|
|
|
|
|
|
signature = re.sub(r'\s', '', signature) |
|
|
|
|
|
|
|
|
|
sigs["0x" + utils.sha3(signature)[:4].hex()] = signature |
|
|
|
|