Embed broadcasting and HW prompt to blockchain interface

pull/1750/head
Kieran R. Prasch 2020-02-26 19:34:26 -07:00
parent 8d833e09e7
commit 33df86b9be
2 changed files with 10 additions and 6 deletions

View File

@ -61,7 +61,7 @@ from nucypher.blockchain.eth.providers import (
from nucypher.blockchain.eth.registry import BaseContractRegistry
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
from nucypher.blockchain.eth.utils import prettify_eth_amount
from nucypher.characters.control.emitters import StdoutEmitter
Web3Providers = Union[IPCProvider, WebsocketProvider, HTTPProvider, EthereumTester]
@ -234,7 +234,6 @@ class BlockchainInterface:
self.client.inject_middleware(geth_poa_middleware, layer=0)
# Gas Price Strategy
self.log.debug('Injecting POA middleware at layer 0')
self.client.w3.eth.setGasPriceStrategy(self.gas_strategy)
self.client.w3.middleware_onion.add(middleware.time_based_cache_middleware)
self.client.w3.middleware_onion.add(middleware.latest_block_based_cache_middleware)
@ -427,18 +426,26 @@ class BlockchainInterface:
) -> dict:
#
# Sign
# Setup
#
emitter = StdoutEmitter() # TODO: Move this to singleton?
if self.transacting_power is READ_ONLY_INTERFACE:
raise self.InterfaceError(str(READ_ONLY_INTERFACE))
#
# Sign
#
if self.transacting_power.device:
emitter.message(f'Confirm transaction {transaction_name} on hardware wallet...', color='yellow')
signed_raw_transaction = self.transacting_power.sign_transaction(unsigned_transaction)
#
# Broadcast
#
emitter.message(f'Broadcasting {transaction_name}...', color='yellow')
txhash = self.client.send_raw_transaction(signed_raw_transaction)
try:
receipt = self.client.wait_for_receipt(txhash, timeout=self.TIMEOUT)

View File

@ -503,7 +503,6 @@ def create(general_config, transacting_staker_options, config_file, force, value
# Authenticate and Execute
STAKEHOLDER.assimilate(checksum_address=client_account, password=password)
emitter.echo("Broadcasting stake...", color='yellow')
new_stake = STAKEHOLDER.initialize_stake(amount=value, lock_periods=lock_periods)
painting.paint_staking_confirmation(emitter=emitter, staker=STAKEHOLDER, new_stake=new_stake)
@ -686,7 +685,6 @@ def divide(general_config, transacting_staker_options, config_file, force, value
# Execute
STAKEHOLDER.assimilate(checksum_address=current_stake.staker_address, password=password)
emitter.echo("Broadcasting Stake Division...", color='yellow')
modified_stake, new_stake = STAKEHOLDER.divide_stake(stake_index=current_stake.index,
target_value=value,
additional_periods=extension)
@ -759,7 +757,6 @@ def prolong(general_config, transacting_staker_options, config_file, force, lock
# Authenticate and Execute
STAKEHOLDER.assimilate(checksum_address=current_stake.staker_address, password=password)
emitter.echo("Broadcasting Stake Extension...", color='yellow')
receipt = STAKEHOLDER.prolong_stake(stake_index=current_stake.index, additional_periods=lock_periods)
# Report