Skip to content

Commit

Permalink
feat: show balances
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj committed Oct 17, 2024
1 parent 3bfc806 commit f5ea5b8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
34 changes: 34 additions & 0 deletions components/Balances.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useBalances } from '@/components/hooks';
import type { ValueView } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb';
import { ValueViewComponent } from '@penumbra-zone/ui/ValueViewComponent';
import type React from 'react';

export function Balances() {
const { data: balances } = useBalances();

return balances
? balances
.map((bal) => bal.balanceView)
.map((balanceView) => (
<BalanceRow
key={balanceView!.toJsonString()}
balance={balanceView!}
/>
))
: null;
}

function BalanceRow({
balance,
}: {
balance: ValueView;
}) {
return (
<div
className="mt-3 flex gap-3 items-center bg-gray-700 text-white p-3"
key={balance.toJsonString()}
>
<ValueViewComponent valueView={balance} />
</div>
);
}
10 changes: 8 additions & 2 deletions pages/web/balances.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Balances} from '@/components/Balances';

# Viewing Balances

To view your balance, simply navigate to the `Assets` tab in the frontend site you are using. The balance of your wallet will be displayed there, separated by asset type.
Here you may also toggle into a `Transactions` view, which will allow you to see the connected wallet's transaction history, and dive into their transaction details.
To view your balance, simply navigate to the `Assets` tab in the frontend site you are using. The balance of your wallet will be displayed there, separated by asset type.
Here you may also toggle into a `Transactions` view, which will allow you to see the connected wallet's transaction history, and dive into their transaction details.

Connected sites can also query your data, so if you connected your wallet, this guide can also show your balances:

<Balances/>

0 comments on commit f5ea5b8

Please sign in to comment.