Skip to content

Commit

Permalink
0.2.5.1 | HOTFIX (#94)
Browse files Browse the repository at this point in the history
* fix qr code generation for all address types

* add ordinal balance to cardinal balance on the main page
  • Loading branch information
kieled authored Jul 21, 2024
1 parent 4c572b6 commit ac051f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 93 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nintondo-extension",
"version": "0.2.5",
"version": "0.2.5.1",
"private": true,
"scripts": {
"dev": "bun build.ts --watch",
Expand Down
2 changes: 1 addition & 1 deletion src/shared/locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"receive": "Receive",
"send": "Send",
"nft": "NFT",
"amount_in_transactions": "Balance"
"amount_in_transactions": "Available balance"
},
"settings": {
"language": "Language",
Expand Down
6 changes: 1 addition & 5 deletions src/ui/pages/main/receive/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ const qrCode = new QRCode({
type: "linear",
}
},
qrOptions: {
errorCorrectionLevel: "H",
typeNumber: 4,
},
backgroundOptions: {
color: "#ffffff00",
},
imageOptions: {
crossOrigin: "anonymous",
margin: 5,
imageSize: 0.25,
imageSize: 0.3,
},
});

Expand Down
113 changes: 27 additions & 86 deletions src/ui/pages/main/wallet/account-panel/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { shortAddress } from "@/shared/utils/transactions";
import CopyBtn from "@/ui/components/copy-btn";
import { t } from "i18next";
import cn from "classnames";
import { Popover, Transition, useClose } from "@headlessui/react";
import { Fragment, useRef } from "react";
import { calcBalanceLength } from "@/ui/utils";
import {
useGetCurrentAccount,
Expand All @@ -19,94 +17,37 @@ const AccountPanel = () => {
const currentAccount = useGetCurrentAccount();
const currentWallet = useGetCurrentWallet();

const close = useClose();
const leaveTimeOutRef = useRef<NodeJS.Timeout | null>(null);
const enterTimeOutRef = useRef<NodeJS.Timeout | null>(null);
const cardinalBalance = currentAccount?.balance ?? 0;
const ordinalBalance = currentAccount?.inscriptionBalance ?? 0;
const balance = (cardinalBalance + ordinalBalance) / 10 ** 8;

const handleEnter = (isOpen: boolean) => {
if (
!currentAccount ||
currentAccount.address ||
leaveTimeOutRef.current === null
)
return;
if (currentAccount.balance === undefined) return;
if (leaveTimeOutRef.current !== null) {
clearTimeout(leaveTimeOutRef.current);
}
enterTimeOutRef.current = setTimeout(() => {
!isOpen && close();
}, 240);
};

const handleLeave = (isOpen: boolean) => {
if (enterTimeOutRef.current !== null) {
clearTimeout(enterTimeOutRef.current);
}
leaveTimeOutRef.current = setTimeout(() => {
isOpen && close();
}, 240);
};

return (
<div className={s.accPanel}>
<Popover className="relative w-full flex">
{({ open }) => (
<>
<div
className={s.balance}
onMouseEnter={() => handleEnter(open)}
onMouseLeave={() => handleLeave(open)}
>
<div className="flex items-center justify-center gap-2">
{currentAccount?.balance === undefined ? (
<div className="pb-1">
<div className="animate-pulse w-40 h-8 rounded-md bg-gray-600 bg-opacity-70" />
</div>
) : (
calcBalanceLength((currentAccount?.balance ?? 0) / 10 ** 8)
)}
<span className="text-xl pb-0.5 text-slate-300">BEL</span>
<div className="relative w-full flex">
<div className={s.balance}>
<div className="flex items-center justify-center gap-2">
{currentAccount?.balance === undefined ? (
<div className="pb-1">
<div className="animate-pulse w-40 h-8 rounded-md bg-gray-600 bg-opacity-70" />
</div>
) : (
calcBalanceLength(balance)
)}
<span className="text-xl pb-0.5 text-slate-300">BEL</span>
</div>
</div>
{currentAccount?.balance !== undefined ? (
currentPrice !== undefined ? (
<div className="text-gray-500 text-sm">
~
{(balance * currentPrice)?.toFixed(3)}
$
</div>
{currentAccount?.balance !== undefined ? (
currentPrice !== undefined ? (
<div className="text-gray-500 text-sm">
~
{((currentAccount.balance / 10 ** 8) * currentPrice)?.toFixed(
3
)}
$
</div>
) : undefined
) : undefined}
<Transition
as={Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-[-50%]"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-[-50%]"
>
<Popover.Panel
onMouseEnter={() => handleEnter(open)}
onMouseLeave={() => handleLeave(open)}
className="absolute w-full flex flex-col top-full left-0 bg-opacity-90 bg-black rounded-xl p-3 text-sm"
>
<p>
{`${t("wallet_page.amount_in_transactions")}: `}
{`${currentAccount?.balance?.toFixed(8)} BEL`}
</p>
<p>
{`${t("wallet_page.amount_in_inscriptions")}: `}
{`${currentAccount?.inscriptionBalance?.toFixed(8)} BEL`}
</p>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
) : undefined
) : undefined}

</div>
<div className="flex gap-3 items-center">
{currentWallet?.type === "root" ? (
<Link to={"/pages/switch-account"}>
Expand All @@ -119,8 +60,8 @@ const AccountPanel = () => {
<div>
<p>
{currentAccount?.id === 0 &&
!currentWallet?.hideRoot &&
currentWallet?.type === "root"
!currentWallet?.hideRoot &&
currentWallet?.type === "root"
? "Root account"
: currentAccount?.name}
</p>
Expand Down

0 comments on commit ac051f1

Please sign in to comment.