-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add idl interaction and parsing to devtools #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8e3267c
feat: add idl interaction and parsing to devtools
stevesarmiento c56f244
chore: split monolithic idl and transaction plugins into smaller modules
stevesarmiento 0f5d3e6
nit: RPC to bottom bar
stevesarmiento 61b51c7
feat: add node based canvas for tx viewing
stevesarmiento 770fe72
feat: add titan transactions for devtools testing
stevesarmiento 0dacb3e
add preflight/postflight simulation, dropdown styles, tab styling
stevesarmiento 05f48d5
Merge branch 'main' into devtools-interact
stevesarmiento 170f8e7
chore: resolve merge conflicts
stevesarmiento 648e18c
greptile review
stevesarmiento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,79 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
|
|
||
| // Demo endpoints by region | ||
| const TITAN_DEMO_URLS: Record<string, string> = { | ||
| us1: 'https://us1.api.demo.titan.exchange', | ||
| jp1: 'https://jp1.api.demo.titan.exchange', | ||
| de1: 'https://de1.api.demo.titan.exchange', | ||
| }; | ||
|
|
||
| /** | ||
| * Next.js API route proxy for Titan API. | ||
| * Proxies all requests to Titan's API to work around CORS restrictions. | ||
| * | ||
| * Usage: /api/titan/api/v1/quote/swap?inputMint=...®ion=us1 | ||
| * → proxied to https://us1.api.demo.titan.exchange/api/v1/quote/swap?inputMint=... | ||
| * | ||
| * Environment: | ||
| * - TITAN_API_TOKEN: Your Titan API JWT token (required for demo endpoints) | ||
| * | ||
| * Query params: | ||
| * - region: 'us1' | 'jp1' | 'de1' (default: 'us1') - selects Titan endpoint | ||
| * - ...all other params forwarded to Titan | ||
| */ | ||
| export async function GET(request: NextRequest, { params }: { params: Promise<{ path: string[] }> }) { | ||
| const { path } = await params; | ||
| const titanPath = '/' + path.join('/'); | ||
| const searchParams = request.nextUrl.searchParams; | ||
|
|
||
| // Extract region (used for routing, not forwarded) | ||
| const region = searchParams.get('region') || 'us1'; | ||
| const baseUrl = TITAN_DEMO_URLS[region] || TITAN_DEMO_URLS.us1; | ||
|
|
||
| // Build params to forward (exclude 'region') | ||
| const forwardParams = new URLSearchParams(); | ||
| searchParams.forEach((value, key) => { | ||
| if (key !== 'region') { | ||
| forwardParams.set(key, value); | ||
| } | ||
| }); | ||
|
|
||
| const url = forwardParams.toString() ? `${baseUrl}${titanPath}?${forwardParams}` : `${baseUrl}${titanPath}`; | ||
|
|
||
| try { | ||
| // Use server-side token from env, or forward client header as fallback | ||
| const authToken = process.env.TITAN_API_TOKEN || request.headers.get('Authorization')?.replace('Bearer ', ''); | ||
| const headers: Record<string, string> = { | ||
| Accept: 'application/msgpack', | ||
| }; | ||
| if (authToken) { | ||
| headers['Authorization'] = `Bearer ${authToken}`; | ||
| } | ||
|
|
||
| const response = await fetch(url, { headers }); | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text().catch(() => 'Unknown error'); | ||
| console.error(`Titan API error (${response.status}) at ${titanPath}:`, errorText); | ||
| return new NextResponse(errorText, { | ||
| status: response.status, | ||
| headers: { 'Content-Type': 'text/plain' }, | ||
| }); | ||
| } | ||
|
|
||
| // Return MessagePack binary response as-is | ||
| const buffer = await response.arrayBuffer(); | ||
| return new NextResponse(buffer, { | ||
| status: 200, | ||
| headers: { | ||
| 'Content-Type': 'application/msgpack', | ||
| }, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Titan API proxy error:', error); | ||
| return new NextResponse(error instanceof Error ? error.message : 'Failed to proxy Titan request', { | ||
| status: 500, | ||
| headers: { 'Content-Type': 'text/plain' }, | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.