UNPKG

@accret/api-client

Version:

A comprehensive SDK for blockchain data access via Moralis, Alchemy, and Shyft APIs

74 lines 3.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AccretClient = void 0; const token_1 = require("./token"); const config_1 = require("./config"); const portfolio_1 = require("./portfolio"); const supportedChain_1 = require("./utils/supportedChain"); const constants_1 = require("./constants"); const types_1 = require("./types"); const alchemy_sdk_1 = require("alchemy-sdk"); class AccretClient { /** * Returns the singleton instance of the AccretClient. * If the instance does not exist, it creates a new one. * @returns The singleton instance of AccretClient. */ constructor() { this.getTokenMetadata = token_1.getTokenMetadata; this.getTokenPrice = token_1.getTokenPrice; this.getHistoricalTokenPrice = token_1.getHistoricalTokenPrice; this.getTokensForWallet = portfolio_1.getTokensForWallet; this.getTransactionHistory = portfolio_1.getTransactionHistory; this.getAccretSupportedChain = supportedChain_1.getAccretSupportedChain; this.getChainIdentifiers = supportedChain_1.getChainIdentifiers; // Exporting types and constants this.AccretSupportedChain = types_1.AccretSupportedChain; this.HistoricalPriceInterval = alchemy_sdk_1.HistoricalPriceInterval; if (!AccretClient.instance) { AccretClient.instance = this; return; } return AccretClient.instance; } /** * Initializes the Accret client with the provided API keys. * @param alchemyApiKey - The Alchemy API key. * @param moralisApiKey - The Moralis API key. * @param shyftApiKey - The Shyft API key. * @param heliusApiKey - The Helius API key. * @throws An error if any of the API keys are invalid. */ async configure({ alchemyApiKey, moralisApiKey, shyftApiKey, heliusApiKey, }) { if (!alchemyApiKey || typeof alchemyApiKey !== "string" || alchemyApiKey.trim().length === 0) { throw new Error("Invalid Alchemy API key: API key must be a non-empty string"); } if (!moralisApiKey || typeof moralisApiKey !== "string" || moralisApiKey.trim().length === 0) { throw new Error("Invalid Moralis API key: API key must be a non-empty string"); } if (!shyftApiKey || typeof shyftApiKey !== "string" || shyftApiKey.trim().length === 0) { throw new Error("Invalid Shyft API key: API key must be a non-empty string"); } if (!heliusApiKey || typeof heliusApiKey !== "string" || heliusApiKey.trim().length === 0) { throw new Error("Invalid Helius API key: API key must be a non-empty string"); } await (0, constants_1.setAPIKeys)({ alchemyApiKey, moralisApiKey, shyftApiKey, heliusApiKey, }); await (0, config_1.InitializeMoralis)(moralisApiKey); return AccretClient.instance; } } exports.AccretClient = AccretClient; //# sourceMappingURL=index.js.map