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
7 files
+ 161
173
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -32,8 +32,7 @@ if TYPE_CHECKING:
from textual.app import ComposeResult
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):
@@ -60,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")
@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):
@@ -137,9 +136,6 @@ class DelegateHivePower(TabPane, OperationActionBindings):
if isinstance(asset, Asset.Hive):
# If the user has passed an amount in `HP` - convert it to `VESTS`. The operation is performed using VESTS.
asset = hive_to_vests(asset, self.provider.content.gdpo)
return DelegateVestingSharesOperation(
delegator=self.working_account, delegatee=self._delegate_input.value_or_error, vesting_shares=asset
)
return DelegateVestingSharesOperation(
delegator=self.working_account, delegatee=self._delegate_input.value_or_error, vesting_shares=asset
)
Loading