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
!319
Implementation of the delegation part of HP management
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implementation of the delegation part of HP management
jziebinski/prepare-delegations
into
develop
Overview
20
Commits
2
Pipelines
44
Changes
3
Merged
Jakub Ziebinski
requested to merge
jziebinski/prepare-delegations
into
develop
1 year ago
Overview
20
Commits
2
Pipelines
44
Changes
6
Expand
Requires:
!312 (merged)
0
0
Merge request reports
Compare
version 8
version 103
9a189059
1 year ago
version 102
9a189059
1 year ago
version 101
50ad1051
1 year ago
version 100
50ad1051
1 year ago
version 99
9b3d511a
1 year ago
version 98
d0710d36
1 year ago
version 97
d0710d36
1 year ago
version 96
31bd36ab
1 year ago
version 95
3947415f
1 year ago
version 94
70ec1c36
1 year ago
version 93
70ec1c36
1 year ago
version 92
70ec1c36
1 year ago
version 91
70ec1c36
1 year ago
version 90
70ec1c36
1 year ago
version 89
70ec1c36
1 year ago
version 88
70ec1c36
1 year ago
version 87
70ec1c36
1 year ago
version 86
70ec1c36
1 year ago
version 85
70ec1c36
1 year ago
version 84
70ec1c36
1 year ago
version 83
70ec1c36
1 year ago
version 82
70ec1c36
1 year ago
version 81
70ec1c36
1 year ago
version 80
70ec1c36
1 year ago
version 79
e03b5379
1 year ago
version 78
e03b5379
1 year ago
version 77
7edf4129
1 year ago
version 76
7edf4129
1 year ago
version 75
e0a03f8b
1 year ago
version 74
e0a03f8b
1 year ago
version 73
16c313f9
1 year ago
version 72
a6dcdbc4
1 year ago
version 71
a6dcdbc4
1 year ago
version 70
a6dcdbc4
1 year ago
version 69
36da4817
1 year ago
version 68
36da4817
1 year ago
version 67
36da4817
1 year ago
version 66
cb24f62d
1 year ago
version 65
cb24f62d
1 year ago
version 64
cb24f62d
1 year ago
version 63
4f9e2c51
1 year ago
version 62
257079b8
1 year ago
version 61
51aa7d08
1 year ago
version 60
6211840a
1 year ago
version 59
2ff2c7e4
1 year ago
version 58
c4e56608
1 year ago
version 57
c6a2b75d
1 year ago
version 56
ae93503b
1 year ago
version 55
7cdca8db
1 year ago
version 54
7cdca8db
1 year ago
version 53
bc03ee72
1 year ago
version 52
3427f1c2
1 year ago
version 51
a27f0301
1 year ago
version 50
a27f0301
1 year ago
version 49
4205e7c0
1 year ago
version 48
4205e7c0
1 year ago
version 47
4205e7c0
1 year ago
version 46
4205e7c0
1 year ago
version 45
4205e7c0
1 year ago
version 44
4205e7c0
1 year ago
version 43
4205e7c0
1 year ago
version 42
4205e7c0
1 year ago
version 41
4205e7c0
1 year ago
version 40
4205e7c0
1 year ago
version 39
4205e7c0
1 year ago
version 38
4205e7c0
1 year ago
version 37
4205e7c0
1 year ago
version 36
4205e7c0
1 year ago
version 35
4205e7c0
1 year ago
version 34
28c36438
1 year ago
version 33
848d709d
1 year ago
version 32
522fe1e5
1 year ago
version 31
522fe1e5
1 year ago
version 30
522fe1e5
1 year ago
version 29
1e57f6d5
1 year ago
version 28
1e57f6d5
1 year ago
version 27
1e57f6d5
1 year ago
version 26
b46dbc3e
1 year ago
version 25
0ec3b3b0
1 year ago
version 24
40208523
1 year ago
version 23
40208523
1 year ago
version 22
12a0f679
1 year ago
version 21
12a0f679
1 year ago
version 20
12a0f679
1 year ago
version 19
12a0f679
1 year ago
version 18
12a0f679
1 year ago
version 17
12a0f679
1 year ago
version 16
12a0f679
1 year ago
version 15
12a0f679
1 year ago
version 14
12a0f679
1 year ago
version 13
0003d9c3
1 year ago
version 12
0003d9c3
1 year ago
version 11
66b53595
1 year ago
version 10
66b53595
1 year ago
version 9
b8f1ef43
1 year ago
version 8
0a6e5068
1 year ago
version 7
541b9b7d
1 year ago
version 6
541b9b7d
1 year ago
version 5
814576ce
1 year ago
version 4
24b1a701
1 year ago
version 3
24b1a701
1 year ago
version 2
8e06a16b
1 year ago
version 1
8e06a16b
1 year ago
develop (base)
and
version 12
latest version
9a189059
2 commits,
1 year ago
version 103
9a189059
2 commits,
1 year ago
version 102
9a189059
2 commits,
1 year ago
version 101
50ad1051
7 commits,
1 year ago
version 100
50ad1051
2 commits,
1 year ago
version 99
9b3d511a
2 commits,
1 year ago
version 98
d0710d36
3 commits,
1 year ago
version 97
d0710d36
2 commits,
1 year ago
version 96
31bd36ab
2 commits,
1 year ago
version 95
3947415f
2 commits,
1 year ago
version 94
70ec1c36
20 commits,
1 year ago
version 93
70ec1c36
20 commits,
1 year ago
version 92
70ec1c36
20 commits,
1 year ago
version 91
70ec1c36
20 commits,
1 year ago
version 90
70ec1c36
20 commits,
1 year ago
version 89
70ec1c36
20 commits,
1 year ago
version 88
70ec1c36
20 commits,
1 year ago
version 87
70ec1c36
20 commits,
1 year ago
version 86
70ec1c36
20 commits,
1 year ago
version 85
70ec1c36
20 commits,
1 year ago
version 84
70ec1c36
20 commits,
1 year ago
version 83
70ec1c36
20 commits,
1 year ago
version 82
70ec1c36
20 commits,
1 year ago
version 81
70ec1c36
20 commits,
1 year ago
version 80
70ec1c36
2 commits,
1 year ago
version 79
e03b5379
7 commits,
1 year ago
version 78
e03b5379
4 commits,
1 year ago
version 77
7edf4129
8 commits,
1 year ago
version 76
7edf4129
4 commits,
1 year ago
version 75
e0a03f8b
13 commits,
1 year ago
version 74
e0a03f8b
4 commits,
1 year ago
version 73
16c313f9
4 commits,
1 year ago
version 72
a6dcdbc4
6 commits,
1 year ago
version 71
a6dcdbc4
6 commits,
1 year ago
version 70
a6dcdbc4
3 commits,
1 year ago
version 69
36da4817
15 commits,
1 year ago
version 68
36da4817
15 commits,
1 year ago
version 67
36da4817
3 commits,
1 year ago
version 66
cb24f62d
14 commits,
1 year ago
version 65
cb24f62d
14 commits,
1 year ago
version 64
cb24f62d
3 commits,
1 year ago
version 63
4f9e2c51
3 commits,
1 year ago
version 62
257079b8
3 commits,
1 year ago
version 61
51aa7d08
3 commits,
1 year ago
version 60
6211840a
3 commits,
1 year ago
version 59
2ff2c7e4
3 commits,
1 year ago
version 58
c4e56608
2 commits,
1 year ago
version 57
c6a2b75d
2 commits,
1 year ago
version 56
ae93503b
2 commits,
1 year ago
version 55
7cdca8db
3 commits,
1 year ago
version 54
7cdca8db
2 commits,
1 year ago
version 53
bc03ee72
2 commits,
1 year ago
version 52
3427f1c2
2 commits,
1 year ago
version 51
a27f0301
16 commits,
1 year ago
version 50
a27f0301
2 commits,
1 year ago
version 49
4205e7c0
16 commits,
1 year ago
version 48
4205e7c0
16 commits,
1 year ago
version 47
4205e7c0
16 commits,
1 year ago
version 46
4205e7c0
16 commits,
1 year ago
version 45
4205e7c0
16 commits,
1 year ago
version 44
4205e7c0
16 commits,
1 year ago
version 43
4205e7c0
16 commits,
1 year ago
version 42
4205e7c0
5 commits,
1 year ago
version 41
4205e7c0
4 commits,
1 year ago
version 40
4205e7c0
4 commits,
1 year ago
version 39
4205e7c0
4 commits,
1 year ago
version 38
4205e7c0
4 commits,
1 year ago
version 37
4205e7c0
4 commits,
1 year ago
version 36
4205e7c0
4 commits,
1 year ago
version 35
4205e7c0
2 commits,
1 year ago
version 34
28c36438
2 commits,
1 year ago
version 33
848d709d
2 commits,
1 year ago
version 32
522fe1e5
4 commits,
1 year ago
version 31
522fe1e5
3 commits,
1 year ago
version 30
522fe1e5
2 commits,
1 year ago
version 29
1e57f6d5
15 commits,
1 year ago
version 28
1e57f6d5
15 commits,
1 year ago
version 27
1e57f6d5
2 commits,
1 year ago
version 26
b46dbc3e
2 commits,
1 year ago
version 25
0ec3b3b0
2 commits,
1 year ago
version 24
40208523
12 commits,
1 year ago
version 23
40208523
2 commits,
1 year ago
version 22
12a0f679
12 commits,
1 year ago
version 21
12a0f679
12 commits,
1 year ago
version 20
12a0f679
12 commits,
1 year ago
version 19
12a0f679
12 commits,
1 year ago
version 18
12a0f679
12 commits,
1 year ago
version 17
12a0f679
12 commits,
1 year ago
version 16
12a0f679
12 commits,
1 year ago
version 15
12a0f679
12 commits,
1 year ago
version 14
12a0f679
2 commits,
1 year ago
version 13
0003d9c3
9 commits,
1 year ago
version 12
0003d9c3
2 commits,
1 year ago
version 11
66b53595
6 commits,
1 year ago
version 10
66b53595
2 commits,
1 year ago
version 9
b8f1ef43
2 commits,
1 year ago
version 8
0a6e5068
2 commits,
1 year ago
version 7
541b9b7d
12 commits,
1 year ago
version 6
541b9b7d
2 commits,
1 year ago
version 5
814576ce
2 commits,
1 year ago
version 4
24b1a701
12 commits,
1 year ago
version 3
24b1a701
2 commits,
1 year ago
version 2
8e06a16b
12 commits,
1 year ago
version 1
8e06a16b
2 commits,
1 year ago
Show latest version
6 files
+
15
−
14
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
clive/__private/ui/operations/hive_power_management/delegate_hive_power/delegate_hive_power.py
+
141
−
3
Options
@@ -2,17 +2,113 @@ from __future__ import annotations
from
typing
import
TYPE_CHECKING
from
textual.widgets
import
TabPane
from
textual
import
on
from
textual.containers
import
Horizontal
,
Vertical
from
textual.widgets
import
Static
,
TabPane
from
clive.__private.ui.widgets.clive_widget
import
CliveWidget
from
clive.__private.core.hive_vests_conversions
import
hive_to_vests
,
vests_to_hive
from
clive.__private.ui.data_providers.hive_power_data_provider
import
HivePowerDataProvider
from
clive.__private.ui.get_css
import
get_css_from_relative_path
from
clive.__private.ui.operations.bindings
import
OperationActionBindings
from
clive.__private.ui.operations.hive_power_management.common_hive_power.hp_vests_factor
import
HpVestsFactor
from
clive.__private.ui.operations.operation_summary.remove_delegation
import
RemoveDelegation
from
clive.__private.ui.widgets.clive_button
import
CliveButton
from
clive.__private.ui.widgets.clive_checkerboard_table
import
(
EVEN_CLASS_NAME
,
ODD_CLASS_NAME
,
CliveCheckerboardTable
,
CliveCheckerBoardTableCell
,
CliveCheckerboardTableRow
,
)
from
clive.__private.ui.widgets.currency_selector.currency_selector_hp_vests
import
CurrencySelectorHpVests
from
clive.__private.ui.widgets.inputs.account_name_input
import
AccountNameInput
from
clive.__private.ui.widgets.inputs.clive_validated_input
import
CliveValidatedInput
from
clive.__private.ui.widgets.inputs.hp_vests_amount_input
import
HPVestsAmountInput
from
clive.__private.ui.widgets.section_title
import
SectionTitle
from
clive.models
import
Asset
from
schemas.operations
import
DelegateVestingSharesOperation
if
TYPE_CHECKING
:
from
rich.text
import
TextType
from
textual.app
import
ComposeResult
from
clive.__private.core.commands.data_retrieval.hive_power_data
import
HivePowerData
from
clive.models.aliased
import
DynamicGlobalProperties
,
VestingDelegation
class
DelegateHivePower
(
TabPane
,
CliveWidget
):
class
PlaceTaker
(
Static
):
pass
class
DelegationsTableHeader
(
Horizontal
):
def
compose
(
self
)
->
ComposeResult
:
yield
Static
(
"
Delegate
"
,
classes
=
ODD_CLASS_NAME
)
yield
Static
(
"
Shares [HP]
"
,
classes
=
EVEN_CLASS_NAME
)
yield
Static
(
"
Shares [VESTS]
"
,
classes
=
ODD_CLASS_NAME
)
yield
PlaceTaker
()
class
Delegation
(
CliveCheckerboardTableRow
):
"""
Row of the `DelegationsTable`.
"""
def
__init__
(
self
,
delegation
:
VestingDelegation
[
Asset
.
Vests
],
dgpo
:
DynamicGlobalProperties
)
->
None
:
"""
Initialize the delegation row.
Args:
----
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
(
self
.
_amount_in_hp
)
}
"
),
CliveCheckerBoardTableCell
(
f
"
{
Asset
.
pretty_amount
(
delegation
.
vesting_shares
)
}
"
),
CliveCheckerBoardTableCell
(
CliveButton
(
"
Remove
"
,
id_
=
"
remove-delegation-button
"
,
variant
=
"
error
"
)),
)
self
.
_delegation
=
delegation
@on
(
CliveButton
.
Pressed
,
"
#remove-delegation-button
"
)
def
push_operation_summary_screen
(
self
)
->
None
:
self
.
app
.
push_screen
(
RemoveDelegation
(
self
.
_delegation
,
self
.
_amount_in_hp
))
class
DelegationsTable
(
CliveCheckerboardTable
):
"""
Table with delegations.
"""
def
__init__
(
self
)
->
None
:
super
().
__init__
(
Static
(
"
Current delegations
"
,
id
=
"
delegations-table-title
"
),
DelegationsTableHeader
(),
dynamic
=
True
)
self
.
_previous_delegations
:
list
[
VestingDelegation
[
Asset
.
Vests
]]
|
None
=
None
def
create_dynamic_rows
(
self
,
content
:
HivePowerData
)
->
list
[
Delegation
]:
self
.
_previous_delegations
=
content
.
delegations
return
[
Delegation
(
delegation
,
content
.
gdpo
)
for
delegation
in
content
.
delegations
]
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
.
_previous_delegations
!=
self
.
provider
.
content
.
delegations
@property
def
is_anything_to_display
(
self
)
->
bool
:
return
len
(
self
.
provider
.
content
.
delegations
)
!=
0
@property
def
provider
(
self
)
->
HivePowerDataProvider
:
return
self
.
screen
.
query_one
(
HivePowerDataProvider
)
class
DelegateHivePower
(
TabPane
,
OperationActionBindings
):
"""
TabPane with all content about delegate hp.
"""
DEFAULT_CSS
=
get_css_from_relative_path
(
__file__
)
def
__init__
(
self
,
title
:
TextType
):
"""
Initialize a TabPane.
@@ -22,3 +118,45 @@ class DelegateHivePower(TabPane, CliveWidget):
title: Title of the TabPane (will be displayed in a tab label).
"""
super
().
__init__
(
title
=
title
)
self
.
_delegate_input
=
AccountNameInput
(
"
Delegate
"
)
self
.
_shares_input
=
HPVestsAmountInput
()
def
compose
(
self
)
->
ComposeResult
:
yield
HpVestsFactor
(
self
.
provider
)
yield
SectionTitle
(
"
Delegate your shares
"
)
with
Vertical
(
id
=
"
inputs-container
"
):
yield
self
.
_delegate_input
yield
self
.
_shares_input
yield
DelegationsTable
()
def
_create_operation
(
self
)
->
DelegateVestingSharesOperation
|
None
:
if
not
CliveValidatedInput
.
validate_many
(
self
.
_delegate_input
,
self
.
_shares_input
):
return
None
asset
=
self
.
_shares_input
.
value_or_error
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
)
@on
(
CurrencySelectorHpVests
.
Changed
)
def
shares_type_changed
(
self
)
->
None
:
"""
Clear input when shares type was changed and hide factor display when vests selected.
"""
self
.
_shares_input
.
input
.
clear
()
hp_vests_factor
=
self
.
query_one
(
HpVestsFactor
)
if
self
.
_shares_input
.
selected_asset_type
is
Asset
.
Vests
:
hp_vests_factor
.
display
=
False
return
hp_vests_factor
.
display
=
True
@property
def
provider
(
self
)
->
HivePowerDataProvider
:
return
self
.
screen
.
query_one
(
HivePowerDataProvider
)
@property
def
working_account
(
self
)
->
str
:
return
self
.
app
.
world
.
profile_data
.
working_account
.
name
Loading