mirror of https://github.com/nucypher/nucypher.git
Conventionally import (collapsed) domains for namespacing
parent
b1afa231d5
commit
0df05d38f2
|
@ -1,5 +1,5 @@
|
|||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.signers import InMemorySigner
|
||||
from nucypher.characters.chaotic import NiceGuyEddie as _Enrico
|
||||
from nucypher.characters.chaotic import ThisBobAlwaysDecrypts
|
||||
|
|
|
@ -10,7 +10,7 @@ from nucypher_core import EncryptedTreasureMap, MessageKit
|
|||
from nucypher_core.umbral import PublicKey
|
||||
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.characters.lawful import Bob
|
||||
from nucypher.crypto.keypairs import DecryptingKeypair, SigningKeypair
|
||||
from nucypher.crypto.powers import DecryptingPower, SigningPower
|
||||
|
|
|
@ -11,7 +11,8 @@ from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Union
|
|||
from nucypher import characters
|
||||
from nucypher.utilities.logging import Logger
|
||||
from .nicknames import Nickname
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from ..blockchain.eth.domains import TACoDomain
|
||||
|
||||
|
||||
class ArchivedFleetState(NamedTuple):
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from pathlib import Path
|
||||
from typing import ClassVar, Dict, List, Optional, Union
|
||||
|
||||
from constant_sorrow.constants import NO_NICKNAME, NO_SIGNING_POWER, STRANGER
|
||||
from eth_utils import to_canonical_address
|
||||
from nucypher_core.umbral import PublicKey
|
||||
from pathlib import Path
|
||||
from typing import ClassVar, Dict, List, Optional, Union
|
||||
|
||||
from nucypher.acumen.nicknames import Nickname
|
||||
from nucypher.blockchain.eth import domains
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
import contextlib
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
from queue import Queue
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
import maya
|
||||
import time
|
||||
from constant_sorrow import constants
|
||||
from constant_sorrow.constants import (
|
||||
INVALIDATED,
|
||||
|
@ -64,13 +48,28 @@ from nucypher_core.umbral import (
|
|||
VerifiedKeyFrag,
|
||||
reencrypt,
|
||||
)
|
||||
from pathlib import Path
|
||||
from queue import Queue
|
||||
from twisted.internet import reactor
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
from web3.types import TxReceipt
|
||||
|
||||
import nucypher
|
||||
from nucypher.acumen.nicknames import Nickname
|
||||
from nucypher.acumen.perception import ArchivedFleetState, RemoteUrsulaStatus
|
||||
from nucypher.blockchain.eth import actors
|
||||
from nucypher.blockchain.eth import actors, domains
|
||||
from nucypher.blockchain.eth.actors import Operator
|
||||
from nucypher.blockchain.eth.agents import (
|
||||
ContractAgency,
|
||||
|
|
|
@ -6,7 +6,7 @@ import click
|
|||
from tabulate import tabulate
|
||||
from web3.main import Web3
|
||||
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.signers.base import Signer
|
||||
from nucypher.cli.actions.configure import get_config_filepaths
|
||||
|
@ -104,7 +104,7 @@ def select_client_account(
|
|||
def select_domain(emitter: StdoutEmitter, message: Optional[str] = None) -> str:
|
||||
"""Interactively select a domain from TACo domain inventory list"""
|
||||
emitter.message(message=message or str(), color="yellow")
|
||||
domain_list = TACoDomain.SUPPORTED_DOMAIN_NAMES
|
||||
domain_list = domains.SUPPORTED_DOMAIN_NAMES
|
||||
rows = [[n] for n in domain_list]
|
||||
emitter.echo(tabulate(rows, showindex="always"))
|
||||
choice = click.prompt(
|
||||
|
|
|
@ -5,6 +5,7 @@ import maya
|
|||
from tabulate import tabulate
|
||||
from web3 import Web3
|
||||
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.agents import (
|
||||
ContractAgency,
|
||||
CoordinatorAgent,
|
||||
|
@ -14,7 +15,7 @@ from nucypher.blockchain.eth.constants import (
|
|||
AVERAGE_BLOCK_TIME_IN_SECONDS,
|
||||
TACO_CONTRACT_NAMES,
|
||||
)
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.utils import truncate_checksum_address
|
||||
from nucypher.cli.config import group_general_config
|
||||
from nucypher.cli.options import (
|
||||
|
@ -46,7 +47,7 @@ option_domain = click.option(
|
|||
"--domain",
|
||||
help="TACo Domain",
|
||||
type=click.STRING,
|
||||
default=click.Choice(TACoDomain.SUPPORTED_DOMAIN_NAMES),
|
||||
default=click.Choice(domains.SUPPORTED_DOMAIN_NAMES),
|
||||
required=True,
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from cryptography.exceptions import InternalError
|
|||
from eth_utils import to_checksum_address
|
||||
from nucypher_core.umbral import PublicKey
|
||||
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.token import TToken
|
||||
from nucypher.policy.payment import PRE_PAYMENT_METHODS
|
||||
from nucypher.utilities.networking import InvalidOperatorIP, validate_operator_ip
|
||||
|
@ -97,9 +97,9 @@ class NuCypherDomainName(click.ParamType):
|
|||
def convert(self, value, param, ctx):
|
||||
if self.validate:
|
||||
domain = str(value).lower()
|
||||
if domain not in TACoDomain.SUPPORTED_DOMAIN_NAMES:
|
||||
if domain not in domains.SUPPORTED_DOMAIN_NAMES:
|
||||
self.fail(
|
||||
f"'{value}' is not a recognized domain. Valid options are: {list(TACoDomain.SUPPORTED_DOMAIN_NAMES)}"
|
||||
f"'{value}' is not a recognized domain. Valid options are: {list(domains.SUPPORTED_DOMAIN_NAMES)}"
|
||||
)
|
||||
else:
|
||||
return domain
|
||||
|
|
|
@ -306,7 +306,7 @@ class CharacterConfiguration(BaseConfiguration):
|
|||
|
||||
CHARACTER_CLASS = NotImplemented
|
||||
MNEMONIC_KEYSTORE = False
|
||||
DEFAULT_DOMAIN = TACoDomain.DEFAULT_DOMAIN_NAME
|
||||
DEFAULT_DOMAIN = domains.DEFAULT_DOMAIN_NAME
|
||||
DEFAULT_NETWORK_MIDDLEWARE = RestMiddleware
|
||||
TEMP_CONFIGURATION_DIR_PREFIX = 'tmp-nucypher'
|
||||
SIGNER_ENVVAR = None
|
||||
|
|
|
@ -27,7 +27,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
TACoApplicationAgent,
|
||||
TACoChildApplicationAgent,
|
||||
)
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.utilities.emitters import StdoutEmitter
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||
|
@ -45,8 +45,8 @@ emitter = StdoutEmitter(verbosity=2)
|
|||
"--domain",
|
||||
"domain",
|
||||
help="TACo domain",
|
||||
type=click.Choice(TACoDomain.SUPPORTED_DOMAIN_NAMES),
|
||||
default=TACoDomain.LYNX.name,
|
||||
type=click.Choice(domains.SUPPORTED_DOMAIN_NAMES),
|
||||
default=domains.LYNX.name,
|
||||
)
|
||||
@click.option(
|
||||
"--eth-endpoint",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.cli.actions.select import select_domain
|
||||
|
||||
__DOMAINS = TACoDomain.SUPPORTED_DOMAIN_NAMES
|
||||
__DOMAINS = domains.SUPPORTED_DOMAIN_NAMES
|
||||
|
||||
|
||||
@pytest.mark.parametrize("user_input", range(0, len(__DOMAINS) - 1))
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.domains import (
|
||||
EthChain,
|
||||
PolygonChain,
|
||||
TACoDomain,
|
||||
)
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ def test_registry(module_mocker):
|
|||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def mock_condition_blockchains(module_mocker):
|
||||
# override fixture which mocks get_domain_info
|
||||
# override fixture which mocks get_domain
|
||||
yield
|
||||
|
||||
|
||||
|
@ -49,9 +49,9 @@ def test_polygon_chains(poly_chain_test):
|
|||
@pytest.mark.parametrize(
|
||||
"taco_domain_test",
|
||||
(
|
||||
(TACoDomain.MAINNET, "mainnet", EthChain.MAINNET, PolygonChain.MAINNET),
|
||||
(TACoDomain.LYNX, "lynx", EthChain.GOERLI, PolygonChain.MUMBAI),
|
||||
(TACoDomain.TAPIR, "tapir", EthChain.SEPOLIA, PolygonChain.MUMBAI),
|
||||
(domains.MAINNET, "mainnet", EthChain.MAINNET, PolygonChain.MAINNET),
|
||||
(domains.LYNX, "lynx", EthChain.GOERLI, PolygonChain.MUMBAI),
|
||||
(domains.TAPIR, "tapir", EthChain.SEPOLIA, PolygonChain.MUMBAI),
|
||||
),
|
||||
)
|
||||
def test_taco_domain_info(taco_domain_test):
|
||||
|
@ -71,16 +71,16 @@ def test_taco_domain_info(taco_domain_test):
|
|||
@pytest.mark.parametrize(
|
||||
"domain_name_test",
|
||||
(
|
||||
("mainnet", TACoDomain.MAINNET),
|
||||
("lynx", TACoDomain.LYNX),
|
||||
("tapir", TACoDomain.TAPIR),
|
||||
("mainnet", domains.MAINNET),
|
||||
("lynx", domains.LYNX),
|
||||
("tapir", domains.TAPIR),
|
||||
),
|
||||
)
|
||||
def test_get_domain_info(domain_name_test):
|
||||
def test_get_domain(domain_name_test):
|
||||
domain_name, expected_domain_info = domain_name_test
|
||||
assert TACoDomain.get_domain_info(domain_name) == expected_domain_info
|
||||
assert domains.get_domain(domain_name) == expected_domain_info
|
||||
|
||||
|
||||
def test_get_domain_info_unrecognized_domain_name():
|
||||
with pytest.raises(TACoDomain.Unrecognized):
|
||||
TACoDomain.get_domain_info(domain="5am_In_Toronto")
|
||||
def test_get_domain_unrecognized_domain_name():
|
||||
with pytest.raises(domains.Unrecognized):
|
||||
domains.get_domain(domain="5am_In_Toronto")
|
||||
|
|
|
@ -5,6 +5,7 @@ from contextlib import contextmanager
|
|||
from eth_utils import to_checksum_address
|
||||
from typing import List
|
||||
|
||||
from nucypher.blockchain.eth import domains
|
||||
from nucypher.blockchain.eth.domains import TACoDomain
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
RegistryData,
|
||||
|
|
Loading…
Reference in New Issue