Skip to content

Commit

Permalink
Handle lists of variables when validating abi type.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed Sep 21, 2023
1 parent 7639c68 commit 70c5f1a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/deployment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import typing
from collections import OrderedDict
from collections import OrderedDict, defaultdict
from pathlib import Path
from typing import Any, List

Expand Down Expand Up @@ -111,7 +111,11 @@ def _validate_constructor_abi_inputs(
if _is_variable(value):
# at the moment only contract addresses are variables
# won't know address until deployment; use a placeholder
value_to_validate = NULL_ADDRESS
context = defaultdict(PlacehodlerContractInstance)
if isinstance(value, list):
value_to_validate = _resolve_list(value, context)
else:
value_to_validate = _resolve_param(value, context)
if not w3.is_encodable(abi_input.type, value_to_validate):
raise ConstructorParameters.Invalid(
f"Constructor param name '{name}' at position {position} has a value '{value}' "
Expand Down Expand Up @@ -157,6 +161,10 @@ def _confirm_resolution(resolved_params: OrderedDict, contract_name: str) -> Non
_confirm_deployment(contract_name)


class PlacehodlerContractInstance(typing.NamedTuple):
address: str = NULL_ADDRESS


class ConstructorParameters:
"""Represents the constructor parameters for a set of contracts."""

Expand Down

0 comments on commit 70c5f1a

Please sign in to comment.