Skip to content

Instantly share code, notes, and snippets.

@0xalpharush
Last active December 9, 2023 21:58
Show Gist options
  • Save 0xalpharush/f577b2ba7939cd01efa4f03fe7366db7 to your computer and use it in GitHub Desktop.
Save 0xalpharush/f577b2ba7939cd01efa4f03fe7366db7 to your computer and use it in GitHub Desktop.
from slither import Slither
from slither.slithir.operations import InternalCall, SolidityCall
from slither.core.expressions.super_call_expression import SuperCallExpression
sl = Slither("MyContract.sol")
c = sl.get_contract_from_name("MyContract")[0]
def get_super_calls(x):
super_call_content = ""
for node in x.nodes:
for op in node.irs:
if isinstance(op, InternalCall) and isinstance(op.expression, SuperCallExpression)
super_call_content = op.function.source_mapping.content
tmp = get_super_calls(op.function)
if tmp != "":
super_call_content += tmp
return super_call_content
for function in c.functions_declared:
print(function.name, "\n")
cnt = get_super_calls(function)
if cnt != "":
with open(function.source_mapping.filename.absolute) as f:
content = f.read()
with open(function.source_mapping.filename.absolute, "w") as f:
f.write(content[:function.source_mapping.start] + cnt + content[function.source_mapping.end:])
print("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment