From c85df1623c215c79759e3a3179a6dc45920a5f15 Mon Sep 17 00:00:00 2001 From: spencer gray Date: Thu, 28 Dec 2023 10:04:04 -0800 Subject: [PATCH 1/9] dynamic cli version number --- .github/workflows/release.yml | 5 +- apps/cli/src/index.ts | 3 + apps/cli/src/index.ts-e | 101 ++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 apps/cli/src/index.ts-e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2a0b2c7b..08abcce9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,9 +24,12 @@ jobs: - name: Install pnpm run: npm install -g pnpm - - name: Set package version + - name: Set desktop app package version run: pnpm pkg set version=${{ github.ref_name }} --prefix apps/sentry-client-desktop + - name: Set cli package version + run: sed -i'' -e 's/VERSION_NUMBER/${{ github.ref_name }}/g' apps/cli/src/index.ts + - name: Install dependencies run: pnpm install diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index cffb1a46a..718fb702d 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -45,6 +45,7 @@ import { eventListener } from './commands/event-listener.js'; import { generateRevenueReport } from './commands/licenses/generate-revenue-report.js'; const cli = new Vorpal(); +export const version = "VERSION_NUMBER"; // entrypoints to each of the commands addAdmin(cli); @@ -92,6 +93,8 @@ toggleAssertionChecking(cli); totalSupply(cli); generateRevenueReport(cli); +console.log("starting cli... ", version); + cli .delimiter('sentry-node$') .show() diff --git a/apps/cli/src/index.ts-e b/apps/cli/src/index.ts-e new file mode 100644 index 000000000..718fb702d --- /dev/null +++ b/apps/cli/src/index.ts-e @@ -0,0 +1,101 @@ +import Vorpal from 'vorpal'; +import { addAdmin } from './commands/access-control/add-admin.js'; +import { addChallenger } from './commands/access-control/add-challenger.js'; +import { bootChallenger } from './commands/boot-challenger.js'; +import { createBlsKeyPair } from './commands/create-bls-key-pair.js'; +import { createMnemonic } from './commands/create-mnemonic.js'; +import { getAssertionCheckingStatus } from './commands/get-assertion-checking-status.js'; +import { getListOfAdmins } from './commands/access-control/get-list-of-admins.js'; +import { getListOfChallengers } from './commands/access-control/get-list-of-challengers.js'; +import { getPrivateKeyFromMnemonic } from './commands/get-private-key-from-memonic.js'; +import { getPublicKeyFromPrivateKey } from './commands/get-public-key-from-private-key.js'; +import { manuallyChallengeAssertion } from './commands/manually-challenge-assertion.js'; +import { removeAdmin } from './commands/access-control/remove-admin.js'; +import { removeChallenger } from './commands/access-control/remove-challenger.js'; +import { setChallengerPublicKey } from './commands/set-challenger-public-key.js'; +import { toggleAssertionChecking } from './commands/toggle-assertion-checking.js'; +import { addOperator } from './commands/operator-control/add-operator.js'; +import { removeOperator } from './commands/operator-control/remove-operator.js'; +import { listOperators } from './commands/operator-control/list-operators.js'; +import { mintNodeLicenses } from "./commands/licenses/mint-node-licenses.js"; +import { listNodeLicenses } from './commands/licenses/list-node-licenses.js'; +import { setRollupAddress } from './commands/set-rollup-address.js'; +import { getListOfKycAdmins } from './commands/access-control/get-list-of-kyc-admins.js'; +import { addKycAdmin } from './commands/access-control/add-kyc-admin.js'; +import { removeKycAdmin } from './commands/access-control/remove-kyc-admin.js'; +import { listKycStatuses } from './commands/kyc/list-kyc-status.js'; +import { checkKycStatus } from './commands/kyc/check-kyc-status.js'; +import { setKycStatus } from './commands/kyc/set-kyc-status.js'; +import { totalSupply } from './commands/xai-token/total-supply.js'; +import { getBalancesForAddresses } from './commands/xai-token/get-balances.js'; +import { getAllContractAddresses } from './commands/get-contract-addresses.js'; +import { checkWhitelist } from './commands/xai-token/check-whitelist.js'; +import { changeWhitelistStatus } from './commands/xai-token/change-whitelist-status.js'; +import { getPriceForQuantity } from './commands/licenses/get-price-for-quantity.js'; +import { listTiers } from './commands/licenses/list-tiers.js'; +import { getTotalSupplyAndCap } from './commands/licenses/get-total-supply-and-cap-of-licenses.js'; +import { getReferralRewards } from './commands/licenses/get-referral-rewards.js'; +import { getReferralDiscountAndRewardPercentages } from './commands/licenses/get-referral-discount-and-reward-percentages.js'; +import { setReferralDiscountAndRewardPercentages } from './commands/licenses/set-referral-discount-and-reward-percentages.js'; +import { bootOperator } from './commands/operator-control/operator-runtime.js'; +import { setOrAddPricingTiersCommand } from './commands/licenses/set-or-add-pricing-tiers.js'; +import { addPromoCode } from './commands/licenses/add-promo-code.js'; +import { removePromoCode } from './commands/licenses/remove-promo-code.js'; +import { eventListener } from './commands/event-listener.js'; +import { generateRevenueReport } from './commands/licenses/generate-revenue-report.js'; + +const cli = new Vorpal(); +export const version = "VERSION_NUMBER"; + +// entrypoints to each of the commands +addAdmin(cli); +addChallenger(cli); +addKycAdmin(cli); +addOperator(cli); +addPromoCode(cli); +bootChallenger(cli); +bootOperator(cli); +changeWhitelistStatus(cli); +checkKycStatus(cli); +checkWhitelist(cli); +createBlsKeyPair(cli); +createMnemonic(cli); +eventListener(cli); +getAllContractAddresses(cli); +getAssertionCheckingStatus(cli); +getBalancesForAddresses(cli); +getListOfAdmins(cli); +getListOfChallengers(cli); +getListOfKycAdmins(cli); +getPriceForQuantity(cli); +getPrivateKeyFromMnemonic(cli); +getPublicKeyFromPrivateKey(cli); +getReferralDiscountAndRewardPercentages(cli); +getReferralRewards(cli); +getTotalSupplyAndCap(cli); +listKycStatuses(cli); +listNodeLicenses(cli); +listOperators(cli); +listTiers(cli); +manuallyChallengeAssertion(cli); +mintNodeLicenses(cli); +removeAdmin(cli); +removeChallenger(cli); +removeKycAdmin(cli); +removeOperator(cli); +removePromoCode(cli); +setChallengerPublicKey(cli); +setKycStatus(cli); +setOrAddPricingTiersCommand(cli); +setReferralDiscountAndRewardPercentages(cli); +setRollupAddress(cli); +toggleAssertionChecking(cli); +totalSupply(cli); +generateRevenueReport(cli); + +console.log("starting cli... ", version); + +cli + .delimiter('sentry-node$') + .show() + .log('\nType "help" to display a list of actions.'); From 3e1416b58383dd266925417dbbdde5c07c55189e Mon Sep 17 00:00:00 2001 From: spencer gray Date: Thu, 28 Dec 2023 11:52:58 -0800 Subject: [PATCH 2/9] move dynamic version number packages /core --- .github/workflows/release.yml | 4 ++-- apps/cli/src/index.ts | 4 ++-- packages/core/src/operator/operatorRuntime.ts | 19 +++++++++++++++++-- packages/core/src/utils/index.ts | 3 ++- packages/core/src/utils/version.ts | 1 + packages/core/src/utils/version.ts-e | 1 + 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/core/src/utils/version.ts create mode 100644 packages/core/src/utils/version.ts-e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08abcce9d..8bb9207c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,8 +27,8 @@ jobs: - name: Set desktop app package version run: pnpm pkg set version=${{ github.ref_name }} --prefix apps/sentry-client-desktop - - name: Set cli package version - run: sed -i'' -e 's/VERSION_NUMBER/${{ github.ref_name }}/g' apps/cli/src/index.ts + - name: Set cli version + run: sed -i'' -e 's/VERSION_NUMBER/${{ github.ref_name }}/g' packages/core/src/utils/version.ts - name: Install dependencies run: pnpm install diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index 718fb702d..db2e3824d 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -43,9 +43,9 @@ import { addPromoCode } from './commands/licenses/add-promo-code.js'; import { removePromoCode } from './commands/licenses/remove-promo-code.js'; import { eventListener } from './commands/event-listener.js'; import { generateRevenueReport } from './commands/licenses/generate-revenue-report.js'; +import {version} from "@sentry/core"; const cli = new Vorpal(); -export const version = "VERSION_NUMBER"; // entrypoints to each of the commands addAdmin(cli); @@ -93,7 +93,7 @@ toggleAssertionChecking(cli); totalSupply(cli); generateRevenueReport(cli); -console.log("starting cli... ", version); +console.log(`Starting Sentry cli version ${version}`); cli .delimiter('sentry-node$') diff --git a/packages/core/src/operator/operatorRuntime.ts b/packages/core/src/operator/operatorRuntime.ts index 6db3109b4..9dde3ddee 100644 --- a/packages/core/src/operator/operatorRuntime.ts +++ b/packages/core/src/operator/operatorRuntime.ts @@ -1,5 +1,20 @@ import { ethers } from "ethers"; -import { Challenge, RefereeAbi, claimReward, config, getMintTimestamp, getSubmissionsForChallenges, listChallenges, listNodeLicenses, listOwnersForOperator, listenForChallenges, submitAssertionToChallenge, checkKycStatus, getProvider } from "../index.js"; +import { + Challenge, + RefereeAbi, + claimReward, + config, + getMintTimestamp, + getSubmissionsForChallenges, + listChallenges, + listNodeLicenses, + listOwnersForOperator, + listenForChallenges, + submitAssertionToChallenge, + checkKycStatus, + getProvider, + version +} from "../index.js"; import { retry } from "../index.js"; export enum NodeLicenseStatus { @@ -302,7 +317,7 @@ export async function operatorRuntime( const fetchBlockNumber = async () => { try { const blockNumber = await provider.getBlockNumber(); - logFunction(`[${new Date().toISOString()}] Health Check on JSON RPC, Operator still healthy. Current block number: ${blockNumber}`); + logFunction(`[${new Date().toISOString()}] [cli ${version}] Health Check on JSON RPC, Operator still healthy. Current block number: ${blockNumber}`); } catch (error) { logFunction(`[${new Date().toISOString()}] Error fetching block number, operator may no longer be connected to the JSON RPC: ${JSON.stringify(error)}.`); } diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index d5d8aae46..4578a78cb 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -8,5 +8,6 @@ export * from "./getClosestBlock.js"; export * from "./findEventTopic.js"; export * from "./getWalletBalance.js"; export * from "./verifyPrivateKey.js"; +export * from "./version.js"; export * from "./retry.js"; -export * from "./resilientEventListener.js"; \ No newline at end of file +export * from "./resilientEventListener.js"; diff --git a/packages/core/src/utils/version.ts b/packages/core/src/utils/version.ts new file mode 100644 index 000000000..a8233d6cf --- /dev/null +++ b/packages/core/src/utils/version.ts @@ -0,0 +1 @@ +export const version = "VERSION_NUMBER"; diff --git a/packages/core/src/utils/version.ts-e b/packages/core/src/utils/version.ts-e new file mode 100644 index 000000000..a8233d6cf --- /dev/null +++ b/packages/core/src/utils/version.ts-e @@ -0,0 +1 @@ +export const version = "VERSION_NUMBER"; From 67976b05798d91e6b1de674b5a675a2d3548b46b Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Tue, 2 Jan 2024 09:19:30 -0800 Subject: [PATCH 3/9] Only display KYC required step to users if they have keys assigned --- .../drawer/ActionsRequiredPromptHandler.tsx | 4 +- .../home/modals/ExportSentryDrawer.tsx | 6 +- .../home/modals/ImportSentryDrawer.tsx | 6 +- .../ActionsRequiredNotAccruingDrawer.tsx | 100 ++++++++++-------- .../actions-required/AllowedWalletsCard.tsx | 50 +++++++++ 5 files changed, 114 insertions(+), 52 deletions(-) create mode 100644 apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx diff --git a/apps/sentry-client-desktop/src/features/drawer/ActionsRequiredPromptHandler.tsx b/apps/sentry-client-desktop/src/features/drawer/ActionsRequiredPromptHandler.tsx index a83d1f8c5..57524521c 100644 --- a/apps/sentry-client-desktop/src/features/drawer/ActionsRequiredPromptHandler.tsx +++ b/apps/sentry-client-desktop/src/features/drawer/ActionsRequiredPromptHandler.tsx @@ -3,10 +3,12 @@ import {AiFillCheckCircle, AiFillWarning} from "react-icons/ai"; import {useSetAtom, useAtomValue} from "jotai"; import {accruingStateAtom} from "@/hooks/useAccruingInfo"; import {chainStateAtom} from "@/hooks/useChainDataWithCallback"; +import {useStorage} from "@/features/storage"; export function ActionsRequiredPromptHandler() { const setDrawerState = useSetAtom(drawerStateAtom); const {accruing, kycRequired} = useAtomValue(accruingStateAtom); + const {data} = useStorage(); const {ownersLoading, ownersKycLoading, licensesLoading, combinedLicensesList} = useAtomValue(chainStateAtom); const keyCount = combinedLicensesList.length; @@ -26,7 +28,7 @@ export function ActionsRequiredPromptHandler() { ) - } else if (!accruing || kycRequired) { + } else if (!accruing || data && data.whitelistedWallets && kycRequired) { return (
diff --git a/apps/sentry-client-desktop/src/features/home/modals/ExportSentryDrawer.tsx b/apps/sentry-client-desktop/src/features/home/modals/ExportSentryDrawer.tsx index 99bc36ab5..ce24eb4cc 100644 --- a/apps/sentry-client-desktop/src/features/home/modals/ExportSentryDrawer.tsx +++ b/apps/sentry-client-desktop/src/features/home/modals/ExportSentryDrawer.tsx @@ -44,8 +44,10 @@ export function ExportSentryDrawer() {
- Export Sentry Wallet + className="w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8"> +
+ Export Sentry Wallet +
setDrawerState(null)}>
diff --git a/apps/sentry-client-desktop/src/features/home/modals/ImportSentryDrawer.tsx b/apps/sentry-client-desktop/src/features/home/modals/ImportSentryDrawer.tsx index ac2cf970b..e79b5f2b5 100644 --- a/apps/sentry-client-desktop/src/features/home/modals/ImportSentryDrawer.tsx +++ b/apps/sentry-client-desktop/src/features/home/modals/ImportSentryDrawer.tsx @@ -65,8 +65,10 @@ export function ImportSentryDrawer() { )}
- Import Sentry Wallet + className="w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8"> +
+ Import Sentry Wallet +
setDrawerState(null)}>
diff --git a/apps/sentry-client-desktop/src/features/home/modals/actions-required/ActionsRequiredNotAccruingDrawer.tsx b/apps/sentry-client-desktop/src/features/home/modals/actions-required/ActionsRequiredNotAccruingDrawer.tsx index b8cdfa641..fba321942 100644 --- a/apps/sentry-client-desktop/src/features/home/modals/actions-required/ActionsRequiredNotAccruingDrawer.tsx +++ b/apps/sentry-client-desktop/src/features/home/modals/actions-required/ActionsRequiredNotAccruingDrawer.tsx @@ -12,12 +12,14 @@ import {BarStepItem} from "@/components/BarStepItem"; import {accruingStateAtom} from "@/hooks/useAccruingInfo"; import {chainStateAtom} from "@/hooks/useChainDataWithCallback"; import {useStorage} from "@/features/storage"; +import {AllowedWalletsCard} from "@/features/home/modals/actions-required/AllowedWalletsCard"; export function ActionsRequiredNotAccruingDrawer() { const setDrawerState = useSetAtom(drawerStateAtom); const {ownersKycMap} = useAtomValue(chainStateAtom); const {accruing, kycRequired} = useAtomValue(accruingStateAtom); const {data} = useStorage(); + const {hasAssignedKeys} = useAtomValue(accruingStateAtom); return (
@@ -81,58 +83,62 @@ export function ActionsRequiredNotAccruingDrawer() { - + -
- {kycRequired ? ( - - -

- You must pass KYC within 180 days of accruing esXAI to claim accrued node - rewards. - Check back in - 48 hours if all docs submitted. Check your inbox (including spam) for updates. - For - KYC issues, - contact window.electron.openExternal(`https://help.blockpass.org/hc/en-us/requests/new`)} - > Blockpass. If not completed, continue submission here. -

-
- ) : ( - - -

- You have successfully completed your KYC on all wallets assigned to the Sentry. -

-
- )} + + + - {data?.whitelistedWallets?.map((owner, i) => { - return ( - - + {kycRequired ? ( + + +

+ You must pass KYC within 180 days of accruing esXAI to claim accrued node + rewards. Check back in 48 hours if all docs submitted. Check your inbox + (including spam) for updates. For KYC issues, contact window.electron.openExternal(`https://help.blockpass.org/hc/en-us/requests/new`)} + > Blockpass. If not completed, continue submission here. +

+
+ ) : ( + + -
- ); - })} -
+

+ You have successfully completed your KYC on all wallets assigned to the + Sentry. +

+ + )} + + {data?.whitelistedWallets?.map((owner, i) => { + return ( + + + + ); + })} +
+ )}
diff --git a/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx new file mode 100644 index 000000000..8419a64a1 --- /dev/null +++ b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx @@ -0,0 +1,50 @@ +import {IconLabel} from "@/components/IconLabel"; +import {SquareCard} from "@/components/SquareCard"; +import {IoMdCloseCircle} from "react-icons/io"; +import {AiFillCheckCircle} from "react-icons/ai"; +import {useSetAtom} from "jotai"; +import {XaiButton} from "@sentry/ui"; +import {useStorage} from "@/features/storage"; +import {drawerStateAtom, DrawerView} from "@/features/drawer/DrawerManager"; + +export function AllowedWalletsCard() { + const setDrawerState = useSetAtom(drawerStateAtom); + const {data} = useStorage(); + + return ( + + {data && data.whitelistedWallets ? ( + + ) : ( + <> + + +

+ Select the wallets you'd like to enable to run on your Sentry. +

+ + setDrawerState(DrawerView.Whitelist)} + width={"100%"} + fontSize={"15px"} + > + Assign allowed wallets + + + )} +
+ ); +} From 23cfa8d692fda42e3113946cf72ed89c4c9534ef Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Tue, 2 Jan 2024 10:29:50 -0800 Subject: [PATCH 4/9] Allowed Wallets changes --- .../src/features/drawer/WhitelistDrawer.tsx | 14 ++++++++++++-- .../modals/actions-required/AllowedWalletsCard.tsx | 9 ++++----- .../modals/actions-required/AssignedKeysCard.tsx | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx b/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx index efdbe6054..fb13fa89c 100644 --- a/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx +++ b/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx @@ -1,11 +1,13 @@ import {useAtomValue, useSetAtom} from "jotai"; import {drawerStateAtom} from "@/features/drawer/DrawerManager"; import {chainStateAtom} from "@/hooks/useChainDataWithCallback"; -import {XaiCheckbox} from "@sentry/ui"; +import {Tooltip, XaiCheckbox} from "@sentry/ui"; import {useEffect, useState} from "react"; import {useStorage} from "@/features/storage"; import {useOperatorRuntime} from "@/hooks/useOperatorRuntime"; import {useOperator} from "@/features/operator"; +import {AiOutlineInfoCircle} from "react-icons/ai"; +import * as React from "react"; export function WhitelistDrawer() { const setDrawerState = useSetAtom(drawerStateAtom); @@ -96,7 +98,15 @@ export function WhitelistDrawer() { to participate in a challenge.

-

Your Sentry Wallet

+
+

Your Sentry Wallet

+ + + +
{getOperatorItem()}

Assigned Wallets

{getDropdownItems()} diff --git a/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx index 8419a64a1..4db3811d1 100644 --- a/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx +++ b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AllowedWalletsCard.tsx @@ -17,18 +17,17 @@ export function AllowedWalletsCard() { ) : ( <> diff --git a/apps/sentry-client-desktop/src/features/home/modals/actions-required/AssignedKeysCard.tsx b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AssignedKeysCard.tsx index c31406198..a3f88417f 100644 --- a/apps/sentry-client-desktop/src/features/home/modals/actions-required/AssignedKeysCard.tsx +++ b/apps/sentry-client-desktop/src/features/home/modals/actions-required/AssignedKeysCard.tsx @@ -21,7 +21,7 @@ export function AssignedKeysCard() { return ( - {hasAssignedKeys ? ( + {!hasAssignedKeys ? ( Date: Tue, 2 Jan 2024 16:20:13 -0800 Subject: [PATCH 5/9] fix macedonia typo --- apps/cli/src/commands/kyc/start-kyc-process.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/cli/src/commands/kyc/start-kyc-process.ts b/apps/cli/src/commands/kyc/start-kyc-process.ts index 728aab430..e9d962358 100644 --- a/apps/cli/src/commands/kyc/start-kyc-process.ts +++ b/apps/cli/src/commands/kyc/start-kyc-process.ts @@ -284,7 +284,7 @@ export function startKycProcess(cli: Vorpal) { if ( country === "china" || //China country === "hong kong" || //Hong Kong - country === "macedonia" || //Macedonia + country === "republic of north macedonia" || //Macedonia country === "turkey" || //Turkey country === "ukraine" //Ukraine ) { @@ -297,4 +297,4 @@ export function startKycProcess(cli: Vorpal) { this.log("Invalid country. Please try again."); } }); -} \ No newline at end of file +} From 150b1a8cf5baf273cf44314c7e87812bbe7decde Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Wed, 3 Jan 2024 09:55:35 -0800 Subject: [PATCH 6/9] Remove unused import from WhitelistDrawer --- .../src/features/drawer/WhitelistDrawer.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx b/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx index fb13fa89c..77c46b0b1 100644 --- a/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx +++ b/apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx @@ -7,7 +7,6 @@ import {useStorage} from "@/features/storage"; import {useOperatorRuntime} from "@/hooks/useOperatorRuntime"; import {useOperator} from "@/features/operator"; import {AiOutlineInfoCircle} from "react-icons/ai"; -import * as React from "react"; export function WhitelistDrawer() { const setDrawerState = useSetAtom(drawerStateAtom); From c7b441d072b2ce90bf51b41b5aeb06ca77e8c83c Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Wed, 3 Jan 2024 14:29:33 -0800 Subject: [PATCH 7/9] Adjusts Sentry Wallet counter --- .../src/features/home/SentryWallet.tsx | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx index 046e970ff..046af8d48 100644 --- a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx +++ b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx @@ -32,7 +32,7 @@ export const recommendedFundingBalance = ethers.parseEther("0.005"); export function SentryWallet() { const [drawerState, setDrawerState] = useAtom(drawerStateAtom); const setModalState = useSetAtom(modalStateAtom); - const {ownersLoading, owners, licensesLoading, licensesList} = useAtomValue(chainStateAtom); + const {ownersLoading, owners, licensesLoading} = useAtomValue(chainStateAtom); const queryClient = useQueryClient(); const {hasAssignedKeys} = useAtomValue(accruingStateAtom); @@ -40,7 +40,6 @@ export function SentryWallet() { const {data: balance} = useBalance(operatorAddress); const loading = operatorLoading || ownersLoading || licensesLoading; - const keyCount = licensesList.length; const [copied, setCopied] = useState(false); const [assignedWallet, setAssignedWallet] = useState<{ show: boolean, txHash: string }>({show: false, txHash: ""}); @@ -157,6 +156,37 @@ export function SentryWallet() { return element; } + + function getWalletCounter() { + const uniqueWallets: Set = new Set(); + let totalKeyLength: number = 0; + + console.log("nodeLicenseStatusMap", nodeLicenseStatusMap) + + new Map([...nodeLicenseStatusMap].filter(([, status]) => { + if (selectedWallet === null) { + return true; + } + return status.ownerPublicKey === selectedWallet; + })) + .forEach((status, key) => { + uniqueWallets.add(status.ownerPublicKey); + totalKeyLength += key.toString().length; + }); + + return ( + <> + {uniqueWallets.size > 0 + ? (loading + ? ("Loading...") + : (`${totalKeyLength} key${totalKeyLength === 1 ? '' : 's'} in ${uniqueWallets.size} wallet${uniqueWallets.size === 1 ? '' : 's'}`)) + : ("Allowed wallets not assigned")} + + ); + + } + + function onCloseWalletConnectedModal() { setAssignedWallet({show: false, txHash: ""}); setUnassignedWallet({show: false, txHash: ""}); @@ -303,11 +333,13 @@ export function SentryWallet() {

Assigned Keys

- {owners.length > 0 ? ( - loading ? "Loading..." : `${keyCount} key${keyCount === 1 ? "" : "s"} in ${owners.length} wallet${owners.length === 1 ? "" : "s"}` - ) : ( - "Keys not assigned" - )} + {getWalletCounter()} + + {/*{owners.length > 0 ? (*/} + {/* loading ? "Loading..." : `${keyCount} key${keyCount === 1 ? "" : "s"} in ${owners.length} wallet${owners.length === 1 ? "" : "s"}`*/} + {/*) : (*/} + {/* "Keys not assigned"*/} + {/*)}*/}

{loading ? ( From b6e036f907900dcd69c0722b7d743945193deb7d Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Fri, 12 Jan 2024 09:01:39 -0800 Subject: [PATCH 8/9] Remove console log --- apps/sentry-client-desktop/src/features/home/SentryWallet.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx index 046af8d48..122e00e85 100644 --- a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx +++ b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx @@ -161,8 +161,6 @@ export function SentryWallet() { const uniqueWallets: Set = new Set(); let totalKeyLength: number = 0; - console.log("nodeLicenseStatusMap", nodeLicenseStatusMap) - new Map([...nodeLicenseStatusMap].filter(([, status]) => { if (selectedWallet === null) { return true; From 81b3662882f02822f0ee421d04eb5290cac9b010 Mon Sep 17 00:00:00 2001 From: James Bartnik Date: Mon, 15 Jan 2024 14:08:51 -0800 Subject: [PATCH 9/9] Update SentryWallet counter to use assigned wallet counter --- .../src/features/home/SentryWallet.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx index 122e00e85..3e6bcb0f1 100644 --- a/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx +++ b/apps/sentry-client-desktop/src/features/home/SentryWallet.tsx @@ -158,7 +158,6 @@ export function SentryWallet() { function getWalletCounter() { - const uniqueWallets: Set = new Set(); let totalKeyLength: number = 0; new Map([...nodeLicenseStatusMap].filter(([, status]) => { @@ -167,18 +166,17 @@ export function SentryWallet() { } return status.ownerPublicKey === selectedWallet; })) - .forEach((status, key) => { - uniqueWallets.add(status.ownerPublicKey); + .forEach((_, key) => { totalKeyLength += key.toString().length; }); return ( <> - {uniqueWallets.size > 0 + {owners.length > 0 ? (loading ? ("Loading...") - : (`${totalKeyLength} key${totalKeyLength === 1 ? '' : 's'} in ${uniqueWallets.size} wallet${uniqueWallets.size === 1 ? '' : 's'}`)) - : ("Allowed wallets not assigned")} + : (`${totalKeyLength} key${totalKeyLength === 1 ? '' : 's'} in ${owners.length} wallet${owners.length === 1 ? '' : 's'}`)) + : ("No keys")} );