UNPKG

tensaikit

Version:

An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.

30 lines (29 loc) 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.makeSubgraphQueryCall = void 0; const fetchFromApi_1 = require("./fetchFromApi"); const makeSubgraphQueryCall = async (subgraphURL, subgraphQuery, apiKey) => { try { const headers = { "Content-Type": "application/json", }; if (apiKey) { headers["Authorization"] = `Bearer ${apiKey}`; } const response = await (0, fetchFromApi_1.fetchFromApi)(subgraphURL, { method: "POST", headers, body: subgraphQuery, }); if (response?.data) { return response.data; } else { return null; } } catch (error) { throw new Error(`Subgraph query failed ${subgraphURL}: ${error.message}`); } }; exports.makeSubgraphQueryCall = makeSubgraphQueryCall;