Skip to content

Commit

Permalink
Rename parameter constants for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed Nov 1, 2023
1 parent 4801a6c commit c36cd4c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions deployment/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from eth_typing import ChecksumAddress
from web3.auto import w3

CONTRACT_CONSTRUCTOR_KEY = "constructor"
CONTRACT_PROXY_KEY = "proxy"
CONTRACT_CONSTRUCTOR_PARAMETER_KEY = "constructor"
CONTRACT_PROXY_PARAMETER_KEY = "proxy"


def _is_variable(param: Any) -> bool:
Expand Down Expand Up @@ -261,8 +261,10 @@ def from_config(cls, config: typing.Dict) -> "ConstructorParameters":
contract_name = list(contract_info.keys())[0] # only one entry
contract_data = contract_info[contract_name]
parameter_values = OrderedDict()
if CONTRACT_CONSTRUCTOR_KEY in contract_data:
parameter_values = OrderedDict(contract_data[CONTRACT_CONSTRUCTOR_KEY])
if CONTRACT_CONSTRUCTOR_PARAMETER_KEY in contract_data:
parameter_values = OrderedDict(
contract_data[CONTRACT_CONSTRUCTOR_PARAMETER_KEY]
)

contract_constructor_params = {contract_name: parameter_values}
else:
Expand Down Expand Up @@ -328,7 +330,7 @@ def from_config(cls, config: typing.Dict) -> "ProxyParameters":

contract_name = list(contract_info.keys())[0] # only one entry
contract_data = contract_info[contract_name]
if CONTRACT_PROXY_KEY not in contract_data:
if CONTRACT_PROXY_PARAMETER_KEY not in contract_data:
continue

proxy_info = cls._generate_proxy_info(contract_name, contract_data)
Expand Down Expand Up @@ -358,16 +360,16 @@ def resolve(self, contract_name: str) -> typing.Tuple[ContractContainer, Ordered

@classmethod
def _generate_proxy_info(cls, contract_name, contract_data) -> ProxyInfo:
proxy_data = contract_data[CONTRACT_PROXY_KEY] or dict()
proxy_data = contract_data[CONTRACT_PROXY_PARAMETER_KEY] or dict()

wrap_container_name = contract_name
if cls.WRAP_CONTAINER_PROPERTY in proxy_data:
wrap_container_name = proxy_data[cls.WRAP_CONTAINER_PROPERTY]
wrap_container = get_contract_container(wrap_container_name)

constructor_data = cls._default_proxy_parameters(contract_name)
if CONTRACT_CONSTRUCTOR_KEY in proxy_data:
for name, value in proxy_data[CONTRACT_CONSTRUCTOR_KEY].items():
if CONTRACT_CONSTRUCTOR_PARAMETER_KEY in proxy_data:
for name, value in proxy_data[CONTRACT_CONSTRUCTOR_PARAMETER_KEY].items():
if name == "_logic":
raise cls.Invalid(
"'_logic' parameter cannot be specified: it is implicitly "
Expand Down

0 comments on commit c36cd4c

Please sign in to comment.