Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add missing pc maps to vyper_json output #3333

Merged
merged 18 commits into from
Apr 7, 2023
1 change: 1 addition & 0 deletions tests/cli/vyper_json/test_output_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_keys():
"object": data["bytecode_runtime"],
"opcodes": data["opcodes_runtime"],
"sourceMap": data["source_map"]["pc_pos_map_compressed"],
"sourceMapFull": data["source_map_full"],
},
"methodIdentifiers": data["method_identifiers"],
},
Expand Down
6 changes: 5 additions & 1 deletion vyper/cli/vyper_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"evm.deployedBytecode.object": "bytecode_runtime",
"evm.deployedBytecode.opcodes": "opcodes_runtime",
"evm.deployedBytecode.sourceMap": "source_map",
"evm.deployedBytecode.sourceMapFull": "source_map_full",
"interface": "interface",
"ir": "ir_dict",
"ir_runtime": "ir_runtime_dict",
Expand Down Expand Up @@ -418,14 +419,17 @@ def format_to_output_dict(compiler_data: Dict) -> Dict:
if "opcodes" in data:
evm["opcodes"] = data["opcodes"]

if any(i + "_runtime" in data for i in evm_keys) or "source_map" in data:
pc_maps_keys = ("source_map", "source_map_full")
if any(i + "_runtime" in data for i in evm_keys) or any(i in data for i in pc_maps_keys):
evm = output_contracts.setdefault("evm", {}).setdefault("deployedBytecode", {})
if "bytecode_runtime" in data:
evm["object"] = data["bytecode_runtime"]
if "opcodes_runtime" in data:
evm["opcodes"] = data["opcodes_runtime"]
if "source_map" in data:
evm["sourceMap"] = data["source_map"]["pc_pos_map_compressed"]
if "source_map_full" in data:
evm["sourceMapFull"] = data["source_map"]

return output_dict

Expand Down
1 change: 1 addition & 0 deletions vyper/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"abi": output.build_abi_output,
"asm": output.build_asm_output,
"source_map": output.build_source_map_output,
"source_map_full": output.build_source_map_output,
charles-cooper marked this conversation as resolved.
Show resolved Hide resolved
# requires bytecode
"bytecode": output.build_bytecode_output,
"bytecode_runtime": output.build_bytecode_runtime_output,
Expand Down