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 15, 2024
2 parents f80ee89 + 81b3662 commit c2807b4
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 68 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 version
run: sed -i'' -e 's/VERSION_NUMBER/${{ github.ref_name }}/g' packages/core/src/utils/version.ts

- name: Install dependencies
run: pnpm install

Expand Down
4 changes: 2 additions & 2 deletions apps/cli/src/commands/kyc/start-kyc-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -297,4 +297,4 @@ export function startKycProcess(cli: Vorpal) {
this.log("Invalid country. Please try again.");
}
});
}
}
3 changes: 3 additions & 0 deletions apps/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { removePromoCode } from './commands/licenses/remove-promo-code.js';
import { eventListener } from './commands/event-listener.js';
import { startKycProcess } from './commands/kyc/start-kyc-process.js';
import { generateRevenueReport } from './commands/licenses/generate-revenue-report.js';
import {version} from "@sentry/core";

const cli = new Vorpal();

Expand Down Expand Up @@ -94,6 +95,8 @@ totalSupply(cli);
startKycProcess(cli);
generateRevenueReport(cli);

console.log(`Starting Sentry cli version ${version}`);

cli
.delimiter('sentry-node$')
.show()
Expand Down
101 changes: 101 additions & 0 deletions apps/cli/src/index.ts-e
Original file line number Diff line number Diff line change
@@ -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.');
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +28,7 @@ export function ActionsRequiredPromptHandler() {
</button>
</div>
)
} else if (!accruing || kycRequired) {
} else if (!accruing || data && data.whitelistedWallets && kycRequired) {
return (
<div className="flex gap-4 bg-[#FFFBEB] p-2 z-10">
<div className="flex flex-row gap-2 items-center">
Expand Down
13 changes: 11 additions & 2 deletions apps/sentry-client-desktop/src/features/drawer/WhitelistDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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";

export function WhitelistDrawer() {
const setDrawerState = useSetAtom(drawerStateAtom);
Expand Down Expand Up @@ -96,7 +97,15 @@ export function WhitelistDrawer() {
to participate in a challenge.
</p>
<div>
<p className="text-[12px]">Your Sentry Wallet</p>
<div className="flex gap-1 items-center">
<p className="text-[12px]">Your Sentry Wallet</p>
<Tooltip
body={"You should allow the Sentry Wallet only if it contains at least one Key. Otherwise, it is not necessary to select."}
position={"end"}
>
<AiOutlineInfoCircle size={14} className="text-[#A3A3A3]"/>
</Tooltip>
</div>
{getOperatorItem()}
<p className="text-[12px]">Assigned Wallets</p>
{getDropdownItems()}
Expand Down
42 changes: 35 additions & 7 deletions apps/sentry-client-desktop/src/features/home/SentryWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ 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);

const {isLoading: operatorLoading, publicKey: operatorAddress} = useOperator();
const {data: balance} = useBalance(operatorAddress);

const loading = operatorLoading || ownersLoading || licensesLoading;
const keyCount = licensesList.length;

const [copied, setCopied] = useState<boolean>(false);
const [assignedWallet, setAssignedWallet] = useState<{ show: boolean, txHash: string }>({show: false, txHash: ""});
Expand Down Expand Up @@ -157,6 +156,33 @@ 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;
});

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

}


function onCloseWalletConnectedModal() {
setAssignedWallet({show: false, txHash: ""});
setUnassignedWallet({show: false, txHash: ""});
Expand Down Expand Up @@ -303,11 +329,13 @@ export function SentryWallet() {
<div className="flex flex-row items-center w-full py-3 pl-10 gap-1">
<h2 className="font-semibold">Assigned Keys</h2>
<p className="text-sm bg-gray-100 px-2 rounded-2xl text-gray-500">
{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"*/}
{/*)}*/}
</p>
{loading ? (
<span className="flex items-center text-[15px] text-[#A3A3A3] select-none">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export function ExportSentryDrawer() {
<div>
<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">
<span>Export Sentry Wallet</span>
className="w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8">
<div className="flex flex-row gap-2 items-center">
<span>Export Sentry Wallet</span>
</div>
<div className="cursor-pointer z-10" onClick={() => setDrawerState(null)}>
<AiOutlineClose/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export function ImportSentryDrawer() {
)}
<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">
<span>Import Sentry Wallet</span>
className="w-full h-[4rem] flex flex-row justify-between items-center border-b border-gray-200 text-lg font-semibold px-8">
<div className="flex flex-row gap-2 items-center">
<span>Import Sentry Wallet</span>
</div>
<div className="cursor-pointer z-10" onClick={() => setDrawerState(null)}>
<AiOutlineClose/>
</div>
Expand Down
Loading

0 comments on commit c2807b4

Please sign in to comment.