mirror of https://github.com/nucypher/nucypher.git
Expands domains data model to include condition chains
parent
1d179cc276
commit
d63a6cb93d
|
@ -9,9 +9,9 @@ from eth_typing import ChecksumAddress
|
||||||
from nucypher_core import FleetStateChecksum, NodeMetadata
|
from nucypher_core import FleetStateChecksum, NodeMetadata
|
||||||
|
|
||||||
from nucypher import characters
|
from nucypher import characters
|
||||||
from nucypher.blockchain.eth.domains import TACoDomain
|
|
||||||
from nucypher.utilities.logging import Logger
|
from nucypher.utilities.logging import Logger
|
||||||
|
|
||||||
|
from ..blockchain.eth.domains import TACoDomain
|
||||||
from .nicknames import Nickname
|
from .nicknames import Nickname
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Dict, NamedTuple
|
from typing import Any, Dict, NamedTuple, Tuple
|
||||||
|
|
||||||
from cytoolz.functoolz import memoize
|
from cytoolz.functoolz import memoize
|
||||||
|
|
||||||
|
@ -25,10 +25,17 @@ class PolygonChain(ChainInfo, Enum):
|
||||||
|
|
||||||
|
|
||||||
class TACoDomain:
|
class TACoDomain:
|
||||||
def __init__(self, name: str, eth_chain: EthChain, polygon_chain: PolygonChain):
|
def __init__(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
eth_chain: EthChain,
|
||||||
|
polygon_chain: PolygonChain,
|
||||||
|
condition_chains: Tuple[ChainInfo, ...],
|
||||||
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.eth_chain = eth_chain
|
self.eth_chain = eth_chain
|
||||||
self.polygon_chain = polygon_chain
|
self.polygon_chain = polygon_chain
|
||||||
|
self.condition_chains = condition_chains
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<TACoDomain {self.name}>"
|
return f"<TACoDomain {self.name}>"
|
||||||
|
@ -63,18 +70,26 @@ MAINNET = TACoDomain(
|
||||||
name="mainnet",
|
name="mainnet",
|
||||||
eth_chain=EthChain.MAINNET,
|
eth_chain=EthChain.MAINNET,
|
||||||
polygon_chain=PolygonChain.MAINNET,
|
polygon_chain=PolygonChain.MAINNET,
|
||||||
|
condition_chains=(EthChain.MAINNET, PolygonChain.MAINNET),
|
||||||
)
|
)
|
||||||
|
|
||||||
LYNX = TACoDomain(
|
LYNX = TACoDomain(
|
||||||
name="lynx",
|
name="lynx",
|
||||||
eth_chain=EthChain.GOERLI,
|
eth_chain=EthChain.GOERLI,
|
||||||
polygon_chain=PolygonChain.MUMBAI,
|
polygon_chain=PolygonChain.MUMBAI,
|
||||||
|
condition_chains=(
|
||||||
|
EthChain.MAINNET,
|
||||||
|
EthChain.GOERLI,
|
||||||
|
PolygonChain.MUMBAI,
|
||||||
|
PolygonChain.MAINNET,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
TAPIR = TACoDomain(
|
TAPIR = TACoDomain(
|
||||||
name="tapir",
|
name="tapir",
|
||||||
eth_chain=EthChain.SEPOLIA,
|
eth_chain=EthChain.SEPOLIA,
|
||||||
polygon_chain=PolygonChain.MUMBAI,
|
polygon_chain=PolygonChain.MUMBAI,
|
||||||
|
condition_chains=(EthChain.SEPOLIA, PolygonChain.MUMBAI),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ from nucypher_core import ReencryptionRequest
|
||||||
from web3.types import ChecksumAddress, Timestamp, TxReceipt, Wei
|
from web3.types import ChecksumAddress, Timestamp, TxReceipt, Wei
|
||||||
|
|
||||||
from nucypher.blockchain.eth.agents import ContractAgency, SubscriptionManagerAgent
|
from nucypher.blockchain.eth.agents import ContractAgency, SubscriptionManagerAgent
|
||||||
from nucypher.blockchain.eth.domains import TACoDomain
|
|
||||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||||
from nucypher.policy import policies
|
from nucypher.policy import policies
|
||||||
|
from tests.utils.registry import TACoDomain
|
||||||
|
|
||||||
|
|
||||||
class PaymentMethod(ABC):
|
class PaymentMethod(ABC):
|
||||||
|
|
|
@ -20,6 +20,7 @@ import rlcompleter
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
from nucypher.blockchain.eth import domains
|
||||||
from nucypher.blockchain.eth.agents import (
|
from nucypher.blockchain.eth.agents import (
|
||||||
ContractAgency,
|
ContractAgency,
|
||||||
CoordinatorAgent,
|
CoordinatorAgent,
|
||||||
|
@ -27,7 +28,6 @@ from nucypher.blockchain.eth.agents import (
|
||||||
TACoApplicationAgent,
|
TACoApplicationAgent,
|
||||||
TACoChildApplicationAgent,
|
TACoChildApplicationAgent,
|
||||||
)
|
)
|
||||||
from nucypher.blockchain.eth import domains
|
|
||||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||||
from nucypher.utilities.emitters import StdoutEmitter
|
from nucypher.utilities.emitters import StdoutEmitter
|
||||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||||
|
|
|
@ -79,6 +79,7 @@ TEMPORARY_DOMAIN = TACoDomain(
|
||||||
name=TEMPORARY_DOMAIN_NAME,
|
name=TEMPORARY_DOMAIN_NAME,
|
||||||
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
|
condition_chains=(TESTERCHAIN_CHAIN_INFO,),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -306,8 +306,6 @@ def lonely_ursula_maker(ursula_test_config, testerchain):
|
||||||
#
|
#
|
||||||
# Blockchain
|
# Blockchain
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def mock_registry_sources(module_mocker):
|
def mock_registry_sources(module_mocker):
|
||||||
with tests.utils.registry.mock_registry_sources(module_mocker):
|
with tests.utils.registry.mock_registry_sources(module_mocker):
|
||||||
|
|
|
@ -286,7 +286,6 @@ def mock_condition_blockchains(module_mocker):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def multichain_ids(module_mocker):
|
def multichain_ids(module_mocker):
|
||||||
ids = mock_permitted_multichain_connections(mocker=module_mocker)
|
ids = mock_permitted_multichain_connections(mocker=module_mocker)
|
||||||
|
|
|
@ -20,6 +20,7 @@ def domain_1():
|
||||||
name="domain_uno",
|
name="domain_uno",
|
||||||
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
|
condition_chains=(TESTERCHAIN_CHAIN_INFO,),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ def domain_2():
|
||||||
name="domain_dos",
|
name="domain_dos",
|
||||||
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
eth_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
polygon_chain=TESTERCHAIN_CHAIN_INFO,
|
||||||
|
condition_chains=(TESTERCHAIN_CHAIN_INFO,),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@ from nucypher.blockchain.eth.domains import (
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def test_registry(module_mocker):
|
def test_registry(module_mocker):
|
||||||
# override fixture which mocks SUPPORTED_DOMAINS
|
# override fixture which mocks domains.SUPPORTED_DOMAINS
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module", autouse=True)
|
@pytest.fixture(scope="module", autouse=True)
|
||||||
def mock_condition_blockchains(module_mocker):
|
def mock_condition_blockchains(module_mocker):
|
||||||
# override fixture which mocks get_domain
|
# override fixture which mocks domains.get_domain
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,9 +49,32 @@ def test_polygon_chains(poly_chain_test):
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"taco_domain_test",
|
"taco_domain_test",
|
||||||
(
|
(
|
||||||
(domains.MAINNET, "mainnet", EthChain.MAINNET, PolygonChain.MAINNET),
|
(
|
||||||
(domains.LYNX, "lynx", EthChain.GOERLI, PolygonChain.MUMBAI),
|
domains.MAINNET,
|
||||||
(domains.TAPIR, "tapir", EthChain.SEPOLIA, PolygonChain.MUMBAI),
|
"mainnet",
|
||||||
|
EthChain.MAINNET,
|
||||||
|
PolygonChain.MAINNET,
|
||||||
|
(EthChain.MAINNET, PolygonChain.MAINNET),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
domains.LYNX,
|
||||||
|
"lynx",
|
||||||
|
EthChain.GOERLI,
|
||||||
|
PolygonChain.MUMBAI,
|
||||||
|
(
|
||||||
|
EthChain.MAINNET,
|
||||||
|
EthChain.GOERLI,
|
||||||
|
PolygonChain.MUMBAI,
|
||||||
|
PolygonChain.MAINNET,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
domains.TAPIR,
|
||||||
|
"tapir",
|
||||||
|
EthChain.SEPOLIA,
|
||||||
|
PolygonChain.MUMBAI,
|
||||||
|
(EthChain.SEPOLIA, PolygonChain.MUMBAI),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_taco_domain_info(taco_domain_test):
|
def test_taco_domain_info(taco_domain_test):
|
||||||
|
|
|
@ -12,7 +12,7 @@ def mock_teacher_nodes(mocker):
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def test_registry(module_mocker):
|
def test_registry(module_mocker):
|
||||||
# override fixture which mocks SUPPORTED_DOMAINS
|
# override fixture which mocks domains.SUPPORTED_DOMAINS
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,10 @@ from tests.constants import TEMPORARY_DOMAIN
|
||||||
def mock_registry_sources(mocker, _domains: List[TACoDomain] = None):
|
def mock_registry_sources(mocker, _domains: List[TACoDomain] = None):
|
||||||
if not _domains:
|
if not _domains:
|
||||||
_domains = [TEMPORARY_DOMAIN]
|
_domains = [TEMPORARY_DOMAIN]
|
||||||
|
|
||||||
_supported_domains = mocker.patch.dict(
|
_supported_domains = mocker.patch.dict(
|
||||||
"nucypher.blockchain.eth.domains.SUPPORTED_DOMAINS",
|
"nucypher.blockchain.eth.domains.SUPPORTED_DOMAINS",
|
||||||
{str(domain): domain for domain in _domains},
|
{str(domain): domain for domain in _domains},
|
||||||
)
|
)
|
||||||
|
|
||||||
mocker.patch.object(MockRegistrySource, "ALLOWED_DOMAINS", list(map(str, _domains)))
|
mocker.patch.object(MockRegistrySource, "ALLOWED_DOMAINS", list(map(str, _domains)))
|
||||||
mocker.patch.object(RegistrySourceManager, "_FALLBACK_CHAIN", (MockRegistrySource,))
|
mocker.patch.object(RegistrySourceManager, "_FALLBACK_CHAIN", (MockRegistrySource,))
|
||||||
yield
|
yield
|
||||||
|
|
Loading…
Reference in New Issue