Skip to content

Commit 619529f

Browse files
authored
chore: Tangle dapp & cloud fixes (#3053)
1 parent 533e9fc commit 619529f

File tree

15 files changed

+87
-35
lines changed

15 files changed

+87
-35
lines changed

.windsurfrules renamed to .windsurf/rules/general.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
trigger: always_on
3+
---
4+
15
# Tangle dApp Monorepo
26

37
This project is Tangle dApp - a monorepo containing multiple dApp projects that serve as the frontend for our custom Substrate-based network/node 'Tangle'. Tangle is a cryptocurrency network created using the Substrate framework, which is part of the Polkadot ecosystem. Tangle is a layer 1 for on-demand services where developers can build and monetize decentralized services using Tangle Blueprints. They can also deploy innovative infrastructure in any blockchain ecosystem.
@@ -61,4 +65,4 @@ Tangle dApp is the main product and focus of the monorepo. Here's the tech stack
6165

6266
# Library: `libs/tangle-shared-ui`
6367

64-
Contains shared logic, hooks, and utility functions between multiple Tangle dApps, such as `tangle-cloud` & `tangle-dapp`. This differs from `ui-components` in that `ui-components` is more geared towards general & re-usable components, not necesarily tied to any context, whereas `libs/tangle-shared-ui` is specific to Tangle-related logic.
68+
Contains shared logic, hooks, and utility functions between multiple Tangle dApps, such as `tangle-cloud` & `tangle-dapp`. This differs from `ui-components` in that `ui-components` is more geared towards general & re-usable components, not necesarily tied to any context, whereas `libs/tangle-shared-ui` is specific to Tangle-related logic.

apps/leaderboard/src/features/leaderboard/components/LeaderboardTable.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CrossCircledIcon } from '@radix-ui/react-icons';
22
import { Spinner } from '@tangle-network/icons';
33
import { Search } from '@tangle-network/icons/Search';
44
import TableStatus from '@tangle-network/tangle-shared-ui/components/tables/TableStatus';
5-
import { NetworkType } from '@tangle-network/tangle-shared-ui/graphql/graphql';
5+
import type { NetworkType } from '@tangle-network/tangle-shared-ui/graphql/graphql';
66
import {
77
Input,
88
isSubstrateAddress,
@@ -206,7 +206,9 @@ export const LeaderboardTable = () => {
206206
pageSize: 15,
207207
});
208208

209-
const [networkTab, setNetworkTab] = useState<NetworkType>('MAINNET');
209+
const [networkTab, setNetworkTab] = useState<NetworkType>(
210+
'MAINNET' as NetworkType,
211+
);
210212

