Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbartnik committed Jan 17, 2024
2 parents c2807b4 + d58dfbf commit 5591b3f
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 51 deletions.
76 changes: 42 additions & 34 deletions apps/sentry-client-desktop/src/features/home/SentryWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import {accruingStateAtom} from "@/hooks/useAccruingInfo";
import {AssignKeysSentryNotRunning} from "@/components/AssignKeysSentryNotRunning";
import {GrRefresh} from "react-icons/gr";
import {LuListChecks} from "react-icons/lu";
import {useStorage} from "@/features/storage";

// TODO -> replace with dynamic value later
export const recommendedFundingBalance = ethers.parseEther("0.005");

export function SentryWallet() {
const [drawerState, setDrawerState] = useAtom(drawerStateAtom);
const setModalState = useSetAtom(modalStateAtom);
const {ownersLoading, owners, licensesLoading} = useAtomValue(chainStateAtom);
const {ownersLoading, owners, licensesLoading, licensesList} = useAtomValue(chainStateAtom);
const queryClient = useQueryClient();
const {hasAssignedKeys} = useAtomValue(accruingStateAtom);

Expand All @@ -50,7 +51,7 @@ export function SentryWallet() {
const [selectedWallet, setSelectedWallet] = useState<string | null>(null);
const [isMoreOptionsOpen, setIsMoreOptionsOpen] = useState<boolean>(false); // dropdown state
const {startRuntime, stopRuntime, sentryRunning, nodeLicenseStatusMap} = useOperatorRuntime();

const {data} = useStorage();

const [isOpen, setIsOpen] = useState<boolean>(false);
const {refresh} = useChainDataRefresh();
Expand Down Expand Up @@ -108,18 +109,34 @@ export function SentryWallet() {
}

function getDropdownItems() {
return owners.map((wallet, i) => (
<p
onClick={() => {
setSelectedWallet(wallet);
setIsOpen(false);
}}
className="p-2 cursor-pointer hover:bg-gray-100"
key={`sentry-item-${i}`}
>
{wallet}
</p>
));
// If the user has whitelisted wallets, update the dropdown to populate with their whitelistedWallets.
if (data?.whitelistedWallets) {
return data?.whitelistedWallets.map((wallet, i) => (
<p
onClick={() => {
setSelectedWallet(wallet);
setIsOpen(false);
}}
className="p-2 cursor-pointer hover:bg-gray-100"
key={`sentry-item-${i}`}
>
{wallet}
</p>
));
} else {
return owners.map((wallet, i) => (
<p
onClick={() => {
setSelectedWallet(wallet);
setIsOpen(false);
}}
className="p-2 cursor-pointer hover:bg-gray-100"
key={`sentry-item-${i}`}
>
{wallet}
</p>
));
}
}

function getKeys() {
Expand Down Expand Up @@ -156,33 +173,24 @@ export function SentryWallet() {
return element;
}


function getWalletCounter() {
let totalKeyLength: number = 0;

new Map([...nodeLicenseStatusMap].filter(([, status]) => {
if (selectedWallet === null) {
return true;
}
return status.ownerPublicKey === selectedWallet;
}))
.forEach((_, key) => {
totalKeyLength += key.toString().length;
});

/**
* By default, use the assignedWallets values.
* If the user has whitelisted wallets, update the counter to populate with their whitelistedWallets values.
*/
const keysCounter = data?.whitelistedWallets
? `${nodeLicenseStatusMap.size} key${nodeLicenseStatusMap.size === 1 ? '' : 's'} in ${data?.whitelistedWallets?.length} wallet${data?.whitelistedWallets?.length === 1 ? '' : 's'}`
: `${licensesList.length} key${licensesList.length === 1 ? '' : 's'} in ${owners.length} wallet${owners.length === 1 ? '' : 's'}`

return (
<>
{owners.length > 0
? (loading
? ("Loading...")
: (`${totalKeyLength} key${totalKeyLength === 1 ? '' : 's'} in ${owners.length} wallet${owners.length === 1 ? '' : 's'}`))
{nodeLicenseStatusMap.size > 0
? (loading ? ("Loading...") : (`${keysCounter}`))
: ("No keys")}
</>
);

}


function onCloseWalletConnectedModal() {
setAssignedWallet({show: false, txHash: ""});
setUnassignedWallet({show: false, txHash: ""});
Expand Down Expand Up @@ -373,7 +381,7 @@ export function SentryWallet() {
onClick={() => setIsOpen(!isOpen)}
className={`flex items-center justify-between w-[538px] border-[#A3A3A3] border-r border-l border-t ${!isOpen ? "border-b" : null} border-[#A3A3A3] p-2`}
>
<p>{selectedWallet || `All assigned wallets (${owners.length})`}</p>
<p>{selectedWallet || `All assigned wallets (${data?.whitelistedWallets ? data.whitelistedWallets.length : owners.length})`}</p>
<IoIosArrowDown
className={`h-[15px] transform ${isOpen ? "rotate-180 transition-transform ease-in-out duration-300" : "transition-transform ease-in-out duration-300"}`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ export function ExportSentryDrawer() {
</div>

) : (
<div className="w-full flex flex-col gap-8 mt-12">
<div className="flex flex-col gap-2 px-6 pt-8">

<p className="text-[15px] text-[#525252] mt-2">
<div className="w-full flex flex-col gap-8">
<div className="flex flex-col gap-2 px-6 pt-6">
<p className="text-[15px] text-[#525252]">
By exporting a Sentry Wallet, you can continue running your node on another client
without the need
to leave your local machine on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ export function ImportSentryDrawer() {
</div>

) : (
<div className="w-full flex flex-col gap-8 mt-12">
<div className="flex flex-col gap-2 px-6 pt-8">

<p className="text-[15px] text-[#525252] mt-2">
<div className="w-full flex flex-col gap-8">
<div className="flex flex-col gap-2 px-6 pt-6">
<p className="text-[15px] text-[#525252]">
By importing a Sentry Wallet, you can continue running your node without the need to
leave your local machine on.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function AssignedKeysCard() {

return (
<SquareCard className="bg-[#F5F5F5]">
{!hasAssignedKeys ? (
{hasAssignedKeys ? (
<IconLabel
icon={AiFillCheckCircle}
color="#16A34A"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export function KycRequiredCard({wallet, status}: KycRequiredCardProps) {
title={`KYC required: ${clampAddress(wallet)}`}
/>

<p className="text-[15px] text-[#525252] mt-3">
180 days remaining for esXAI to be claimed
</p>
<Blockpass onClick={onStartKyc}/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function ViewKeysDrawer() {
<div
className="h-full flex flex-col justify-start items-center">
<div
className="absolute top-0 w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8">
className="w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8">
<span>View keys in wallet</span>
<div className="cursor-pointer z-10" onClick={() => setDrawerState(null)}>
<AiOutlineClose/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ export function ViewKeysFlow() {
if (!loading && !success) {
return (
<div>
<div className="w-full flex flex-col gap-8 mt-12">
<div className="flex flex-col gap-2 px-6 pt-8">
<p className="text-[15px] text-[#525252] mt-2">
<div className="w-full flex flex-col gap-8">
<div className="flex flex-col gap-2 px-6 pt-6">
<p className="text-[15px] text-[#525252]">
Enter the the public key of the wallet you want to view keys for
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export function BuyKeysFlow() {
<div className="relative w-full h-screen flex flex-col gap-8">
{/* Top of buy */}
<div className="flex flex-col gap-8">

<div className="flex flex-col gap-2 px-6 pt-8">
<div className="flex flex-row items-center gap-2">
<span className="flex gap-3 items-center text-lg font-semibold">
Expand Down

0 comments on commit 5591b3f

Please sign in to comment.