mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 23:16:55 +00:00
feat: change jup api to fetch token directly (#122)
# Pull Request Description ## Related Issue Fixes # (issue number) ## Changes Made This PR adds the following changes: <!-- List the key changes made in this PR --> - change jup api to fetch token directly ## Implementation Details <!-- Provide technical details about the implementation --> doc api: https://station.jup.ag/docs/token-list/token-list-api ## Transaction executed by agent <!-- If applicable, provide example usage, transactions, or screenshots --> Example transaction: ## Prompt Used <!-- If relevant, include the prompt or configuration used --> ``` Get token data from either a token address or ticker symbol ``` ## Additional Notes <!-- Any additional information that reviewers should know --> <img width="1455" alt="image" src="https://github.com/user-attachments/assets/1a95ec16-ad10-461e-8ca9-90f4f89616aa" /> ## Checklist - [x] I have tested these changes locally - [ ] I have updated the documentation - [ ] I have added a transaction link - [x] I have added the prompt used to test it
This commit is contained in:
@@ -9,17 +9,14 @@ export async function getTokenDataByAddress(
|
||||
throw new Error("Mint address is required");
|
||||
}
|
||||
|
||||
const response = await fetch("https://tokens.jup.ag/tokens?tags=verified", {
|
||||
const response = await fetch(`https://tokens.jup.ag/token/${mint}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
const data = (await response.json()) as JupiterTokenData[];
|
||||
const token = data.find((token: JupiterTokenData) => {
|
||||
return token.address === mint.toBase58();
|
||||
});
|
||||
const token = (await response.json()) as JupiterTokenData;
|
||||
return token;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Error fetching token data: ${error.message}`);
|
||||
|
||||
Reference in New Issue
Block a user