Skip to content

Commit

Permalink
refine naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperski95 committed Aug 3, 2022
1 parent b2a9122 commit 33ad368
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions protostar/compiler/compiled_contract_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ def save(self, output_dir: Path) -> None:
def save_compiled_contract(self, output_dir: Path) -> None:
self._create_output_dir(output_dir)
serialized_contract = self._contract.Schema().dump(self._contract)
self._save_as_json(
data=serialized_contract, path=output_dir / f"{self._contract_name}.json"
)
file_path = output_dir / f"{self._contract_name}.json"
self._save_as_json(data=serialized_contract, path=file_path)

def save_compiled_contract_abi(self, output_dir: Path) -> None:
if not self._contract.abi:
return
self._create_output_dir(output_dir)
self._save_as_json(
data=self._contract.abi, path=output_dir / f"{self._contract_name}_abi.json"
)
file_path = output_dir / f"{self._contract_name}_abi.json"
self._save_as_json(data=self._contract.abi, path=file_path)

@staticmethod
def _create_output_dir(output_dir: Path):
Expand All @@ -40,6 +38,6 @@ def _save_as_json(data: Any, path: Path):
path,
mode="w",
encoding="utf-8",
) as output_abi_file:
json.dump(data, output_abi_file, indent=4, sort_keys=True)
output_abi_file.write("\n")
) as output_file:
json.dump(data, output_file, indent=4, sort_keys=True)
output_file.write("\n")

0 comments on commit 33ad368

Please sign in to comment.