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