Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export const accountPlan = {
enterprise: "enterprise",
} as const;

type AccountStatus = (typeof accountStatus)[keyof typeof accountStatus];
type AccountPlan = (typeof accountPlan)[keyof typeof accountPlan];

export type AuthorizedWallet = {
id: string;
accountId: string;
Expand All @@ -47,30 +44,17 @@ export type Account = {
id: string;
isStaff: boolean;
creatorWalletAddress: string;
status: AccountStatus;
plan: AccountPlan;
name?: string;
email?: string;
advancedEnabled: boolean;
currentBillingPeriodStartsAt: string;
currentBillingPeriodEndsAt: string;
emailConfirmedAt?: string;
unconfirmedEmail?: string;
trialPeriodEndedAt?: string;
emailConfirmationWalletAddress?: string;
stripePaymentActionUrl?: string;
onboardSkipped?: boolean;
paymentAttemptCount?: number;
notificationPreferences?: {
billing: "email" | "none";
updates: "email" | "none";
};
recurringPaymentFailures: {
subscriptionId: string;
subscriptionDescription: string;
paymentFailureCode: string;
serviceCutoffDate: string;
}[];
// TODO - add image URL
};

Expand Down Expand Up @@ -194,33 +178,16 @@ export interface UpdateKeyInput {
redirectUrls: string[];
}

interface UsageBundler {
chainId: number;
sumTransactionFee: string;
}

interface UsageStorage {
sumFileSizeBytes: number;
}

interface UsageEmbeddedWallets {
countWalletAddresses: number;
}

export interface UsageBillableByService {
usage: {
bundler: UsageBundler[];
storage: UsageStorage;
embeddedWallets: UsageEmbeddedWallets;
};
billableUsd: {
bundler: number;
storage: number;
embeddedWallets: number;
};
limits: {
storage: number;
embeddedWallets: number;
};
rateLimits: {
storage: number;
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/app/api/testnet-faucet/claim/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const POST = async (req: NextRequest) => {
const account: { data: Account } = await accountRes.json();

// Make sure the logged-in account has verified its email
if (account.data.status === "noCustomer") {
if (!account.data.email) {
return NextResponse.json(
{
error: "Account owner hasn't verified email",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {
import { ImageUpload } from "@/components/ui/image-upload";
import { Input } from "@/components/ui/input";
import { RadioGroup, RadioGroupItemButton } from "@/components/ui/radio-group";
import { ToolTipLabel } from "@/components/ui/tooltip";
import { useDashboardRouter } from "@/lib/DashboardRouter";
import { accountStatus, useAccount } from "@3rdweb-sdk/react/hooks/useApi";
import { zodResolver } from "@hookform/resolvers/zod";
import { Loader2 } from "lucide-react";
import Link from "next/link";
Expand Down Expand Up @@ -49,7 +47,6 @@ export function CreateEcosystemForm(props: {
const [formDataToBeConfirmed, setFormDataToBeConfirmed] = useState<
z.infer<typeof formSchema> | undefined
>();
const { data: billingAccountInfo } = useAccount();

const router = useDashboardRouter();
const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -164,31 +161,16 @@ export function CreateEcosystemForm(props: {
)}
/>
</div>
{billingAccountInfo?.status !== accountStatus.validPayment ? (
<ToolTipLabel label="Please update your payment method to create an ecosystem">
{/* Allows the button to be disabled but the tooltip still works */}
<div className="w-full">
<Button
type="submit"
disabled={true}
variant="primary"
className="w-full opacity-50"
>
Create
</Button>
</div>
</ToolTipLabel>
) : (
<Button
type="submit"
variant="primary"
className="w-full"
disabled={isPending}
>
{isPending && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
Create
</Button>
)}

<Button
type="submit"
variant="primary"
className="w-full"
disabled={isPending}
>
{isPending && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
Create
</Button>
</form>
</Form>
<ConfirmationDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export const Usage: React.FC<UsageProps> = ({
return {
total: `${toSize(Math.min(consumedBytes, limitBytes), "MB")} of ${toSize(limitBytes)} included storage used`,
progress: percent,
...(usageData.billableUsd.storage > 0
? {
overage: usageData.billableUsd.storage,
}
: {}),
totalUsage: `Total Usage: ${toSize(consumedBytes, "MB")}`,
};
}, [usageData]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"use client";

import { Spinner } from "@/components/ui/Spinner/Spinner";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { TrackedLinkTW } from "@/components/ui/tracked-link";
import {
type ApiKeyService,
accountStatus,
useAccount,
} from "@3rdweb-sdk/react/hooks/useApi";
import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser";
import { SmartWalletsBillingAlert } from "components/settings/ApiKeys/Alerts";
Expand All @@ -26,24 +24,20 @@ export function AccountAbstractionPage(props: {
teamSlug: string;
projectKey: string;
apiKeyServices: ApiKeyService[];
billingStatus: "validPayment" | (string & {}) | null;
tab?: string;
}) {
const { apiKeyServices } = props;
const looggedInUserQuery = useLoggedInUser();
const accountQuery = useAccount();
const chain = useActiveWalletChain();

const hasSmartWalletsWithoutBilling = useMemo(() => {
if (!accountQuery.data) {
return;
}

return apiKeyServices.find(
(s) =>
accountQuery.data.status !== accountStatus.validPayment &&
props.billingStatus !== accountStatus.validPayment &&
s.name === "bundler",
);
}, [apiKeyServices, accountQuery.data]);
}, [apiKeyServices, props.billingStatus]);

const isOpChain = chain?.id ? isOpChainId(chain.id) : false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getProject } from "@/api/projects";
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { notFound, redirect } from "next/navigation";
import { getTeamBySlug } from "../../../../../../@/api/team";
import { getAbsoluteUrl } from "../../../../../../lib/vercel-utils";
import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys";
import { AccountAbstractionPage } from "./AccountAbstractionPage";
Expand All @@ -11,7 +12,15 @@ export default async function Page(props: {
searchParams: Promise<{ tab?: string }>;
}) {
const { team_slug, project_slug } = await props.params;
const project = await getProject(team_slug, project_slug);

const [team, project] = await Promise.all([
getTeamBySlug(team_slug),
getProject(team_slug, project_slug),
]);

if (!team) {
redirect("/team");
}

if (!project) {
notFound();
Expand All @@ -28,6 +37,7 @@ export default async function Page(props: {
<AccountAbstractionPage
projectSlug={project.slug}
teamSlug={team_slug}
billingStatus={team.billingStatus}
projectKey={project.publishableKey}
apiKeyServices={apiKey.services || []}
tab={(await props.searchParams).tab}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const Onboarding: React.FC<{
);
}
// skip when going thru claiming trial growth
else if (account?.trialPeriodEndedAt) {
else if (account?.onboardSkipped) {
setState("skipped");
}
// user hasn't skipped onboarding, has valid email and no valid payment yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ function OnboardingUI(props: {
break;
case "confirming":
// after confirming, only show plan if user has not skipped onboarding earlier or trial period has ended
nextStep =
account.onboardSkipped || account?.trialPeriodEndedAt
? "skipped"
: "plan";
nextStep = account.onboardSkipped ? "skipped" : "plan";
break;
case "confirmLinking":
nextStep = "skipped";
Expand Down Expand Up @@ -145,7 +142,8 @@ function OnboardingUI(props: {
setState("skipped");
skipOnboarding();
}}
canTrialGrowth={!account.trialPeriodEndedAt}
// TODO: what can we do here? assume true for the moment
canTrialGrowth={true}
/>
</Suspense>
)}
Expand Down
Loading