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

Feature/add verify contract to cli #40

Merged
merged 16 commits into from
Feb 3, 2023
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion game7ctl/game7ctl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ def diamond(
diamond_address: Optional[str] = None,
diamond_loupe_address: Optional[str] = None,
ownership_address: Optional[str] = None,
verify_contract: Optional[bool] = False,
) -> Dict[str, Any]:
"""
Deploy diamond along with all its basic facets and attach those facets to the diamond.

Returns addresses of all the deployed contracts with the contract names as keys.
Return addresses of all the deployed contracts with the contract names as keys.
"""
result: Dict[str, Any] = {"contracts": {}, "attached": []}

Expand Down Expand Up @@ -276,6 +277,18 @@ def diamond(
return result
result["attached"].append("OwnershipFacet")

if verify_contract:
try:
diamond_cut_facet.verify_contract()
diamond.verify_contract()
diamond_loupe_facet.verify_contract()
ownership_facet.verify_contract()

except Exception as e:
print(e)
result["error"] = "Failed to verify Diamond Facets"
return result
result["verified_diamond_facets"] = True
return result


Expand All @@ -289,7 +302,9 @@ def systems(
diamond_loupe_address: Optional[str] = None,
ownership_address: Optional[str] = None,
inventory_facet_address: Optional[str] = None,
verify_contract: Optional[bool] = False,
) -> Dict[str, Any]:

"""
Deploys an EIP2535 Diamond contract and an InventoryFacet and mounts the InventoryFacet onto the Diamond contract.

Expand All @@ -302,6 +317,7 @@ def systems(
diamond_address=diamond_address,
diamond_loupe_address=diamond_loupe_address,
ownership_address=ownership_address,
verify_contract=verify_contract,
)

if inventory_facet_address is None:
Expand All @@ -310,6 +326,9 @@ def systems(
else:
inventory_facet = InventoryFacet.InventoryFacet(inventory_facet_address)

if verify_contract:
inventory_facet.verify_contract()

deployment_info["contracts"]["InventoryFacet"] = inventory_facet.address

facet_cut(
Expand Down Expand Up @@ -365,6 +384,7 @@ def handle_systems(args: argparse.Namespace) -> None:
diamond_loupe_address=args.diamond_loupe_address,
ownership_address=args.ownership_address,
inventory_facet_address=args.inventory_facet_address,
verify_contract=args.verify_contract,
)
if args.outfile is not None:
with args.outfile:
Expand Down Expand Up @@ -406,6 +426,7 @@ def generate_cli():
facet_cut_parser.add_argument(
"--initializer-address",
default=ZERO_ADDRESS,
required=True,
help=f"Address of contract to run as initializer after cut (default: {ZERO_ADDRESS})",
)
facet_cut_parser.add_argument(
Expand Down Expand Up @@ -435,6 +456,13 @@ def generate_cli():
description="Deploy G7 diamond contract",
)
Diamond.add_default_arguments(contracts_parser, transact=True)
contracts_parser.add_argument(
ogarciarevett marked this conversation as resolved.
Show resolved Hide resolved
"--verify-contract",
required=False,
type=bool,
default=False,
help="Verify contracts",
)
contracts_parser.add_argument(
"--admin-terminus-address",
required=True,
Expand Down