-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create operation_summary screen with remove delegation
- Loading branch information
1 parent
c35ce64
commit a4afa7a
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
clive/__private/ui/operations/operation_summary/remove_delegation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, ClassVar, Final | ||
|
||
from clive.__private.ui.operations.operation_summary.operation_summary import OperationSummary | ||
from clive.__private.ui.widgets.inputs.labelized_input import LabelizedInput | ||
from clive.models import Asset | ||
from schemas.operations import DelegateVestingSharesOperation | ||
|
||
if TYPE_CHECKING: | ||
from textual.app import ComposeResult | ||
|
||
from clive.models.aliased import VestingDelegation | ||
|
||
|
||
DELEGATION_REMOVE_VESTS_VALUE: Final[Asset.Vests] = Asset.vests(0) | ||
|
||
|
||
class RemoveDelegation(OperationSummary): | ||
"""Screen to remove delegation.""" | ||
|
||
BIG_TITLE: ClassVar[str] = "Remove delegation" | ||
|
||
def __init__(self, delegation: VestingDelegation[Asset.Vests], amount_in_hp: Asset.Hive) -> None: | ||
super().__init__() | ||
self._delegation = delegation | ||
self._amount_in_hp = amount_in_hp | ||
|
||
def content(self) -> ComposeResult: | ||
yield LabelizedInput("Delegator", self.working_account) | ||
yield LabelizedInput("Delegate", self._delegation.delegatee) | ||
yield LabelizedInput( | ||
"Shares [HP]", | ||
f"{Asset.pretty_amount(self._amount_in_hp)}", | ||
) | ||
yield LabelizedInput( | ||
"Shares [VESTS]", | ||
f"{Asset.pretty_amount(self._delegation.vesting_shares)}", | ||
) | ||
|
||
def _create_operation(self) -> DelegateVestingSharesOperation: | ||
return DelegateVestingSharesOperation( | ||
delegator=self.working_account, | ||
delegatee=self._delegation.delegatee, | ||
vesting_shares=DELEGATION_REMOVE_VESTS_VALUE, | ||
) | ||
|
||
@property | ||
def working_account(self) -> str: | ||
return self.app.world.profile_data.working_account.name |