Skip to content

Commit

Permalink
fix: use header key from api config (#2518)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcel Rableski <[email protected]>
Co-authored-by: Sayo <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2025
1 parent 1c3da82 commit ace85ae
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-coingecko/src/actions/getMarkets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default {

try {
const config = await validateCoingeckoConfig(runtime);
const { baseUrl, apiKey } = getApiConfig(config);
const { baseUrl, apiKey, headerKey } = getApiConfig(config);

// Get categories through the provider
const categories = await getCategoriesData(runtime);
Expand Down Expand Up @@ -186,7 +186,7 @@ export default {
{
headers: {
'accept': 'application/json',
'x-cg-pro-api-key': apiKey
[headerKey]: apiKey
},
params: {
vs_currency: content.vs_currency,
Expand Down Expand Up @@ -305,4 +305,4 @@ export default {
},
],
] as ActionExample[][],
} as Action;
} as Action;
4 changes: 2 additions & 2 deletions packages/plugin-coingecko/src/actions/getPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {

// Fetch price from CoinGecko
const config = await validateCoingeckoConfig(runtime);
const { baseUrl, apiKey } = getApiConfig(config);
const { baseUrl, apiKey, headerKey } = getApiConfig(config);

elizaLogger.log(`Fetching prices for ${coinIds} in ${vs_currencies}...`);
elizaLogger.log("API request URL:", `${baseUrl}/simple/price`);
Expand All @@ -146,7 +146,7 @@ export default {
},
headers: {
'accept': 'application/json',
'x-cg-pro-api-key': apiKey
[headerKey]: apiKey
}
}
);
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-coingecko/src/actions/getPricePerAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {

// Get API configuration
const config = await validateCoingeckoConfig(runtime);
const { baseUrl, apiKey } = getApiConfig(config);
const { baseUrl, apiKey, headerKey } = getApiConfig(config);

// Fetch token data
elizaLogger.log("Fetching token data...");
Expand All @@ -107,7 +107,7 @@ export default {
{
headers: {
accept: "application/json",
"x-cg-pro-api-key": apiKey,
[headerKey]: apiKey,
},
}
);
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-coingecko/src/providers/categoriesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const MAX_RETRIES = 3;

async function fetchCategories(runtime: IAgentRuntime): Promise<CategoryItem[]> {
const config = await validateCoingeckoConfig(runtime);
const { baseUrl, apiKey } = getApiConfig(config);
const { baseUrl, apiKey, headerKey } = getApiConfig(config);

const response = await axios.get<CategoryItem[]>(
`${baseUrl}/coins/categories/list`,
{
headers: {
'accept': 'application/json',
'x-cg-pro-api-key': apiKey
[headerKey]: apiKey
},
timeout: 5000 // 5 second timeout
}
Expand Down Expand Up @@ -107,4 +107,4 @@ export const categoriesProvider: Provider = {
// Helper function for actions to get raw categories data
export async function getCategoriesData(runtime: IAgentRuntime): Promise<CategoryItem[]> {
return getCategories(runtime);
}
}
6 changes: 3 additions & 3 deletions packages/plugin-coingecko/src/providers/coinsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MAX_RETRIES = 3;

async function fetchCoins(runtime: IAgentRuntime, includePlatform = false): Promise<CoinItem[]> {
const config = await validateCoingeckoConfig(runtime);
const { baseUrl, apiKey } = getApiConfig(config);
const { baseUrl, apiKey, headerKey } = getApiConfig(config);

const response = await axios.get<CoinItem[]>(
`${baseUrl}/coins/list`,
Expand All @@ -24,7 +24,7 @@ async function fetchCoins(runtime: IAgentRuntime, includePlatform = false): Prom
},
headers: {
'accept': 'application/json',
'x-cg-pro-api-key': apiKey
[headerKey]: apiKey
},
timeout: 5000 // 5 second timeout
}
Expand Down Expand Up @@ -111,4 +111,4 @@ export const coinsProvider: Provider = {
// Helper function for actions to get raw coins data
export async function getCoinsData(runtime: IAgentRuntime, includePlatform = false): Promise<CoinItem[]> {
return getCoins(runtime, includePlatform);
}
}

0 comments on commit ace85ae

Please sign in to comment.