Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Updating cli scripts to Moonworm v0.6.2 #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 16 additions & 3 deletions dao/Diamond.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by moonworm : https://github.com/bugout-dev/moonworm
# Moonworm version : 0.1.14
# Moonworm version : 0.6.2

import argparse
import json
Expand Down Expand Up @@ -30,8 +30,8 @@ def boolean_argument_type(raw_value: str) -> bool:
)


def bytes_argument_type(raw_value: str) -> bytes:
return raw_value.encode()
def bytes_argument_type(raw_value: str) -> str:
return raw_value


def get_abi_json(abi_name: str) -> List[Dict[str, Any]]:
Expand Down Expand Up @@ -92,6 +92,7 @@ def deploy(
)
self.address = deployed_contract.address
self.contract = deployed_contract
return deployed_contract.tx

def assert_contract_is_instantiated(self) -> None:
if self.contract is None:
Expand Down Expand Up @@ -127,6 +128,12 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
"--address", required=False, help="Address of deployed contract to connect to"
)
if not transact:
parser.add_argument(
"--block-number",
required=False,
type=int,
help="Call at the given block number, defaults to latest",
)
return
parser.add_argument(
"--sender", required=True, help="Path to keystore file for transaction sender"
Expand Down Expand Up @@ -158,6 +165,10 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
parser.add_argument(
"--nonce", type=int, default=None, help="Nonce for the transaction (optional)"
)
parser.add_argument(
"--value", default=None, help="Value of the transaction in wei(optional)"
)
parser.add_argument("--verbose", action="store_true", help="Print verbose output")


def handle_deploy(args: argparse.Namespace) -> None:
Expand All @@ -170,6 +181,8 @@ def handle_deploy(args: argparse.Namespace) -> None:
transaction_config=transaction_config,
)
print(result)
if args.verbose:
print(result.info())


def handle_verify_contract(args: argparse.Namespace) -> None:
Expand Down
21 changes: 18 additions & 3 deletions dao/DiamondCutFacet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by moonworm : https://github.com/bugout-dev/moonworm
# Moonworm version : 0.1.14
# Moonworm version : 0.6.2

import argparse
import json
Expand Down Expand Up @@ -30,8 +30,8 @@ def boolean_argument_type(raw_value: str) -> bool:
)


def bytes_argument_type(raw_value: str) -> bytes:
return raw_value.encode()
def bytes_argument_type(raw_value: str) -> str:
return raw_value


def get_abi_json(abi_name: str) -> List[Dict[str, Any]]:
Expand Down Expand Up @@ -85,6 +85,7 @@ def deploy(self, transaction_config):
deployed_contract = contract_class.deploy(transaction_config)
self.address = deployed_contract.address
self.contract = deployed_contract
return deployed_contract.tx

def assert_contract_is_instantiated(self) -> None:
if self.contract is None:
Expand Down Expand Up @@ -132,6 +133,12 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
"--address", required=False, help="Address of deployed contract to connect to"
)
if not transact:
parser.add_argument(
"--block-number",
required=False,
type=int,
help="Call at the given block number, defaults to latest",
)
return
parser.add_argument(
"--sender", required=True, help="Path to keystore file for transaction sender"
Expand Down Expand Up @@ -163,6 +170,10 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
parser.add_argument(
"--nonce", type=int, default=None, help="Nonce for the transaction (optional)"
)
parser.add_argument(
"--value", default=None, help="Value of the transaction in wei(optional)"
)
parser.add_argument("--verbose", action="store_true", help="Print verbose output")


def handle_deploy(args: argparse.Namespace) -> None:
Expand All @@ -171,6 +182,8 @@ def handle_deploy(args: argparse.Namespace) -> None:
contract = DiamondCutFacet(None)
result = contract.deploy(transaction_config=transaction_config)
print(result)
if args.verbose:
print(result.info())


def handle_verify_contract(args: argparse.Namespace) -> None:
Expand All @@ -191,6 +204,8 @@ def handle_diamond_cut(args: argparse.Namespace) -> None:
transaction_config=transaction_config,
)
print(result)
if args.verbose:
print(result.info())


def generate_cli() -> argparse.ArgumentParser:
Expand Down
73 changes: 55 additions & 18 deletions dao/DiamondLoupeFacet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code generated by moonworm : https://github.com/bugout-dev/moonworm
# Moonworm version : 0.1.14
# Moonworm version : 0.6.2

import argparse
import json
Expand Down Expand Up @@ -30,8 +30,8 @@ def boolean_argument_type(raw_value: str) -> bool:
)


def bytes_argument_type(raw_value: str) -> bytes:
return raw_value.encode()
def bytes_argument_type(raw_value: str) -> str:
return raw_value


def get_abi_json(abi_name: str) -> List[Dict[str, Any]]:
Expand Down Expand Up @@ -85,6 +85,7 @@ def deploy(self, transaction_config):
deployed_contract = contract_class.deploy(transaction_config)
self.address = deployed_contract.address
self.contract = deployed_contract
return deployed_contract.tx

