mirror of https://github.com/nucypher/nucypher.git
Agency transaction usage bug fixes
parent
bc4c6fc6e5
commit
974cc23058
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue