Skip to content

Commit 775d95f

Browse files
committed
SD-91: Improve activity history display and transaction handling
1 parent 94d9151 commit 775d95f

33 files changed

+1071
-257
lines changed

package-lock.json

Lines changed: 440 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@number-flow/react": "^0.5.7",
2626
"@radix-ui/react-dialog": "^1.1.6",
2727
"@radix-ui/react-popover": "^1.1.13",
28+
"@radix-ui/react-tooltip": "^1.2.7",
2829
"@react-hookz/web": "^25.1.0",
2930
"@reown/appkit": "^1.7.0",
3031
"@reown/appkit-adapter-wagmi": "^1.7.0",
@@ -49,6 +50,7 @@
4950
"ts-pattern": "^5.6.2",
5051
"tsafe": "^1.8.5",
5152
"utility-types": "^3.11.0",
53+
"uuid": "^11.1.0",
5254
"viem": "^2.23.14",
5355
"vite-plugin-svgr": "^4.3.0",
5456
"wagmi": "^2.14.15",

src/domains/misc/components/AccountTypeIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled, { css } from 'styled-components';
22

3-
import ChainIcon from 'src/domains/chains/components/ChainIcon.tsx';
3+
import ChainIcon from 'src/domains/chains/components/ChainIcon';
44
import CIcon from 'src/domains/misc/components/CIcon';
55
import vars from 'src/domains/styling/utils/vars';
66

src/domains/misc/components/CIcon/CIcon.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ComponentProps, forwardRef } from 'react';
12
import styled from 'styled-components';
23

34
import { icons, IconName } from './icons';
@@ -10,27 +11,32 @@ type Props = {
1011
color?: string,
1112
strokeWidth?: number,
1213
className?: string,
13-
};
14+
} & ComponentProps<'svg'>;
1415

15-
const CIcon = ({
16+
const CIcon = forwardRef<SVGSVGElement, Props>(({
1617
icon,
1718
size = 24,
1819
color,
1920
strokeWidth = 0,
2021
className,
21-
}: Props) => {
22+
...props
23+
}, ref) => {
2224
const IconComponent = icons[icon];
2325

2426
return (
2527
<Icon
28+
ref={ref}
2629
as={IconComponent}
2730
$size={size}
2831
$color={color}
2932
$strokeWidth={strokeWidth}
3033
className={className}
34+
{...props}
3135
/>
3236
);
33-
};
37+
});
38+
39+
CIcon.displayName = 'CIcon';
3440

3541
export default styled(CIcon)``;
3642

src/domains/misc/components/InfoPair.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
import { styled } from 'styled-components';
55

66
import CIcon from 'src/domains/misc/components/CIcon';
7+
import Tooltip from 'src/domains/misc/components/Tooltip';
78
import { typography } from 'src/domains/styling/utils/tokens';
89
import vars from 'src/domains/styling/utils/vars';
910

@@ -20,7 +21,11 @@ const InfoPair = ({ label, className, tooltipText, ...props }: Props) => (
2021
<ContainerHorizontal className={className}>
2122
<Label>
2223
{label}
23-
{tooltipText && <CIcon icon="Info" color={vars('--color-neutral-foreground-4-rest')} />}
24+
{tooltipText && (
25+
<Tooltip text={tooltipText}>
26+
<CIcon icon="Info" color={vars('--color-neutral-foreground-4-rest')} size={16} />
27+
</Tooltip>
28+
)}
2429
</Label>
2530
<Separator />
2631
<Value>

src/domains/misc/components/Layout/TopBar/TopBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { useMediaQuery } from '@react-hookz/web';
22
import styled from 'styled-components';
33

44
import ChainSelector from 'src/domains/chains/components/ChainSelector';
5-
import ConnectModal from 'src/domains/chains/components/ConnectModal.tsx';
5+
import ConnectModal from 'src/domains/chains/components/ConnectModal';
66
import { useWallet } from 'src/domains/chains/components/WalletProvider';
77
import Button from 'src/domains/misc/components/Button';
8+
import { useModal } from 'src/domains/misc/components/Modal';
89
import { BOTTOM_MENU_BREAKPOINT } from 'src/domains/misc/consts/consts';
910
import formatAddress from 'src/domains/misc/utils/formatAddress';
1011
import { typography } from 'src/domains/styling/utils/tokens';
1112
import vars from 'src/domains/styling/utils/vars';
1213

13-
import { useModal } from '../../Modal';
1414
import Navigation from '../Navigation';
1515

1616
import Brand from './Brand';

src/domains/misc/components/Modal/Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useToast } from 'src/domains/misc/components/Toast';
1010
import { boxShadows } from 'src/domains/styling/utils/tokens';
1111
import vars from 'src/domains/styling/utils/vars';
1212

