-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a user's unstaked tokens on the validators page (#590)
* Move <Card> into <ValidatorsTable /> * Rename type/helper * Show unstaked tokens on Validators page
- Loading branch information
1 parent
3ac4b84
commit 8c2150b
Showing
7 changed files
with
136 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { getDisplayDenomFromView } from '@penumbra-zone/types'; | ||
import { | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
CardTitle, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableRow, | ||
} from '@penumbra-zone/ui'; | ||
import { BalancesByAccount } from '../../../fetchers/balances/by-account'; | ||
import { ValueViewComponent } from '@penumbra-zone/ui/components/ui/tx/view/value'; | ||
import { useMemo } from 'react'; | ||
|
||
export const Account = ({ account }: { account: BalancesByAccount }) => { | ||
const unstakedBalance = useMemo( | ||
() => account.balances.find(balance => getDisplayDenomFromView(balance.value) === 'penumbra'), | ||
[account.balances], | ||
); | ||
|
||
if (!unstakedBalance) return null; | ||
|
||
return ( | ||
<Card gradient> | ||
<CardHeader> | ||
<CardTitle>Account #{account.index.account}</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<Table> | ||
<TableBody> | ||
<TableRow> | ||
<TableCell> | ||
<ValueViewComponent view={unstakedBalance.value} /> | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useLoaderData } from 'react-router-dom'; | ||
import { BalancesByAccount } from '../../../fetchers/balances/by-account'; | ||
import { Account } from './account'; | ||
|
||
export const Accounts = () => { | ||
const balancesByAccount = useLoaderData() as BalancesByAccount[]; | ||
|
||
return ( | ||
<> | ||
{balancesByAccount.map(account => ( | ||
<Account account={account} key={account.index.account} /> | ||
))} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters