Skip to content

Commit

Permalink
enhancement: adjusting formatAsset function
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Oct 23, 2024
1 parent b43df27 commit 1e5feb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lib/utils/assets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Asset } from '@wharfkit/antelope';

export function formatAsset(asset: Asset) {
export function formatAsset(asset: Asset, decimals = 0) {
const formattedValue = asset.value.toLocaleString('en-US', {
minimumFractionDigits: asset.symbol.precision,
maximumFractionDigits: asset.symbol.precision
minimumFractionDigits: decimals,
maximumFractionDigits: decimals
});
return `${formattedValue} ${asset.symbol.code}`;
}
2 changes: 1 addition & 1 deletion src/routes/[network]/(account)/ram/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</Card>
<Card class="ml-2 h-32 w-full bg-gray-800">
<p class="text-gray-400">RAM Supply</p>
<p class="-mt-8 font-bold text-white">{ramSupply ? formatAsset(ramSupply) : '0 GB'}</p>
<p class="-mt-8 font-bold text-white">{ramSupply ? formatAsset(ramSupply, 3) : '0 GB'}</p>
</Card>
</div>
</div>

0 comments on commit 1e5feb9

Please sign in to comment.