Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release #40

Merged
merged 8 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
env:
PROJECT_ID: bright-meridian-316511

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,13 +48,13 @@ jobs:
echo "::set-output name=tag::$(git rev-parse --short HEAD)"
if [ "$REF" = "refs/heads/main" ]; then
echo "::set-output name=app_env::prod"
echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/graphql"
echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet:prod/api/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet:prod/api/graphql"
echo "::set-output name=enable_demo_features::false"
else
echo "::set-output name=app_env::dev"
echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet/v/v5/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet/v/v5/graphql"
echo "::set-output name=testnet_squid_api_url::https://subsquid.squids.live/subsquid-network-testnet:dev/api/graphql"
echo "::set-output name=mainnet_squid_api_url::https://subsquid.squids.live/subsquid-network-mainnet:dev/api/graphql"
echo "::set-output name=enable_demo_features::true"
fi
if [ "$NETWORK" = "mainnet" ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/api/subsquid-network-squid/settings-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function useNetworkSummary() {
epoch: res.epoches.length ? res.epoches[0] : undefined,
};
},
refetchInterval: 6000, // a half of block time in l1
refetchInterval: 12_000, // block time in l1
},
);

Expand Down
10 changes: 10 additions & 0 deletions src/hooks/useCountdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { relativeDateFormat } from '@i18n';

import { useTicker } from './useTicker';

export function useCountdown({ timestamp }: { timestamp?: Date | string | number | undefined }) {
const curTimestamp = useTicker(() => Date.now(), 1000);
const timeLeft = timestamp ? relativeDateFormat(curTimestamp, timestamp) : undefined;

return timeLeft;
}
14 changes: 14 additions & 0 deletions src/hooks/useTicker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useEffect, useState } from 'react';

