Skip to content
Snippets Groups Projects

Implementation of the delegation part of HP management

Merged Jakub Ziebinski requested to merge jziebinski/prepare-delegations into develop
All threads resolved!
Compare and Show latest version
8 files
+ 71
82
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -30,11 +30,9 @@ from schemas.operations import DelegateVestingSharesOperation
if TYPE_CHECKING:
from rich.text import TextType
from textual.app import ComposeResult
from textual.widget import Widget
from clive.__private.core.commands.data_retrieval.hive_power_data import HivePowerData
from clive.models.aliased import DynamicGlobalProperties
from schemas.apis.database_api.fundaments_of_reponses import VestingDelegationsFundament as VestingDelegation
from clive.models.aliased import DynamicGlobalProperties, VestingDelegation
class PlaceTaker(Static):
@@ -61,18 +59,18 @@ class Delegation(CliveCheckerboardTableRow):
delegation: delegation data to display.
dgpo: dynamic global properties.
"""
self._amount_in_hp = vests_to_hive(delegation.vesting_shares, dgpo)
super().__init__(
CliveCheckerBoardTableCell(delegation.delegatee),
CliveCheckerBoardTableCell(f"{Asset.pretty_amount(vests_to_hive(delegation.vesting_shares, dgpo))}"),
CliveCheckerBoardTableCell(f"{Asset.pretty_amount(self._amount_in_hp)}"),
CliveCheckerBoardTableCell(f"{Asset.pretty_amount(delegation.vesting_shares)}"),
CliveCheckerBoardTableCell(CliveButton("Remove", classes="remove-delegation-button", variant="error")),
CliveCheckerBoardTableCell(CliveButton("Remove", id_="remove-delegation-button", variant="error")),
)
self._delegation = delegation
self._dgpo = dgpo
@on(CliveButton.Pressed, ".remove-delegation-button")
def push_operation_summary_screen(self) -> None:
self.app.push_screen(RemoveDelegation(self._delegation, self._dgpo))
self.app.push_screen(RemoveDelegation(self._delegation, self._amount_in_hp))
class DelegationsTable(CliveCheckerboardTable):
@@ -82,22 +80,19 @@ class DelegationsTable(CliveCheckerboardTable):
super().__init__(
Static("Current delegations", id="delegations-table-title"), DelegationsTableHeader(), dynamic=True
)
self._delegations: list[VestingDelegation[Asset.Vests]] | None = None
self._previous_delegations: list[VestingDelegation[Asset.Vests]] | None = None
def create_dynamic_rows(self, content: HivePowerData) -> list[CliveCheckerboardTableRow]:
self._delegations = content.delegations
def create_dynamic_rows(self, content: HivePowerData) -> list[Delegation]:
self._previous_delegations = content.delegations
delegations: list[CliveCheckerboardTableRow] = [
Delegation(delegation, content.gdpo) for delegation in content.delegations
]
return delegations
return [Delegation(delegation, content.gdpo) for delegation in content.delegations]
def get_no_content_available_widget(self) -> Widget:
def get_no_content_available_widget(self) -> Static:
return Static("You have no delegations", id="no-delegations-info")
@property
def check_if_should_be_updated(self) -> bool:
return self._delegations != self.provider.content.delegations
return self._previous_delegations != self.provider.content.delegations
@property
def is_anything_to_display(self) -> bool:
Loading