Skip to content

Commit a3cdc9e

Browse files
committed
Dashboard: Remove OP superchain banner, CTAs, credits (#7569)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring the code by removing unnecessary imports and simplifying components, particularly in the billing and chain management sections. It also eliminates unused functions and optimizes the handling of credits. ### Detailed summary - Removed `getGasSponsoredChains` function and its usage. - Simplified `CreditsInfoCard` by removing props and using `useAccountCredits`. - Removed `GasCreditAlert` component and its references. - Cleaned up `CreditsItem` by removing unnecessary props and logic. - Removed unused imports in various files, improving code clarity. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Simplified the billing credits display by removing special handling and application UI for "Optimism sponsorship credits". * Streamlined the CreditsInfoCard component to reduce dependencies and remove special credit handling. * Removed logic and UI related to gas-sponsored chains and gas sponsorship call-to-actions. * Deleted the GasCreditAlert component and its alert UI from the account abstraction page. * Reduced authentication and client dependencies in the billing page for improved simplicity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 772eb0c commit a3cdc9e

File tree

6 files changed

+15
-210
lines changed

6 files changed

+15
-210
lines changed

apps/dashboard/src/@/api/chain.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
11
import "server-only";
22
import type { ChainMetadata } from "thirdweb/chains";
33
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs";
4-
import { API_SERVER_SECRET } from "@/constants/server-envs";
54
import type { ChainService } from "@/types/chain";
65

7-
export async function getGasSponsoredChains() {
8-
if (!API_SERVER_SECRET) {
9-
throw new Error("API_SERVER_SECRET is not set");
10-
}
11-
const res = await fetch(
12-
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains/gas-sponsored`,
13-
{
14-
headers: {
15-
"Content-Type": "application/json",
16-
"x-service-api-key": API_SERVER_SECRET,
17-
},
18-
next: {
19-
revalidate: 15 * 60, //15 minutes
20-
},
21-
},
22-
);
23-
24-
if (!res.ok) {
25-
console.error(
26-
"Failed to fetch gas sponsored chains",
27-
res.status,
28-
res.statusText,
29-
);
30-
res.body?.cancel();
31-
return [];
32-
}
33-
34-
try {
35-
return (await res.json()).data as number[];
36-
} catch (e) {
37-
console.error("Failed to parse gas sponsored chains", e);
38-
return [];
39-
}
40-
}
41-
426
export function getChains() {
437
return fetch(
448
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains`,
Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,18 @@
11
import { formatDistance } from "date-fns";
2-
import { CircleAlertIcon } from "lucide-react";
32
import Image from "next/image";
4-
import Link from "next/link";
5-
import type { ThirdwebClient } from "thirdweb";
6-
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
7-
import { Button } from "@/components/ui/button";
8-
import type { Account, BillingCredit } from "@/hooks/useApi";
9-
import { useLocalStorage } from "@/hooks/useLocalStorage";
10-
import { ChainIconClient } from "@/icons/ChainIcon";
3+
import type { BillingCredit } from "@/hooks/useApi";
114
import { formatToDollars } from "./formatToDollars";
125

136
interface CreditsItemProps {
147
credit?: BillingCredit;
15-
isOpCreditDefault?: boolean;
16-
onClickApply?: () => void;
17-
twAccount: Account;
18-
client: ThirdwebClient;
19-
teamSlug: string;
208
}
219

22-
export const CreditsItem: React.FC<CreditsItemProps> = ({
23-
credit,
24-
isOpCreditDefault,
25-
onClickApply,
26-
twAccount,
27-
client,
28-
teamSlug,
29-
}) => {
30-
const [hasAppliedForOpGrant] = useLocalStorage(
31-
`appliedForOpGrant-${twAccount.id}`,
32-
false,
33-
);
34-
35-
const isOpCredit = credit?.name.startsWith("OP -") || isOpCreditDefault;
10+
export const CreditsItem: React.FC<CreditsItemProps> = ({ credit }) => {
3611
const isTwCredit = credit?.name.startsWith("TW -");
3712
const isStartupCredit = credit?.name.startsWith("SU -");
3813

3914
let creditTitle = credit?.name ?? "thirdweb credits";
40-
if (isOpCredit) {
41-
creditTitle = "Optimism sponsorship credits";
42-
} else if (isTwCredit) {
15+
if (isTwCredit) {
4316
creditTitle = "thirdweb credits";
4417
} else if (isStartupCredit) {
4518
creditTitle = "Startup grant credits";
@@ -50,13 +23,7 @@ export const CreditsItem: React.FC<CreditsItemProps> = ({
5023
<div className="flex flex-col gap-3 p-4 lg:p-6">
5124
<div className="relative">
5225
<div className="absolute top-0 right-0">
53-
{isOpCredit ? (
54-
<ChainIconClient
55-
className="size-6"
56-
client={client}
57-
src="ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/optimism/512.png"
58-
/>
59-
) : isTwCredit ? (
26+
{isTwCredit ? (
6027
<Image
6128
alt="tw-credit"
6229
className="size-6"
@@ -112,35 +79,7 @@ export const CreditsItem: React.FC<CreditsItemProps> = ({
11279
</div>
11380
)}
11481
</div>
115-
116-
{hasAppliedForOpGrant && !credit && isOpCredit && (
117-
<Alert variant="info">
118-
<CircleAlertIcon className="size-5" />
119-
<AlertTitle>Grant application pending approval</AlertTitle>
120-
<AlertDescription>
121-
You will receive an email once your application&apos;s status
122-
changes.
123-
</AlertDescription>
124-
</Alert>
125-
)}
12682
</div>
127-
128-
{!hasAppliedForOpGrant && isOpCredit && (
129-
<div className="mt-2 flex justify-end border-t px-4 py-4 lg:px-6">
130-
<Button asChild size="sm" variant="outline">
131-
<Link
132-
href={`/team/${teamSlug}/~/settings/credits`}
133-
onClick={() => {
134-
if (onClickApply) {
135-
onClickApply();
136-
}
137-
}}
138-
>
139-
Apply Now
140-
</Link>
141-
</Button>
142-
</div>
143-
)}
14483
</div>
14584
);
14685
};

apps/dashboard/src/@/components/billing/PlanCard.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,26 @@
22

33
// TODO - convert to RSC
44

5-
import type { ThirdwebClient } from "thirdweb";
6-
import { type Account, useAccountCredits } from "@/hooks/useApi";
5+
import { useAccountCredits } from "@/hooks/useApi";
76
import { CreditsItem } from "./CreditsItem";
87

9-
export const CreditsInfoCard = (props: {
10-
twAccount: Account;
11-
client: ThirdwebClient;
12-
teamSlug: string;
13-
}) => {
8+
export const CreditsInfoCard = () => {
149
const { data: credits } = useAccountCredits();
1510

1611
if (!credits) {
1712
return null;
1813
}
1914

20-
const opCredit = credits.find((crd) => crd.name.startsWith("OP -"));
2115
const restCredits = credits.filter((crd) => !crd.name.startsWith("OP -"));
2216

17+
if (restCredits.length === 0) {
18+
return null;
19+
}
20+
2321
return (
2422
<section className="flex flex-col gap-4">
25-
<CreditsItem
26-
client={props.client}
27-
credit={opCredit}
28-
isOpCreditDefault={true}
29-
teamSlug={props.teamSlug}
30-
twAccount={props.twAccount}
31-
/>
32-
{restCredits?.map((credit) => (
33-
<CreditsItem
34-
client={props.client}
35-
credit={credit}
36-
key={credit.couponId}
37-
teamSlug={props.teamSlug}
38-
twAccount={props.twAccount}
39-
/>
23+
{restCredits.map((credit) => (
24+
<CreditsItem credit={credit} key={credit.couponId} />
4025
))}
4126
</section>
4227
);

apps/dashboard/src/app/(app)/(dashboard)/(chain)/utils.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import "server-only";
22

33
import { notFound } from "next/navigation";
44
import type { ChainMetadata } from "thirdweb/chains";
5-
import {
6-
getChainServices,
7-
getChains,
8-
getGasSponsoredChains,
9-
} from "@/api/chain";
5+
import { getChainServices, getChains } from "@/api/chain";
106
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs";
117
import type { ChainMetadataWithServices, ChainServices } from "@/types/chain";
128
import type { ChainCTAProps } from "./[chain_id]/(chainPage)/components/server/cta-card";
@@ -25,7 +21,6 @@ import cotiBanner from "./temp-assets/COTI_Banner.jpg";
2521
import cotiCTA from "./temp-assets/COTI_CTA.jpg";
2622
import creatorBanner from "./temp-assets/creatorBanner.png";
2723
import creatorCTA from "./temp-assets/creatorCTA.png";
28-
import superchainCTABG from "./temp-assets/cta-bg-superchain.png";
2924
import xaiCTABg from "./temp-assets/cta-bg-xai-connect.png";
3025
import thirdwebCTA from "./temp-assets/cta-thirdweb.png";
3126
import cyberChainBanner from "./temp-assets/cyberChainBanner.png";
@@ -135,17 +130,6 @@ type ExtraChainMetadata = Partial<{
135130
cta: ChainCTAProps;
136131
}>;
137132

138-
// TEMPORARY
139-
140-
const OP_CTA = {
141-
backgroundImageUrl: superchainCTABG.src,
142-
buttonLink: "/team/~/~/settings/credits",
143-
buttonText: "Apply now",
144-
description:
145-
"Successful applicants receive gas grants for use across all supported Optimism Superchain networks. These grants can sponsor gas fees for any onchain activity using our Account Abstraction tools.",
146-
title: "Optimism Superchain App Accelerator",
147-
} satisfies ChainCTAProps;
148-
149133
const chainMetaRecord = {
150134
// Flare
151135
14: {
@@ -933,22 +917,12 @@ const chainMetaRecord = {
933917
export async function getChainMetadata(
934918
chainId: number,
935919
): Promise<(ExtraChainMetadata & { gasSponsored?: true }) | null> {
936-
const gasSponsoredChains = await getGasSponsoredChains();
937-
938-
const isGasSponsored = gasSponsoredChains.includes(chainId);
939-
940920
// TODO: fetch this from the API
941921
if (chainId in chainMetaRecord) {
942922
return {
943-
...(isGasSponsored ? { cta: OP_CTA, gasSponsored: true } : {}),
944923
// this will OVERRIDE the op CTA if there is a custom one configured
945924
...chainMetaRecord[chainId as keyof typeof chainMetaRecord],
946925
};
947-
} else if (isGasSponsored) {
948-
return {
949-
cta: OP_CTA,
950-
gasSponsored: true,
951-
};
952926
}
953927
return null;
954928
}

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/page.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { redirect } from "next/navigation";
22
import { getStripeBalance } from "@/actions/stripe-actions";
3-
import { getAuthToken } from "@/api/auth-token";
43
import { getTeamBySlug, type Team } from "@/api/team";
54
import { getMemberByAccountId } from "@/api/team-members";
65
import { getTeamSubscriptions } from "@/api/team-subscription";
76
import { CreditsInfoCard } from "@/components/billing/PlanCard";
87
import { Coupons } from "@/components/billing/SubscriptionCoupons/Coupons";
9-
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
108
import { getValidAccount } from "../../../../../account/settings/getAccount";
119
import { CreditBalanceSection } from "./components/credit-balance-section.client";
1210
import { PlanInfoCardClient } from "./components/PlanInfoCard.client";
@@ -28,9 +26,8 @@ export default async function Page(props: {
2826

2927
const account = await getValidAccount(pagePath);
3028

31-
const [team, authToken, teamMember] = await Promise.all([
29+
const [team, teamMember] = await Promise.all([
3230
getTeamBySlug(params.team_slug),
33-
getAuthToken(),
3431
getMemberByAccountId(params.team_slug, account.id),
3532
]);
3633

@@ -50,11 +47,6 @@ export default async function Page(props: {
5047
);
5148
}
5249

53-
const client = getClientThirdwebClient({
54-
jwt: authToken,
55-
teamId: team.id,
56-
});
57-
5850
const highlightPlan =
5951
typeof searchParams.highlight === "string"
6052
? (searchParams.highlight as Team["billingPlan"])
@@ -84,11 +76,7 @@ export default async function Page(props: {
8476
/>
8577
)}
8678

87-
<CreditsInfoCard
88-
client={client}
89-
teamSlug={team.slug}
90-
twAccount={account}
91-
/>
79+
<CreditsInfoCard />
9280
<Coupons isPaymentSetup={validPayment} teamId={team.id} />
9381
</div>
9482
);

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/AccountAbstractionPage.tsx

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
"use client";
22

33
import { SmartWalletsBillingAlert } from "@app/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/Alerts";
4-
import { ArrowRightIcon } from "lucide-react";
5-
import Link from "next/link";
6-
import { DismissibleAlert } from "@/components/blocks/dismissible-alert";
7-
import { Button } from "@/components/ui/button";
84
import { TabPathLinks } from "@/components/ui/tabs";
95
import { UnderlineLink } from "@/components/ui/UnderlineLink";
106
import { AAFooter } from "./AAFooterSection";
@@ -44,10 +40,6 @@ export function AccountAbstractionLayout(props: {
4440
{props.hasSmartWalletsWithoutBilling && (
4541
<SmartWalletsBillingAlert teamSlug={props.teamSlug} />
4642
)}
47-
<GasCreditAlert
48-
projectId={props.projectId}
49-
teamSlug={props.teamSlug}
50-
/>
5143
</div>
5244

5345
<div className="h-4" />
@@ -89,40 +81,3 @@ export function AccountAbstractionLayout(props: {
8981
</div>
9082
);
9183
}
92-
93-
function GasCreditAlert(props: { teamSlug: string; projectId: string }) {
94-
return (
95-
<DismissibleAlert
96-
description={
97-
<>
98-
Redeem credits towards gas Sponsorship. <br className="lg:hidden" />
99-
<UnderlineLink
100-
href="https://thirdweb.com/superchain"
101-
rel="noopener noreferrer"
102-
target="_blank"
103-
>
104-
Learn More
105-
</UnderlineLink>
106-
<div className="mt-4 flex items-center gap-4">
107-
<Button
108-
asChild
109-
className="bg-background"
110-
size="sm"
111-
variant="outline"
112-
>
113-
<Link
114-
className="gap-2"
115-
href={`/team/${props.teamSlug}/~/settings/credits`}
116-
target="_blank"
117-
>
118-
Claim your credits <ArrowRightIcon className="size-4" />
119-
</Link>
120-
</Button>
121-
</div>
122-
</>
123-
}
124-
localStorageId={`${props.projectId}-gas-credit-alert`}
125-
title="OP Gas Credit Program"
126-
/>
127-
);
128-
}

0 commit comments

Comments
 (0)