mirror of https://github.com/nucypher/nucypher.git
Cleanup blockchain defaults and constants integration
parent
7e04dd117b
commit
dadb49c4ce
|
@ -80,12 +80,10 @@ class Miner(NucypherTokenActor):
|
||||||
class MinerError(NucypherTokenActor.ActorError):
|
class MinerError(NucypherTokenActor.ActorError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self, miner_agent: MinerAgent, is_me=True, *args, **kwargs) -> None:
|
||||||
is_me=True,
|
if miner_agent is None:
|
||||||
miner_agent: MinerAgent = None,
|
token_agent = NucypherTokenAgent()
|
||||||
*args, **kwargs) -> None:
|
miner_agent = MinerAgent(token_agent=token_agent)
|
||||||
|
|
||||||
miner_agent = miner_agent if miner_agent is not None else MinerAgent()
|
|
||||||
super().__init__(token_agent=miner_agent.token_agent, *args, **kwargs)
|
super().__init__(token_agent=miner_agent.token_agent, *args, **kwargs)
|
||||||
|
|
||||||
# Extrapolate dependencies
|
# Extrapolate dependencies
|
||||||
|
@ -98,6 +96,7 @@ class Miner(NucypherTokenActor):
|
||||||
#
|
#
|
||||||
# Staking
|
# Staking
|
||||||
#
|
#
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_staking(self):
|
def is_staking(self):
|
||||||
"""Checks if this Miner currently has locked tokens."""
|
"""Checks if this Miner currently has locked tokens."""
|
||||||
|
|
|
@ -35,9 +35,7 @@ class EthereumContractAgent(ABC):
|
||||||
contract: Contract = None
|
contract: Contract = None
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
if blockchain is None:
|
self.blockchain = blockchain or Blockchain.connect()
|
||||||
blockchain = Blockchain.connect()
|
|
||||||
self.blockchain = blockchain
|
|
||||||
|
|
||||||
if registry_filepath is not None:
|
if registry_filepath is not None:
|
||||||
# TODO: Warn on override/ do this elsewhere?
|
# TODO: Warn on override/ do this elsewhere?
|
||||||
|
@ -100,23 +98,13 @@ class MinerAgent(EthereumContractAgent):
|
||||||
|
|
||||||
principal_contract_name = "MinersEscrow"
|
principal_contract_name = "MinersEscrow"
|
||||||
_upgradeable = True
|
_upgradeable = True
|
||||||
__instance = None # TODO: constants.NO_CONTRACT_AVAILABLE
|
__instance = NO_CONTRACT_AVAILABLE
|
||||||
|
|
||||||
class NotEnoughMiners(Exception):
|
class NotEnoughMiners(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self, token_agent: NucypherTokenAgent, *args, **kwargs) -> None:
|
||||||
token_agent: NucypherTokenAgent = None,
|
super().__init__(blockchain=token_agent.blockchain, *args, **kwargs)
|
||||||
registry_filepath: str = None,
|
|
||||||
*args, **kwargs
|
|
||||||
) -> None:
|
|
||||||
|
|
||||||
token_agent = token_agent if token_agent is not None else NucypherTokenAgent(registry_filepath=registry_filepath)
|
|
||||||
|
|
||||||
super().__init__(blockchain=token_agent.blockchain,
|
|
||||||
registry_filepath=registry_filepath,
|
|
||||||
*args, **kwargs)
|
|
||||||
|
|
||||||
self.token_agent = token_agent
|
self.token_agent = token_agent
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,23 +1,16 @@
|
||||||
from typing import List, Union
|
from constant_sorrow.constants import NO_BLOCKCHAIN_AVAILABLE
|
||||||
|
from typing import Union
|
||||||
from constant_sorrow import constants
|
from web3.contract import Contract
|
||||||
from web3.middleware import geth_poa_middleware
|
|
||||||
|
|
||||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface, BlockchainDeployerInterface
|
from nucypher.blockchain.eth.interfaces import BlockchainInterface, BlockchainDeployerInterface
|
||||||
from nucypher.config.blockchain import BlockchainConfiguration
|
|
||||||
from nucypher.config.parsers import parse_blockchain_config
|
|
||||||
|
|
||||||
|
|
||||||
class Blockchain:
|
class Blockchain:
|
||||||
"""A view of a blockchain through a provided interface"""
|
"""A view of a blockchain through a provided interface"""
|
||||||
|
|
||||||
_instance = None
|
_instance = NO_BLOCKCHAIN_AVAILABLE
|
||||||
_default_network = NotImplemented
|
|
||||||
__default_interface_class = BlockchainInterface
|
__default_interface_class = BlockchainInterface
|
||||||
|
|
||||||
test_chains = ('tester', 'temp')
|
|
||||||
public_chains = ('mainnet', 'ropsten')
|
|
||||||
|
|
||||||
class ConnectionNotEstablished(RuntimeError):
|
class ConnectionNotEstablished(RuntimeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue