diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 052084eb3..9405e1d07 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -350,10 +350,10 @@ class Miner(NucypherTokenActor): return policy_reward_txhash @only_me - def collect_staking_reward(self) -> str: + def collect_staking_reward(self, collector_address: str) -> str: """Withdraw tokens rewarded for staking.""" - collection_txhash = self.miner_agent.collect_staking_reward(collector_address=self.checksum_public_address) + collection_txhash = self.miner_agent.collect_staking_reward(collector_address=collector_address) self._transaction_cache.append((datetime.utcnow(), collection_txhash)) return collection_txhash diff --git a/nucypher/blockchain/eth/agents.py b/nucypher/blockchain/eth/agents.py index dbdc72d64..c592c0bab 100644 --- a/nucypher/blockchain/eth/agents.py +++ b/nucypher/blockchain/eth/agents.py @@ -25,10 +25,10 @@ class EthereumContractAgent(ABC): class ContractNotDeployed(Exception): pass - def __new__(cls, *args, **kwargs) -> 'EthereumContractAgent': - if cls.__instance is NO_CONTRACT_AVAILABLE: - cls.__instance = super(EthereumContractAgent, cls).__new__(cls) - return cls.__instance + # def __new__(cls, *args, **kwargs) -> 'EthereumContractAgent': TODO: remove? + # if cls.__instance is NO_CONTRACT_AVAILABLE: + # cls.__instance = super(EthereumContractAgent, cls).__new__(cls) + # return cls.__instance def __init__(self, blockchain: Blockchain = None, @@ -290,7 +290,7 @@ class PolicyAgent(EthereumContractAgent): def revoke_policy(self, policy_id: bytes, author_address) -> str: """Revoke by arrangement ID; Only the policy's author_address can revoke the policy.""" - txhash = self.contract.functions.revokePolicy(policy_id).transact({'from': author_address.address}) + txhash = self.contract.functions.revokePolicy(policy_id).transact({'from': author_address}) self.blockchain.wait_for_receipt(txhash) return txhash @@ -301,13 +301,13 @@ class PolicyAgent(EthereumContractAgent): return policy_reward_txhash def fetch_policy_arrangements(self, policy_id): - records = self.contract.functions.getArrangementsLength(policy_id).call() - for records in range(records): - arrangement = self.contract.functions.getArrangementInfo(policy_id, 0).call()[records] + record_count = self.contract.functions.getArrangementsLength(policy_id).call() + for index in range(record_count): + arrangement = self.contract.functions.getArrangementInfo(policy_id, index).call() yield arrangement - def revoke_arrangement(self, policy_id: str, node_address: str): - txhash = self.contract.functions.revokeArrangement(policy_id, node_address) + def revoke_arrangement(self, policy_id: str, node_address: str, author_address: str): + txhash = self.contract.functions.revokeArrangement(policy_id, node_address).transact({'from': author_address}) self.blockchain.wait_for_receipt(txhash) return txhash diff --git a/nucypher/blockchain/eth/deployers.py b/nucypher/blockchain/eth/deployers.py index ab33908bc..80c8d4015 100644 --- a/nucypher/blockchain/eth/deployers.py +++ b/nucypher/blockchain/eth/deployers.py @@ -1,4 +1,5 @@ from constant_sorrow.constants import CONTRACT_NOT_DEPLOYED, NO_DEPLOYER_CONFIGURED +from eth_utils import is_checksum_address from typing import Tuple, Dict from nucypher.blockchain.eth import constants diff --git a/tests/blockchain/eth/interfaces/test_chains.py b/tests/blockchain/eth/interfaces/test_chains.py index 82a198d19..3081f8593 100644 --- a/tests/blockchain/eth/interfaces/test_chains.py +++ b/tests/blockchain/eth/interfaces/test_chains.py @@ -1,6 +1,3 @@ -from nucypher.blockchain.eth.deployers import NucypherTokenDeployer - - def test_testerchain_creation(testerchain): # Ensure we are testing on the correct network... assert 'tester' in testerchain.interface.provider_uri @@ -9,9 +6,3 @@ def test_testerchain_creation(testerchain): assert testerchain.interface.w3.eth.blockNumber >= 0 -def test_nucypher_contract_compiled(testerchain): - # Ensure that solidity smart contacts are available, post-compile. - origin, *everybody_else = testerchain.interface.w3.eth.accounts - - token_contract_identifier = NucypherTokenDeployer(blockchain=testerchain, deployer_address=origin)._contract_name - assert token_contract_identifier in testerchain.interface._BlockchainInterface__raw_contract_cache