diff --git a/apps/deploy-web/src/components/deployments/DeploymentList.tsx b/apps/deploy-web/src/components/deployments/DeploymentList.tsx index 5003ab3cab..bd8db015d8 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentList.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentList.tsx @@ -208,12 +208,7 @@ export const DeploymentList: React.FunctionComponent = () => { )} {filteredDeployments?.length === 0 && !isLoadingDeployments && !search && ( - 0)} - isWalletConnected={isWalletConnected} - showTemplatesButton - /> + 0)} showTemplatesButton /> )} {(!filteredDeployments || filteredDeployments?.length === 0) && isLoadingDeployments && !search && ( diff --git a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx index 28a935b07b..c5cecdc6c0 100644 --- a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx +++ b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx @@ -19,14 +19,12 @@ import { udenomToDenom } from "@src/utils/mathHelpers"; import { uaktToAKT } from "@src/utils/priceUtils"; import { UrlService } from "@src/utils/urlUtils"; import { ExternalLink } from "../shared/ExternalLink"; -import { WalletConnectionButtons } from "../wallet/WalletConnectionButtons"; import { QontoConnector, QontoStepIcon } from "./Stepper"; export const DEPENDENCIES = { useWallet, useWalletBalance, useChainParam, - WalletConnectionButtons, AddFundsLink }; @@ -81,13 +79,6 @@ export const GetStartedStepper: React.FunctionComponent<{ dependencies?: typeof - {!isWalletConnected && ( -

- You can pay using either USD (fiat) or with crypto ($AKT or $USDC). To pay with USD, click "Start Trial". To pay with crypto, click "Connect - Wallet" -

- )} - {isWalletConnected && !isManagedWallet && (
@@ -132,13 +123,9 @@ export const GetStartedStepper: React.FunctionComponent<{ dependencies?: typeof )} {!isWalletConnected && ( -
-
- - Billing is not set up -
- - +
+ + Billing is not set up
)} diff --git a/apps/deploy-web/src/components/home/NoDeploymentsState.tsx b/apps/deploy-web/src/components/home/NoDeploymentsState.tsx index 24325e5edd..f9d15484ac 100644 --- a/apps/deploy-web/src/components/home/NoDeploymentsState.tsx +++ b/apps/deploy-web/src/components/home/NoDeploymentsState.tsx @@ -2,27 +2,20 @@ import React from "react"; import { Button, Card, CardContent } from "@akashnetwork/ui/components"; import { MultiplePages, Rocket } from "iconoir-react"; -import { useAtom } from "jotai"; import Link from "next/link"; -import { WalletConnectionButtons } from "@src/components/wallet/WalletConnectionButtons"; import { useServices } from "@src/context/ServicesProvider"; -import { useCustomUser } from "@src/hooks/useCustomUser"; import { useNewDeploymentUrl } from "@src/hooks/useNewDeploymentUrl/useNewDeploymentUrl"; -import walletStore from "@src/store/walletStore"; type Props = { onDeployClick: () => void; hasDeployments?: boolean; - isWalletConnected?: boolean; showTemplatesButton?: boolean; }; -export const NoDeploymentsState: React.FC = ({ onDeployClick, hasDeployments = false, isWalletConnected = true, showTemplatesButton = true }) => { +export const NoDeploymentsState: React.FC = ({ onDeployClick, hasDeployments = false, showTemplatesButton = true }) => { const { urlService } = useServices(); const newDeploymentUrl = useNewDeploymentUrl(); - const [isSignedInWithTrial] = useAtom(walletStore.isSignedInWithTrial); - const { user } = useCustomUser(); const title = hasDeployments ? "No active deployments." : "No deployments yet."; @@ -34,36 +27,28 @@ export const NoDeploymentsState: React.FC = ({ onDeployClick, hasDeployme

{title}

- {isSignedInWithTrial && !user && ( -

If you are expecting to see some, you may need to sign in or connect a wallet

- )} - {showTemplatesButton && (

Use one of our most popular templates below or create your first deployment using our SDL builder.

)} - {isWalletConnected ? ( -
- + {showTemplatesButton && ( + - {showTemplatesButton && ( - - )} -
- ) : ( - - )} + )} +
); diff --git a/apps/deploy-web/src/components/layout/WalletStatus.spec.tsx b/apps/deploy-web/src/components/layout/WalletStatus.spec.tsx index 65a825edff..167bf7311d 100644 --- a/apps/deploy-web/src/components/layout/WalletStatus.spec.tsx +++ b/apps/deploy-web/src/components/layout/WalletStatus.spec.tsx @@ -17,11 +17,9 @@ describe(WalletStatus.name, () => { expect(screen.queryByLabelText("Connected wallet name and balance")).not.toBeInTheDocument(); }); - it("renders the WalletConnectionButtons when no wallet is connected", () => { - const WalletConnectionButtons = vi.fn(ComponentMock); - setup({ isWalletConnected: false, dependencies: { WalletConnectionButtons } }); + it("renders nothing when no wallet is connected", () => { + setup({ isWalletConnected: false }); - expect(WalletConnectionButtons).toHaveBeenCalled(); expect(screen.queryByLabelText("Connected wallet name and balance")).not.toBeInTheDocument(); }); @@ -78,7 +76,6 @@ describe(WalletStatus.name, () => { refetch: vi.fn() }) as unknown as ReturnType, ManagedWalletPopup: vi.fn(ComponentMock) as unknown as typeof DEPENDENCIES.ManagedWalletPopup, - WalletConnectionButtons: vi.fn(ComponentMock) as unknown as typeof DEPENDENCIES.WalletConnectionButtons, FormattedNumber: ({ value }: { value: number }) => ${value}, ...input.dependencies } as unknown as typeof DEPENDENCIES; diff --git a/apps/deploy-web/src/components/layout/WalletStatus.tsx b/apps/deploy-web/src/components/layout/WalletStatus.tsx index 91f28b6d06..00cc3bf060 100644 --- a/apps/deploy-web/src/components/layout/WalletStatus.tsx +++ b/apps/deploy-web/src/components/layout/WalletStatus.tsx @@ -7,13 +7,11 @@ import { NavArrowDown, Wallet } from "iconoir-react"; import { useWallet } from "@src/context/WalletProvider"; import { useWalletBalance } from "@src/hooks/useWalletBalance"; import { ManagedWalletPopup } from "../wallet/ManagedWalletPopup/ManagedWalletPopup"; -import { WalletConnectionButtons } from "../wallet/WalletConnectionButtons"; export const DEPENDENCIES = { useWallet, useWalletBalance, ManagedWalletPopup, - WalletConnectionButtons, FormattedNumber }; @@ -64,9 +62,7 @@ export function WalletStatus({ dependencies: d = DEPENDENCIES }: Props = {}) { - ) : ( - - ) + ) : null ) : (
diff --git a/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.spec.tsx b/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.spec.tsx deleted file mode 100644 index d78b0ec480..0000000000 --- a/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.spec.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { describe, expect, it, vi } from "vitest"; -import { mock } from "vitest-mock-extended"; - -import { ConnectManagedWalletButton } from "./ConnectManagedWalletButton"; - -import { render } from "@testing-library/react"; - -describe(ConnectManagedWalletButton.name, () => { - it("renders button enabled when blockchain is up", () => { - const { getByText } = setup({ isBlockchainDown: false }); - - expect(getByText("Start Trial").parentElement).not.toHaveAttribute("disabled"); - }); - - it("renders button disabled when blockchain is unavailable", () => { - const { getByText } = setup({ isBlockchainDown: true }); - - expect(getByText("Start Trial").parentElement).toHaveAttribute("disabled"); - }); - - function setup(input?: { isRegistered?: boolean; isBlockchainDown?: boolean }) { - return render( - mock(), - useSettings: () => ({ - settings: { - apiEndpoint: "https://api.example.com", - rpcEndpoint: "https://rpc.example.com", - isBlockchainDown: input?.isBlockchainDown ?? false - }, - setSettings: vi.fn(), - isLoadingSettings: false, - isSettingsInit: true - }) - }} - /> - ); - } -}); diff --git a/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx b/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx deleted file mode 100644 index 1bfa586d0c..0000000000 --- a/apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx +++ /dev/null @@ -1,43 +0,0 @@ -"use client"; -import type { ReactNode } from "react"; -import React, { useCallback } from "react"; -import type { ButtonProps } from "@akashnetwork/ui/components"; -import { Button, Spinner } from "@akashnetwork/ui/components"; -import { Rocket } from "iconoir-react"; -import { useRouter } from "next/navigation"; - -import { useSettings } from "@src/context/SettingsProvider"; -import { useWallet } from "@src/context/WalletProvider"; -import { UrlService } from "@src/utils/urlUtils"; - -const DEPENDENCIES = { - useRouter, - useSettings -}; - -interface Props extends ButtonProps { - children?: ReactNode; - className?: string; - dependencies?: typeof DEPENDENCIES; -} - -export const ConnectManagedWalletButton: React.FunctionComponent = ({ className = "", dependencies: d = DEPENDENCIES, ...rest }) => { - const { settings } = d.useSettings(); - const { hasManagedWallet, isWalletLoading } = useWallet(); - const router = d.useRouter(); - - const handleClick: React.MouseEventHandler = useCallback(() => { - router.push(UrlService.onboarding()); - }, [router]); - - if (hasManagedWallet) { - return null; - } - - return ( - - ); -}; diff --git a/apps/deploy-web/src/components/wallet/WalletConnectionButtons.spec.tsx b/apps/deploy-web/src/components/wallet/WalletConnectionButtons.spec.tsx deleted file mode 100644 index ca3e768dd3..0000000000 --- a/apps/deploy-web/src/components/wallet/WalletConnectionButtons.spec.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { createStore, Provider } from "jotai"; -import { describe, expect, it, vi } from "vitest"; -import { mock } from "vitest-mock-extended"; - -import walletStore from "@src/store/walletStore"; -import type { DEPENDENCIES } from "./WalletConnectionButtons"; -import { WalletConnectionButtons } from "./WalletConnectionButtons"; - -import { render, screen } from "@testing-library/react"; -import { ComponentMock } from "@tests/unit/mocks"; - -describe(WalletConnectionButtons.name, () => { - it("renders the managed-wallet connect button by default", () => { - const ConnectManagedWalletButton = vi.fn(ComponentMock); - setup({ dependencies: { ConnectManagedWalletButton } }); - - expect(ConnectManagedWalletButton).toHaveBeenCalled(); - }); - - it("shows the Sign in link when signed in with trial and no user", () => { - setup({ isSignedInWithTrial: true, user: null }); - - expect(screen.getByRole("link", { name: /Sign in/ })).toBeInTheDocument(); - }); - - function setup(input: { isSignedInWithTrial?: boolean; user?: Record | null; dependencies?: Partial }) { - const store = createStore(); - store.set(walletStore.isSignedInWithTrial, input.isSignedInWithTrial ?? false); - - const dependencies: typeof DEPENDENCIES = { - useCustomUser: () => - mock>({ - user: ("user" in input ? input.user : { id: "user-1" }) as ReturnType["user"] - }), - ConnectManagedWalletButton: vi.fn(ComponentMock) as unknown as typeof DEPENDENCIES.ConnectManagedWalletButton, - ...input.dependencies - }; - - return render( - - - - ); - } -}); diff --git a/apps/deploy-web/src/components/wallet/WalletConnectionButtons.tsx b/apps/deploy-web/src/components/wallet/WalletConnectionButtons.tsx deleted file mode 100644 index 6a3203ccd3..0000000000 --- a/apps/deploy-web/src/components/wallet/WalletConnectionButtons.tsx +++ /dev/null @@ -1,44 +0,0 @@ -"use client"; -import React from "react"; -import { buttonVariants } from "@akashnetwork/ui/components"; -import { cn } from "@akashnetwork/ui/utils"; -import { LogIn } from "iconoir-react"; -import { useAtom } from "jotai"; -import Link from "next/link"; - -import { useCustomUser } from "@src/hooks/useCustomUser"; -import walletStore from "@src/store/walletStore"; -import { UrlService } from "@src/utils/urlUtils"; -import { ConnectManagedWalletButton } from "./ConnectManagedWalletButton"; - -interface WalletConnectionButtonsProps { - className?: string; - connectManagedWalletButtonClassName?: string; - dependencies?: typeof DEPENDENCIES; -} - -export const DEPENDENCIES = { - useCustomUser, - ConnectManagedWalletButton -}; - -export const WalletConnectionButtons: React.FC = ({ - className, - connectManagedWalletButtonClassName, - dependencies: d = DEPENDENCIES -}) => { - const [isSignedInWithTrial] = useAtom(walletStore.isSignedInWithTrial); - const { user } = d.useCustomUser(); - - return ( -
- {!isSignedInWithTrial && } - {isSignedInWithTrial && !user && ( - - - Sign in - - )} -
- ); -}; diff --git a/apps/deploy-web/src/hooks/useManagedWallet.ts b/apps/deploy-web/src/hooks/useManagedWallet.ts index a7e165572b..fa203b7880 100644 --- a/apps/deploy-web/src/hooks/useManagedWallet.ts +++ b/apps/deploy-web/src/hooks/useManagedWallet.ts @@ -1,18 +1,14 @@ import { useEffect, useMemo } from "react"; import type { ApiManagedWalletOutput } from "@akashnetwork/http-sdk"; import { useIsMutating } from "@tanstack/react-query"; -import { useAtom } from "jotai"; import { useUser } from "@src/hooks/useUser"; import { QueryKeys } from "@src/queries/queryKeys"; import { useCreateManagedWalletMutation, useManagedWalletQuery } from "@src/queries/useManagedWalletQuery"; -import walletStore from "@src/store/walletStore"; import { ensureUserManagedWalletOwnership, updateStorageManagedWallet } from "@src/utils/walletUtils"; -import { useCustomUser } from "./useCustomUser"; export const useManagedWallet = () => { const { user } = useUser(); - const { user: signedInUser } = useCustomUser(); const { data: queried, isLoading: isInitialLoading, isFetching, refetch } = useManagedWalletQuery(user?.id); const { mutate: create, @@ -30,13 +26,6 @@ export const useManagedWallet = () => { const isCreatingManagedWallet = useIsMutating({ mutationKey: QueryKeys.getManagedWalletCreateMutationKey() }) > 0; const wallet = useMemo(() => (queried || created) as ApiManagedWalletOutput, [queried, created]); const isLoading = isInitialLoading || isCreating || isCreatingManagedWallet; - const [, setIsSignedInWithTrial] = useAtom(walletStore.isSignedInWithTrial); - - useEffect(() => { - if (signedInUser?.id && (!!queried || !!created)) { - setIsSignedInWithTrial(true); - } - }, [signedInUser?.id, queried, created, setIsSignedInWithTrial]); useEffect(() => { if (!wallet?.address) { diff --git a/apps/deploy-web/src/store/walletStore.ts b/apps/deploy-web/src/store/walletStore.ts index 04c0121bde..ce1ce9737d 100644 --- a/apps/deploy-web/src/store/walletStore.ts +++ b/apps/deploy-web/src/store/walletStore.ts @@ -1,14 +1,11 @@ import { atom } from "jotai"; -import { atomWithStorage } from "jotai/utils"; import type { WalletBalance } from "@src/hooks/useWalletBalance"; -const isSignedInWithTrial = atomWithStorage("isSignedInWithTrial", false); const isWalletModalOpen = atom(false); const balance = atom(null); const walletStore = { - isSignedInWithTrial, isWalletModalOpen, balance };