13-
import { useModalControls } from './';
13+
import { useModalControls } from './ModalProvider';
1414

1515
type Config = {
1616
title?: string | ReactElement,

src/domains/misc/components/Modal/ModalProvider.tsx

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { v4 as uuidv4 } from 'uuid';
1515

1616
import vars from 'src/domains/styling/utils/vars';
1717

18-
import Modal from './Modal';
19-
2018
type Modal = {
2119
id: string,
2220
modal: ReactElement,
@@ -26,8 +24,6 @@ type Modal = {
2624
type ModalContextType = {
2725
mount: (modal: Modal, options?: { checkDuplicateBy?: string[] }) => void,
2826
unmount: (id: string) => void,
29-
updateId: (oldId: string, newId: string) => Promise<Modal | null>,
30-
getModals: () => Modal[],
3127
modals: Modal[],
3228
};
3329

@@ -59,31 +55,8 @@ export const ModalProvider = ({ children }: { children: ReactNode }) => {
5955
setModals(prev => prev.filter(m => m.id !== id));
6056
}, []);
6157

62-
const updateId = useCallback(async (oldId: string, newId: string): Promise<Modal | null> => {
63-
return new Promise(resolve => {
64-
setModals(prev => {
65-
const modalIndex = prev.findIndex(modal => modal.id === oldId);
66-
67-
if (modalIndex === -1) {
68-
resolve(null);
69-
return prev;
70-
}
71-
72-
const updatedModal = { ...prev[modalIndex], id: newId };
73-
const updatedModals = prev.map((modal, index) =>
74-
index === modalIndex ? updatedModal : modal
75-
);
76-
77-
resolve(updatedModal);
78-
return updatedModals;
79-
});
80-
});
81-
}, []);
82-
83-
const getModals = () => modals;
84-
8558
return (
86-
<ModalContext.Provider value={{ mount, unmount, updateId, modals, getModals }}>
59+
<ModalContext.Provider value={{ mount, unmount, modals }}>
8760
{children}
8861
{createPortal(
8962
<AnimatePresence>
@@ -123,9 +96,9 @@ export const useModals = () => {
12396
};
12497

12598
export const useModal = () => {
126-
const { mount, unmount, modals, updateId: _updateId } = useModals();
127-
const defaultId = useRef(uuidv4()).current;
128-
const currentIdRef = useRef<string>(defaultId);
99+
const { mount, unmount, modals } = useModals();
100+
const [defaultId] = useState(uuidv4());
101+
const currentIdRef = useRef(defaultId);
129102

130103
const open = useCallback((modalElement: ReactElement, options?: { idOverride?: string }) => {
131104
const modalId = options?.idOverride ?? defaultId;
@@ -137,23 +110,18 @@ export const useModal = () => {
137110
unmount(currentIdRef.current);
138111
}, [unmount]);
139112

140-
const updateId = async (newId: string) => {
141-
return _updateId(currentIdRef.current, newId);
142-
};
143-
144113
const modal = modals.find(m => m.id === currentIdRef.current);
145114

146115
return {
147116
open,
148117
close,
149118
isOpen: !!modal,
150-
updateId,
151119
};
152120
};
153121

154122
export const useModalControls = () => {
155123
const ctx = useContext(ModalControlsContext);
156-
if (!ctx) throw new Error('useModal must be used within ModalControlsProvider');
124+
if (!ctx) throw new Error('useModalControls must be used within ModalControlsProvider');
157125

158126
return ctx;
159127
};

src/domains/misc/components/Providers/Providers.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import { WagmiProvider } from 'wagmi';
66
import WalletProvider from 'src/domains/chains/components/WalletProvider';
77
import { wagmiAdapter } from 'src/domains/chains/utils/clients';
88
import { Definition } from 'src/domains/chains/utils/definitions';
9+
import { ModalProvider } from 'src/domains/misc/components/Modal';
910
import { ToastsProvider } from 'src/domains/misc/components/Toast';
1011
import { QueryClientProvider } from 'src/domains/misc/utils/queryClient';
1112
import WasmProvider from 'src/domains/shielder/utils/WasmProvider';
1213

13-
import { ModalProvider } from '../Modal';
14-
1514
import GlobalStylesWithTheme from './GlobalStylesWithTheme';
1615
import PostHogProvider from './PostHogProvider';
1716

src/domains/misc/components/Toast/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const Toast = ({
5353
return (
5454
<Container title="Toast">
5555
<IconContainer>
56-
{status === 'inProgress' ? <Spinner icon="Spinner" size={16} /> : <CIcon size={16} icon={icon} color={color} />}
56+
{status === 'inProgress' ? <Spinner icon="Spinner" size={20} /> : <CIcon size={20} icon={icon} color={color} />}
5757
</IconContainer>
5858
<RightSection>
5959
<Header>

0 commit comments

Comments
 (0)