UNPKG

@accret/api-client

Version:

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

52 lines 2.04 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEVMTransactionHistory = getEVMTransactionHistory; exports.getSolanaTransactionHistory = getSolanaTransactionHistory; const moralis_1 = __importDefault(require("moralis")); const constants_1 = require("../constants"); const axios_1 = __importDefault(require("axios")); /** * Get the EVM transaction history for a specific address and network. * @param address The wallet address to fetch the transaction history for. * @param network The EVM chain to fetch the transaction history from. * @returns A promise that resolves to the transaction history response. */ async function getEVMTransactionHistory({ address, network, }) { try { const response = await moralis_1.default.EvmApi.wallets.getWalletHistory({ address, chain: network, order: "DESC", }); return response; } catch (error) { console.error("Error fetching EVM transaction history:", error); throw error; } } /** * @description Fetches the transaction history for a given Solana address using the Helius API. * @param address The Solana wallet address to fetch the transaction history for. * @returns A promise that resolves to the transaction history for the specified Solana address. */ async function getSolanaTransactionHistory(address) { try { const heliusApiKey = constants_1.API_KEYS.HELIUS_API_KEY; const url = `https://api.helius.xyz/v0/addresses/${address}/transactions`; const response = await axios_1.default.get(url, { params: { "api-key": heliusApiKey, }, }); return response.data; } catch (error) { console.log("Error fetching Solana transaction history:", error); return null; } } //# sourceMappingURL=transaction-history.js.map