Skip to content

Commit

Permalink
Ensure required values are provided to Porter object initialization v…
Browse files Browse the repository at this point in the history
…ia CLI and programmatically.
  • Loading branch information
derekpierre committed Nov 17, 2023
1 parent 64c507d commit 7723d6e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions porter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ContractAgency,
TACoChildApplicationAgent,
)
from nucypher.blockchain.eth.domains import TACoDomain
from nucypher.blockchain.eth.domains import DEFAULT_DOMAIN, TACoDomain
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
from nucypher.blockchain.eth.registry import ContractRegistry
from nucypher.characters.lawful import Ursula
Expand Down Expand Up @@ -87,16 +87,23 @@ class DecryptOutcome(NamedTuple):

def __init__(
self,
domain: TACoDomain = None,
eth_endpoint: str,
polygon_endpoint: str,
domain: TACoDomain = DEFAULT_DOMAIN,
registry: ContractRegistry = None,
controller: bool = True,
node_class: object = Ursula,
eth_endpoint: str = None,
polygon_endpoint: str = None,
execution_timeout: int = DEFAULT_EXECUTION_TIMEOUT,
*args,
**kwargs,
):
if not domain:
raise ValueError("TACo Domain must be provided.")
if not eth_endpoint:
raise ValueError("ETH Provider URI must be provided.")
if not polygon_endpoint:
raise ValueError("Polygon Provider URI must be provided.")

self._initialize_endpoints(eth_endpoint, polygon_endpoint)
self.eth_endpoint, self.polygon_endpoint = eth_endpoint, polygon_endpoint

Expand Down Expand Up @@ -125,19 +132,15 @@ def __init__(

@staticmethod
def _initialize_endpoints(eth_endpoint: str, polygon_endpoint: str):
if not eth_endpoint:
raise ValueError("ETH Provider URI is required for Porter.")
if not BlockchainInterfaceFactory.is_interface_initialized(
endpoint=eth_endpoint
):
BlockchainInterfaceFactory.initialize_interface(endpoint=eth_endpoint)

if not polygon_endpoint:
raise ValueError("Polygon Provider URI is required for Porter.")
if not BlockchainInterfaceFactory.is_interface_initialized(
endpoint=polygon_endpoint
):
BlockchainInterfaceFactory.initialize_interface(endpoint=eth_endpoint)
BlockchainInterfaceFactory.initialize_interface(endpoint=polygon_endpoint)

def get_ursulas(self,
quantity: int,
Expand Down

0 comments on commit 7723d6e

Please sign in to comment.