mirror of https://github.com/nucypher/nucypher.git
nucypher packages Base|InMemory|ContractRegistry -> ContractRegistry
parent
d441356336
commit
e1f81d9a5e
|
@ -3,7 +3,7 @@ import os
|
|||
from nucypher_core.ferveo import DkgPublicKey
|
||||
|
||||
from nucypher.blockchain.eth.agents import CoordinatorAgent
|
||||
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.blockchain.eth.signers import InMemorySigner
|
||||
from nucypher.characters.lawful import Bob, Enrico
|
||||
from nucypher.policy.conditions.lingo import ConditionLingo
|
||||
|
@ -32,8 +32,8 @@ print("--------- Threshold Encryption ---------")
|
|||
|
||||
coordinator_agent = CoordinatorAgent(
|
||||
provider_uri=coordinator_provider_uri,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
registry=ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
),
|
||||
)
|
||||
ritual_id = 1 # got this from a side channel
|
||||
|
@ -102,7 +102,7 @@ bob = Bob(
|
|||
domain=network,
|
||||
coordinator_provider_uri=coordinator_provider_uri,
|
||||
coordinator_network=coordinator_network,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(network=network),
|
||||
registry=ContractRegistry.from_latest_publication(domain=network),
|
||||
)
|
||||
|
||||
bob.start_learning_loop(now=True)
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
from nucypher_core.ferveo import DkgPublicKey
|
||||
|
||||
from nucypher.blockchain.eth.agents import CoordinatorAgent
|
||||
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.blockchain.eth.signers import InMemorySigner
|
||||
from nucypher.characters.lawful import Bob, Enrico
|
||||
from nucypher.policy.conditions.lingo import ConditionLingo
|
||||
|
@ -32,8 +32,8 @@ print("--------- Threshold Encryption ---------")
|
|||
|
||||
coordinator_agent = CoordinatorAgent(
|
||||
provider_uri=coordinator_provider_uri,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
registry=ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
),
|
||||
)
|
||||
ritual_id = 1 # got this from a side channel
|
||||
|
@ -79,7 +79,7 @@ bob = Bob(
|
|||
domain=network,
|
||||
coordinator_provider_uri=coordinator_provider_uri,
|
||||
coordinator_network=coordinator_network,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(network=network),
|
||||
registry=ContractRegistry.from_latest_publication(domain=network),
|
||||
)
|
||||
|
||||
bob.start_learning_loop(now=True)
|
||||
|
|
|
@ -39,8 +39,7 @@ from nucypher.blockchain.eth.constants import NULL_ADDRESS
|
|||
from nucypher.blockchain.eth.decorators import validate_checksum_address
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.blockchain.eth.signers import Signer
|
||||
from nucypher.blockchain.eth.token import NU
|
||||
|
@ -72,7 +71,7 @@ class BaseActor:
|
|||
def __init__(
|
||||
self,
|
||||
domain: Optional[str],
|
||||
registry: BaseContractRegistry,
|
||||
registry: ContractRegistry,
|
||||
transacting_power: Optional[TransactingPower] = None,
|
||||
checksum_address: Optional[ChecksumAddress] = None,
|
||||
):
|
||||
|
@ -127,7 +126,7 @@ class NucypherTokenActor(BaseActor):
|
|||
Actor to interface with the NuCypherToken contract
|
||||
"""
|
||||
|
||||
def __init__(self, registry: BaseContractRegistry, **kwargs):
|
||||
def __init__(self, registry: ContractRegistry, **kwargs):
|
||||
super().__init__(registry=registry, **kwargs)
|
||||
self.__token_agent = None
|
||||
|
||||
|
@ -210,8 +209,8 @@ class Operator(BaseActor):
|
|||
)
|
||||
|
||||
# TODO: registry usage (and subsequently "network") is inconsistent here
|
||||
coordinator_network_registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
coordinator_network_registry = ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
)
|
||||
self.child_application_agent = ContractAgency.get_agent(
|
||||
TACoChildApplicationAgent,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
import random
|
||||
import sys
|
||||
from bisect import bisect_right
|
||||
from dataclasses import dataclass, field
|
||||
from itertools import accumulate
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
|
@ -15,7 +17,6 @@ from typing import (
|
|||
cast,
|
||||
)
|
||||
|
||||
import sys
|
||||
from constant_sorrow.constants import (
|
||||
# type: ignore
|
||||
CONTRACT_CALL,
|
||||
|
@ -24,7 +25,6 @@ from constant_sorrow.constants import (
|
|||
from eth_typing.evm import ChecksumAddress
|
||||
from eth_utils.address import to_checksum_address
|
||||
from hexbytes import HexBytes
|
||||
from itertools import accumulate
|
||||
from nucypher_core import SessionStaticKey
|
||||
from nucypher_core.ferveo import (
|
||||
AggregatedTranscript,
|
||||
|
@ -48,7 +48,7 @@ from nucypher.blockchain.eth.constants import (
|
|||
from nucypher.blockchain.eth.decorators import contract_api
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.config.constants import (
|
||||
NUCYPHER_ENVVAR_STAKING_PROVIDERS_PAGINATION_SIZE,
|
||||
|
@ -82,7 +82,7 @@ class EthereumContractAgent:
|
|||
def __init__(
|
||||
self,
|
||||
provider_uri: str,
|
||||
registry: BaseContractRegistry,
|
||||
registry: ContractRegistry,
|
||||
contract: Optional[Contract] = None,
|
||||
transaction_gas: Optional[Wei] = None,
|
||||
):
|
||||
|
@ -844,7 +844,7 @@ class ContractAgency:
|
|||
def get_agent(
|
||||
cls,
|
||||
agent_class: Type[types.Agent],
|
||||
registry: Optional[BaseContractRegistry],
|
||||
registry: Optional[ContractRegistry],
|
||||
provider_uri: Optional[str],
|
||||
contract_version: Optional[str] = None,
|
||||
) -> types.Agent:
|
||||
|
@ -888,7 +888,7 @@ class ContractAgency:
|
|||
def get_agent_by_contract_name(
|
||||
cls,
|
||||
contract_name: str,
|
||||
registry: BaseContractRegistry,
|
||||
registry: ContractRegistry,
|
||||
provider_uri: str,
|
||||
contract_version: Optional[str] = None,
|
||||
) -> EthereumContractAgent:
|
||||
|
|
|
@ -19,7 +19,7 @@ class NetworksInventory: # TODO: See #1564
|
|||
IBEX: 5, # this is required for configuration file migrations (backwards compatibility)
|
||||
LYNX: 5, # Goerli
|
||||
TAPIR: 11155111, # Sepolia
|
||||
ORYX: 5 # Goerli
|
||||
ORYX: 5, # Goerli
|
||||
}
|
||||
__to_chain_id_polygon = {
|
||||
# TODO: Use naming scheme?
|
||||
|
|
|
@ -7,8 +7,7 @@ from nucypher_core.umbral import PublicKey
|
|||
|
||||
from nucypher.acumen.nicknames import Nickname
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.blockchain.eth.signers.base import Signer
|
||||
from nucypher.config.constants import TEMPORARY_DOMAIN
|
||||
|
@ -44,7 +43,7 @@ class Character(Learner):
|
|||
crypto_power: CryptoPower = None,
|
||||
crypto_power_ups: List[CryptoPowerUp] = None,
|
||||
signer: Signer = None,
|
||||
registry: BaseContractRegistry = None,
|
||||
registry: ContractRegistry = None,
|
||||
include_self_in_the_state: bool = False,
|
||||
*args,
|
||||
**kwargs,
|
||||
|
@ -115,9 +114,8 @@ class Character(Learner):
|
|||
self._stamp = NO_SIGNING_POWER
|
||||
|
||||
self.eth_provider_uri = eth_provider_uri
|
||||
self.registry = (
|
||||
registry
|
||||
or InMemoryContractRegistry.from_latest_publication(network=domain)
|
||||
self.registry = registry or ContractRegistry.from_latest_publication(
|
||||
domain=domain
|
||||
) # See #1580
|
||||
|
||||
# REST
|
||||
|
|
|
@ -79,8 +79,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.blockchain.eth.signers import Signer
|
||||
from nucypher.blockchain.eth.signers.software import Web3Signer
|
||||
|
@ -484,8 +483,8 @@ class Bob(Character):
|
|||
coordinator_agent = ContractAgency.get_agent(
|
||||
CoordinatorAgent,
|
||||
provider_uri=coordinator_provider_uri,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
registry=ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
),
|
||||
)
|
||||
self.coordinator_agent = coordinator_agent
|
||||
|
@ -1207,7 +1206,7 @@ class Ursula(Teacher, Character, Operator):
|
|||
teacher_uri: str,
|
||||
min_stake: int,
|
||||
provider_uri: str,
|
||||
registry: BaseContractRegistry = None,
|
||||
registry: ContractRegistry = None,
|
||||
network_middleware: RestMiddleware = None,
|
||||
retry_attempts: int = 2,
|
||||
retry_interval: int = 2,
|
||||
|
@ -1246,7 +1245,7 @@ class Ursula(Teacher, Character, Operator):
|
|||
cls,
|
||||
seed_uri: str,
|
||||
provider_uri: str,
|
||||
registry: BaseContractRegistry = None,
|
||||
registry: ContractRegistry = None,
|
||||
minimum_stake: int = 0,
|
||||
network_middleware: RestMiddleware = None,
|
||||
) -> Union["Ursula", "NodeSprout"]:
|
||||
|
|
|
@ -12,8 +12,7 @@ from nucypher.blockchain.eth.agents import ContractAgency, NucypherTokenAgent
|
|||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.blockchain.eth.signers.base import Signer
|
||||
from nucypher.blockchain.eth.token import NU
|
||||
|
@ -35,19 +34,20 @@ from nucypher.config.constants import (
|
|||
from nucypher.utilities.emitters import StdoutEmitter
|
||||
|
||||
|
||||
def select_client_account(emitter,
|
||||
eth_provider_uri: str = None,
|
||||
signer: Signer = None,
|
||||
signer_uri: str = None,
|
||||
prompt: str = None,
|
||||
default: int = 0,
|
||||
registry: BaseContractRegistry = None,
|
||||
show_eth_balance: bool = False,
|
||||
show_nu_balance: bool = False,
|
||||
show_staking: bool = False,
|
||||
network: str = None,
|
||||
poa: bool = None
|
||||
) -> str:
|
||||
def select_client_account(
|
||||
emitter,
|
||||
eth_provider_uri: str = None,
|
||||
signer: Signer = None,
|
||||
signer_uri: str = None,
|
||||
prompt: str = None,
|
||||
default: int = 0,
|
||||
registry: ContractRegistry = None,
|
||||
show_eth_balance: bool = False,
|
||||
show_nu_balance: bool = False,
|
||||
show_staking: bool = False,
|
||||
network: str = None,
|
||||
poa: bool = None,
|
||||
) -> str:
|
||||
"""
|
||||
Interactively select an ethereum wallet account from a table of nucypher account metadata.
|
||||
|
||||
|
@ -78,7 +78,7 @@ def select_client_account(emitter,
|
|||
if not registry:
|
||||
if not network:
|
||||
raise ValueError("Pass network name or registry; Got neither.")
|
||||
registry = InMemoryContractRegistry.from_latest_publication(network=network)
|
||||
registry = ContractRegistry.from_latest_publication(domain=network)
|
||||
|
||||
enumerated_accounts = dict(enumerate(signer.accounts))
|
||||
if len(enumerated_accounts) < 1:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from distutils.util import strtobool
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional, Tuple
|
||||
|
@ -16,9 +15,7 @@ from nucypher.blockchain.eth.interfaces import (
|
|||
BlockchainInterfaceFactory,
|
||||
)
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
LocalContractRegistry,
|
||||
ContractRegistry,
|
||||
)
|
||||
from nucypher.characters.base import Character
|
||||
from nucypher.cli.actions.auth import (
|
||||
|
@ -31,9 +28,7 @@ from nucypher.cli.literature import (
|
|||
CONNECTING_TO_BLOCKCHAIN,
|
||||
ETHERSCAN_FLAG_DISABLED_WARNING,
|
||||
ETHERSCAN_FLAG_ENABLED_WARNING,
|
||||
LOCAL_REGISTRY_ADVISORY,
|
||||
NO_HARDWARE_WALLET_WARNING,
|
||||
PRODUCTION_REGISTRY_ADVISORY,
|
||||
)
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.utilities.emitters import StdoutEmitter
|
||||
|
@ -106,11 +101,13 @@ def make_cli_character(
|
|||
return CHARACTER
|
||||
|
||||
|
||||
def get_registry(network: str, registry_filepath: Optional[Path] = None) -> BaseContractRegistry:
|
||||
def get_registry(
|
||||
network: str, registry_filepath: Optional[Path] = None
|
||||
) -> ContractRegistry:
|
||||
if registry_filepath:
|
||||
registry = LocalContractRegistry(filepath=registry_filepath)
|
||||
registry = ContractRegistry(filepath=registry_filepath)
|
||||
else:
|
||||
registry = InMemoryContractRegistry.from_latest_publication(network=network)
|
||||
registry = ContractRegistry.from_latest_publication(domain=network)
|
||||
return registry
|
||||
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@ from eth_utils.address import is_checksum_address
|
|||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
LocalContractRegistry,
|
||||
ContractRegistry,
|
||||
LocalRegistrySource,
|
||||
)
|
||||
from nucypher.blockchain.eth.signers import Signer
|
||||
from nucypher.characters.lawful import Ursula
|
||||
|
@ -379,9 +378,9 @@ class CharacterConfiguration(BaseConfiguration):
|
|||
pre_payment_provider: Optional[str] = None,
|
||||
pre_payment_network: Optional[str] = None,
|
||||
# Registries
|
||||
registry: Optional[BaseContractRegistry] = None,
|
||||
registry: Optional[ContractRegistry] = None,
|
||||
registry_filepath: Optional[Path] = None,
|
||||
policy_registry: Optional[BaseContractRegistry] = None,
|
||||
policy_registry: Optional[ContractRegistry] = None,
|
||||
policy_registry_filepath: Optional[Path] = None,
|
||||
):
|
||||
|
||||
|
@ -472,16 +471,16 @@ class CharacterConfiguration(BaseConfiguration):
|
|||
)
|
||||
|
||||
if not self.registry:
|
||||
# TODO: These two code blocks are untested.
|
||||
if (
|
||||
not self.registry_filepath
|
||||
): # TODO: Registry URI (goerli://speedynet.json) :-)
|
||||
if not self.registry_filepath:
|
||||
self.log.info("Fetching latest registry from source.")
|
||||
self.registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=self.domain
|
||||
self.registry = ContractRegistry.from_latest_publication(
|
||||
domain=self.domain
|
||||
)
|
||||
else:
|
||||
self.registry = LocalContractRegistry(filepath=self.registry_filepath)
|
||||
source = LocalRegistrySource(
|
||||
domain=self.domain, filepath=self.registry_filepath
|
||||
)
|
||||
self.registry = ContractRegistry(source=source)
|
||||
self.log.info(f"Using local registry ({self.registry}).")
|
||||
|
||||
self.testnet = self.domain != NetworksInventory.MAINNET
|
||||
|
@ -511,13 +510,11 @@ class CharacterConfiguration(BaseConfiguration):
|
|||
if not self.policy_registry:
|
||||
if not self.policy_registry_filepath:
|
||||
self.log.info("Fetching latest policy registry from source.")
|
||||
self.policy_registry = (
|
||||
InMemoryContractRegistry.from_latest_publication(
|
||||
network=self.pre_payment_network
|
||||
)
|
||||
self.policy_registry = ContractRegistry.from_latest_publication(
|
||||
domain=self.pre_payment_network
|
||||
)
|
||||
else:
|
||||
self.policy_registry = LocalContractRegistry(
|
||||
self.policy_registry = ContractRegistry(
|
||||
filepath=self.policy_registry_filepath
|
||||
)
|
||||
self.log.info(
|
||||
|
|
|
@ -13,7 +13,7 @@ from cryptography.hazmat.primitives.serialization import Encoding
|
|||
from cryptography.x509 import Certificate
|
||||
|
||||
from nucypher.blockchain.eth.decorators import validate_checksum_address
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.config.util import cast_paths_from
|
||||
from nucypher.crypto.signing import SignatureStamp
|
||||
|
@ -33,7 +33,7 @@ class NodeStorage(ABC):
|
|||
class UnknownNode(NodeStorageError):
|
||||
pass
|
||||
|
||||
def __init__(self, character_class=None, registry: BaseContractRegistry = None):
|
||||
def __init__(self, character_class=None, registry: ContractRegistry = None):
|
||||
|
||||
from nucypher.characters.lawful import Ursula
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ from nucypher_core import FleetStateChecksum, MetadataRequest, NodeMetadata
|
|||
from requests.exceptions import SSLError
|
||||
|
||||
from nucypher import characters
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.config.storages import ForgetfulNodeStorage, NodeStorage
|
||||
from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||
from nucypher.utilities.logging import Logger
|
||||
|
@ -29,7 +29,7 @@ class NucypherMiddlewareClient:
|
|||
def __init__(
|
||||
self,
|
||||
eth_provider_uri: Optional[str],
|
||||
registry: Optional[BaseContractRegistry] = None,
|
||||
registry: Optional[ContractRegistry] = None,
|
||||
storage: Optional[NodeStorage] = None,
|
||||
*args,
|
||||
**kwargs,
|
||||
|
|
|
@ -29,7 +29,7 @@ from nucypher.acumen.perception import FleetSensor
|
|||
from nucypher.blockchain.eth.agents import ContractAgency, TACoApplicationAgent
|
||||
from nucypher.blockchain.eth.constants import NULL_ADDRESS
|
||||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.config.constants import SeednodeMetadata
|
||||
from nucypher.config.storages import ForgetfulNodeStorage
|
||||
from nucypher.crypto.powers import (
|
||||
|
@ -1040,7 +1040,7 @@ class Teacher:
|
|||
return bytes(response)
|
||||
|
||||
def _operator_is_bonded(
|
||||
self, provider_uri: str, registry: BaseContractRegistry
|
||||
self, provider_uri: str, registry: ContractRegistry
|
||||
) -> bool:
|
||||
"""
|
||||
This method assumes the stamp's signature is valid and accurate.
|
||||
|
@ -1055,7 +1055,9 @@ class Teacher:
|
|||
raise self.UnbondedOperator(f"Operator {self.operator_address} is not bonded")
|
||||
return staking_provider_address == self.checksum_address
|
||||
|
||||
def _staking_provider_is_really_staking(self, registry: BaseContractRegistry, eth_provider_uri: Optional[str] = None) -> bool:
|
||||
def _staking_provider_is_really_staking(
|
||||
self, registry: ContractRegistry, eth_provider_uri: Optional[str] = None
|
||||
) -> bool:
|
||||
"""
|
||||
This method assumes the stamp's signature is valid and accurate.
|
||||
As a follow-up, this checks that the staking provider is, indeed, staking.
|
||||
|
@ -1068,7 +1070,7 @@ class Teacher:
|
|||
|
||||
def validate_operator(
|
||||
self,
|
||||
registry: BaseContractRegistry = None,
|
||||
registry: ContractRegistry = None,
|
||||
eth_provider_uri: Optional[str] = None,
|
||||
) -> None:
|
||||
# TODO: restore this enforcement
|
||||
|
@ -1112,8 +1114,9 @@ class Teacher:
|
|||
else:
|
||||
raise self.InvalidNode("Metadata signature is invalid")
|
||||
|
||||
def validate_metadata(self, registry: BaseContractRegistry = None, eth_provider_uri: Optional[str] = None):
|
||||
|
||||
def validate_metadata(
|
||||
self, registry: ContractRegistry = None, eth_provider_uri: Optional[str] = None
|
||||
):
|
||||
# Verify the metadata signature
|
||||
if not self.verified_metadata:
|
||||
self.validate_metadata_signature()
|
||||
|
@ -1125,13 +1128,14 @@ class Teacher:
|
|||
# Offline check of valid stamp signature by worker
|
||||
self.validate_operator(registry=registry, eth_provider_uri=eth_provider_uri)
|
||||
|
||||
def verify_node(self,
|
||||
network_middleware_client,
|
||||
registry: BaseContractRegistry = None,
|
||||
eth_provider_uri: Optional[str] = None,
|
||||
certificate_filepath: Optional[Path] = None,
|
||||
force: bool = False
|
||||
) -> bool:
|
||||
def verify_node(
|
||||
self,
|
||||
network_middleware_client,
|
||||
registry: ContractRegistry = None,
|
||||
eth_provider_uri: Optional[str] = None,
|
||||
certificate_filepath: Optional[Path] = None,
|
||||
force: bool = False,
|
||||
) -> bool:
|
||||
"""
|
||||
Three things happening here:
|
||||
|
||||
|
|
|
@ -6,10 +6,7 @@ from nucypher_core import ReencryptionRequest
|
|||
from web3.types import ChecksumAddress, Timestamp, TxReceipt, Wei
|
||||
|
||||
from nucypher.blockchain.eth.agents import ContractAgency, SubscriptionManagerAgent
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
BaseContractRegistry,
|
||||
InMemoryContractRegistry,
|
||||
)
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.policy import policies
|
||||
|
||||
|
||||
|
@ -65,16 +62,19 @@ class ContractPayment(PaymentMethod, ABC):
|
|||
rate: Wei
|
||||
value: Wei
|
||||
|
||||
def __init__(self,
|
||||
eth_provider: str,
|
||||
network: str,
|
||||
registry: Optional[BaseContractRegistry] = None,
|
||||
*args, **kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
eth_provider: str,
|
||||
network: str,
|
||||
registry: Optional[ContractRegistry] = None,
|
||||
*args,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.provider = eth_provider
|
||||
self.network = network
|
||||
if not registry:
|
||||
registry = InMemoryContractRegistry.from_latest_publication(network=network)
|
||||
registry = ContractRegistry.from_latest_publication(domain=network)
|
||||
self.registry = registry
|
||||
self.__agent = None # delay blockchain/registry reads until later
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import requests
|
|||
from requests.exceptions import HTTPError, RequestException
|
||||
|
||||
from nucypher.acumen.perception import FleetSensor
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.config.storages import LocalFileBasedNodeStorage
|
||||
from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||
from nucypher.network.middleware import NucypherMiddlewareClient, RestMiddleware
|
||||
|
@ -102,7 +102,7 @@ def _request_from_node(
|
|||
def get_external_ip_from_default_teacher(
|
||||
network: str,
|
||||
provider_uri: str,
|
||||
registry: Optional[BaseContractRegistry] = None,
|
||||
registry: Optional[ContractRegistry] = None,
|
||||
log: Logger = IP_DETECTION_LOGGER,
|
||||
) -> Union[str, None]:
|
||||
# Prevents circular imports
|
||||
|
|
|
@ -22,7 +22,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
TACoApplicationAgent,
|
||||
)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
|
||||
from nucypher.blockchain.eth.registry import BaseContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.characters import lawful
|
||||
|
||||
|
||||
|
@ -149,7 +149,7 @@ class StakingProviderMetricsCollector(BaseMetricsCollector):
|
|||
def __init__(
|
||||
self,
|
||||
staking_provider_address: ChecksumAddress,
|
||||
contract_registry: BaseContractRegistry,
|
||||
contract_registry: ContractRegistry,
|
||||
eth_provider_uri: str,
|
||||
):
|
||||
super().__init__()
|
||||
|
@ -200,7 +200,13 @@ class StakingProviderMetricsCollector(BaseMetricsCollector):
|
|||
|
||||
class OperatorMetricsCollector(BaseMetricsCollector):
|
||||
"""Collector for Operator specific metrics."""
|
||||
def __init__(self, domain: str, operator_address: ChecksumAddress, contract_registry: BaseContractRegistry):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
domain: str,
|
||||
operator_address: ChecksumAddress,
|
||||
contract_registry: ContractRegistry,
|
||||
):
|
||||
super().__init__()
|
||||
self.domain = domain
|
||||
self.operator_address = operator_address
|
||||
|
@ -228,12 +234,15 @@ class OperatorMetricsCollector(BaseMetricsCollector):
|
|||
|
||||
class EventMetricsCollector(BaseMetricsCollector):
|
||||
"""General collector for emitted events."""
|
||||
def __init__(self,
|
||||
event_name: str,
|
||||
event_args_config: Dict[str, tuple],
|
||||
argument_filters: Dict[str, str],
|
||||
contract_agent_class: Type[EthereumContractAgent],
|
||||
contract_registry: BaseContractRegistry):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
event_name: str,
|
||||
event_args_config: Dict[str, tuple],
|
||||
argument_filters: Dict[str, str],
|
||||
contract_agent_class: Type[EthereumContractAgent],
|
||||
contract_registry: ContractRegistry,
|
||||
):
|
||||
super().__init__()
|
||||
self.event_name = event_name
|
||||
self.contract_agent_class = contract_agent_class
|
||||
|
|
|
@ -28,7 +28,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
TACoChildApplicationAgent,
|
||||
)
|
||||
from nucypher.blockchain.eth.networks import NetworksInventory
|
||||
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.utilities.emitters import StdoutEmitter
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||
|
||||
|
@ -75,8 +75,8 @@ def nucypher_agents(
|
|||
coordinator_provider_uri,
|
||||
coordinator_network,
|
||||
):
|
||||
staking_registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=eth_staking_network
|
||||
staking_registry = ContractRegistry.from_latest_publication(
|
||||
domain=eth_staking_network
|
||||
)
|
||||
emitter.echo(f"NOTICE: Connecting to {eth_staking_network} network", color="yellow")
|
||||
|
||||
|
@ -86,8 +86,8 @@ def nucypher_agents(
|
|||
provider_uri=eth_provider_uri,
|
||||
) # type: TACoApplicationAgent
|
||||
|
||||
coordinator_network_registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
coordinator_network_registry = ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
)
|
||||
emitter.echo(f"NOTICE: Connecting to {coordinator_network} network", color="yellow")
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from nucypher.blockchain.eth.agents import (
|
|||
CoordinatorAgent,
|
||||
TACoApplicationAgent,
|
||||
)
|
||||
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
||||
from nucypher.blockchain.eth.registry import ContractRegistry
|
||||
from nucypher.blockchain.eth.signers import InMemorySigner, Signer
|
||||
from nucypher.characters.lawful import Bob, Enrico
|
||||
from nucypher.crypto.powers import TransactingPower
|
||||
|
@ -161,8 +161,8 @@ def nucypher_dkg(
|
|||
),
|
||||
)
|
||||
|
||||
coordinator_network_registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
coordinator_network_registry = ContractRegistry.from_latest_publication(
|
||||
domain=coordinator_network
|
||||
)
|
||||
coordinator_agent = ContractAgency.get_agent(
|
||||
agent_class=CoordinatorAgent,
|
||||
|
@ -170,8 +170,8 @@ def nucypher_dkg(
|
|||
provider_uri=coordinator_provider_uri,
|
||||
) # type: CoordinatorAgent
|
||||
|
||||
staking_network_registry = InMemoryContractRegistry.from_latest_publication(
|
||||
network=eth_staking_network
|
||||
staking_network_registry = ContractRegistry.from_latest_publication(
|
||||
domain=eth_staking_network
|
||||
)
|
||||
application_agent = ContractAgency.get_agent(
|
||||
agent_class=TACoApplicationAgent,
|
||||
|
|
Loading…
Reference in New Issue