From 8883c78315a17178ee5c3d859dc89b258da1311b Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 27 Nov 2023 16:46:21 +0100 Subject: [PATCH] Don't use test utils for deployment --- scripts/change_registry_handler.py | 4 +--- scripts/class_diagram.py | 3 +++ scripts/deployment_utils.py | 16 ++++++++++++++-- scripts/print_missing.py | 3 +++ scripts/setup_metaregistry.py | 3 +-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/change_registry_handler.py b/scripts/change_registry_handler.py index 6bcbfad..7da239b 100644 --- a/scripts/change_registry_handler.py +++ b/scripts/change_registry_handler.py @@ -3,11 +3,9 @@ import boa from rich.console import Console as RichConsole -from scripts.deployment_utils import setup_environment -from tests.utils import ZERO_ADDRESS, get_deployed_contract +from scripts.deployment_utils import setup_environment, ZERO_ADDRESS, get_deployed_contract RICH_CONSOLE = RichConsole(file=sys.stdout) -ADDRESS_PROVIDER = "0x0000000022D53366457F9d5E68Ec105046FC4383" CRYPTO_REGISTRY_HANDLER = "0x5f493fEE8D67D3AE3bA730827B34126CFcA0ae94" CRYPTO_REGISTRY_HANDLER_ID = 2 OLD_CRYPTO_REGISTRY_HANDLER = "0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56" diff --git a/scripts/class_diagram.py b/scripts/class_diagram.py index 19ea47a..909c2b1 100644 --- a/scripts/class_diagram.py +++ b/scripts/class_diagram.py @@ -3,6 +3,9 @@ the dependencies between contracts. Usage: python scripts/class_diagram.py [glob_pattern] (--internal) (--members) + +Unfortunately, rich doesn't support images in the terminal yet, so you'll have to +copy the source or link to the image and paste it in your browser. """ import sys from base64 import b64encode diff --git a/scripts/deployment_utils.py b/scripts/deployment_utils.py index 969b01b..7a4362b 100644 --- a/scripts/deployment_utils.py +++ b/scripts/deployment_utils.py @@ -3,10 +3,13 @@ import boa from boa.network import NetworkEnv +from boa.vyper.contract import VyperContract from eth_account import Account from rich.console import Console as RichConsole -FIDDYDEPLOYER = "0x2d12D0907A388811e3AA855A550F959501d303EE" +ADDRESS_PROVIDER = "0x0000000022D53366457F9d5E68Ec105046FC4383" +FIDDY_DEPLOYER = "0x2d12D0907A388811e3AA855A550F959501d303EE" +ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" def setup_environment(console: RichConsole): @@ -30,5 +33,14 @@ def setup_environment(console: RichConsole): console.log("Simulation Mode. Writing to mainnet-fork.") boa.env.fork(url=environ["RPC_ETHEREUM"]) - boa.env.eoa = FIDDYDEPLOYER + boa.env.eoa = FIDDY_DEPLOYER return False + +def get_deployed_contract(contract_name: str, address: str) -> VyperContract: + """ + Loads a contract and retrieves a deployed instance of it with the given address. + :param contract_name: The name of the contract ABI to load. + :param address: The address of the deployed contract. + """ + file_name = f"contracts/interfaces/{contract_name}.json" + return boa.load_abi(file_name).at(address) diff --git a/scripts/print_missing.py b/scripts/print_missing.py index 21dab1c..e7630d8 100644 --- a/scripts/print_missing.py +++ b/scripts/print_missing.py @@ -1,3 +1,6 @@ +""" +Print the missing functions from the registry. +""" import json import boa diff --git a/scripts/setup_metaregistry.py b/scripts/setup_metaregistry.py index 5fad82d..20e72bd 100644 --- a/scripts/setup_metaregistry.py +++ b/scripts/setup_metaregistry.py @@ -13,8 +13,7 @@ import boa from rich.console import Console as RichConsole -from scripts.deployment_utils import setup_environment -from tests.utils import ZERO_ADDRESS, get_deployed_contract +from scripts.deployment_utils import ZERO_ADDRESS, get_deployed_contract, setup_environment RICH_CONSOLE = RichConsole(file=sys.stdout)