Skip to content

Commit 23ddb2a

Browse files
show all supported chains in AA docs
1 parent df128bf commit 23ddb2a

File tree

4 files changed

+71
-38
lines changed

4 files changed

+71
-38
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextResponse } from "next/server";
2+
import invariant from "tiny-invariant";
3+
4+
export async function GET() {
5+
const bundlerServiceKey = process.env.BUNDLER_SERVICE_KEY;
6+
invariant(bundlerServiceKey, "BUNDLER_SERVICE_KEY is not set");
7+
8+
const response = await fetch("http://1.bundler.thirdweb.com/service/chains", {
9+
headers: {
10+
"Content-Type": "application/json",
11+
"x-service-api-key": bundlerServiceKey,
12+
},
13+
});
14+
const data = await response.json();
15+
return NextResponse.json(data);
16+
}

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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* eslint-disable @next/next/no-img-element */
2+
import { cn } from "@/lib/utils";
3+
import {
4+
type ChainMetadata,
5+
defineChain,
6+
getChainMetadata,
7+
} from "thirdweb/chains";
8+
import { getBaseUrl } from "../../lib/getBaseUrl";
9+
10+
async function getChains(): Promise<ChainMetadata[]> {
11+
const chains = await fetch(`${getBaseUrl()}/api/aa-chains`);
12+
if (!chains.ok) {
13+
return [];
14+
}
15+
const aaChains = (await chains.json()) as { data: number[] };
16+
const chunkSize = 5;
17+
// dont fetch all chains at once to avoid rate limiting
18+
const allChains = await Promise.all(
19+
Array.from(
20+
{ length: Math.ceil(aaChains.data.length / chunkSize) },
21+
async (_, i) => {
22+
if (i > 0) {
23+
await new Promise((resolve) => setTimeout(resolve, 300));
24+
}
25+
return Promise.all(
26+
aaChains.data
27+
.slice(i * chunkSize, (i + 1) * chunkSize)
28+
.map((id) => getChainMetadata(defineChain({ id }))),
29+
);
30+
},
31+
),
32+
);
33+
return allChains
34+
.flat()
35+
.filter((c) => c.name)
36+
.sort((a, b) => a.name.localeCompare(b.name));
37+
}
38+
39+
export async function AAChainList() {
40+
const chains = await getChains();
41+
return (
42+
<div className={cn("my-4 rounded-lg border p-4")}>
43+
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
44+
{chains?.map((chain) => (
45+
<li key={chain.name} className="flex items-center">
46+
{chain.name} ({chain.chainId})
47+
</li>
48+
))}
49+
</ul>
50+
</div>
51+
);
52+
}

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)