Skip to content

Commit

Permalink
Select max-size bytecode if no contract name specified for solc
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhs committed Mar 18, 2020
1 parent 2d3da0a commit 4f99c05
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mythx_cli/payload/solidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def generate_solidity_payload(
"sources": {},
"solc_version": solc_version,
}

bytecode_max = 0
for contract_name, contract_data in result.items():
ast = contract_data["ast"]
source_path = str(Path(ast.get("attributes", {}).get("absolutePath")))
Expand All @@ -112,9 +114,11 @@ def generate_solidity_payload(

# always add source and AST, even if dependency
payload["sources"][source_path] = {"source": source, "ast": ast}
if contracts and contract_name not in contracts:
if (contracts and contract_name not in contracts) or \
(not contracts and len(creation_bytecode) < bytecode_max):
continue

bytecode_max = len(creation_bytecode)
payload.update({
"contract_name": contract_name,
"main_source": source_path,
Expand Down

0 comments on commit 4f99c05

Please sign in to comment.