mirror of https://github.com/nucypher/nucypher.git
Move provider_uri validation
parent
2119c1abee
commit
259067b0b9
|
@ -84,7 +84,6 @@ class Character(Learner):
|
|||
signer: Signer = None,
|
||||
registry: BaseContractRegistry = None,
|
||||
include_self_in_the_state: bool = False,
|
||||
is_offchain: bool = False,
|
||||
*args, **kwargs
|
||||
) -> None:
|
||||
|
||||
|
@ -179,9 +178,7 @@ class Character(Learner):
|
|||
self._stamp = NO_SIGNING_POWER
|
||||
|
||||
# Blockchainy
|
||||
if not self.federated_only and not is_offchain:
|
||||
if not provider_uri:
|
||||
raise ValueError('Provider URI is required to init a decentralized character.')
|
||||
if not self.federated_only:
|
||||
self.provider_uri = provider_uri
|
||||
|
||||
# TODO: Implicit / lazy blockchain connection here?
|
||||
|
|
|
@ -112,6 +112,7 @@ class Alice(Character, BlockchainPolicyAuthor):
|
|||
# Mode
|
||||
is_me: bool = True,
|
||||
federated_only: bool = False,
|
||||
provider_uri: str = None,
|
||||
signer=None,
|
||||
|
||||
# Ownership
|
||||
|
@ -156,11 +157,15 @@ class Alice(Character, BlockchainPolicyAuthor):
|
|||
known_node_class=Ursula,
|
||||
is_me=is_me,
|
||||
federated_only=federated_only,
|
||||
provider_uri=provider_uri,
|
||||
checksum_address=checksum_address,
|
||||
network_middleware=network_middleware,
|
||||
*args, **kwargs)
|
||||
|
||||
if is_me and not federated_only: # TODO: #289
|
||||
if not provider_uri:
|
||||
raise ValueError('Provider URI is required to init a decentralized character.')
|
||||
|
||||
blockchain = BlockchainInterfaceFactory.get_interface(provider_uri=self.provider_uri)
|
||||
signer = signer or Web3Signer(blockchain.client) # fallback to web3 provider by default for Alice.
|
||||
self.transacting_power = TransactingPower(account=self.checksum_address, signer=signer)
|
||||
|
@ -172,7 +177,6 @@ class Alice(Character, BlockchainPolicyAuthor):
|
|||
rate=rate,
|
||||
duration_periods=duration_periods)
|
||||
|
||||
|
||||
self.log = Logger(self.__class__.__name__)
|
||||
if is_me:
|
||||
if controller:
|
||||
|
@ -502,7 +506,6 @@ class Bob(Character):
|
|||
is_me=is_me,
|
||||
known_node_class=Ursula,
|
||||
verify_node_bonding=verify_node_bonding,
|
||||
is_offchain=provider_uri is None,
|
||||
provider_uri=provider_uri,
|
||||
*args, **kwargs)
|
||||
|
||||
|
@ -1080,6 +1083,7 @@ class Ursula(Teacher, Character, Worker):
|
|||
worker_address: ChecksumAddress = None, # TODO: deprecate, and rename to "checksum_address"
|
||||
client_password: str = None,
|
||||
decentralized_identity_evidence=NOT_SIGNED,
|
||||
provider_uri: str = None,
|
||||
|
||||
# Character
|
||||
abort_on_learning_error: bool = False,
|
||||
|
@ -1100,6 +1104,7 @@ class Ursula(Teacher, Character, Worker):
|
|||
domain=domain,
|
||||
known_node_class=Ursula,
|
||||
include_self_in_the_state=True,
|
||||
provider_uri=provider_uri,
|
||||
**character_kwargs)
|
||||
|
||||
if is_me:
|
||||
|
@ -1118,6 +1123,9 @@ class Ursula(Teacher, Character, Worker):
|
|||
# Decentralized Worker
|
||||
if not federated_only:
|
||||
|
||||
if not provider_uri:
|
||||
raise ValueError('Provider URI is required to init a decentralized character.')
|
||||
|
||||
# TODO: Move to method
|
||||
# Prepare a TransactingPower from worker node's transacting keys
|
||||
transacting_power = TransactingPower(account=worker_address,
|
||||
|
|
Loading…
Reference in New Issue