Skip to content

Commit c54822f

Browse files
committed
[Dashboard] Fix: Only show sponsorship banner on AA page when on eligible chain (#4362)
<!-- start pr-codex --> ## PR-Codex overview The focus of this PR is to implement a feature that automatically applies gas credits for specific blockchain chains in the application. ### Detailed summary - Added `chain` state using `useActiveWalletChain` hook - Implemented logic to check if the current chain is in a predefined list - Updated UI to display information based on the chain eligibility > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent d8c88ef commit c54822f

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

apps/dashboard/src/pages/dashboard/connect/account-abstraction.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { NextSeo } from "next-seo";
2828
import { useRouter } from "next/router";
2929
import { PageId } from "page-id";
3030
import { useMemo, useState } from "react";
31+
import { useActiveWalletChain } from "thirdweb/react";
3132
import {
3233
Card,
3334
Heading,
@@ -53,6 +54,7 @@ const DashboardConnectAccountAbstraction: ThirdwebNextPage = () => {
5354
const [selectedKey_, setSelectedKey] = useState<undefined | ApiKey>();
5455
const meQuery = useAccount();
5556
const account = meQuery?.data;
57+
const chain = useActiveWalletChain();
5658

5759
const apiKeys = useMemo(() => {
5860
return (keysQuery?.data || []).filter((key) => {
@@ -89,6 +91,10 @@ const DashboardConnectAccountAbstraction: ThirdwebNextPage = () => {
8991
);
9092
}, [apiKeys, account]);
9193

94+
const isOpChain = useMemo(() => {
95+
return [10, 8453, 7777777, 252, 34443].includes(chain?.id || 0);
96+
}, [chain]);
97+
9298
const seo = {
9399
title: "The Complete Account Abstraction Toolkit | thirdweb",
94100
desc: "Add account abstraction to your web3 app & unlock powerful features for seamless onboarding, customizable transactions, & maximum security. Get started.",
@@ -167,27 +173,29 @@ const DashboardConnectAccountAbstraction: ThirdwebNextPage = () => {
167173
{hasSmartWalletsWithoutBilling ? (
168174
<SmartWalletsBillingAlert />
169175
) : (
170-
<Alert
171-
status="info"
172-
borderRadius="lg"
173-
backgroundColor="backgroundCardHighlight"
174-
borderLeftColor="blue.500"
175-
borderLeftWidth={4}
176-
as={Flex}
177-
gap={1}
178-
>
179-
<AlertIcon />
180-
<Flex flexDir="column">
181-
<AlertTitle>
182-
Using the gas credits for OP chain paymaster
183-
</AlertTitle>
184-
<AlertDescription as={Text}>
185-
Credits will automatically be applied to cover gas fees for any
186-
onchain activity across thirdweb services. <br />
187-
Eligible chains: OP Mainnet, Base, Zora, Frax, Mode.
188-
</AlertDescription>
189-
</Flex>
190-
</Alert>
176+
isOpChain && (
177+
<Alert
178+
status="info"
179+
borderRadius="lg"
180+
backgroundColor="backgroundCardHighlight"
181+
borderLeftColor="blue.500"
182+
borderLeftWidth={4}
183+
as={Flex}
184+
gap={1}
185+
>
186+
<AlertIcon />
187+
<Flex flexDir="column">
188+
<AlertTitle>
189+
Using the gas credits for OP chain paymaster
190+
</AlertTitle>
191+
<AlertDescription as={Text}>
192+
Credits will automatically be applied to cover gas fees for any
193+
onchain activity across thirdweb services. <br />
194+
Eligible chains: OP Mainnet, Base, Zora, Frax, Mode.
195+
</AlertDescription>
196+
</Flex>
197+
</Alert>
198+
)
191199
)}
192200

193201
{!hasApiKeys && <NoApiKeys service="Account Abstraction" />}

0 commit comments

Comments
 (0)