Skip to content

Commit c9b7715

Browse files
Fixed BRC Tokens Value Func.
1 parent 23add45 commit c9b7715

File tree

1 file changed

+80
-58
lines changed

1 file changed

+80
-58
lines changed

src/views/address/overview.tsx

Lines changed: 80 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export default function AccountOverview({ tokens }: OverviewProps) {
4646
if (isNaN(bValue)) return -1;
4747
return bValue - aValue;
4848
});
49-
console.log(sortedTokens);
5049

50+
const BTCPrice = exchangeRatesQuery.data?.PBTC;
5151

5252
const ordinalsMarketcap = ordinalsMarketcapQuery.data;
5353

@@ -63,72 +63,94 @@ export default function AccountOverview({ tokens }: OverviewProps) {
6363
</tr>
6464
</thead>
6565
<tbody>
66-
{sortedTokens
67-
.filter((token) => token.contract !== 'ord.libre' && token.amount !== 0)
68-
.map((token) => (
69-
// ... Rest of your code for rendering each token
70-
71-
72-
73-
<tr key={token.symbol}>
74-
<td>
75-
<div className="flex items-center space-x-4">
76-
<div className="">
77-
{["PBTC", "PUSDT", "BTCUSD", "LIBRE", "BTCLIB"].includes(
78-
token.symbol.toUpperCase()
79-
) ? (
80-
<img
81-
src={`/images/symbols/${token.symbol.toUpperCase()}.svg`}
82-
alt={token.symbol.toUpperCase()}
83-
className="h-8 w-8 shrink-0"
84-
/>
85-
) : (
86-
<div className="flex h-11 w-11 flex-col items-center justify-center rounded-full bg-blue-500">
87-
<a className="text-xs uppercase">
88-
{token.symbol.toUpperCase()}
89-
</a>
90-
</div>
91-
)}
66+
{sortedTokens
67+
.filter(
68+
(token) => token.contract !== "ord.libre" && token.amount !== 0
69+
)
70+
.map((token) => (
71+
// ... Rest of your code for rendering each token
72+
73+
<tr key={token.symbol}>
74+
<td>
75+
<div className="flex items-center space-x-4">
76+
<div className="">
77+
{[
78+
"PBTC",
79+
"PUSDT",
80+
"BTCUSD",
81+
"LIBRE",
82+
"BTCLIB",
83+
].includes(token.symbol.toUpperCase()) ? (
84+
<img
85+
src={`/images/symbols/${token.symbol.toUpperCase()}.svg`}
86+
alt={token.symbol.toUpperCase()}
87+
className="h-8 w-8 shrink-0"
88+
/>
89+
) : (
90+
<div className="flex h-11 w-11 flex-col items-center justify-center rounded-full bg-blue-500">
91+
<a className="text-xs uppercase">
92+
{token.symbol.toUpperCase()}
93+
</a>
94+
</div>
95+
)}
96+
</div>
97+
98+
<Link
99+
href={"../tokens"}
100+
className="inline-block max-w-full truncate align-middle hover:underline"
101+
>
102+
<span>{token.symbol}</span>
103+
</Link>
92104
</div>
93-
94-
<Link
95-
href={"../tokens"}
96-
className="inline-block max-w-full truncate align-middle hover:underline"
97-
>
98-
<span>{token.symbol}</span>
99-
</Link>
100-
</div>
101-
</td>
102-
<td>{token?.amount ?? 0}</td>
103-
<td>
104-
{isNaN(token.amount * exchangeRates[token.symbol]) ? (
105-
<span style={{ color: "white" }}>
106-
${token.amount * (ordinalsMarketcap.tokens.find((t) => t.mappedName === token.symbol)?.price ?? 0)}
107-
108-
109-
</span>
110-
) : (
111-
<span style={{ color: "white" }}>
112-
$
113-
{(
114-
token.amount * exchangeRates[token.symbol]
115-
).toLocaleString("en-US", {
116-
maximumFractionDigits: 3,
117-
})}
118-
</span>
119-
)}
120-
</td>
121-
</tr>
122-
))}
105+
</td>
106+
<td>{token?.amount ?? 0}</td>
107+
<td>
108+
{isNaN(token.amount * exchangeRates[token.symbol]) ? (
109+
<span style={{ color: "white" }}>
110+
$
111+
{(
112+
token.amount *
113+
(ordinalsMarketcap.tokens.find(
114+
(t) => t.mappedName === token.symbol
115+
)?.price ?? 0) *
116+
BTCPrice
117+
).toLocaleString("en-US", {
118+
maximumFractionDigits: 3,
119+
})}
120+
</span>
121+
) : (
122+
<span style={{ color: "white" }}>
123+
$
124+
{(
125+
token.amount * exchangeRates[token.symbol]
126+
).toLocaleString("en-US", {
127+
maximumFractionDigits: 3,
128+
})}
129+
</span>
130+
)}
131+
</td>
132+
</tr>
133+
))}
123134
</tbody>
124135
<div></div>
125136

126137
<div></div>
127138
</table>
128139
<div className=" flex justify-center py-3 text-[15px]">
129-
<div>
140+
<div
141+
style={{
142+
display: "flex",
143+
flexDirection: "column",
144+
alignItems: "center",
145+
}}
146+
>
130147
Total: $
131148
{totalValue.toLocaleString("en-US", { maximumFractionDigits: 3 })}
149+
<br />
150+
<span style={{ fontSize: "small" }}>
151+
{" "}
152+
(Calculated excluding BRC Tokens)
153+
</span>
132154
</div>
133155
</div>
134156
</div>

0 commit comments

Comments
 (0)