mirror of https://github.com/nucypher/nucypher.git
Commit the TransactingPower to activation inside actor.Deployer.__init__
parent
56f4ec1844
commit
63bbe2edf7
|
@ -21,22 +21,16 @@ from datetime import datetime
|
|||
from decimal import Decimal
|
||||
from json import JSONDecodeError
|
||||
from typing import Tuple, List, Dict, Union
|
||||
from eth_utils import keccak
|
||||
|
||||
import maya
|
||||
from constant_sorrow.constants import (
|
||||
CONTRACT_NOT_DEPLOYED,
|
||||
NO_DEPLOYER_ADDRESS,
|
||||
EMPTY_STAKING_SLOT,
|
||||
UNKNOWN_STAKES,
|
||||
NOT_STAKING,
|
||||
NO_STAKES,
|
||||
STRANGER_STAKER,
|
||||
NO_STAKING_DEVICE,
|
||||
STRANGER_WORKER,
|
||||
WORKER_NOT_RUNNING
|
||||
)
|
||||
from eth_tester.exceptions import TransactionFailed
|
||||
from eth_utils import keccak
|
||||
from twisted.logger import Logger
|
||||
|
||||
from nucypher.blockchain.economics import TokenEconomics
|
||||
|
@ -47,7 +41,6 @@ from nucypher.blockchain.eth.agents import (
|
|||
AdjudicatorAgent,
|
||||
EthereumContractAgent
|
||||
)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.deployers import (
|
||||
NucypherTokenDeployer,
|
||||
StakingEscrowDeployer,
|
||||
|
@ -57,10 +50,12 @@ from nucypher.blockchain.eth.deployers import (
|
|||
AdjudicatorDeployer,
|
||||
ContractDeployer)
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
||||
from nucypher.blockchain.eth.interfaces import BlockchainInterface
|
||||
from nucypher.blockchain.eth.registry import AllocationRegistry
|
||||
from nucypher.blockchain.eth.token import NU, Stake, StakeTracker
|
||||
from nucypher.blockchain.eth.utils import datetime_to_period, calculate_period_duration
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.crypto.powers import TransactingPower
|
||||
|
||||
|
||||
def only_me(func):
|
||||
|
@ -146,6 +141,8 @@ class Deployer(NucypherTokenActor):
|
|||
def __init__(self,
|
||||
blockchain: BlockchainInterface,
|
||||
deployer_address: str = None,
|
||||
device = NO_STAKING_DEVICE,
|
||||
client_password: str = None,
|
||||
bare: bool = True
|
||||
) -> None:
|
||||
|
||||
|
@ -162,6 +159,12 @@ class Deployer(NucypherTokenActor):
|
|||
|
||||
self.user_escrow_deployers = dict()
|
||||
self.deployers = {d.contract_name: d for d in self.deployer_classes}
|
||||
|
||||
blockchain.transacting_power = TransactingPower(blockchain=blockchain,
|
||||
account=deployer_address,
|
||||
password=client_password,
|
||||
device=device)
|
||||
blockchain.transacting_power.activate()
|
||||
self.log = Logger("Deployment-Actor")
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -19,6 +19,7 @@ import time
|
|||
|
||||
import click
|
||||
import maya
|
||||
from constant_sorrow.constants import NO_STAKING_DEVICE
|
||||
|
||||
from nucypher.blockchain.eth.actors import Deployer
|
||||
from nucypher.blockchain.eth.agents import NucypherTokenAgent
|
||||
|
@ -27,10 +28,10 @@ from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
|
|||
from nucypher.blockchain.eth.registry import EthereumContractRegistry
|
||||
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
|
||||
from nucypher.characters.banners import NU_BANNER
|
||||
from nucypher.cli.actions import get_password
|
||||
from nucypher.cli.config import nucypher_deployer_config
|
||||
from nucypher.cli.types import EIP55_CHECKSUM_ADDRESS, EXISTING_READABLE_FILE
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
from nucypher.crypto.powers import TransactingPower
|
||||
|
||||
|
||||
@click.command()
|
||||
|
@ -125,12 +126,10 @@ def deploy(click_config,
|
|||
if not force:
|
||||
click.confirm("Selected {} - Continue?".format(deployer_address), abort=True)
|
||||
|
||||
# TODO: Integrate with Deployer Actor (Character)
|
||||
blockchain.transacting_power = TransactingPower(blockchain=blockchain,
|
||||
account=deployer_address,
|
||||
password=click.prompt("Enter ETH node password", hide_input=True))
|
||||
blockchain.transacting_power.activate()
|
||||
deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address)
|
||||
deployer = Deployer(blockchain=blockchain,
|
||||
device=NO_STAKING_DEVICE,
|
||||
client_password=get_password(confirm=False),
|
||||
deployer_address=deployer_address)
|
||||
|
||||
# Verify ETH Balance
|
||||
click.secho(f"\n\nDeployer ETH balance: {deployer.eth_balance}")
|
||||
|
|
|
@ -148,7 +148,6 @@ class TransactingPower(CryptoPowerUp):
|
|||
def unlock_account(self, password: str = None):
|
||||
if self.device is not NO_STAKING_DEVICE:
|
||||
# TODO: Embed in TrustedDevice
|
||||
_hd_path = self.device.get_address_path(checksum_address=self.account)
|
||||
ping = 'PING|PONG'
|
||||
pong = self.device.client.ping(ping) # TODO: Use pin protection?
|
||||
if not ping == pong:
|
||||
|
|
Loading…
Reference in New Issue