def assert_contract_is_instantiated(self) -> None:
if self.contract is None:
Expand All @@ -95,25 +96,43 @@ def verify_contract(self):
contract_class = contract_from_build(self.contract_name)
contract_class.publish_source(self.contract)

def facet_address(self, _function_selector: bytes) -> Any:
def facet_address(
self,
_function_selector: bytes,
block_number: Optional[Union[str, int]] = "latest",
) -> Any:
self.assert_contract_is_instantiated()
return self.contract.facetAddress.call(_function_selector)
return self.contract.facetAddress.call(
_function_selector, block_identifier=block_number
)

def facet_addresses(self) -> Any:
def facet_addresses(
self, block_number: Optional[Union[str, int]] = "latest"
) -> Any:
self.assert_contract_is_instantiated()
return self.contract.facetAddresses.call()
return self.contract.facetAddresses.call(block_identifier=block_number)

def facet_function_selectors(self, _facet: ChecksumAddress) -> Any:
def facet_function_selectors(
self,
_facet: ChecksumAddress,
block_number: Optional[Union[str, int]] = "latest",
) -> Any:
self.assert_contract_is_instantiated()
return self.contract.facetFunctionSelectors.call(_facet)
return self.contract.facetFunctionSelectors.call(
_facet, block_identifier=block_number
)

def facets(self) -> Any:
def facets(self, block_number: Optional[Union[str, int]] = "latest") -> Any:
self.assert_contract_is_instantiated()
return self.contract.facets.call()
return self.contract.facets.call(block_identifier=block_number)

def supports_interface(self, _interface_id: bytes) -> Any:
def supports_interface(
self, _interface_id: bytes, block_number: Optional[Union[str, int]] = "latest"
) -> Any:
self.assert_contract_is_instantiated()
return self.contract.supportsInterface.call(_interface_id)
return self.contract.supportsInterface.call(
_interface_id, block_identifier=block_number
)


def get_transaction_config(args: argparse.Namespace) -> Dict[str, Any]:
Expand All @@ -140,6 +159,12 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
"--address", required=False, help="Address of deployed contract to connect to"
)
if not transact:
parser.add_argument(
"--block-number",
required=False,
type=int,
help="Call at the given block number, defaults to latest",
)
return
parser.add_argument(
"--sender", required=True, help="Path to keystore file for transaction sender"
Expand Down Expand Up @@ -171,6 +196,10 @@ def add_default_arguments(parser: argparse.ArgumentParser, transact: bool) -> No
parser.add_argument(
"--nonce", type=int, default=None, help="Nonce for the transaction (optional)"
)
parser.add_argument(
"--value", default=None, help="Value of the transaction in wei(optional)"
)
parser.add_argument("--verbose", action="store_true", help="Print verbose output")


def handle_deploy(args: argparse.Namespace) -> None:
Expand All @@ -179,6 +208,8 @@ def handle_deploy(args: argparse.Namespace) -> None:
contract = DiamondLoupeFacet(None)
result = contract.deploy(transaction_config=transaction_config)
print(result)
if args.verbose:
print(result.info())


def handle_verify_contract(args: argparse.Namespace) -> None:
Expand All @@ -191,35 +222,41 @@ def handle_verify_contract(args: argparse.Namespace) -> None:
def handle_facet_address(args: argparse.Namespace) -> None:
network.connect(args.network)
contract = DiamondLoupeFacet(args.address)
result = contract.facet_address(_function_selector=args.function_selector_arg)
result = contract.facet_address(
_function_selector=args.function_selector_arg, block_number=args.block_number
)
print(result)


def handle_facet_addresses(args: argparse.Namespace) -> None:
network.connect(args.network)
contract = DiamondLoupeFacet(args.address)
result = contract.facet_addresses()
result = contract.facet_addresses(block_number=args.block_number)
print(result)


def handle_facet_function_selectors(args: argparse.Namespace) -> None:
network.connect(args.network)
contract = DiamondLoupeFacet(args.address)
result = contract.facet_function_selectors(_facet=args.facet_arg)
result = contract.facet_function_selectors(
_facet=args.facet_arg, block_number=args.block_number
)
print(result)


def handle_facets(args: argparse.Namespace) -> None:
network.connect(args.network)
contract = DiamondLoupeFacet(args.address)
result = contract.facets()
result = contract.facets(block_number=args.block_number)
print(result)


def handle_supports_interface(args: argparse.Namespace) -> None:
network.connect(args.network)
contract = DiamondLoupeFacet(args.address)
result = contract.supports_interface(_interface_id=args.interface_id_arg)
result = contract.supports_interface(
_interface_id=args.interface_id_arg, block_number=args.block_number
)
print(result)


Expand Down
Loading