211213
const {
212214
data: latestBlock,

apps/tangle-cloud/src/pages/blueprints/[id]/page.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ import { z } from 'zod';
2222

2323
const RestakeOperatorAction: FC<PropsWithChildren<{ address: string }>> = ({
2424
children,
25-
address,
2625
}) => {
2726
return (
28-
<Link
29-
to={`${TangleDAppPagePath.RESTAKE_OPERATOR}/${address}`}
30-
target="_blank"
31-
>
27+
<Link to={TangleDAppPagePath.RESTAKE_DELEGATE} target="_blank">
3228
{children}
3329
</Link>
3430
);

apps/tangle-cloud/src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export enum PagePath {
1414
}
1515

1616
export enum TangleDAppPagePath {
17-
RESTAKE_OPERATOR = `${TANGLE_DAPP_URL}restake/operators`,
1817
RESTAKE_DEPOSIT = `${TANGLE_DAPP_URL}restake?vault={{vault}}`,
18+
RESTAKE_DELEGATE = `${TANGLE_DAPP_URL}restake/delegate`,
19+
RESTAKE_OPERATOR = `${TANGLE_DAPP_URL}restake/operators`,
1920
}
2021

2122
export type ApprovalConfirmationFormFields = {

apps/tangle-dapp/src/components/AvatarWithText.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { Avatar } from '@tangle-network/ui-components/components/Avatar';
44
import { Typography } from '@tangle-network/ui-components/typography/Typography';
55
import { shortenHex } from '@tangle-network/ui-components/utils/shortenHex';
66
import { shortenString } from '@tangle-network/ui-components/utils/shortenString';
7+
import { toSubstrateAddress } from '@tangle-network/ui-components/utils/toSubstrateAddress';
8+
import useNetworkStore from '@tangle-network/tangle-shared-ui/context/useNetworkStore';
79
import isEqual from 'lodash/isEqual';
8-
import { type ComponentProps, memo, type ReactNode } from 'react';
10+
import { type ComponentProps, memo, type ReactNode, useMemo } from 'react';
911
import { twMerge } from 'tailwind-merge';
1012
import { isHex } from 'viem';
1113

@@ -26,6 +28,14 @@ const AvatarWithText = ({
2628
overrideTypographyProps,
2729
...props
2830
}: Props) => {
31+
const ss58Prefix = useNetworkStore((store) => store.network.ss58Prefix);
32+
33+
const tangleFormattedAddress = useMemo(() => {
34+
return isEthereumAddress(accountAddress)
35+
? accountAddress
36+
: toSubstrateAddress(accountAddress, ss58Prefix);
37+
}, [accountAddress, ss58Prefix]);
38+
2939
return (
3040
<div
3141
{...props}
@@ -36,7 +46,7 @@ const AvatarWithText = ({
3646
>
3747
<Avatar
3848
theme={isEthereumAddress(accountAddress) ? 'ethereum' : 'substrate'}
39-
value={accountAddress}
49+
value={tangleFormattedAddress}
4050
{...overrideAvatarProps}
4151
className={twMerge(
4252
`${getFlexBasic('lg')} shrink-0`,
@@ -55,9 +65,9 @@ const AvatarWithText = ({
5565
)}
5666
>
5767
{identityName ||
58-
(isHex(accountAddress)
59-
? shortenHex(accountAddress)
60-
: shortenString(accountAddress))}
68+
(isHex(tangleFormattedAddress)
69+
? shortenHex(tangleFormattedAddress)
70+
: shortenString(tangleFormattedAddress))}
6171
</Typography>
6272

6373
{description}

apps/tangle-dapp/src/components/Lists/OperatorListItem.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import {
33
Avatar,
44
KeyValueWithButton,
55
shortenString,
6+
toSubstrateAddress,
67
} from '@tangle-network/ui-components';
7-
import { FC } from 'react';
8+
import { FC, useMemo } from 'react';
9+
import useNetworkStore from '@tangle-network/tangle-shared-ui/context/useNetworkStore';
810
import LogoListItem from './LogoListItem';
911

1012
type Props = {
@@ -20,17 +22,25 @@ const OperatorListItem: FC<Props> = ({
2022
rightUpperText,
2123
rightBottomText,
2224
}) => {
23-
const shortAccountAddress = shortenString(accountAddress);
25+
const ss58Prefix = useNetworkStore((store) => store.network.ss58Prefix);
26+
27+
const tangleFormattedAddress = useMemo(() => {
28+
return toSubstrateAddress(accountAddress, ss58Prefix);
29+
}, [accountAddress, ss58Prefix]);
30+
31+
const shortAccountAddress = shortenString(tangleFormattedAddress);
2432
const leftUpperContent = identity ?? shortAccountAddress;
2533

2634
return (
2735
<LogoListItem
28-
logo={<Avatar size="lg" theme="substrate" value={accountAddress} />}
36+
logo={
37+
<Avatar size="lg" theme="substrate" value={tangleFormattedAddress} />
38+
}
2939
leftUpperContent={leftUpperContent}
3040
leftBottomContent={
3141
<KeyValueWithButton
3242
size="sm"
33-
keyValue={accountAddress}
43+
keyValue={tangleFormattedAddress}
3444
valueFontWeight="normal"
3545
valueVariant="body1"
3646
/>

apps/tangle-dapp/src/containers/restaking/RestakeOverviewTabs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ type Props = {
3737
operatorMap: OperatorMap;
3838
operatorTVL?: OperatorTvlGroup['operatorTvl'];
3939
action: RestakeAction;
40+
onOperatorJoined?: () => void;
4041
};
4142

4243
const RestakeOverviewTabs: FC<Props> = ({
4344
operatorConcentration,
4445
operatorMap,
4546
operatorTVL,
4647
action,
48+
onOperatorJoined,
4749
}) => {
4850
const [tab, setTab] = useState(RestakeTab.RESTAKE);
4951

@@ -97,6 +99,7 @@ const RestakeOverviewTabs: FC<Props> = ({
9799
onRestakeClickedPagePath={PagePath.RESTAKE_DELEGATE}
98100
onRestakeClickedQueryParamKey={QueryParamKey.RESTAKE_OPERATOR}
99101
isLoading={isLoadingAssets}
102+
onOperatorJoined={onOperatorJoined}
100103
/>
101104
</TabContent>
102105

apps/tangle-dapp/src/containers/restaking/RestakeTabContent.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode, useCallback, useEffect, type FC } from 'react';
1+
import { ReactNode, useCallback, useEffect, useState, type FC } from 'react';
22
import RestakeTabs from '../../pages/restake/RestakeTabs';
33
import { RestakeAction, RestakeTab } from '../../constants';
44
import DepositForm from '../../pages/restake/deposit/DepositForm';
@@ -30,11 +30,20 @@ type Props = {
3030

3131
const RestakeTabContent: FC<Props> = ({ tab }) => {
3232
const { result: delegatorInfo } = useRestakeDelegatorInfo();
33+
34+
const [refreshTrigger, setRefreshTrigger] = useState(0);
35+
36+
const handleOperatorJoined = useCallback(() => {
37+
setTimeout(() => {
38+
setRefreshTrigger((v) => v + 1);
39+
}, 2000);
40+
}, []);
41+
3342
const {
3443
result: operatorMap,
3544
isLoading: isLoadingOperators,
3645
error: operatorMapError,
37-
} = useRestakeOperatorMap();
46+
} = useRestakeOperatorMap(refreshTrigger);
3847
const { operatorConcentration, operatorTvl } = useRestakeTvl(delegatorInfo);
3948
const navigate = useNavigate();
4049

@@ -84,6 +93,7 @@ const RestakeTabContent: FC<Props> = ({ tab }) => {
8493
onRestakeClickedPagePath={PagePath.RESTAKE_DELEGATE}
8594
onRestakeClickedQueryParamKey={QueryParamKey.RESTAKE_OPERATOR}
8695
isLoading={isLoadingOperators}
96+
onOperatorJoined={handleOperatorJoined}
8797
/>
8898
);
8999
case RestakeTab.BLUEPRINTS:

apps/tangle-dapp/src/features/points/data/useActiveAccountPoints.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useMemo } from 'react';
66
import { ReactQueryKey } from '../../../constants/reactQuery';
77
import useNetworkStore from '@tangle-network/tangle-shared-ui/context/useNetworkStore';
88
import { NetworkId } from '@tangle-network/ui-components/constants/networks';
9-
import { NetworkType } from '@tangle-network/tangle-shared-ui/graphql/graphql';
9+
import type { NetworkType } from '@tangle-network/tangle-shared-ui/graphql/graphql';
1010

1111
const GetAccountPointsQueryDocument = graphql(/* GraphQL */ `
1212
query GetAccountPoints($account: String!) {
@@ -37,7 +37,9 @@ export default function useActiveAccountPoints() {
3737
queryKey: [ReactQueryKey.GetAccountPoints, activeAccount],
3838
queryFn: () =>
3939
fetcher(
40-
network.id === NetworkId.TANGLE_MAINNET ? 'MAINNET' : 'TESTNET',
40+
(network.id === NetworkId.TANGLE_MAINNET
41+
? 'MAINNET'
42+
: 'TESTNET') as NetworkType,
4143
activeAccount,
4244
),
4345
retry: 10,

apps/tangle-dapp/src/pages/restake/delegate/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const RestakeDelegateForm: FC<Props> = ({ assets }) => {
6969
watch,
7070
formState: { errors, isValid, isSubmitting },
7171
} = useForm<DelegationFormFields>({
72-
mode: 'onBlur',
72+
mode: 'onChange',
7373
});
7474

7575
const selectedOperatorAddress = watch('operatorAccountId');

0 commit comments

Comments
 (0)