mirror of https://github.com/nucypher/nucypher.git
transaction_function -> contract_function
parent
d539017426
commit
b0f015b9ae
|
@ -118,7 +118,7 @@ class NucypherTokenAgent(EthereumContractAgent, metaclass=Agency):
|
|||
"""Approve the transfer of token from the sender address to the target address."""
|
||||
payload = {'gas': 500_000} # TODO #413: gas needed for use with geth.
|
||||
contract_function = self.contract.functions.approve(target_address, amount)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function,
|
||||
payload=payload,
|
||||
sender_address=sender_address)
|
||||
return receipt
|
||||
|
@ -126,7 +126,7 @@ class NucypherTokenAgent(EthereumContractAgent, metaclass=Agency):
|
|||
def transfer(self, amount: int, target_address: str, sender_address: str):
|
||||
self.approve_transfer(amount=amount, target_address=target_address, sender_address=sender_address)
|
||||
contract_function = self.contract.functions.transfer(target_address, amount)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=sender_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=sender_address)
|
||||
return receipt
|
||||
|
||||
|
||||
|
@ -186,13 +186,13 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
def deposit_tokens(self, amount: int, lock_periods: int, sender_address: str):
|
||||
"""Send tokens to the escrow from the staker's address"""
|
||||
contract_function = self.contract.functions.deposit(amount, lock_periods)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function,
|
||||
sender_address=sender_address)
|
||||
return receipt
|
||||
|
||||
def divide_stake(self, staker_address: str, stake_index: int, target_value: int, periods: int):
|
||||
contract_function = self.contract.functions.divideStake(stake_index, target_value, periods)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=staker_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=staker_address)
|
||||
return receipt
|
||||
|
||||
def get_last_active_period(self, address: str) -> int:
|
||||
|
@ -209,7 +209,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
|
||||
def set_worker(self, staker_address: str, worker_address: str):
|
||||
contract_function = self.contract.functions.setWorker(worker_address)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=staker_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=staker_address)
|
||||
return receipt
|
||||
|
||||
def release_worker(self, staker_address: str):
|
||||
|
@ -220,7 +220,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
For each period that the worker confirms activity, the staker is rewarded.
|
||||
"""
|
||||
contract_function = self.contract.functions.confirmActivity()
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=worker_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=worker_address)
|
||||
return receipt
|
||||
|
||||
def mint(self, staker_address: str):
|
||||
|
@ -230,7 +230,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
when you intend to withdraw 100% of tokens.
|
||||
"""
|
||||
contract_function = self.contract.functions.mint()
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=staker_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=staker_address)
|
||||
return receipt
|
||||
|
||||
@validate_checksum_address
|
||||
|
@ -252,7 +252,7 @@ class StakingEscrowAgent(EthereumContractAgent, metaclass=Agency):
|
|||
"""Withdraw tokens"""
|
||||
payload = {'gas': 500_000} # TODO: #842 Gas Management
|
||||
contract_function = self.contract.functions.withdraw(amount)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function,
|
||||
payload=payload,
|
||||
sender_address=staker_address)
|
||||
return receipt
|
||||
|
@ -322,7 +322,7 @@ class PolicyAgent(EthereumContractAgent, metaclass=Agency):
|
|||
|
||||
payload = {'value': value}
|
||||
contract_function = self.contract.functions.createPolicy(policy_id, periods, initial_reward, node_addresses)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function,
|
||||
payload=payload,
|
||||
sender_address=author_address)
|
||||
return receipt
|
||||
|
@ -335,13 +335,13 @@ class PolicyAgent(EthereumContractAgent, metaclass=Agency):
|
|||
def revoke_policy(self, policy_id: bytes, author_address: str):
|
||||
"""Revoke by arrangement ID; Only the policy's author_address can revoke the policy."""
|
||||
contract_function = self.contract.functions.revokePolicy(policy_id)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=author_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=author_address)
|
||||
return receipt
|
||||
|
||||
def collect_policy_reward(self, collector_address: str, staker_address: str):
|
||||
"""Collect rewarded ETH"""
|
||||
contract_function = self.contract.functions.withdraw(collector_address)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=staker_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=staker_address)
|
||||
return receipt
|
||||
|
||||
def fetch_policy_arrangements(self, policy_id):
|
||||
|
@ -352,17 +352,17 @@ class PolicyAgent(EthereumContractAgent, metaclass=Agency):
|
|||
|
||||
def revoke_arrangement(self, policy_id: str, node_address: str, author_address: str):
|
||||
contract_function = self.contract.functions.revokeArrangement(policy_id, node_address)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=author_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=author_address)
|
||||
return receipt
|
||||
|
||||
def calculate_refund(self, policy_id: str, author_address: str):
|
||||
contract_function = self.contract.functions.calculateRefundValue(policy_id)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=author_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=author_address)
|
||||
return receipt
|
||||
|
||||
def collect_refund(self, policy_id: str, author_address: str):
|
||||
contract_function = self.contract.functions.refund(policy_id)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=author_address)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=author_address)
|
||||
return receipt
|
||||
|
||||
|
||||
|
@ -455,47 +455,47 @@ class UserEscrowAgent(EthereumContractAgent):
|
|||
|
||||
def lock(self, amount: int, periods: int):
|
||||
contract_function = self.__proxy_contract.functions.lock(amount, periods)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def withdraw_tokens(self, value: int):
|
||||
contract_function = self.principal_contract.functions.withdrawTokens(value)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def withdraw_eth(self):
|
||||
contract_function = self.principal_contract.functions.withdrawETH()
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def deposit_as_staker(self, value: int, periods: int):
|
||||
contract_function = self.__proxy_contract.functions.depositAsStaker(value, periods)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def withdraw_as_staker(self, value: int):
|
||||
contract_function = self.__proxy_contract.functions.withdrawAsStaker(value)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def set_worker(self, worker_address: str):
|
||||
contract_function = self.__proxy_contract.functions.setWorker(worker_address)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def mint(self):
|
||||
contract_function = self.__proxy_contract.functions.mint()
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def collect_policy_reward(self):
|
||||
contract_function = self.__proxy_contract.functions.withdrawPolicyReward()
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
def set_min_reward_rate(self, rate: int):
|
||||
contract_function = self.__proxy_contract.functions.setMinRewardRate(rate)
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function, sender_address=self.__beneficiary)
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function, sender_address=self.__beneficiary)
|
||||
return receipt
|
||||
|
||||
|
||||
|
@ -513,7 +513,7 @@ class AdjudicatorAgent(EthereumContractAgent, metaclass=Agency):
|
|||
"""
|
||||
payload = {'gas': 500_000} # TODO #413: gas needed for use with geth.
|
||||
contract_function = self.contract.functions.evaluateCFrag(*evidence.evaluation_arguments())
|
||||
receipt = self.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.blockchain.send_transaction(contract_function=contract_function,
|
||||
sender_address=sender_address,
|
||||
payload=payload)
|
||||
return receipt
|
||||
|
|
|
@ -204,7 +204,7 @@ class DispatcherDeployer(ContractDeployer):
|
|||
|
||||
origin_args = {'from': self.deployer_address, 'gasPrice': self.blockchain.client.gas_price} # TODO: Gas management
|
||||
upgrade_function = self._contract.functions.upgrade(new_target, existing_secret_plaintext, new_secret_hash)
|
||||
upgrade_receipt = self.blockchain.send_transaction(transaction_function=upgrade_function,
|
||||
upgrade_receipt = self.blockchain.send_transaction(contract_function=upgrade_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=origin_args)
|
||||
return upgrade_receipt
|
||||
|
@ -212,7 +212,7 @@ class DispatcherDeployer(ContractDeployer):
|
|||
def rollback(self, existing_secret_plaintext: bytes, new_secret_hash: bytes) -> dict:
|
||||
origin_args = {'from': self.deployer_address, 'gasPrice': self.blockchain.client.gas_price} # TODO: Gas management
|
||||
rollback_function = self._contract.functions.rollback(existing_secret_plaintext, new_secret_hash)
|
||||
rollback_receipt = self.blockchain.send_transaction(transaction_function=rollback_function,
|
||||
rollback_receipt = self.blockchain.send_transaction(contract_function=rollback_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=origin_args)
|
||||
return rollback_receipt
|
||||
|
@ -294,7 +294,7 @@ class StakingEscrowDeployer(ContractDeployer):
|
|||
reward_function = self.token_agent.contract.functions.transfer(the_escrow_contract.address,
|
||||
self.__economics.erc20_reward_supply)
|
||||
|
||||
reward_receipt = self.blockchain.send_transaction(transaction_function=reward_function,
|
||||
reward_receipt = self.blockchain.send_transaction(contract_function=reward_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=origin_args)
|
||||
|
||||
|
@ -304,7 +304,7 @@ class StakingEscrowDeployer(ContractDeployer):
|
|||
# 4 - Initialize the Staker Escrow contract
|
||||
init_function = the_escrow_contract.functions.initialize()
|
||||
|
||||
init_receipt = self.blockchain.send_transaction(transaction_function=init_function,
|
||||
init_receipt = self.blockchain.send_transaction(contract_function=init_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=origin_args)
|
||||
|
||||
|
@ -418,7 +418,7 @@ class PolicyManagerDeployer(ContractDeployer):
|
|||
if gas_limit:
|
||||
tx_args.update({'gas': gas_limit})
|
||||
set_policy_manager_function = self.staking_agent.contract.functions.setPolicyManager(policy_manager_contract.address)
|
||||
set_policy_manager_receipt = self.blockchain.send_transaction(transaction_function=set_policy_manager_function,
|
||||
set_policy_manager_receipt = self.blockchain.send_transaction(contract_function=set_policy_manager_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=tx_args)
|
||||
|
||||
|
@ -505,7 +505,7 @@ class LibraryLinkerDeployer(ContractDeployer):
|
|||
|
||||
origin_args = {'from': self.deployer_address} # TODO: Gas management
|
||||
retarget_function = self._contract.functions.upgrade(new_target, existing_secret_plaintext, new_secret_hash)
|
||||
retarget_receipt = self.blockchain.send_transaction(transaction_function=retarget_function,
|
||||
retarget_receipt = self.blockchain.send_transaction(contract_function=retarget_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=origin_args)
|
||||
return retarget_receipt
|
||||
|
@ -636,7 +636,7 @@ class UserEscrowDeployer(ContractDeployer):
|
|||
# TODO: #413, #842 - Gas Management
|
||||
payload = {'from': self.deployer_address, 'gas': 500_000, 'gasPrice': self.blockchain.client.gas_price}
|
||||
transfer_owner_function = self.contract.functions.transferOwnership(beneficiary_address)
|
||||
transfer_owner_receipt = self.blockchain.send_transaction(transaction_function=transfer_owner_function,
|
||||
transfer_owner_receipt = self.blockchain.send_transaction(contract_function=transfer_owner_function,
|
||||
payload=payload,
|
||||
sender_address=self.deployer_address)
|
||||
self.__beneficiary_address = beneficiary_address
|
||||
|
@ -657,7 +657,7 @@ class UserEscrowDeployer(ContractDeployer):
|
|||
'gasPrice': self.blockchain.client.gas_price,
|
||||
'gas': 200_000}
|
||||
deposit_function = self.contract.functions.initialDeposit(value, duration)
|
||||
deposit_receipt = self.blockchain.send_transaction(transaction_function=deposit_function,
|
||||
deposit_receipt = self.blockchain.send_transaction(contract_function=deposit_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=args)
|
||||
|
||||
|
@ -748,7 +748,7 @@ class AdjudicatorDeployer(ContractDeployer):
|
|||
if gas_limit:
|
||||
tx_args.update({'gas': gas_limit})
|
||||
set_adjudicator_function = self.staking_agent.contract.functions.setAdjudicator(adjudicator_contract.address)
|
||||
set_adjudicator_receipt = self.blockchain.send_transaction(transaction_function=set_adjudicator_function,
|
||||
set_adjudicator_receipt = self.blockchain.send_transaction(contract_function=set_adjudicator_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=tx_args)
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ class BlockchainInterface:
|
|||
self._provider = provider
|
||||
|
||||
def send_transaction(self,
|
||||
transaction_function: ContractFunction,
|
||||
contract_function: ContractFunction,
|
||||
sender_address: str,
|
||||
payload: dict = None,
|
||||
) -> dict:
|
||||
|
@ -308,9 +308,9 @@ class BlockchainInterface:
|
|||
|
||||
# Get interface name
|
||||
try:
|
||||
transaction_name = transaction_function.fn_name.upper()
|
||||
transaction_name = contract_function.fn_name.upper()
|
||||
except AttributeError:
|
||||
if isinstance(transaction_function, ContractConstructor):
|
||||
if isinstance(contract_function, ContractConstructor):
|
||||
transaction_name = 'DEPLOY'
|
||||
else:
|
||||
transaction_name = 'UNKNOWN'
|
||||
|
@ -500,7 +500,7 @@ class BlockchainDeployerInterface(BlockchainInterface):
|
|||
# Transmit the deployment tx #
|
||||
#
|
||||
|
||||
receipt = self.send_transaction(transaction_function=transaction_function,
|
||||
receipt = self.send_transaction(contract_function=transaction_function,
|
||||
sender_address=self.deployer_address,
|
||||
payload=deploy_transaction)
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ class BlockchainPolicy(Policy):
|
|||
|
||||
# Transact
|
||||
contract_function = self.author.policy_agent.contract.functions.createPolicy(*policy_args)
|
||||
receipt = self.author.blockchain.send_transaction(transaction_function=contract_function,
|
||||
receipt = self.author.blockchain.send_transaction(contract_function=contract_function,
|
||||
sender_address=self.author.checksum_address,
|
||||
payload=payload)
|
||||
txhash = receipt['transactionHash']
|
||||
|
|
|
@ -52,7 +52,7 @@ def token_airdrop(token_agent, amount: NU, origin: str, addresses: List[str]):
|
|||
args = {'from': origin, 'gasPrice': token_agent.blockchain.client.gas_price}
|
||||
for address in addresses:
|
||||
contract_function = token_agent.contract.functions.transfer(address, int(amount))
|
||||
_receipt = token_agent.blockchain.send_transaction(transaction_function=contract_function,
|
||||
_receipt = token_agent.blockchain.send_transaction(contract_function=contract_function,
|
||||
sender_address=origin,
|
||||
payload=args)
|
||||
yield _receipt
|
||||
|
|
Loading…
Reference in New Issue