-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add a prototype edge function using the solflare token SDK
- Loading branch information
1 parent
47006f0
commit 361bed5
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NextRequest, NextResponse } from "next/server" | ||
import { Client, ChainId, UtlConfig } from '@solflare-wallet/utl-sdk'; | ||
|
||
export async function GET(req: NextRequest) { | ||
const params = req.nextUrl.searchParams; | ||
const query = params.get('query'); | ||
if (!query) return NextResponse.json([]); | ||
|
||
const config: UtlConfig = { | ||
...new UtlConfig(), | ||
chainId: ChainId.MAINNET // TODO: query param | ||
}; | ||
const tokenClient = new Client(config); | ||
const tokens = await tokenClient.searchMints(query, { start: 0, limit: 20 }); | ||
|
||
return NextResponse.json(tokens); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NextRequest, NextResponse } from "next/server" | ||
import { Client, ChainId, UtlConfig } from '@solflare-wallet/utl-sdk'; | ||
|
||
|
||
export const config = { | ||
runtime: 'edge', | ||
} | ||
|
||
export async function GET(req: NextRequest) { | ||
const params = req.nextUrl.searchParams; | ||
const query = params.get('query'); | ||
if (!query) return NextResponse.json([]); | ||
|
||
const config: UtlConfig = { | ||
...new UtlConfig(), | ||
chainId: ChainId.MAINNET // TODO: query param | ||
}; | ||
const tokenClient = new Client(config); | ||
const tokens = await tokenClient.searchMints(query, { start: 0, limit: 20 }); | ||
|
||
return NextResponse.json(tokens); | ||
} |