"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Moralis = void 0;
const ApiHandler_1 = require("../helper/ApiHandler");
class Moralis {
    constructor() {
        this.apiKey = process.env.MORALIS_API_KEY || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImU4MGFjNmFhLTIwMTQtNGRjNi05MmFiLTliZDI1MDljNDI1MiIsIm9yZ0lkIjoiNDQ5OTY2IiwidXNlcklkIjoiNDYyOTc1IiwidHlwZUlkIjoiMjU3M2YyYmEtYTY0Yy00MDA1LTk3ODQtYWZkMmJkNmFhZjg3IiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3NDg1NDE2MzksImV4cCI6NDkwNDMwMTYzOX0.JUgAV1BTI_hN7hJA8D9ufTL_23WOX7UxyekCw71ANfg";
        if (!this.apiKey) {
            throw new Error("MORALIS_API_KEY is not set in the environment variables.");
        }
        this.apiHandler = new ApiHandler_1.ApiHandler("https://deep-index.moralis.io/api/v2.2");
    }
    async getDefiPositionsbyAddress(address) {
        try {
            return await this.apiHandler.get(`/wallets/${address}/defi/positions`, {
                "accept": "application/json",
                "X-API-Key": this.apiKey
            }, {});
        }
        catch (error) {
            console.error("Error fetching Defi Positions by address:", error);
            return null;
        }
    }
    async getNFTsbyAddress(address, chain) {
        try {
            return await this.apiHandler.get(`/${address}/nft?chain=${chain}&format=decimal&normalizeMetadata=true&media_items=false&include_prices=true`, {
                "accept": "application/json",
                "X-API-Key": this.apiKey
            }, {});
        }
        catch (error) {
            console.error("Error fetching NFTs by address:", error);
            return null;
        }
    }
}
exports.Moralis = Moralis;
