fix: latest pull

This commit is contained in:
simplysabir
2025-01-01 17:17:24 +05:30
parent 42b64f2264
commit 376eaadffe
8 changed files with 184 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
import exp from "constants";
export * from "./request_faucet_funds";
export * from "./deploy_token";
export * from "./deploy_collection";
@@ -52,3 +54,4 @@ export * from "./rock_paper_scissor";
export * from "./create_tiplinks";
export * from "./tensor_trade";
export * from "./rugcheck";

53
src/tools/rugcheck.ts Normal file
View File

@@ -0,0 +1,53 @@
import { TokenCheck } from "../types";
const BASE_URL = "https://api.rugcheck.xyz/v1";
/**
* Fetches a summary report for a specific token.
* @async
* @param {string} mint - The mint address of the token.
* @returns {Promise<TokenCheck>} The token summary report.
* @throws {Error} If the API call fails.
*/
export async function fetchTokenReportSummary(
mint: string,
): Promise<TokenCheck> {
try {
const response = await fetch(`${BASE_URL}/tokens/${mint}/report/summary`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error: any) {
console.error(
`Error fetching report summary for token ${mint}:`,
error.message,
);
throw new Error(`Failed to fetch report summary for token ${mint}.`);
}
}
/**
* Fetches a detailed report for a specific token.
* @async
* @param {string} mint - The mint address of the token.
* @returns {Promise<TokenCheck>} The detailed token report.
* @throws {Error} If the API call fails.
*/
export async function fetchTokenDetailedReport(
mint: string,
): Promise<TokenCheck> {
try {
const response = await fetch(`${BASE_URL}/tokens/${mint}/report`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error: any) {
console.error(
`Error fetching detailed report for token ${mint}:`,
error.message,
);
throw new Error(`Failed to fetch detailed report for token ${mint}.`);
}
}