From 3102001453207c95fd7772026c3573cb1528605e Mon Sep 17 00:00:00 2001 From: vidvidvid Date: Fri, 20 Dec 2024 10:43:34 +0100 Subject: [PATCH] remove zustand --- packages/contracts/package.json | 2 +- packages/ui/app/_components/Navbar.tsx | 5 ++--- .../ui/app/_components/markets/NetworkSelector.tsx | 4 ++-- packages/ui/context/MultiIonicContext.tsx | 11 +++++++++-- packages/ui/package.json | 3 +-- packages/ui/store/Store.ts | 12 ------------ yarn.lock | 3 +-- 7 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 packages/ui/store/Store.ts diff --git a/packages/contracts/package.json b/packages/contracts/package.json index c6708b19e..cefe08b53 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -59,4 +59,4 @@ "typescript": "^5.5.3", "viem": "^2.21.55" } -} \ No newline at end of file +} diff --git a/packages/ui/app/_components/Navbar.tsx b/packages/ui/app/_components/Navbar.tsx index 98c5b2a9b..2d9116250 100644 --- a/packages/ui/app/_components/Navbar.tsx +++ b/packages/ui/app/_components/Navbar.tsx @@ -12,11 +12,10 @@ import { http, createConfig, useChainId } from 'wagmi'; import { base, mode } from 'wagmi/chains'; import { coinbaseWallet } from 'wagmi/connectors'; -import { useStore } from '@ui/store/Store'; - import ConnectButton from './ConnectButton'; import DynamicSubNav from './DynamicSubNav'; import { BlackCreateWalletButton } from './navbar/BlackCreateWalletButton'; +import { useMultiIonic } from '@ui/context/MultiIonicContext'; // import { useEthersSigner } from '@ui/hooks/useEthersSigner'; @@ -42,7 +41,7 @@ export default function Navbar() { const [isActive, setIsActive] = useState(false); const [swapWidgetOpen, setSwapWidgetOpen] = useState(false); const pathname = usePathname(); - const dropChain = useStore((state) => state.dropChain); + const { dropChain } = useMultiIonic(); const chainId = useChainId(); // const signer = useEthersSigner(); diff --git a/packages/ui/app/_components/markets/NetworkSelector.tsx b/packages/ui/app/_components/markets/NetworkSelector.tsx index fefcf6cb8..0bb5a90e4 100644 --- a/packages/ui/app/_components/markets/NetworkSelector.tsx +++ b/packages/ui/app/_components/markets/NetworkSelector.tsx @@ -12,7 +12,7 @@ import { TooltipTrigger } from '@ui/components/ui/tooltip'; import { pools } from '@ui/constants/index'; -import { useStore } from '@ui/store/Store'; +import { useMultiIonic } from '@ui/context/MultiIonicContext'; interface INetworkSelector { dropdownSelectedChain: number; @@ -40,7 +40,7 @@ function NetworkSelector({ }: INetworkSelector) { const pathname = usePathname(); const searchParams = useSearchParams(); - const setDropChain = useStore((state) => state.setDropChain); + const { setDropChain } = useMultiIonic(); const orderedNetworks = ACTIVE_NETWORKS.map((networkName) => Object.entries(pools).find(([_, pool]) => pool.name === networkName) diff --git a/packages/ui/context/MultiIonicContext.tsx b/packages/ui/context/MultiIonicContext.tsx index e675c10fc..797604332 100644 --- a/packages/ui/context/MultiIonicContext.tsx +++ b/packages/ui/context/MultiIonicContext.tsx @@ -46,6 +46,8 @@ export interface MultiIonicContextData { setGlobalLoading: Dispatch; setIsSidebarCollapsed: Dispatch; walletClient?: WalletClient; + dropChain: string; + setDropChain: (val: string) => void; } export const MultiIonicContext = createContext< @@ -76,6 +78,7 @@ export const MultiIonicProvider = ( >(); const [isGlobalLoading, setGlobalLoading] = useState(false); const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(); + const [dropChain, setDropChain] = useState('34443'); const [sdks, securities, chainIds] = useMemo(() => { const _sdks: IonicSdk[] = []; @@ -204,7 +207,9 @@ export const MultiIonicProvider = ( setAddress, setGlobalLoading, setIsSidebarCollapsed, - walletClient + walletClient, + dropChain, + setDropChain }; }, [ sdks, @@ -222,7 +227,9 @@ export const MultiIonicProvider = ( walletClient, setAddress, isSidebarCollapsed, - setIsSidebarCollapsed + setIsSidebarCollapsed, + dropChain, + setDropChain ]); return ( diff --git a/packages/ui/package.json b/packages/ui/package.json index 9aba521e2..df6b1be2e 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -63,8 +63,7 @@ "tailwind-scrollbar-hide": "^1.1.7", "tailwindcss-animate": "^1.0.7", "viem": "^2.21.34", - "wagmi": "^2.12.25", - "zustand": "^4.5.4" + "wagmi": "^2.12.25" }, "devDependencies": { "@types/node": "^20", diff --git a/packages/ui/store/Store.ts b/packages/ui/store/Store.ts deleted file mode 100644 index 513584017..000000000 --- a/packages/ui/store/Store.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { create } from 'zustand'; - -interface IStore { - dropChain: string; - setDropChain: (val: string) => void; -} - -export const useStore = create((set) => ({ - dropChain: '34443', - setDropChain: (data: string) => - set((state) => ({ ...state, dropChain: data })) -})); diff --git a/yarn.lock b/yarn.lock index ec51e175c..0de3eb3e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2466,7 +2466,6 @@ __metadata: typescript: "npm:^5.5.3" viem: "npm:^2.21.34" wagmi: "npm:^2.12.25" - zustand: "npm:^4.5.4" languageName: unknown linkType: soft @@ -27637,7 +27636,7 @@ __metadata: languageName: node linkType: hard -"zustand@npm:^4.5.4, zustand@npm:^4.5.5": +"zustand@npm:^4.5.5": version: 4.5.5 resolution: "zustand@npm:4.5.5" dependencies: