Fix formatting issues and removing unusued libaries

This commit is contained in:
Fahri Bilici
2024-12-30 22:31:15 +01:00
parent 3b4fddd65a
commit c00515f3d2
35 changed files with 574 additions and 662 deletions

View File

@@ -12,14 +12,14 @@ const getTokenDataAction: Action = {
"token details",
"lookup token",
"find token",
"token data"
"token data",
],
description: "Get token data from either a token address or ticker symbol",
examples: [
[
{
input: {
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
},
output: {
status: "success",
@@ -27,16 +27,16 @@ const getTokenDataAction: Action = {
name: "USD Coin",
symbol: "USDC",
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
decimals: 6
}
decimals: 6,
},
},
explanation: "Get token data using the token's address"
}
explanation: "Get token data using the token's address",
},
],
[
{
input: {
ticker: "SOL"
ticker: "SOL",
},
output: {
status: "success",
@@ -44,19 +44,21 @@ const getTokenDataAction: Action = {
name: "Wrapped SOL",
symbol: "SOL",
address: "So11111111111111111111111111111111111111112",
decimals: 9
}
decimals: 9,
},
},
explanation: "Get token data using the token's ticker symbol"
}
]
explanation: "Get token data using the token's ticker symbol",
},
],
],
schema: z.object({
address: z.string().optional().describe("The token's mint address"),
ticker: z.string().optional().describe("The token's ticker symbol")
}).refine(data => data.address || data.ticker, {
message: "Either address or ticker must be provided"
}),
schema: z
.object({
address: z.string().optional().describe("The token's mint address"),
ticker: z.string().optional().describe("The token's ticker symbol"),
})
.refine((data) => data.address || data.ticker, {
message: "Either address or ticker must be provided",
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
let tokenData: JupiterTokenData | undefined;
@@ -71,7 +73,7 @@ const getTokenDataAction: Action = {
if (!tokenData) {
return {
status: "error",
message: "Token not found or not verified"
message: "Token not found or not verified",
};
}
return {
@@ -81,16 +83,16 @@ const getTokenDataAction: Action = {
symbol: tokenData.symbol,
address: tokenData.address,
decimals: tokenData.decimals,
logoURI: tokenData.logoURI
}
logoURI: tokenData.logoURI,
},
};
} catch (error: any) {
return {
status: "error",
message: `Failed to get token data: ${error.message}`
message: `Failed to get token data: ${error.message}`,
};
}
}
},
};
export default getTokenDataAction;
export default getTokenDataAction;