diff --git a/package-lock.json b/package-lock.json index 416ca78..65883f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@aarc-xyz/deposit-widget": "^0.2.1", - "@clerk/nextjs": "^5.2.8", + "@clerk/nextjs": "^5.4.1", "@clerk/themes": "^2.1.1", "@headlessui/react": "^1.7.19", "@popperjs/core": "^2.11.8", @@ -2307,12 +2307,12 @@ "license": "MIT" }, "node_modules/@clerk/backend": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@clerk/backend/-/backend-1.4.3.tgz", - "integrity": "sha512-wj4qsZO6iNiY9vF7vLH5v1f3oLh1yCLgFa0PedLzJAIJgepZl23C1/ubrRm7vyewjQEMHZwod4816mZlHDfoqA==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@clerk/backend/-/backend-1.9.2.tgz", + "integrity": "sha512-8vCYux8Xbu5TQ2iq9tYuDnNhv3K/XhZ+34QJG+n4ZX4w4FfTTuzwb5OylcmP69vPvYybhoQfjpK57kBOW22deg==", "dependencies": { - "@clerk/shared": "2.4.1", - "@clerk/types": "4.9.1", + "@clerk/shared": "2.6.2", + "@clerk/types": "4.19.0", "cookie": "0.5.0", "snakecase-keys": "5.4.4", "tslib": "2.4.1" @@ -2327,12 +2327,12 @@ "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, "node_modules/@clerk/clerk-react": { - "version": "5.2.10", - "resolved": "https://registry.npmjs.org/@clerk/clerk-react/-/clerk-react-5.2.10.tgz", - "integrity": "sha512-qJZ79aiB80cUuqccKqhk6QImGIji4y1bjK1xbGnqiAthtMegxFShLJwEsrF7nl0Rw5yM9cphiwETEqBWfIPL4Q==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@clerk/clerk-react/-/clerk-react-5.7.0.tgz", + "integrity": "sha512-VCYj/Qhm4P5u0A3X1M+yycod8cz8flFwtpnI8+ajGUDmMdel9iuR5ix01cgsHfyPuamfiuP1a4xNg7F0d+2P7Q==", "dependencies": { - "@clerk/shared": "2.4.1", - "@clerk/types": "4.9.1", + "@clerk/shared": "2.6.2", + "@clerk/types": "4.19.0", "tslib": "2.4.1" }, "engines": { @@ -2349,14 +2349,14 @@ "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, "node_modules/@clerk/nextjs": { - "version": "5.2.8", - "resolved": "https://registry.npmjs.org/@clerk/nextjs/-/nextjs-5.2.8.tgz", - "integrity": "sha512-dy4K1e2ygWBsDjnLmQKtoeRpoToCNFRXMu6GN4VesE9/mOYNXKiyJE2/DY6lGV3oR2f8Qr9YjcXzphRnf1d/OQ==", - "dependencies": { - "@clerk/backend": "1.4.3", - "@clerk/clerk-react": "5.2.10", - "@clerk/shared": "2.4.1", - "@clerk/types": "4.9.1", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@clerk/nextjs/-/nextjs-5.4.1.tgz", + "integrity": "sha512-rW/UIdsR0hDd90OTy0HS1dk69y8cO24GjnMXX7A2WhN2LmLtvC6K8pIX2w/mOajWNm6MTSBuzTDwLB8rYii9Ww==", + "dependencies": { + "@clerk/backend": "1.9.2", + "@clerk/clerk-react": "5.7.0", + "@clerk/shared": "2.6.2", + "@clerk/types": "4.19.0", "crypto-js": "4.2.0", "path-to-regexp": "6.2.2", "server-only": "0.0.1", @@ -2376,12 +2376,12 @@ "license": "0BSD" }, "node_modules/@clerk/shared": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@clerk/shared/-/shared-2.4.1.tgz", - "integrity": "sha512-sApuz6hDRIai4Jwo/fBcihX74+DdrKLt08LkEVrooh/7zc0ipDOSGlqmAy15yNuKPaxpemp/9nW4T8gq6uIr9Q==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/@clerk/shared/-/shared-2.6.2.tgz", + "integrity": "sha512-RkrNknIr98GPu3srXLhjJViC1Mom1gUsRMNnf1deibX2yvRnndloZGnFb0qxf+pFL/NCkKd3nSHtK3eCJQrVYQ==", "hasInstallScript": true, "dependencies": { - "@clerk/types": "4.9.1", + "@clerk/types": "4.19.0", "glob-to-regexp": "0.4.1", "js-cookie": "3.0.5", "std-env": "^3.7.0", @@ -2433,9 +2433,9 @@ "license": "0BSD" }, "node_modules/@clerk/types": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/@clerk/types/-/types-4.9.1.tgz", - "integrity": "sha512-fCmqzPBFh0rH9TlUVPpvPW225DtGJDuCv5GecwuuzD8hcgwGetTfRSDRNl5Dub5aJuqYWGQQCCnKfnfCrhZvrA==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@clerk/types/-/types-4.19.0.tgz", + "integrity": "sha512-bDN/nRUD5PFCehQ+Kjdcft0I3b9CIyCcY3OBNDSc1L6RQhlXH+J48EtaP/cbRdslb83LJiBPQ2i/gV4VgblzwA==", "dependencies": { "csstype": "3.1.1" }, diff --git a/package.json b/package.json index a3e1125..50933e0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "@aarc-xyz/deposit-widget": "^0.2.1", - "@clerk/nextjs": "^5.2.8", + "@clerk/nextjs": "^5.4.1", "@clerk/themes": "^2.1.1", "@headlessui/react": "^1.7.19", "@popperjs/core": "^2.11.8", diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx index 999dd6d..1df0898 100644 --- a/src/app/home/page.tsx +++ b/src/app/home/page.tsx @@ -4,13 +4,15 @@ import { Suspense } from "react"; import Loader from "@/components/Loader"; import LockerNav from "@/components/LockerNav"; -import { LockerPortfolioProvider } from "@/components/LockerPortfolioContext"; +import { LockerProvider } from "@/providers/LockerProvider"; import { LockerDb, PolicyDb } from "@/types"; import { TABLE_LOCKERS } from "@/utils/supabase/tables"; -import { supabaseServerClient } from "../utils/server"; +import { createClerkSupabaseClientSsr } from "../utils/server"; async function HomePage() { + const supabaseServerClient = createClerkSupabaseClientSsr(); + const { data: lockersData, error: lockersError } = await supabaseServerClient .from(TABLE_LOCKERS) @@ -46,13 +48,13 @@ async function HomePage() { return (
}> - - +
); diff --git a/src/app/utils/server.ts b/src/app/utils/server.ts index 940b83a..c5a1781 100644 --- a/src/app/utils/server.ts +++ b/src/app/utils/server.ts @@ -32,5 +32,3 @@ export function createClerkSupabaseClientSsr() { } ); } - -export const supabaseServerClient = createClerkSupabaseClientSsr(); diff --git a/src/components/LockerNav.tsx b/src/components/LockerNav.tsx index 0542f02..1db86a5 100644 --- a/src/components/LockerNav.tsx +++ b/src/components/LockerNav.tsx @@ -1,12 +1,12 @@ "use client"; +import { useLocker } from "../providers/LockerProvider"; import LockerCreate from "./LockerCreate"; import LockerPortfolio from "./LockerPortfolio"; -import { useLockerPortfolio } from "./LockerPortfolioContext"; import LockerSetup from "./LockerSetup"; function LockerNav() { - const { lockers, policies } = useLockerPortfolio(); + const { lockers, policies } = useLocker(); const shouldCreateLocker = lockers && lockers.length === 0; if (shouldCreateLocker) return ; diff --git a/src/components/LockerPortfolio.tsx b/src/components/LockerPortfolio.tsx index cf6d0e7..0d54425 100644 --- a/src/components/LockerPortfolio.tsx +++ b/src/components/LockerPortfolio.tsx @@ -17,10 +17,10 @@ import { getFundedChainIds } from "@/utils/getFundedChainIds"; import { isChainSupported } from "@/utils/isChainSupported"; import { isTestnet } from "@/utils/isTestnet"; -import { useLockerPortfolio } from "./LockerPortfolioContext"; +import { useLocker } from "../providers/LockerProvider"; function LockerPortfolio() { - const { lockers, policies, txs, offrampAddresses } = useLockerPortfolio(); + const { lockers, policies, txs, offrampAddresses } = useLocker(); const [errorMessage, setErrorMessage] = useState(""); const [tokenList, setTokenList] = useState([]); const [fundedChainIds, setFundedChainIds] = useState([]); diff --git a/src/components/LockerSetup.tsx b/src/components/LockerSetup.tsx index 2ad8327..0a20d09 100644 --- a/src/components/LockerSetup.tsx +++ b/src/components/LockerSetup.tsx @@ -10,13 +10,13 @@ import { useAccount } from "wagmi"; import ChannelPieChart from "@/components/ChannelPieChart"; import ChannelSelection from "@/components/ChannelSelection"; import DistributionBox from "@/components/DistributionBox"; -import Steps from "@/components/Steps"; import TxTable from "@/components/TxTable"; import { disclosures } from "@/data/constants/disclosures"; import { errors } from "@/data/constants/errorMessages"; import { useConnectModal } from "@/hooks/useConnectModal"; import { usePolicyReviewModal } from "@/hooks/usePolicyReviewModal"; import useSmartAccount from "@/hooks/useSmartAccount"; +import { useLocker } from "@/providers/LockerProvider"; import { createPolicy } from "@/services/lockers"; import { Automation, @@ -26,10 +26,10 @@ import { } from "@/types"; import { isChainSupported } from "@/utils/isChainSupported"; -import { useLockerPortfolio } from "./LockerPortfolioContext"; +import Steps from "./Steps"; function LockerSetup() { - const { lockers } = useLockerPortfolio(); + const { lockers } = useLocker(); const [sendToAddress, setSendToAddress] = useState( lockers[0].ownerAddress ); diff --git a/src/app/utils/useJwt.ts b/src/hooks/useJwt.ts similarity index 100% rename from src/app/utils/useJwt.ts rename to src/hooks/useJwt.ts diff --git a/src/app/utils/useRealtimeTable.ts b/src/hooks/useRealtimeTable.ts similarity index 96% rename from src/app/utils/useRealtimeTable.ts rename to src/hooks/useRealtimeTable.ts index f23da4a..f01020b 100644 --- a/src/app/utils/useRealtimeTable.ts +++ b/src/hooks/useRealtimeTable.ts @@ -7,8 +7,9 @@ import { } from "@supabase/supabase-js"; import { useCallback, useEffect, useState } from "react"; -import { convertKeysToCamelCase } from "../../utils/strings"; -import { supabaseJwtClient } from "../../utils/supabase/jwt"; +import { convertKeysToCamelCase } from "@/utils/strings"; +import { supabaseJwtClient } from "@/utils/supabase/jwt"; + import { useJwt } from "./useJwt"; export const useRealtimeTable = ( diff --git a/src/components/LockerPortfolioContext.tsx b/src/providers/LockerProvider.tsx similarity index 91% rename from src/components/LockerPortfolioContext.tsx rename to src/providers/LockerProvider.tsx index be9938b..752f626 100644 --- a/src/components/LockerPortfolioContext.tsx +++ b/src/providers/LockerProvider.tsx @@ -2,7 +2,7 @@ import { createContext, ReactNode, useContext, useMemo, useState } from "react"; -import { useRealtimeTable } from "@/app/utils/useRealtimeTable"; +import { useRealtimeTable } from "@/hooks/useRealtimeTable"; import { LockerDb, PolicyDb, Tx } from "@/types"; import { TABLE_LOCKERS, @@ -29,7 +29,7 @@ const LockerPortfolioContext = createContext< >(undefined); // Provider component -export function LockerPortfolioProvider({ +export function LockerProvider({ initialLockers, initialPolicies, initialOfframpAddresses, @@ -73,7 +73,7 @@ export function LockerPortfolioProvider({ } // Custom hook for accessing the context -export const useLockerPortfolio = (): LockerPortfolioContextProps => { +export const useLocker = (): LockerPortfolioContextProps => { const context = useContext(LockerPortfolioContext); if (!context) { throw new Error(