def test_mint(click_runner, manual_staker, testerchain, agency_local_registry, stakeholder_configuration_file_location): testerchain.time_travel(periods=2) staker = Staker(is_me=True, checksum_address=manual_staker, registry=agency_local_registry) assert staker.mintable_periods() > 0 owned_tokens = staker.owned_tokens() mint_args = ('stake', 'mint', '--config-file', stakeholder_configuration_file_location, '--staking-address', manual_staker, '--force') result = click_runner.invoke(nucypher_cli, mint_args, input=INSECURE_DEVELOPMENT_PASSWORD, catch_exceptions=False) assert result.exit_code == 0 assert staker.owned_tokens() > owned_tokens assert staker.mintable_periods() == 0 assert SUCCESSFUL_MINTING in result.output
def paint_stakers(emitter, stakers: List[str], registry: BaseContractRegistry) -> None: staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry) current_period = staking_agent.get_current_period() emitter.echo(f"\nCurrent period: {current_period}") emitter.echo("\n| Stakers |\n") emitter.echo(f"{'Checksum address':42} Staker information") emitter.echo('=' * (42 + 2 + 53)) for staker_address in stakers: staker = Staker(is_me=False, checksum_address=staker_address, registry=registry) nickname = Nickname.from_seed(staker_address) emitter.echo( f"{staker_address} {'Nickname:':10} {nickname} {nickname.icon}") tab = " " * len(staker_address) owned_tokens = staker.owned_tokens() last_committed_period = staker.last_committed_period worker = staker.worker_address is_restaking = staker.is_restaking is_winding_down = staker.is_winding_down is_taking_snapshots = staker.is_taking_snapshots missing_commitments = current_period - last_committed_period owned_in_nu = round(owned_tokens, 2) current_locked_tokens = round(staker.locked_tokens(periods=0), 2) next_locked_tokens = round(staker.locked_tokens(periods=1), 2) emitter.echo(f"{tab} {'Owned:':10} {owned_in_nu}") emitter.echo( f"{tab} Staked in current period: {current_locked_tokens}") emitter.echo(f"{tab} Staked in next period: {next_locked_tokens}") if is_restaking: emitter.echo(f"{tab} {'Re-staking:':10} Yes") else: emitter.echo(f"{tab} {'Re-staking:':10} No") emitter.echo( f"{tab} {'Winding down:':10} {'Yes' if is_winding_down else 'No'}" ) emitter.echo( f"{tab} {'Snapshots:':10} {'Yes' if is_taking_snapshots else 'No'}" ) emitter.echo(f"{tab} {'Activity:':10} ", nl=False) if missing_commitments == -1: emitter.echo(f"Next period committed (#{last_committed_period})", color='green') elif missing_commitments == 0: emitter.echo( f"Current period committed (#{last_committed_period}). " f"Pending commitment to next period.", color='yellow') elif missing_commitments == current_period: emitter.echo(f"Never made a commitment", color='red') else: emitter.echo( f"Missing {missing_commitments} commitments " f"(last time for period #{last_committed_period})", color='red') emitter.echo(f"{tab} {'Worker:':10} ", nl=False) if worker == NULL_ADDRESS: emitter.echo(f"Worker not bonded", color='red') else: emitter.echo(f"{worker}") fees = prettify_eth_amount(staker.calculate_policy_fee()) emitter.echo(f"{tab} Unclaimed fees: {fees}") min_rate = prettify_eth_amount(staker.min_fee_rate) emitter.echo(f"{tab} Min fee rate: {min_rate}")