Skip to content

Commit 0898092

Browse files
show all supported chains in AA docs
1 parent 1a45f21 commit 0898092

File tree

4 files changed

+82
-38
lines changed

4 files changed

+82
-38
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { NextResponse } from "next/server";
2+
import type { ChainMetadata } from "thirdweb/chains";
3+
import invariant from "tiny-invariant";
4+
5+
export const maxDuration = 300; // max timeout 300 seconds (5min)
6+
export const revalidate = 86400; // Revalidate every 24 hours (86400 seconds)
7+
8+
export async function GET() {
9+
const bundlerServiceKey = process.env.BUNDLER_SERVICE_KEY;
10+
invariant(bundlerServiceKey, "BUNDLER_SERVICE_KEY is not set");
11+
12+
const [aaChains, allChains] = await Promise.all([
13+
fetch("https://1.bundler.thirdweb.com/service/chains", {
14+
headers: {
15+
"Content-Type": "application/json",
16+
"x-service-api-key": bundlerServiceKey,
17+
},
18+
})
19+
.then((res) => res.json() as Promise<{ data: number[] }>)
20+
.catch((error) => {
21+
console.error(error);
22+
return { data: [] as number[] };
23+
}),
24+
fetch("https://api.thirdweb.com/v1/chains", {
25+
headers: {
26+
"Content-Type": "application/json",
27+
},
28+
})
29+
.then((res) => res.json() as Promise<{ data: ChainMetadata[] }>)
30+
.catch((error) => {
31+
console.error(error);
32+
return { data: [] as ChainMetadata[] };
33+
}),
34+
]);
35+
36+
const intersectedChains = allChains.data
37+
.filter((chain) =>
38+
aaChains.data.some((aaChainId) => aaChainId === chain.chainId),
39+
)
40+
.filter((c) => c.name)
41+
.sort((a, b) => a.name.localeCompare(b.name));
42+
43+
return NextResponse.json({
44+
data: intersectedChains,
45+
});
46+
}

apps/portal/src/app/connect/account-abstraction/infrastructure/page.mdx

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createMetadata } from "@doc";
1+
import { createMetadata, AAChainList } from "@doc";
22

33
export const metadata = createMetadata({
44
image: {
@@ -23,43 +23,7 @@ You can configure your client ID to restrict interactions only with your own con
2323

2424
With a thirdweb API key, you get access to bundler and paymaster infrastructure on the following chains:
2525

26-
| Chain | Mainnet | Testnet |
27-
| -------------------- | ------- | ------- |
28-
| Ethereum |||
29-
| Polygon |||
30-
| Arbitrum (one, nova) |||
31-
| Optimism |||
32-
| Gnosis |||
33-
| Linea |||
34-
| Base |||
35-
| Avalanche C-Chain |||
36-
| Scroll |||
37-
| Celo |||
38-
| Binance |||
39-
| Xai Orbit |||
40-
| Mode |||
41-
| Zora |||
42-
| Fraxtal |||
43-
| Lisk |||
44-
| Taiko |||
45-
| Degen |||
46-
| Mantle |||
47-
| Ancient8 |||
48-
| Blast |||
49-
| B3 |||
50-
| Plume |||
51-
| Camp Network |||
52-
| Vanar |||
53-
| DFK |||
54-
| Form |||
55-
| Cyber |||
56-
| Treasure Ruby |||
57-
| Redstone |||
58-
| Klaytn Cypress |||
59-
| OpBNB |||
60-
| Nautilus |||
61-
| Fuse |||
62-
| zkCandy |||
26+
<AAChainList />
6327

6428
To support a chain not listed, [contact us](https://thirdweb.com/contact-us).
6529

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable @next/next/no-img-element */
2+
import { cn } from "@/lib/utils";
3+
import type { ChainMetadata } from "thirdweb/chains";
4+
import { getBaseUrl } from "../../lib/getBaseUrl";
5+
6+
async function getChains(): Promise<ChainMetadata[]> {
7+
try {
8+
const chains = await fetch(`${getBaseUrl()}/api/aa-chains`);
9+
if (!chains.ok) {
10+
return [];
11+
}
12+
const result = (await chains.json()) as { data: ChainMetadata[] };
13+
return result.data;
14+
} catch (error) {
15+
console.error(error);
16+
return [];
17+
}
18+
}
19+
20+
export async function AAChainList() {
21+
const chains = await getChains();
22+
return (
23+
<div className={cn("my-4 rounded-lg border p-4")}>
24+
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
25+
{chains?.map((chain) => (
26+
<li key={chain.name} className="flex items-center">
27+
{chain.name} ({chain.chainId})
28+
</li>
29+
))}
30+
</ul>
31+
</div>
32+
);
33+
}

apps/portal/src/components/Document/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export { Stack } from "./Stack";
2525
export { createMetadata } from "./metadata";
2626
export { ConnectCard } from "./Cards/ConnectCard";
2727
export { FeatureCard } from "./FeatureCard";
28+
export { AAChainList } from "./AAChainList";

0 commit comments

Comments
 (0)