Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
clive
Merge requests
!297
Implement `Power up` part of hive power management
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement `Power up` part of hive power management
jziebinski/prepare-hp-management
into
develop
Overview
96
Commits
16
Pipelines
95
Changes
2
Merged
Jakub Ziebinski
requested to merge
jziebinski/prepare-hp-management
into
develop
1 year ago
Overview
96
Commits
16
Pipelines
95
Changes
2
Expand
Requires:
!298 (merged)
(to change the inputs to the new)
Edited
1 year ago
by
Jakub Ziebinski
0
0
Merge request reports
Viewing commit
06b7da9f
Show latest version
2 files
+
91
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
06b7da9f
Implement PowerUp TabPane
· 06b7da9f
Jakub Ziebinski
authored
1 year ago
clive/__private/ui/operations/hive_power_management/power_up/power_up.py
+
68
−
1
Options
@@ -2,21 +2,48 @@ from __future__ import annotations
from
typing
import
TYPE_CHECKING
from
textual.widgets
import
TabPane
from
textual
import
on
from
textual.binding
import
Binding
from
textual.containers
import
Grid
from
textual.widgets
import
Static
,
TabPane
from
clive.__private.ui.get_css
import
get_css_from_relative_path
from
clive.__private.ui.operations.hive_power_management.common_hive_power.hp_information_table
import
(
HpInformationTable
,
)
from
clive.__private.ui.operations.raw.transfer_to_vesting.transfer_to_vesting
import
TransferToVesting
from
clive.__private.ui.widgets.clive_button
import
CliveButton
from
clive.__private.ui.widgets.clive_widget
import
CliveWidget
from
clive.__private.ui.widgets.currency_selector.currency_selector_base
import
CurrencySelectorBase
from
clive.__private.ui.widgets.inputs.account_name_input
import
AccountNameInput
from
clive.__private.ui.widgets.inputs.numeric_input
import
NumericInput
from
clive.models
import
Asset
from
clive.models.asset
import
AssetFactoryHolder
if
TYPE_CHECKING
:
from
rich.text
import
TextType
from
textual.app
import
ComposeResult
class
CurrencySelectorHive
(
CurrencySelectorBase
[
Asset
.
Hive
]):
@staticmethod
def
_create_selectable
()
->
dict
[
str
,
AssetFactoryHolder
[
Asset
.
Hive
]]:
return
{
"
HIVE
"
:
AssetFactoryHolder
(
asset_cls
=
Asset
.
Hive
,
asset_factory
=
Asset
.
hive
),
}
class
PlaceTaker
(
Static
):
"""
Static widget to ensure correct display of the grid.
"""
class
PowerUp
(
TabPane
,
CliveWidget
):
"""
TabPane with all content about power up.
"""
BINDINGS
=
[
Binding
(
"
f2
"
,
"
power_up
"
,
"
Power up
"
)]
DEFAULT_CSS
=
get_css_from_relative_path
(
__file__
)
def
__init__
(
self
,
title
:
TextType
):
"""
Initialize a TabPane.
@@ -26,6 +53,46 @@ class PowerUp(TabPane, CliveWidget):
title: Title of the TabPane (will be displayed in a tab label).
"""
super
().
__init__
(
title
=
title
)
working_account_name
=
self
.
app
.
world
.
profile_data
.
working_account
.
name
self
.
_account_name_input
=
AccountNameInput
(
label
=
"
receiver
"
,
value
=
working_account_name
)
self
.
_asset_input
=
NumericInput
()
self
.
_currency_selector
=
CurrencySelectorHive
()
self
.
_currency_selector
.
disabled
=
True
def
compose
(
self
)
->
ComposeResult
:
yield
HpInformationTable
()
with
Grid
(
id
=
"
power-up-inputs
"
):
yield
self
.
_account_name_input
yield
PlaceTaker
()
yield
PlaceTaker
()
yield
self
.
_asset_input
yield
self
.
_currency_selector
yield
CliveButton
(
"
All !
"
,
id_
=
"
clive-button-all
"
)
yield
Static
(
"
Notice ! Your governance voting power will be increased after 30 days
"
,
id
=
"
power-up-information
"
)
@on
(
CliveButton
.
Pressed
)
def
fill_input_by_all
(
self
)
->
None
:
hive_balance
=
self
.
app
.
world
.
profile_data
.
working_account
.
data
.
hive_balance
if
float
(
hive_balance
.
amount
)
==
0
:
self
.
notify
(
"
Zero is not enough value to make power up
"
,
severity
=
"
warning
"
)
self
.
_asset_input
.
input
.
value
=
str
(
int
(
hive_balance
.
amount
)
/
10
**
hive_balance
.
precision
)
def
action_power_up
(
self
)
->
None
:
asset
=
self
.
_asset_input
.
value
if
not
asset
:
return
self
.
_currency_selector
.
create_asset
(
asset
)
# just validate here, the conversion is performed in the `TransferToVesting` screen
account_name
=
self
.
_account_name_input
.
value
if
not
account_name
:
return
self
.
_asset_input
.
input
.
value
=
""
self
.
app
.
push_screen
(
TransferToVesting
(
account_name
=
account_name
,
hive_amount
=
asset
))
Loading