Skip to content

Commit

Permalink
feat(cyberver): updates (#1163)
Browse files Browse the repository at this point in the history
Co-authored-by: dimakorzhovnik <[email protected]>
  • Loading branch information
happylolonly and dimakorzhovnik authored Sep 4, 2024
1 parent 4c37291 commit 91c7712
Show file tree
Hide file tree
Showing 24 changed files with 93 additions and 103 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# CHAIN_ID = space-pussy
3 changes: 2 additions & 1 deletion src/components/IconsNumber/IconsNumber.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.icon {
display: flex;
flex-direction: row;
margin-left: 3px;

.vertical {
flex-direction: column;
Expand All @@ -15,4 +16,4 @@

.tooltipWrapper {
white-space: nowrap;
}
}
10 changes: 5 additions & 5 deletions src/components/IconsNumber/IconsNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import { formatNumber } from 'src/utils/utils';
import getPrefixNumber from 'src/utils/getPrefixNumber';
import cx from 'classnames';
import hydrogen from '../../image/hydrogen.svg';
import Tooltip from '../tooltip/tooltip';
import hydrogen from '../../image/hydrogen.svg';
import styles from './IconsNumber.module.scss';

enum TypesEnum {
Expand Down Expand Up @@ -53,7 +53,7 @@ export default function IconsNumber({ value, type, isVertical }: Props) {
.dp(0, BigNumber.ROUND_FLOOR)
.toNumber();

const i = new Array(prefix).fill(icons[type]).map((el, i) => {
const i = new Array(prefix || 1).fill(icons[type]).map((el, i) => {
// maybe fix
if (typeof el === 'object') {
return React.cloneElement(el, { key: i });
Expand All @@ -64,12 +64,12 @@ export default function IconsNumber({ value, type, isVertical }: Props) {

return (
<span className={styles.wrapper}>
{number}{' '}
{number}
<Tooltip
tooltip={
<span className={styles.tooltipWrapper}>
{formatNumber(value?.toLocaleString()?.replaceAll(',', ' ')) || 0}
{icons[type]}
{formatNumber(value?.toLocaleString()?.replaceAll(',', ' ')) || 0}{' '}
{icons[type]} {type}
</span>
}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { routes } from 'src/routes';
import usePassportByAddress from 'src/features/passport/hooks/usePassportByAddress';
import cx from 'classnames';
import { BECH32_PREFIX_VALOPER } from 'src/constants/config';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { trimString } from '../../utils/utils';
import { AvataImgIpfs } from '../../containers/portal/components/avataIpfs';
import styles from './account.module.scss';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import Tooltip from '../tooltip/tooltip';

function useGetValidatorInfo(address: string) {
Expand Down
2 changes: 0 additions & 2 deletions src/components/containerGradient/Display/Display.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
overflow: auto;
height: 100%;
max-height: 100%;

@include blueScroll;
}

&.noPaddingX {
Expand Down
13 changes: 7 additions & 6 deletions src/containers/Search/Filters/Filters.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useState } from 'react';
import styles from './Filters.module.scss';
import { useState } from 'react';
import ButtonsGroup from 'src/components/buttons/ButtonsGroup/ButtonsGroup';
import { LinksTypeFilter, SortBy } from '../types';
import { initialContentTypeFilterState } from '../constants';
import Links from 'src/components/search/Spark/Meta/Links/Links';
import { Account, Tooltip } from 'src/components';
import { Tooltip } from 'src/components';
import { AccountInput } from 'src/pages/teleport/components/Inputs';
import useCurrentAddress from 'src/hooks/useCurrentAddress';

import { AvataImgIpfs } from 'src/containers/portal/components/avataIpfs';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import useCurrentPassport from 'src/features/passport/hooks/useCurrentPassport';
import { initialContentTypeFilterState } from '../constants';
import { LinksTypeFilter, SortBy } from '../types';
import styles from './Filters.module.scss';

enum NeuronFilterType {
me = 'me',
Expand Down
1 change: 1 addition & 0 deletions src/containers/application/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useSenseManager from 'src/features/sense/ui/useSenseManager';

// eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars
import { initCyblog } from 'src/utils/logging/bootstrap';

import { setTimeHistoryRoute } from 'src/features/TimeHistory/redux/TimeHistory.redux';
import { PreviousPageProvider } from 'src/contexts/previousPage';
import { cybernetRoutes } from 'src/features/cybernet/ui/routes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const findSelectAppByUrl = (
let pathname = url;
const isRobot = url.includes('@') || url.includes('neuron/');
const isOracle = url.includes('oracle');
const isCyberver = url.includes('cyberver');

const itemsMenuObj = reduceRobotSubItems(passport, address);

Expand All @@ -23,6 +24,10 @@ const findSelectAppByUrl = (
pathname = routes.oracle.path;
}

if (isCyberver) {
pathname = '/cyberver';
}

const value = findApp(itemsMenuObj, pathname);

return value;
Expand Down
7 changes: 3 additions & 4 deletions src/containers/portal/gift/ActionBarPortalGift.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { toAscii, toBase64 } from '@cosmjs/encoding';
import { useSigningClient } from 'src/contexts/signerClient';
import { getKeplr } from 'src/utils/keplrUtils';
import useWaitForTransaction from 'src/hooks/useWaitForTransaction';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { Citizenship } from 'src/types/citizenship';
import { RootState } from 'src/redux/store';
import { useBackend } from 'src/contexts/backend/backend';
import { PATTERN_CYBER } from 'src/constants/patterns';
import Soft3MessageFactory from 'src/services/soft.js/api/msgs';
import BigNumber from 'bignumber.js';
import { Nullable } from 'src/types';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { CHAIN_ID } from 'src/constants/config';
import {
Dots,
ButtonIcon,
Expand Down Expand Up @@ -47,8 +48,6 @@ import {
} from '../../../features/passport/passports.redux';
import { ClaimMsg } from './type';
import { TxHash } from '../hook/usePingTxs';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { CHAIN_ID } from 'src/constants/config';

const gasPrice = GasPrice.fromString('0.001boot');

Expand Down
12 changes: 9 additions & 3 deletions src/containers/sigma/hooks/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import BigNumber from 'bignumber.js';
import { useQuery } from '@tanstack/react-query';
import { getDelegatorDelegations } from 'src/utils/search/utils';
import { BECH32_PREFIX_VALOPER, BASE_DENOM } from 'src/constants/config';
import { useStake as useVerseStake } from 'src/features/cybernet/ui/hooks/useCurrentAccountStake';
import { CYBERVER_CONTRACTS } from 'src/features/cybernet/constants';
import { useQueryClient } from 'src/contexts/queryClient';
import {
useStake as useVerseStake,
useStake as useVerseStake,
} from 'src/features/cybernet/ui/hooks/useCurrentAccountStake';
import {
CYBERVER_CONTRACTS,
CYBERVER_CONTRACTS,
} from 'src/features/cybernet/constants';
import { useQueryClient, useQueryClient } from 'src/contexts/queryClient';

import { isPussyChain } from 'src/utils/chains/pussy';
import { fromBech32 } from '../../../utils/utils';
Expand Down
6 changes: 3 additions & 3 deletions src/containers/sigma/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import TokenChange from 'src/components/TokenChange/TokenChange';
import { routes } from 'src/routes';
import Display from 'src/components/containerGradient/Display/Display';
import { useAppSelector } from 'src/redux/hooks';
import DisplayTitle from 'src/components/containerGradient/DisplayTitle/DisplayTitle';
import useCurrentPassport from 'src/features/passport/hooks/useCurrentPassport';
import useAdviserTexts from 'src/features/adviser/useAdviserTexts';
import { SigmaContext } from './SigmaContext';

import { CardPassport } from './components';
import ActionBarPortalGift from '../portal/gift/ActionBarPortalGift';
import STEP_INFO from '../portal/gift/utils';
import DisplayTitle from 'src/components/containerGradient/DisplayTitle/DisplayTitle';
import useCurrentPassport from 'src/features/passport/hooks/useCurrentPassport';
import useAdviserTexts from 'src/features/adviser/useAdviserTexts';

const valueContext = {
totalCap: 0,
Expand Down
2 changes: 0 additions & 2 deletions src/features/adviser/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ function AdviserProvider({ children }: { children: React.ReactNode }) {
const priorityItem = [...state].reverse().find((item) => item.isPriority);
const lastItem = priorityItem || state[state.length - 1];

// console.log(state);

const { content, color } = lastItem || {};

const value = useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/features/cybernet/ui/pages/Delegates/Delegates.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DelegatesTable from './DelegatesTable/DelegatesTable';
import Display from 'src/components/containerGradient/Display/Display';
import DisplayTitle from 'src/components/containerGradient/DisplayTitle/DisplayTitle';
import useAdviserTexts from 'src/features/adviser/useAdviserTexts';
import useCybernetTexts from '../../useCybernetTexts';
import { useDelegates } from '../../hooks/useDelegate';
import DelegatesTable from './DelegatesTable/DelegatesTable';

function Delegates() {
const { loading, error } = useDelegates();
Expand All @@ -13,7 +13,7 @@ function Delegates() {
useAdviserTexts({
isLoading: loading,
loadingText: `loading ${getText('delegate', true)}`,
error,
error: error?.message,
defaultText: `choose ${getText('delegate')} for learning`,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/* eslint-disable react/no-unstable-nested-components */
import React, { useMemo } from 'react';
import { SubnetInfo } from '../../types';
import { useMemo } from 'react';
import { createColumnHelper } from '@tanstack/react-table';
import Table from 'src/components/Table/Table';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { Delegator } from 'src/features/cybernet/types';
import { Account, AmountDenom } from 'src/components';
import useCurrentAddress from 'src/features/cybernet/_move/useCurrentAddress';
import { Account } from 'src/components';

import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { tableIDs } from 'src/components/Table/tableIDs';
import useCybernetTexts from '../../../useCybernetTexts';
import { cybernetRoutes } from '../../../routes';
import { useCybernet } from '../../../cybernet.context';
import { useDelegates } from '../../../hooks/useDelegate';
import useCurrentAccountStake from '../../../hooks/useCurrentAccountStake';
import IconsNumber from '../../../../../../components/IconsNumber/IconsNumber';
import SubnetPreview, {
SubnetPreviewGroup,
} from '../../../components/SubnetPreview/SubnetPreview';
import { tableIDs } from 'src/components/Table/tableIDs';
import { SubnetPreviewGroup } from '../../../components/SubnetPreview/SubnetPreview';

type Props = {};

Expand Down
27 changes: 5 additions & 22 deletions src/features/cybernet/ui/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,23 @@ import Display from 'src/components/containerGradient/Display/Display';
import { LinkWindow } from 'src/components';
import DisplayTitle from 'src/components/containerGradient/DisplayTitle/DisplayTitle';
import { Link, Navigate, useParams } from 'react-router-dom';
import useAdviserTexts from 'src/features/adviser/useAdviserTexts';

import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { Stars } from 'src/containers/portal/components';
import { cybernetRoutes } from '../../routes';
import useCurrentAddress from 'src/features/cybernet/_move/useCurrentAddress';
import styles from './Main.module.scss';
import useCurrentAccountStake from '../../hooks/useCurrentAccountStake';
import useDelegate from '../../hooks/useDelegate';
import ContractsTable from './ContractsTable/ContractsTable';
import useCybernetTexts from '../../useCybernetTexts';
import useDelegate from '../../hooks/useDelegate';
import { useCybernet } from '../../cybernet.context';
import ContractsTable from './ContractsTable/ContractsTable';
import Banner from './Banner/Banner';
import { Stars } from 'src/containers/portal/components';

function Main() {
const address = useCurrentAddress();

const { getText } = useCybernetTexts();

useAdviserTexts({
defaultText: (
<div>
Rewards are currently not being distributed because
<br /> contract execution is exceeding the block gas limit
<br />
This issue{' '}
<Link
to="https://x.com/cyber_devs/status/1805173737970405599"
target="_blank"
>
will be resolved soon
</Link>
</div>
),
});

const { data } = useDelegate(address);
const currentAddressIsDelegator = !!data;

Expand Down
14 changes: 7 additions & 7 deletions src/features/cybernet/ui/pages/Sigma/Sigma.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Account, AmountDenom, MainContainer } from 'src/components';
import Sigma from '../../../../../containers/sigma/index';
import useCurrentAddress from 'src/features/cybernet/_move/useCurrentAddress';
import { Account, AmountDenom } from 'src/components';

import useCurrentAddress from 'src/hooks/useCurrentAddress';
import Display from 'src/components/containerGradient/Display/Display';
import { cybernetRoutes } from '../../routes';
import { useStake } from '../../hooks/useCurrentAccountStake';
import DisplayTitle from 'src/components/containerGradient/DisplayTitle/DisplayTitle';
import { trimString } from 'src/utils/utils';
import styles from './Sigma.module.scss';
import Loader2 from 'src/components/ui/Loader2';
import useAdviserTexts from 'src/features/adviser/useAdviserTexts';
import { Link } from 'react-router-dom';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { routes } from 'src/routes';
import { useCybernet } from '../../cybernet.context';
import { AccountInput } from 'src/pages/teleport/components/Inputs';
import IconsNumber from 'src/components/IconsNumber/IconsNumber';
import {
CYBERVER_CONTRACTS,
CYBERVER_CONTRACTS_LEGACY,
} from 'src/features/cybernet/constants';
import { useCybernet } from '../../cybernet.context';
import styles from './Sigma.module.scss';
import { useStake } from '../../hooks/useCurrentAccountStake';
import { cybernetRoutes } from '../../routes';

function Item({ contractAddress, callback, address }) {
const query = useStake({
Expand Down
3 changes: 2 additions & 1 deletion src/features/cybernet/ui/pages/Subnet/subnet.context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useMemo } from 'react';
import { useParams } from 'react-router-dom';
import useCurrentAddress from 'src/features/cybernet/_move/useCurrentAddress';

import useCurrentAddress from 'src/hooks/useCurrentAddress';
import {
SubnetHyperParameters,
SubnetInfo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/* eslint-disable react/no-unstable-nested-components */
import { Link } from 'react-router-dom';
import { Delegator, SubnetNeuron } from 'src/features/cybernet/types';
import { cybernetRoutes } from '../../../../../routes';
import Table from 'src/components/Table/Table';
import { createColumnHelper } from '@tanstack/react-table';
import { routes } from 'src/routes';
import { Account, Tooltip } from 'src/components';
import { useCurrentSubnet } from '../../../subnet.context';
import useCurrentAddress from 'src/features/cybernet/_move/useCurrentAddress';
import useCurrentAddress from 'src/hooks/useCurrentAddress';
import { useAppData } from 'src/contexts/appData';
import GradeSetterInput from '../../../GradeSetterInput/GradeSetterInput';
import { useEffect, useMemo } from 'react';
import { useMemo } from 'react';
import useCybernetTexts from 'src/features/cybernet/ui/useCybernetTexts';
import {
useCurrentContract,
useCybernet,
} from 'src/features/cybernet/ui/cybernet.context';
import { getColor } from '../../Weights/WeightsTable/WeightsTable';
import colorStyles from '../../Weights/WeightsTable/temp.module.scss';
import { checkIsMLVerse } from 'src/features/cybernet/ui/utils/verses';
import IconsNumber from 'src/components/IconsNumber/IconsNumber';
import AdviserHoverWrapper from 'src/features/adviser/AdviserHoverWrapper/AdviserHoverWrapper';
import { tableIDs } from 'src/components/Table/tableIDs';
import { useDelegates } from 'src/features/cybernet/ui/hooks/useDelegate';
import { SubnetPreviewGroup } from 'src/features/cybernet/ui/components/SubnetPreview/SubnetPreview';
import colorStyles from '../../Weights/WeightsTable/temp.module.scss';
import { getColor } from '../../Weights/WeightsTable/WeightsTable';
import GradeSetterInput from '../../../GradeSetterInput/GradeSetterInput';
import { useCurrentSubnet } from '../../../subnet.context';
import { cybernetRoutes } from '../../../../../routes';

type Props = {};

Expand Down Expand Up @@ -250,10 +250,9 @@ function SubnetNeuronsTable({}: Props) {

handleSave(hotkey, netuid, +block, address);
}}
to={
routes.oracle.ask.getLink(metadata.particle) +
`?neuron=${hotkey}&subnet=${netuid}`
}
to={`${routes.oracle.ask.getLink(
metadata.particle
)}?neuron=${hotkey}&subnet=${netuid}`}
>
<Tooltip
tooltip={`check what job have been done by this ${getText(
Expand Down
Loading

0 comments on commit 91c7712

Please sign in to comment.