Skip to content

Commit

Permalink
Ensure dictionary size for contract information is 1 before only gett…
Browse files Browse the repository at this point in the history
…ing only first entry. Pretty sure YAML prevents this but just being safe with our logic.
  • Loading branch information
derekpierre committed Nov 1, 2023
1 parent c502849 commit 73ecedc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions deployment/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ def from_config(cls, config: typing.Dict) -> "ConstructorParameters":
if isinstance(contract_info, str):
contract_constructor_params = {contract_info: OrderedDict()}
elif isinstance(contract_info, dict):
if len(contract_info) != 1:
raise ValueError("Malformed constructor parameters YAML.")

contract_name = list(contract_info.keys())[0] # only one entry
contract_data = contract_info[contract_name]
parameter_values = OrderedDict()
Expand Down Expand Up @@ -305,7 +308,7 @@ def from_config(cls, config: typing.Dict) -> "ProxyParameters":
if isinstance(contract_info, str):
continue

if not isinstance(contract_info, dict):
if not isinstance(contract_info, dict) or len(contract_info) != 1:
raise ValueError("Malformed constructor parameters YAML.")

contract_name = list(contract_info.keys())[0] # only one entry
Expand Down Expand Up @@ -461,7 +464,9 @@ def deploy(self, container: ContractContainer) -> ContractInstance:
contract_type_container, resolved_proxy_params = self.proxy_parameters.resolve(
contract_name=contract_name
)
instance = self._deploy_proxy(contract_name, contract_type_container, resolved_proxy_params)
instance = self._deploy_proxy(
contract_name, contract_type_container, resolved_proxy_params
)

return instance

Expand Down

0 comments on commit 73ecedc

Please sign in to comment.