export function useTicker<T>(ticker: () => T, ms: number = 1000) {
const [tickerValue, setTickerValue] = useState(ticker());

useEffect(() => {
const interval = setInterval(() => {
setTickerValue(ticker());
}, ms);
return () => clearInterval(interval);
}, [ms, ticker]);

return tickerValue;
}
6 changes: 3 additions & 3 deletions src/i18n/dateFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ export function dateFormat(
value: Date | string | number | undefined,
tpl: 'dateTime' | 'date' | string = 'date',
) {
if (!value) return null;
if (!value) return undefined;

if (tpl === 'dateTime') {
tpl = 'dd.MM.yyyy HH:mm:ss';
} else if (tpl === 'date') {
tpl = 'dd.MM.yyyy';
}

if (value.valueOf() == 0) return null;
if (value.valueOf() == 0) return undefined;

const date = new Date(value);
if (!isValid(date)) return null;
if (!isValid(date)) return undefined;

return format(new Date(value), tpl);
}
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/NetworkLayout/BasicMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Item = styled(MenuItem)(({ theme }) => ({
transition: 'all ease-out 150ms',
// paddingLeft: theme.spacing(1.5),
// paddingRight: theme.spacing(1),
// borderRadius: '2px',
borderRadius: '4px',
'& path': {
transition: 'fill ease-out 150ms',
},
Expand Down
6 changes: 5 additions & 1 deletion src/layouts/NetworkLayout/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { LogoutMenuItem } from './LogoutMenuItem';

export const UserMenuStyled = styled(Menu, {
name: 'UserMenuStyled',
})(() => ({
})(({ theme }) => ({
minWidth: '100%',
}));

Expand Down Expand Up @@ -71,6 +71,10 @@ export function UserMenu() {
sx: {
overflow: 'visible',
width: 192,
pl: 1,
pr: 1,
pt: 0.5,
pb: 0.5,
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const formatter8 = new Intl.NumberFormat('en', {
});

export function numberWithCommasFormatter(val?: number | bigint | string) {
if (val === undefined) return '';
if (!val) return '0';

return formatter8.format(typeof val === 'string' ? Number(val) : val);
}
Expand Down
10 changes: 9 additions & 1 deletion src/pages/AssetsPage/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ export function MyAssets() {
background: theme.palette.secondary.main,
tip: 'Tokens delegated to workers',
};
const lockedPortal: TokenBalance = {
name: 'Locked in Portal',
value: BigNumber(0),
color: theme.palette.text.primary,
background: theme.palette.text.primary,
tip: '',
};

sourcesQuery?.accounts.forEach(s => {
if (s.type === AccountType.User) {
Expand All @@ -185,7 +192,7 @@ export function MyAssets() {
});
});

return [transferable, vesting, claimable, bonded, delegated];
return [transferable, vesting, claimable, bonded, delegated, lockedPortal];
}, [sourcesQuery?.accounts, theme.palette]);

const totalBalance = useMemo(() => {
Expand Down Expand Up @@ -274,6 +281,7 @@ export function MyAssets() {
<Stack divider={<Divider flexItem />} spacing={1} flex={1}>
<TokenBalance balance={balances[3]} />
<TokenBalance balance={balances[4]} />
{/* <TokenBalance balance={balances[5]} /> */}
</Stack>
</Stack>
</Grid>
Expand Down
36 changes: 20 additions & 16 deletions src/pages/DashboardPage/Summary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { PropsWithChildren, useEffect, useMemo, useState } from 'react';

import { relativeDateFormat } from '@i18n';
import {
bytesFormatter,
numberWithCommasFormatter,
Expand All @@ -21,12 +20,12 @@ import {
} from '@mui/material';
import Grid from '@mui/material/Unstable_Grid2';
import { AreaChart, Area, ResponsiveContainer, Tooltip, TooltipProps } from 'recharts';
import { useDebounce } from 'use-debounce';

import { useNetworkSummary } from '@api/subsquid-network-squid';
import SquaredChip from '@components/Chip/SquaredChip';
import { HelpTooltip } from '@components/HelpTooltip';
import { Loader } from '@components/Loader';
import { useCountdown } from '@hooks/useCountdown';
import { useContracts } from '@network/useContracts';

export function ColumnLabel({ children, color }: PropsWithChildren<{ color?: string }>) {
Expand Down Expand Up @@ -107,15 +106,24 @@ function OnlineInfo() {
);
}

function CurrentEpochEstimation({ epochEnd }: { epochEnd: number }) {
const timeLeft = useCountdown({ timestamp: epochEnd });

return (
<Stack direction="row" spacing={1}>
<span>Ends in</span>
<SquaredChip
label={<Typography variant="subtitle1">~{timeLeft}</Typography>}
color="warning"
/>
</Stack>
);
}

function CurrentEpoch() {
const { data, isLoading } = useNetworkSummary();

const [epochEnd, setEpochEnd] = useState<number>(Date.now());

const [curTime] = useDebounce(Date.now(), 1000);

const epochEndsIn = useMemo(() => relativeDateFormat(curTime, epochEnd), [curTime, epochEnd]);

useEffect(() => {
if (!data || !data.epoch) return;

Expand All @@ -131,15 +139,7 @@ function CurrentEpoch() {
sx={{ height: 1 }}
loading={isLoading}
title={<SquaredChip label="Current epoch" color="primary" />}
action={
<Stack direction="row" spacing={1}>
<span>Ends in</span>
<SquaredChip
label={<Typography variant="subtitle1">~{epochEndsIn}</Typography>}
color="warning"
/>
</Stack>
}
action={<CurrentEpochEstimation epochEnd={epochEnd} />}
>
<Typography variant="h1">{data?.epoch?.number || 0}</Typography>
</SummarySection>
Expand Down Expand Up @@ -230,11 +230,15 @@ function AprChart({ data }: { data: { date: string; value: number }[] }) {
// contentStyle={{ transition: 'all ease-out 5500ms' }}
content={<AprTooltip />}
animationDuration={0}
// animationEasing="ease-out"
cursor={{
stroke: theme.palette.text.secondary,
strokeWidth: 2,
strokeDasharray: 6,
}}
cursorStyle={{
transition: 'all ease-out 300ms !important',
}}
defaultIndex={Math.max(data.length - 2, 0)}
active
allowEscapeViewBox={{ x: true }}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/GatewaysPage/AddNewGateway.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useMemo, useState } from 'react';
import { peerIdToHex } from '@lib/network';
import { Add } from '@mui/icons-material';
import { LoadingButton } from '@mui/lab';
import { Alert, SxProps } from '@mui/material';
import { SxProps } from '@mui/material';
import { useFormik } from 'formik';
import toast from 'react-hot-toast';
import { useClient } from 'wagmi';
Expand Down Expand Up @@ -117,7 +117,7 @@ export function AddGatewayDialog({

onClose();
} catch (e: unknown) {
toast.custom(<Alert color="error">{errorMessage(e)}</Alert>);
toast.error(errorMessage(e));
}
},
});
Expand Down Expand Up @@ -160,7 +160,7 @@ export function AddGatewayDialog({
showErrorOnlyOfTouched
id="peerId"
label={
<HelpTooltip title="Lorem ipsum dolor sit amet consectetur adipisicing elit">
<HelpTooltip title="A PeerID is a unique identifier that distinguishes one peer from another within the SQD Network">
<span>Peer ID</span>
</HelpTooltip>
}
Expand Down
Loading
Loading