Skip to content

Commit

Permalink
add: price util & filter out local chain (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
clmntsnr authored Dec 16, 2024
1 parent 821ccfe commit 312fdde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/context/Dapp.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function DAppProvider({
}: PropsWithChildren<DAppProviderProps>) {
return (
<ThemeProvider sizing={sizing} themes={themes ?? demoThemes} modes={modes}>
<WalletProvider chains={chains} config={config}>
<WalletProvider chains={chains.filter(({ id }) => id !== 1337)} config={config}>
{children}
</WalletProvider>
</ThemeProvider>
Expand Down
6 changes: 5 additions & 1 deletion src/utils/formatter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export class FormatterService {
}
}

toNumber(value: bigint | string, decimals = 18): number {
public static toPrice(value: bigint | string, token: { price?: number | null; decimals: number }): number {
return FormatterService.toNumber(value, token.decimals) * (token.price ?? 0);
}

public static toNumber(value: bigint | string, decimals = 18): number {
const bi = BigInt(value);

const fractionalPart = Number.parseFloat((bi % BigInt(10 ** decimals)).toString()) / 10 ** decimals;
Expand Down

0 comments on commit 312fdde

Please sign in to comment.