Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes committed Dec 9, 2024
1 parent 489200b commit 5ff3c93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 41 deletions.
56 changes: 18 additions & 38 deletions src/components/dapp/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,27 @@ import WalletConnectors from "./WalletConnectors";
export type WalletButton = ButtonProps;

export default function WalletButton(props: ButtonProps) {
const {
address,
disconnect,
connected,
connector,
chainId,
switchChain,
chains,
} = useWalletContext();
const { address, disconnect, connected, connector, chainId, switchChain, chains } = useWalletContext();

const chainOptions = useMemo(() => {
if (!chains) return [];
return chains.reduce((obj, chain) => {
obj[chain.id] = (
<Group>
<Icon src={chain?.icon} />
{chain.name}
</Group>
);
return obj;
}, {} as { [chainId: number]: ReactNode });
return chains.reduce(
(obj, chain) => {
obj[chain.id] = (
<Group>
<Icon src={chain?.icon} />
{chain.name}
</Group>
);
return obj;
},
{} as { [chainId: number]: ReactNode },
);
}, [chains]);

if (!connected)
return (
<Modal
title="Connect Wallet"
className="mx-auto w-full max-w-[500px]"
modal={<WalletConnectors />}
>
<Modal title="Connect Wallet" className="mx-auto w-full max-w-[500px]" modal={<WalletConnectors />}>
<Button look="hype" size="lg" {...props}>
Connect wallet
</Button>
Expand All @@ -54,10 +45,7 @@ export default function WalletButton(props: ButtonProps) {

return (
<>
<Select
state={[chainId, (c) => switchChain(+c)]}
options={chainOptions}
/>
<Select state={[chainId, c => switchChain(+c)]} options={chainOptions} />
<Dropdown
size="lg"
padding="xs"
Expand All @@ -66,20 +54,13 @@ export default function WalletButton(props: ButtonProps) {
<Group className="items-center justify-between" size="xl">
<Group className="items-center">
{/* TODO: Show the account icon by default if there is no ENS icon */}
<Icon
className="text-main-11 !w-xl*2 !h-xl*2"
remix="RiAccountCircleFill"
/>
<Icon className="text-main-11 !w-xl*2 !h-xl*2" remix="RiAccountCircleFill" />
<Image className="h-lg*2 w-lg*2" src={connector?.icon} />
<Hash size="lg" bold copy format="short">
{address}
</Hash>
</Group>
<Button
look="soft"
onClick={disconnect}
className="bg-main-5 !p-sm"
>
<Button look="soft" onClick={disconnect} className="bg-main-5 !p-sm">
<Icon className="text-main-11" remix="RiShutDownLine" />
</Button>
</Group>
Expand All @@ -97,8 +78,7 @@ export default function WalletButton(props: ButtonProps) {
</Button>
</Group>
</>
}
>
}>
<Button look="tint" className="w-full justify-center">
{Fmt.address(address, "short")}
</Button>
Expand Down
4 changes: 1 addition & 3 deletions src/utils/formatter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export class FormatterService {
toNumber(value: bigint | string, decimals = 18): number {
const bi = BigInt(value);

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

// trim the integer part if it's too large to avoid potential overflows
Expand Down

0 comments on commit 5ff3c93

Please sign in to comment.