-
Notifications
You must be signed in to change notification settings - Fork 136
[CON-667] Update Solana Staking UI #146
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
4fc0074
update to Jupiter Price API v3, rebrand to Quicknode
mikejhale 6a830a1
update next to patch vulnerability
mikejhale 7237327
add link to Jupiter for API key
mikejhale 967c392
move price call to api, update README.md
mikejhale 0be11d7
update logo
c8b487f
Merge branch 'main' into con-667-update-solana-staking-ui
mikejhale 89cc9da
remove unused code
mikejhale 04f06a7
update NextJS version in README
mikejhale 66fe802
update branding and preview
mikejhale 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| DEVNET_RPC_ENDPOINT=https://example.solana-devnet.quiknode.pro/12345/ | ||
| MAINNET_RPC_ENDPOINT=https://example.solana-mainnet.quiknode.pro/12345/ | ||
| NEXT_PUBLIC_NETWORK_ENV=mainnet | ||
| NEXT_PUBLIC_VALIDATOR_ADDRESS=5s3vajJvaAbabQvxFdiMfg14y23b2jvK6K2Mw4PYcYK | ||
| NEXT_PUBLIC_VALIDATOR_ADDRESS=5s3vajJvaAbabQvxFdiMfg14y23b2jvK6K2Mw4PYcYK | ||
| JUPITER_API_KEY=your_jupiter_api_key |
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,54 @@ | ||
| import { NextResponse } from "next/server"; | ||
| import { WRAPPED_SOL_ADDRESS } from "@/utils/solana/price"; | ||
|
|
||
| const JUPITER_PRICE_ENDPOINT = "https://api.jup.ag/price/v3"; | ||
|
|
||
| interface TokenPrice { | ||
| createdAt: string; | ||
| liquidity: number; | ||
| usdPrice: number; | ||
| blockId: number; | ||
| decimals: number; | ||
| } | ||
|
|
||
| interface JupiterPriceResponse { | ||
| [address: string]: TokenPrice; | ||
| } | ||
|
|
||
| export async function GET() { | ||
| try { | ||
| const url = new URL(JUPITER_PRICE_ENDPOINT); | ||
| url.searchParams.set("ids", WRAPPED_SOL_ADDRESS); | ||
|
|
||
| const apiKey = process.env.JUPITER_API_KEY; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we throw earlier (ie, as soon as the server starts) if the environment variable isn't set, rather than waiting for an incoming GET? |
||
| if (!apiKey) { | ||
| return NextResponse.json( | ||
| { error: "JUPITER_API_KEY is not set in environment variables" }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
|
|
||
| const response = await fetch(url, { | ||
| headers: { | ||
| "x-api-key": apiKey, | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| return NextResponse.json( | ||
| { error: `Failed to fetch price: ${response.status}` }, | ||
| { status: response.status } | ||
| ); | ||
| } | ||
|
|
||
| const data: JupiterPriceResponse = await response.json(); | ||
| return NextResponse.json(data); | ||
| } catch (error) { | ||
| console.error("Error fetching price:", error); | ||
| return NextResponse.json( | ||
| { error: "Failed to fetch SOL price" }, | ||
| { status: 500 } | ||
| ); | ||
| } | ||
| } | ||
|
|
||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can update the screenshot due to rebranding