Skip to content

Commit

Permalink
show immature amount for only dcr and add locked
Browse files Browse the repository at this point in the history
amount to only dcr account detail page

Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Jan 17, 2024
1 parent 8d44387 commit 51e423d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
14 changes: 9 additions & 5 deletions ui/page/accounts/accounts_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,18 @@ func (pg *Page) accountItemLayout(gtx C, account *sharedW.Account) D {
if bal.LockedByTickets != nil {
locked = pg.wallet.ToAmount(locked.ToInt() + bal.LockedByTickets.ToInt())
}
immature := bal.ImmatureReward
if bal.ImmatureStakeGeneration != nil {
immature = pg.wallet.ToAmount(immature.ToInt() + bal.ImmatureStakeGeneration.ToInt())
}
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.accountBalanceLayout(values.String(values.StrLabelSpendable), bal.Spendable, layout.Horizontal)),
layout.Rigid(pg.accountBalanceLayout(values.String(values.StrLocked), locked, layout.Horizontal)),
layout.Rigid(pg.accountBalanceLayout(values.String(values.StrImmature), immature, layout.Horizontal)),
layout.Rigid(func(gtx C) D {
if pg.wallet.GetAssetType() != libutils.DCRWalletAsset {
return D{}
}

// Display immature for only DCR.
immature := pg.wallet.ToAmount(bal.ImmatureReward.ToInt() + bal.ImmatureStakeGeneration.ToInt())
return pg.accountBalanceLayout(values.String(values.StrImmature), immature, layout.Horizontal)(gtx)
}),
)
}),
)
Expand Down
43 changes: 19 additions & 24 deletions ui/page/accounts/dcr_account_details_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ type AcctDetailsPage struct {
showExtendedKeyButton *cryptomaterial.Clickable
infoButton cryptomaterial.IconButton

stakingBalance int64
nonSpendableBal int64
lockedBalance string
totalBalance string
spendable string
immatureRewards string
lockedByTickets string
spendableBalance string
immatureBalance string
votingAuthority string
immatureStakeGen string
hdPath string
keys string
extendedKey string
Expand Down Expand Up @@ -84,19 +83,18 @@ func NewDCRAcctDetailsPage(l *load.Load, wallet sharedW.Asset, account *sharedW.
// Part of the load.Page interface.
func (pg *AcctDetailsPage) OnNavigatedTo() {

balance := pg.account.Balance
bal := pg.account.Balance
pg.nonSpendableBal = bal.ImmatureReward.ToInt() +
bal.LockedByTickets.ToInt() +
bal.VotingAuthority.ToInt() +
bal.ImmatureStakeGeneration.ToInt() +
bal.Locked.ToInt()

pg.stakingBalance = balance.ImmatureReward.ToInt() +
balance.LockedByTickets.ToInt() +
balance.VotingAuthority.ToInt() +
balance.ImmatureStakeGeneration.ToInt()

pg.totalBalance = balance.Total.String()
pg.spendable = balance.Spendable.String()
pg.immatureRewards = balance.ImmatureReward.String()
pg.lockedByTickets = balance.LockedByTickets.String()
pg.votingAuthority = balance.VotingAuthority.String()
pg.immatureStakeGen = balance.ImmatureStakeGeneration.String()
pg.lockedBalance = pg.wallet.ToAmount(bal.Locked.ToInt() + bal.LockedByTickets.ToInt()).String()
pg.totalBalance = bal.Total.String()
pg.spendableBalance = bal.Spendable.String()
pg.immatureBalance = pg.wallet.ToAmount(bal.ImmatureReward.ToInt() + bal.ImmatureStakeGeneration.ToInt()).String()
pg.votingAuthority = bal.VotingAuthority.String()

pg.hdPath = pg.AssetsManager.DCRHDPrefix() + strconv.Itoa(int(pg.account.Number)) + "'"

Expand Down Expand Up @@ -234,26 +232,23 @@ func (pg *AcctDetailsPage) accountBalanceLayout(gtx C) D {
)
}),
layout.Rigid(func(gtx C) D {
return pg.acctBalLayout(gtx, values.String(values.StrLabelSpendable), pg.spendable, false)
return pg.acctBalLayout(gtx, values.String(values.StrLabelSpendable), pg.spendableBalance, false)
}),
layout.Rigid(func(gtx C) D {
if pg.stakingBalance == 0 {
if pg.nonSpendableBal == 0 {
return D{}
}

return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.acctBalLayout(gtx, values.String(values.StrImmatureRewards), pg.immatureRewards, false)
return pg.acctBalLayout(gtx, values.String(values.StrLocked), pg.lockedBalance, false)
}),
layout.Rigid(func(gtx C) D {
return pg.acctBalLayout(gtx, values.String(values.StrLockedByTickets), pg.lockedByTickets, false)
return pg.acctBalLayout(gtx, values.String(values.StrImmature), pg.immatureBalance, false)
}),
layout.Rigid(func(gtx C) D {
return pg.acctBalLayout(gtx, values.String(values.StrVotingAuthority), pg.votingAuthority, false)
}),
layout.Rigid(func(gtx C) D {
return pg.acctBalLayout(gtx, values.String(values.StrImmatureStakeGen), pg.immatureStakeGen, false)
}),
)
}),
)
Expand Down

0 comments on commit 51e423d

Please sign in to comment.