From 62131b4c3f204907d89ae748f93426b7dcf6dc7e Mon Sep 17 00:00:00 2001 From: Sergii Date: Mon, 5 Jan 2026 23:05:05 +0100 Subject: [PATCH 1/2] refactor: injects browserEnvConfig from DI container --- .../deployments/DeploymentDetailTopBar.tsx | 5 ++--- .../get-started/GetStartedStepper.tsx | 9 ++++---- .../layout/CustomGoogleAnalytics.tsx | 5 +++-- .../src/components/layout/TrackingScripts.tsx | 13 ++++++------ .../src/components/layout/WalletStatus.tsx | 7 ++----- .../update/RemoteDeployUpdate.tsx | 5 +++-- .../shared/TrialDeploymentBadge.tsx | 5 +++-- .../wallet/CustodialWalletPopup.tsx | 21 +++++++------------ .../src/config/browser-env.config.ts | 1 - .../src/context/FlagProvider/FlagProvider.tsx | 5 +++-- .../src/hooks/useAutoTopUpLimits.tsx | 11 +++++----- apps/deploy-web/src/hooks/useFlag.tsx | 9 ++++++-- .../src/hooks/useHasCreditCardBanner.ts | 5 +---- apps/deploy-web/src/hooks/useManagedWallet.ts | 14 +------------ .../src/hooks/useManagedWalletDenom.ts | 5 +++-- 15 files changed, 53 insertions(+), 67 deletions(-) diff --git a/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx b/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx index 6479bb7cc0..20fddff0c5 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx @@ -13,7 +13,6 @@ import { Edit, MoreHoriz, NavArrowLeft, Refresh, Upload, XmarkSquare } from "ico import { useRouter } from "next/navigation"; import { CustomDropdownLinkItem } from "@src/components/shared/CustomDropdownLinkItem"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; import { useServices } from "@src/context/ServicesProvider"; import { useWallet } from "@src/context/WalletProvider"; @@ -48,7 +47,7 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({ deployment, leases }) => { - const { analyticsService } = useServices(); + const { analyticsService, publicConfig } = useServices(); const { changeDeploymentName, getDeploymentData, getDeploymentName } = useLocalNotes(); const { udenomToUsd } = usePricing(); const router = useRouter(); @@ -232,7 +231,7 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({
- Estimated amount: ${udenomToUsd(deploymentSetting.data?.estimatedTopUpAmount || 0, browserEnvConfig.NEXT_PUBLIC_MANAGED_WALLET_DENOM)} + Estimated amount: ${udenomToUsd(deploymentSetting.data?.estimatedTopUpAmount || 0, publicConfig.NEXT_PUBLIC_MANAGED_WALLET_DENOM)}
Check period: {formatDuration(intervalToDuration({ start: 0, end: deploymentSetting.data?.topUpFrequencyMs || 0 }))}
diff --git a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx index 7ffdccd62e..a7e227ef10 100644 --- a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx +++ b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx @@ -13,7 +13,7 @@ import Link from "next/link"; import { AddFundsLink } from "@src/components/user/AddFundsLink"; import { ConnectManagedWalletButton } from "@src/components/wallet/ConnectManagedWalletButton"; -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; import { useWallet } from "@src/context/WalletProvider"; import { useChainParam } from "@src/hooks/useChainParam/useChainParam"; import { useCustomUser } from "@src/hooks/useCustomUser"; @@ -29,6 +29,7 @@ import { ConnectWalletButton } from "../wallet/ConnectWalletButton"; import { QontoConnector, QontoStepIcon } from "./Stepper"; export const GetStartedStepper: React.FunctionComponent = () => { + const { publicConfig } = useServices(); const [activeStep, setActiveStep] = useState(0); const { isWalletConnected, address, isManaged: isManagedWallet, isTrialing } = useWallet(); const { refetch: refetchBalances, balance: walletBalance } = useWalletBalance(); @@ -76,11 +77,11 @@ export const GetStartedStepper: React.FunctionComponent = () => { onClick={() => (activeStep > 0 ? onStepClick(0) : null)} classes={{ label: cn("text-xl tracking-tight", { ["cursor-pointer hover:text-primary"]: activeStep > 0, ["!font-bold"]: activeStep === 0 }) }} > - {browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED ? "Trial / Billing" : "Billing"} + {publicConfig.NEXT_PUBLIC_BILLING_ENABLED ? "Trial / Billing" : "Billing"} - {browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED && !isWalletConnected && ( + {publicConfig.NEXT_PUBLIC_BILLING_ENABLED && !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" @@ -143,7 +144,7 @@ export const GetStartedStepper: React.FunctionComponent = () => {

- {browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED && !isSignedInWithTrial && } + {publicConfig.NEXT_PUBLIC_BILLING_ENABLED && !isSignedInWithTrial && } {isSignedInWithTrial && !user && ( diff --git a/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx b/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx index f07dd16d0d..e3d5842b18 100644 --- a/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx +++ b/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx @@ -2,9 +2,10 @@ import { useReportWebVitals } from "next/web-vitals"; import { event, GoogleAnalytics as GAnalytics } from "nextjs-google-analytics"; -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; export default function GoogleAnalytics() { + const { publicConfig } = useServices(); useReportWebVitals(({ id, name, label, value }) => { event(name, { category: label === "web-vital" ? "Web Vitals" : "Next.js custom metric", @@ -13,5 +14,5 @@ export default function GoogleAnalytics() { nonInteraction: true // avoids affecting bounce rate. }); }); - return <>{!!browserEnvConfig.NEXT_PUBLIC_GA_ENABLED && }; + return <>{!!publicConfig.NEXT_PUBLIC_GA_ENABLED && }; } diff --git a/apps/deploy-web/src/components/layout/TrackingScripts.tsx b/apps/deploy-web/src/components/layout/TrackingScripts.tsx index 50fadc2df9..1dd5218fb1 100644 --- a/apps/deploy-web/src/components/layout/TrackingScripts.tsx +++ b/apps/deploy-web/src/components/layout/TrackingScripts.tsx @@ -1,15 +1,16 @@ "use client"; import { useEffect } from "react"; -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; import { addScriptToBody } from "@src/utils/domUtils"; export const TrackingScripts = () => { - const isProduction = browserEnvConfig.NEXT_PUBLIC_NODE_ENV === "production"; + const { publicConfig } = useServices(); + const isProduction = publicConfig.NEXT_PUBLIC_NODE_ENV === "production"; useEffect(() => { - const shouldShowTracking = browserEnvConfig.NEXT_PUBLIC_TRACKING_ENABLED; - const shouldShowGrowthChannel = browserEnvConfig.NEXT_PUBLIC_GROWTH_CHANNEL_TRACKING_ENABLED; + const shouldShowTracking = publicConfig.NEXT_PUBLIC_TRACKING_ENABLED; + const shouldShowGrowthChannel = publicConfig.NEXT_PUBLIC_GROWTH_CHANNEL_TRACKING_ENABLED; if (isProduction && shouldShowTracking) { // Google Tag Manager @@ -21,14 +22,14 @@ export const TrackingScripts = () => { new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); - })(window,document,'script','dataLayer','${browserEnvConfig.NEXT_PUBLIC_GTM_ID}'); + })(window,document,'script','dataLayer','${publicConfig.NEXT_PUBLIC_GTM_ID}'); ` }); // GTM noscript fallback const gtmNoscript = document.createElement("noscript"); const gtmIframe = document.createElement("iframe"); - gtmIframe.src = `https://www.googletagmanager.com/ns.html?id=${browserEnvConfig.NEXT_PUBLIC_GTM_ID}`; + gtmIframe.src = `https://www.googletagmanager.com/ns.html?id=${publicConfig.NEXT_PUBLIC_GTM_ID}`; gtmIframe.height = "0"; gtmIframe.width = "0"; gtmIframe.style.display = "none"; diff --git a/apps/deploy-web/src/components/layout/WalletStatus.tsx b/apps/deploy-web/src/components/layout/WalletStatus.tsx index 26f14aec09..aef56a4722 100644 --- a/apps/deploy-web/src/components/layout/WalletStatus.tsx +++ b/apps/deploy-web/src/components/layout/WalletStatus.tsx @@ -8,7 +8,6 @@ import { NavArrowDown, Wallet } from "iconoir-react"; import { useAtom } from "jotai"; import { ConnectManagedWalletButton } from "@src/components/wallet/ConnectManagedWalletButton"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { useWallet } from "@src/context/WalletProvider"; import { getSplitText } from "@src/hooks/useShortText"; import { useWalletBalance } from "@src/hooks/useWalletBalance"; @@ -17,8 +16,6 @@ import { ConnectWalletButton } from "../wallet/ConnectWalletButton"; import { CustodialWalletPopup } from "../wallet/CustodialWalletPopup"; import { ManagedWalletPopup } from "../wallet/ManagedWalletPopup"; -const withBilling = browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED; - export function WalletStatus() { const { walletName, isWalletLoaded, isWalletConnected, isManaged, isWalletLoading, isTrialing } = useWallet(); const { balance: walletBalance, isLoading: isWalletBalanceLoading } = useWalletBalance(); @@ -84,7 +81,7 @@ export function WalletStatus() { >
{!isManaged && } - {withBilling && isManaged && } + {isManaged && }
@@ -93,7 +90,7 @@ export function WalletStatus() {
) : (
- {withBilling && !isSignedInWithTrial && } + {!isSignedInWithTrial && }
) diff --git a/apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx b/apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx index 12ba488327..ba64d8a7dd 100644 --- a/apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx +++ b/apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx @@ -6,9 +6,9 @@ import { useSnackbar } from "notistack"; import { EnvFormModal } from "@src/components/sdl/EnvFormModal/EnvFormModal"; import { EnvVarList } from "@src/components/sdl/EnvVarList"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { CURRENT_SERVICE, protectedEnvironmentVariables } from "@src/config/remote-deploy.config"; import { SdlBuilderProvider } from "@src/context/SdlBuilderProvider"; +import { useServices } from "@src/context/ServicesProvider"; import { EnvVarUpdater } from "@src/services/remote-deploy/remote-deployment-controller.service"; import { tokens } from "@src/store/remoteDeployStore"; import type { SdlBuilderFormValuesType, ServiceType } from "@src/types"; @@ -27,6 +27,7 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string const { control, watch, setValue } = useForm({ defaultValues: { services: [defaultService] } }); const { fields: services } = useFieldArray({ control, name: "services", keyName: "id" }); const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]); + const { publicConfig } = useServices(); useEffect(() => { const { unsubscribe }: any = watch(data => { @@ -60,7 +61,7 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string } } }; - return services?.[0]?.image.startsWith(browserEnvConfig.NEXT_PUBLIC_CI_CD_IMAGE_NAME) && services?.[0]?.env && services?.[0]?.env?.length > 0 ? ( + return services?.[0]?.image.startsWith(publicConfig.NEXT_PUBLIC_CI_CD_IMAGE_NAME) && services?.[0]?.env && services?.[0]?.env?.length > 0 ? (
diff --git a/apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx b/apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx index ef28be561a..da85a24eb9 100644 --- a/apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx +++ b/apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx @@ -4,7 +4,7 @@ import { Badge, CustomTooltip } from "@akashnetwork/ui/components"; import { cn } from "@akashnetwork/ui/utils"; import { Info } from "lucide-react"; -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; import { useTrialDeploymentTimeRemaining } from "@src/hooks/useTrialDeploymentTimeRemaining"; import { TrialDeploymentTooltip } from "./TrialDeploymentTooltip"; @@ -24,7 +24,8 @@ export const DEPENDENCIES = { }; export function TrialDeploymentBadge({ createdHeight, trialDurationHours, averageBlockTime = 6, className, dependencies: d = DEPENDENCIES }: Props) { - const trialDuration = trialDurationHours ?? browserEnvConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS; + const { publicConfig } = useServices(); + const trialDuration = trialDurationHours ?? publicConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS; const { isExpired, timeRemainingText } = d.useTrialTimeRemaining({ createdHeight, diff --git a/apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx b/apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx index 0cafc15950..3e3e239baf 100644 --- a/apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx +++ b/apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx @@ -7,7 +7,6 @@ import { useAtom } from "jotai"; import Link from "next/link"; import { useRouter } from "next/router"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { UAKT_DENOM } from "@src/config/denom.config"; import { useWallet } from "@src/context/WalletProvider"; import { useCustomUser } from "@src/hooks/useCustomUser"; @@ -23,8 +22,6 @@ interface CustodialWalletPopupProps extends React.PropsWithChildren { walletBalance?: WalletBalance | null; } -const withBilling = browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED; - export const CustodialWalletPopup: React.FC = ({ walletBalance }) => { const { address, logout } = useWallet(); const router = useRouter(); @@ -85,18 +82,14 @@ export const CustodialWalletPopup: React.FC = ({ wall Disconnect Wallet - {withBilling && ( - <> - + - {isSignedInWithTrial && !user ? ( - - Sign in for USD Payments - - ) : ( - - )} - + {isSignedInWithTrial && !user ? ( + + Sign in for USD Payments + + ) : ( + )}
diff --git a/apps/deploy-web/src/config/browser-env.config.ts b/apps/deploy-web/src/config/browser-env.config.ts index 060f7555c1..7a46a38910 100644 --- a/apps/deploy-web/src/config/browser-env.config.ts +++ b/apps/deploy-web/src/config/browser-env.config.ts @@ -9,7 +9,6 @@ export const browserEnvConfig = validateStaticEnvVars({ NEXT_PUBLIC_MASTER_WALLET_ADDRESS: process.env.NEXT_PUBLIC_MASTER_WALLET_ADDRESS, NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS: process.env.NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS, NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS: process.env.NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS, - NEXT_PUBLIC_BILLING_ENABLED: process.env.NEXT_PUBLIC_BILLING_ENABLED, NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID: process.env.NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID, NEXT_PUBLIC_MANAGED_WALLET_DENOM: process.env.NEXT_PUBLIC_MANAGED_WALLET_DENOM, NEXT_PUBLIC_DEFAULT_INITIAL_DEPOSIT: process.env.NEXT_PUBLIC_DEFAULT_INITIAL_DEPOSIT, diff --git a/apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx b/apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx index f6f5c8967e..396bcc782c 100644 --- a/apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx +++ b/apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx @@ -3,9 +3,9 @@ import { useEffect, useState } from "react"; import { FlagProvider as FlagProviderOriginal, useUnleashClient } from "@unleash/nextjs"; import { Loading } from "@src/components/layout/Layout"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { useUser } from "@src/hooks/useUser"; import type { FCWithChildren } from "@src/types/component"; +import { useServices } from "../ServicesProvider"; const COMPONENTS = { FlagProvider: FlagProviderOriginal, @@ -16,8 +16,9 @@ const COMPONENTS = { export type Props = { components?: typeof COMPONENTS }; export const UserAwareFlagProvider: FCWithChildren = ({ children, components: c = COMPONENTS }) => { + const { publicConfig } = useServices(); const { user } = c.useUser(); - const isEnableAll = browserEnvConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL; + const isEnableAll = publicConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL; return ( { + const { publicConfig } = useServices(); const { address } = useWallet(); - const uaktFeeAllowance = useExactFeeAllowanceQuery(address, browserEnvConfig.NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); - const uaktDeploymentGrant = useExactDeploymentGrantsQuery(address, browserEnvConfig.NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); - const usdcFeeAllowance = useExactFeeAllowanceQuery(address, browserEnvConfig.NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); - const usdcDeploymentGrant = useExactDeploymentGrantsQuery(address, browserEnvConfig.NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); + const uaktFeeAllowance = useExactFeeAllowanceQuery(address, publicConfig.NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); + const uaktDeploymentGrant = useExactDeploymentGrantsQuery(address, publicConfig.NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); + const usdcFeeAllowance = useExactFeeAllowanceQuery(address, publicConfig.NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); + const usdcDeploymentGrant = useExactDeploymentGrantsQuery(address, publicConfig.NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS, { enabled: false }); const uaktFeeLimit = useMemo(() => extractFeeLimit(uaktFeeAllowance.data), [uaktFeeAllowance.data]); const usdcFeeLimit = useMemo(() => extractFeeLimit(usdcFeeAllowance.data), [usdcFeeAllowance.data]); const uaktDeploymentLimit = useMemo(() => extractDeploymentLimit(uaktDeploymentGrant.data), [uaktDeploymentGrant.data]); diff --git a/apps/deploy-web/src/hooks/useFlag.tsx b/apps/deploy-web/src/hooks/useFlag.tsx index 33df853f5b..cea7a3b698 100644 --- a/apps/deploy-web/src/hooks/useFlag.tsx +++ b/apps/deploy-web/src/hooks/useFlag.tsx @@ -1,9 +1,14 @@ import { useFlag as useFlagOriginal } from "@unleash/nextjs/client"; -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; import type { FeatureFlag } from "@src/types/feature-flags"; const useDummyFlag: FeatureFlagHook = () => true; -export const useFlag: FeatureFlagHook = browserEnvConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL ? useDummyFlag : useFlagOriginal; +export const useFlag: FeatureFlagHook = flag => { + const { publicConfig } = useServices(); + const useHook = publicConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL ? useDummyFlag : useFlagOriginal; + return useHook(flag); +}; + type FeatureFlagHook = (flag: FeatureFlag) => boolean; diff --git a/apps/deploy-web/src/hooks/useHasCreditCardBanner.ts b/apps/deploy-web/src/hooks/useHasCreditCardBanner.ts index 1591847adc..92f304fd37 100644 --- a/apps/deploy-web/src/hooks/useHasCreditCardBanner.ts +++ b/apps/deploy-web/src/hooks/useHasCreditCardBanner.ts @@ -1,13 +1,10 @@ import { useEffect, useMemo, useState } from "react"; import { useAtom } from "jotai"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { useWallet } from "@src/context/WalletProvider"; import walletStore from "@src/store/walletStore"; import { useUser } from "./useUser"; -const withBilling = browserEnvConfig.NEXT_PUBLIC_BILLING_ENABLED; - export function useHasCreditCardBanner() { const { user } = useUser(); const [isBannerVisible, setIsBannerVisible] = useState(false); @@ -15,7 +12,7 @@ export function useHasCreditCardBanner() { const { hasManagedWallet, isWalletLoading } = useWallet(); const [isSignedInWithTrial] = useAtom(walletStore.isSignedInWithTrial); const shouldShowBanner = useMemo( - () => isInitialized && withBilling && !hasManagedWallet && !isWalletLoading && !isSignedInWithTrial, + () => isInitialized && !hasManagedWallet && !isWalletLoading && !isSignedInWithTrial, [isInitialized, hasManagedWallet, isWalletLoading, isSignedInWithTrial] ); diff --git a/apps/deploy-web/src/hooks/useManagedWallet.ts b/apps/deploy-web/src/hooks/useManagedWallet.ts index 30bf3885e5..440b374728 100644 --- a/apps/deploy-web/src/hooks/useManagedWallet.ts +++ b/apps/deploy-web/src/hooks/useManagedWallet.ts @@ -2,7 +2,6 @@ import { useEffect, useMemo } from "react"; import type { ApiManagedWalletOutput } from "@akashnetwork/http-sdk"; import { useAtom } from "jotai"; -import { browserEnvConfig } from "@src/config/browser-env.config"; import { useSelectedChain } from "@src/context/CustomChainProvider"; import { useUser } from "@src/hooks/useUser"; import { useCreateManagedWalletMutation, useManagedWalletQuery } from "@src/queries/useManagedWalletQuery"; @@ -10,15 +9,12 @@ import walletStore from "@src/store/walletStore"; import { ensureUserManagedWalletOwnership, getSelectedStorageWallet, updateStorageManagedWallet } from "@src/utils/walletUtils"; import { useCustomUser } from "./useCustomUser"; -const { NEXT_PUBLIC_BILLING_ENABLED } = browserEnvConfig; -const isBillingEnabled = NEXT_PUBLIC_BILLING_ENABLED; - export const useManagedWallet = () => { const { user } = useUser(); const { user: signedInUser } = useCustomUser(); const userWallet = useSelectedChain(); const [selectedWalletType, setSelectedWalletType] = useAtom(walletStore.selectedWalletType); - const { data: queried, isLoading: isInitialLoading, isFetching, refetch } = useManagedWalletQuery(isBillingEnabled ? user?.id : undefined); + const { data: queried, isLoading: isInitialLoading, isFetching, refetch } = useManagedWalletQuery(user?.id); const { mutate: create, data: created, isPending: isCreating, isSuccess: isCreated, error: createError } = useCreateManagedWalletMutation(); const wallet = useMemo(() => (queried || created) as ApiManagedWalletOutput, [queried, created]); const isLoading = isInitialLoading || isCreating; @@ -38,10 +34,6 @@ export const useManagedWallet = () => { }, [signedInUser?.id, queried, created, setIsSignedInWithTrial]); useEffect(() => { - if (!isBillingEnabled) { - return; - } - if (wallet && isCreated) { updateStorageManagedWallet({ ...wallet, selected: true }); } else if (wallet) { @@ -59,10 +51,6 @@ export const useManagedWallet = () => { const isConfigured = !!wallet; return { create: () => { - if (!isBillingEnabled) { - throw new Error("Billing is not enabled"); - } - if (!user?.id) { throw new Error("User is not initialized yet"); } diff --git a/apps/deploy-web/src/hooks/useManagedWalletDenom.ts b/apps/deploy-web/src/hooks/useManagedWalletDenom.ts index d6435a48ae..a9ee5661e3 100644 --- a/apps/deploy-web/src/hooks/useManagedWalletDenom.ts +++ b/apps/deploy-web/src/hooks/useManagedWalletDenom.ts @@ -1,10 +1,11 @@ -import { browserEnvConfig } from "@src/config/browser-env.config"; +import { useServices } from "@src/context/ServicesProvider"; import { useWallet } from "@src/context/WalletProvider"; import { useUsdcDenom } from "@src/hooks/useDenom"; export const useManagedWalletDenom = () => { + const { publicConfig } = useServices(); const wallet = useWallet(); const usdcDenom = useUsdcDenom(); - return wallet.isManaged && browserEnvConfig.NEXT_PUBLIC_MANAGED_WALLET_DENOM === "usdc" ? usdcDenom : "uakt"; + return wallet.isManaged && publicConfig.NEXT_PUBLIC_MANAGED_WALLET_DENOM === "usdc" ? usdcDenom : "uakt"; }; From b48362552bda617fb951827d163525aacdd8e05d Mon Sep 17 00:00:00 2001 From: Sergii Date: Mon, 12 Jan 2026 10:56:24 +0100 Subject: [PATCH 2/2] chore: cleanup NEXT_PUBLIC_BILLING_ENABLED/BILLING_ENABLED usage --- apps/api/env/.env.functional.test | 1 - apps/api/env/.env.production | 3 +-- apps/api/env/.env.sample | 1 - apps/api/env/.env.staging | 1 - apps/api/env/.env.unit.test | 1 - apps/deploy-web/.env.local.sample | 1 - .../src/components/get-started/GetStartedStepper.tsx | 8 +++----- .../components/user/UserProviders/UserProviders.spec.tsx | 7 +------ .../src/components/user/UserProviders/UserProviders.tsx | 8 ++------ apps/deploy-web/src/config/env-config.schema.ts | 1 - 10 files changed, 7 insertions(+), 25 deletions(-) diff --git a/apps/api/env/.env.functional.test b/apps/api/env/.env.functional.test index 0d8a8e9099..d5fe48e01d 100644 --- a/apps/api/env/.env.functional.test +++ b/apps/api/env/.env.functional.test @@ -10,7 +10,6 @@ FEE_ALLOWANCE_REFILL_AMOUNT=5000000 FEE_ALLOWANCE_REFILL_THRESHOLD=500000 DEPLOYMENT_GRANT_DENOM=uakt LOG_LEVEL=debug -BILLING_ENABLED=true ANONYMOUS_USER_TOKEN_SECRET=ANONYMOUS_USER_TOKEN_SECRET STRIPE_SECRET_KEY=STRIPE_SECRET_KEY STRIPE_PRODUCT_ID=STRIPE_PRODUCT_ID diff --git a/apps/api/env/.env.production b/apps/api/env/.env.production index 804095541e..38a764112a 100644 --- a/apps/api/env/.env.production +++ b/apps/api/env/.env.production @@ -5,11 +5,10 @@ AUTH0_M2M_DOMAIN=cloudmos-prod.us.auth0.com PORT=80 SERVER_ORIGIN=https://console-api.akash.network DRIZZLE_MIGRATIONS_FOLDER=./dist/drizzle -BILLING_ENABLED=true PROVIDER_PROXY_URL=https://console-provider-proxy.akash.network AMPLITUDE_SAMPLING=1 DEPLOY_WEB_BASE_URL=https://console.akash.network CONSOLE_WEB_PAYMENT_LINK=${DEPLOY_WEB_BASE_URL}/payment -STRIPE_CHECKOUT_REDIRECT_URL=${DEPLOY_WEB_BASE_URL} \ No newline at end of file +STRIPE_CHECKOUT_REDIRECT_URL=${DEPLOY_WEB_BASE_URL} diff --git a/apps/api/env/.env.sample b/apps/api/env/.env.sample index 4cc1426f63..1045dea950 100644 --- a/apps/api/env/.env.sample +++ b/apps/api/env/.env.sample @@ -18,7 +18,6 @@ AUTH0_ISSUER= AUTH0_JWKS_URI= AUTH0_SECRET= AUTH0_CLIENT_ID= -BILLING_ENABLED= DEPLOYMENT_ALLOWANCE_REFILL_AMOUNT= DEPLOYMENT_ALLOWANCE_REFILL_THRESHOLD= DEPLOYMENT_ENV= diff --git a/apps/api/env/.env.staging b/apps/api/env/.env.staging index f79ce94b49..bc9bfa2ad8 100644 --- a/apps/api/env/.env.staging +++ b/apps/api/env/.env.staging @@ -4,7 +4,6 @@ AUTH0_JWKS_URI=https://dev-5aprb0lr.us.auth0.com/.well-known/jwks.json AUTH0_AUDIENCE=https://console-api.akash.network AUTH0_ISSUER=https://dev-5aprb0lr.us.auth0.com/ AUTH0_M2M_DOMAIN=dev-5aprb0lr.us.auth0.com -BILLING_ENABLED=true AMPLITUDE_SAMPLING=1 DEPLOY_WEB_BASE_URL=https://console-beta.akash.network CONSOLE_WEB_PAYMENT_LINK=${DEPLOY_WEB_BASE_URL}/payment diff --git a/apps/api/env/.env.unit.test b/apps/api/env/.env.unit.test index 744d63687c..258d58ecb4 100644 --- a/apps/api/env/.env.unit.test +++ b/apps/api/env/.env.unit.test @@ -14,7 +14,6 @@ FEE_ALLOWANCE_REFILL_AMOUNT=5000000 FEE_ALLOWANCE_REFILL_THRESHOLD=500000 DEPLOYMENT_GRANT_DENOM=uakt LOG_LEVEL=debug -BILLING_ENABLED=true ANONYMOUS_USER_TOKEN_SECRET=ANONYMOUS_USER_TOKEN_SECRET STRIPE_SECRET_KEY=STRIPE_SECRET_KEY STRIPE_PRODUCT_ID=STRIPE_PRODUCT_ID diff --git a/apps/deploy-web/.env.local.sample b/apps/deploy-web/.env.local.sample index 9f11009dfe..2e7cc98ca7 100644 --- a/apps/deploy-web/.env.local.sample +++ b/apps/deploy-web/.env.local.sample @@ -9,7 +9,6 @@ AUTH0_SCOPE=openid profile email AUTH0_SECRET=random_super_secret AUTH0_LOCAL_ENABLED=true -NEXT_PUBLIC_BILLING_ENABLED=true NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID=sandbox NEXT_PUBLIC_MANAGED_WALLET_DENOM=uakt diff --git a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx index a7e227ef10..505e6204e1 100644 --- a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx +++ b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx @@ -13,7 +13,6 @@ import Link from "next/link"; import { AddFundsLink } from "@src/components/user/AddFundsLink"; import { ConnectManagedWalletButton } from "@src/components/wallet/ConnectManagedWalletButton"; -import { useServices } from "@src/context/ServicesProvider"; import { useWallet } from "@src/context/WalletProvider"; import { useChainParam } from "@src/hooks/useChainParam/useChainParam"; import { useCustomUser } from "@src/hooks/useCustomUser"; @@ -29,7 +28,6 @@ import { ConnectWalletButton } from "../wallet/ConnectWalletButton"; import { QontoConnector, QontoStepIcon } from "./Stepper"; export const GetStartedStepper: React.FunctionComponent = () => { - const { publicConfig } = useServices(); const [activeStep, setActiveStep] = useState(0); const { isWalletConnected, address, isManaged: isManagedWallet, isTrialing } = useWallet(); const { refetch: refetchBalances, balance: walletBalance } = useWalletBalance(); @@ -77,11 +75,11 @@ export const GetStartedStepper: React.FunctionComponent = () => { onClick={() => (activeStep > 0 ? onStepClick(0) : null)} classes={{ label: cn("text-xl tracking-tight", { ["cursor-pointer hover:text-primary"]: activeStep > 0, ["!font-bold"]: activeStep === 0 }) }} > - {publicConfig.NEXT_PUBLIC_BILLING_ENABLED ? "Trial / Billing" : "Billing"} + Trial / Billing - {publicConfig.NEXT_PUBLIC_BILLING_ENABLED && !isWalletConnected && ( + {!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" @@ -144,7 +142,7 @@ export const GetStartedStepper: React.FunctionComponent = () => {

- {publicConfig.NEXT_PUBLIC_BILLING_ENABLED && !isSignedInWithTrial && } + {!isSignedInWithTrial && } {isSignedInWithTrial && !user && ( diff --git a/apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx b/apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx index 2dd20a2d26..3dd1071b7c 100644 --- a/apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx +++ b/apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx @@ -1,7 +1,6 @@ import type { AxiosInstance } from "axios"; import { mock } from "jest-mock-extended"; -import type { BrowserEnvConfig } from "@src/config/browser-env.config"; import type { AnalyticsService } from "@src/services/analytics/analytics.service"; import type { UserTracker } from "@src/services/user-tracker/user-tracker.service"; import type { CustomUserProfile } from "@src/types/user"; @@ -66,11 +65,7 @@ describe(UserProviders.name, () => { }) as AxiosInstance["get"] }) as unknown as AxiosInstance, userTracker: () => input?.userTracker || mock(), - analyticsService: () => input?.analyticsService || mock(), - appConfig: () => - mock({ - NEXT_PUBLIC_BILLING_ENABLED: true - }) + analyticsService: () => input?.analyticsService || mock() }; let id = 0; const genContent = () => ( diff --git a/apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx b/apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx index 6a7c384578..174271cfc8 100644 --- a/apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx +++ b/apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx @@ -11,17 +11,13 @@ import type { FCWithChildren } from "@src/types/component"; * which is a client only component. */ export const UserProviders: FCWithChildren = ({ children }) => { - const { internalApiHttpClient, publicConfig } = useServices(); - return publicConfig.NEXT_PUBLIC_BILLING_ENABLED ? ( + const { internalApiHttpClient } = useServices(); + return ( internalApiHttpClient.get(url).then(response => response.data)}> {children} - ) : ( - - {children} - ); }; diff --git a/apps/deploy-web/src/config/env-config.schema.ts b/apps/deploy-web/src/config/env-config.schema.ts index 1916a0c008..1060d93af7 100644 --- a/apps/deploy-web/src/config/env-config.schema.ts +++ b/apps/deploy-web/src/config/env-config.schema.ts @@ -7,7 +7,6 @@ export const browserEnvSchema = z.object({ NEXT_PUBLIC_MASTER_WALLET_ADDRESS: z.string(), NEXT_PUBLIC_UAKT_TOP_UP_MASTER_WALLET_ADDRESS: z.string(), NEXT_PUBLIC_USDC_TOP_UP_MASTER_WALLET_ADDRESS: z.string(), - NEXT_PUBLIC_BILLING_ENABLED: coercedBoolean().optional().default("false"), NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID: networkId.optional().default("mainnet"), NEXT_PUBLIC_DEFAULT_NETWORK_ID: networkId.optional().default("mainnet"), NEXT_PUBLIC_MANAGED_WALLET_DENOM: z.enum(["uakt", "usdc"]).optional().default("usdc"),