Skip to content
Open
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
17 changes: 17 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"permissions": {
"allow": [
"Bash(rtk grep *)",
"Bash(rtk read *)",
Comment on lines +1 to +5
"Bash(rtk find *)",
"Bash(rtk ls *)",
"Bash(rtk tsc *)",
"Bash(rtk lint *)",
"Bash(rtk prettier *)",
"Bash(rtk proxy *)",
"Bash(python3 -)",
"Bash(rtk vitest *)",
"Bash(MEASURE=1 rtk proxy pnpm exec vitest --config vitest.config.ts --run --reporter=verbose src/token-registry/__tests__/measure.test.ts)"
]
}
}
Empty file.
Binary file added .pnpm-store/v11/index.db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { NextRequest, NextResponse } from 'next/server';

import { isSupportedPair } from '@/app/src/token-registry/constants';
import { resolveImport } from '@/app/src/token-registry/server/resolveImport';

export const dynamic = 'force-dynamic';

export async function GET(
_request: NextRequest,
{
params,
}: {
params: Promise<{
sourceChainId: string;
destinationChainId: string;
address: string;
}>;
},
) {
const { sourceChainId, destinationChainId, address } = await params;
const pair = {
sourceChainId: Number(sourceChainId),
destinationChainId: Number(destinationChainId),
};

if (!isSupportedPair(pair)) {
return NextResponse.json(
{
error: `Unsupported chain pair: ${sourceChainId} -> ${destinationChainId}`,
},
{ status: 404 },
);
}

const resolution = await resolveImport(pair, address);

if (!resolution) {
return NextResponse.json(
{ error: 'Token is not transferable on this chain pair' },
{ status: 404 },
);
}

return NextResponse.json(resolution);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from 'next/server';

import { getRouteMap } from '@/app/src/token-registry/server/generate';

export const dynamic = 'force-dynamic';

export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ sourceChainId: string; destinationChainId: string }> },
) {
const { sourceChainId, destinationChainId } = await params;
const pair = {
sourceChainId: Number(sourceChainId),
destinationChainId: Number(destinationChainId),
};

const artifact = await getRouteMap(pair);

if (!artifact) {
return NextResponse.json(
{
error: `Unsupported chain pair: ${sourceChainId} -> ${destinationChainId}`,
},
{ status: 404 },
);
}

return NextResponse.json(artifact, {
headers: {
'Cache-Control': 'public, max-age=0, s-maxage=3600, stale-while-revalidate=3600',
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from 'next/server';

import { getSwapDestinations } from '@/app/src/token-registry/server/generate';

export const dynamic = 'force-dynamic';

export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ sourceChainId: string; destinationChainId: string }> },
) {
const { sourceChainId, destinationChainId } = await params;
const pair = {
sourceChainId: Number(sourceChainId),
destinationChainId: Number(destinationChainId),
};

const swapDestinations = await getSwapDestinations(pair);

if (swapDestinations === null) {
return NextResponse.json(
{
error: `Unsupported chain pair: ${sourceChainId} -> ${destinationChainId}`,
},
{ status: 404 },
);
}

return NextResponse.json(swapDestinations, {
headers: {
'Cache-Control': 'public, max-age=0, s-maxage=3600, stale-while-revalidate=3600',
},
});
}
26 changes: 26 additions & 0 deletions packages/app/src/app/api/token-registry/tokens/[chainId]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextRequest, NextResponse } from 'next/server';

import { supportedChainIds } from '@/app/src/token-registry/constants';
import { getChainTokens } from '@/app/src/token-registry/server/generate';

export const dynamic = 'force-dynamic';

export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ chainId: string }> },
) {
const { chainId: rawChainId } = await params;
const chainId = Number(rawChainId);

if (!supportedChainIds.includes(chainId)) {
return NextResponse.json({ error: `Unsupported chain: ${rawChainId}` }, { status: 404 });
}

const tokens = await getChainTokens(chainId);

return NextResponse.json(tokens, {
headers: {
'Cache-Control': 'public, max-age=0, s-maxage=3600, stale-while-revalidate=3600',
},
});
}
Loading
Loading