Created
April 5, 2023 12:19
-
-
Save 019ec6e2/be317d247dd3d5df7f7c06d2f390e61a to your computer and use it in GitHub Desktop.
python wrapper for Surya solidity analyzer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
class Surya: | |
def __init__(self, contract_path): | |
self.contract_path = contract_path | |
self.command = 'surya' | |
def _run_command(self, arguments): | |
result = subprocess.run([self.command] + arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True).stdout | |
return result | |
def describe(self): | |
return self._run_command(['describe', self.contract_path]) | |
def graph(self, flags=None): | |
args = ['graph', self.contract_path] | |
if flags: | |
args.extend(flags) | |
return self._run_command(args) | |
def ftrace(self, contract_function, call_type, flags=None): | |
args = ['ftrace', contract_function, call_type, self.contract_path] | |
if flags: | |
args.extend(flags) | |
return self._run_command(args) | |
def flatten(self): | |
return self._run_command(['flatten', self.contract_path]) | |
def inheritance(self): | |
return self._run_command(['inheritance', self.contract_path]) | |
def dependencies(self, contract_name): | |
return self._run_command(['dependencies', contract_name, self.contract_path]) | |
def parse(self, flags=None): | |
args = ['parse', self.contract_path] | |
if flags: | |
args.extend(flags) | |
return self._run_command(args) | |
def mdreport(self, report_outfile): | |
return self._run_command(['mdreport', report_outfile, self.contract_path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment