@accret/api-client
Version:
A comprehensive SDK for blockchain data access via Moralis, Alchemy, and Shyft APIs
50 lines • 2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEVMTokensForWallet = getEVMTokensForWallet;
exports.getSolanaTokensForWallet = getSolanaTokensForWallet;
const moralis_1 = __importDefault(require("moralis"));
const constants_1 = require("../constants");
const config_1 = require("../config");
const js_1 = require("@shyft-to/js");
/**
* @description Fetches the token balances and prices for a given wallet address on an EVM chain.
* @param walletAddress The address of the wallet to fetch token balances for.
* @param network The EVM chain to fetch token balances from.
* @returns A paginated response containing the token balances and their prices.
*/
async function getEVMTokensForWallet(walletAddress, network) {
try {
const response = await moralis_1.default.EvmApi.wallets.getWalletTokenBalancesPrice({
address: walletAddress,
chain: network,
});
return response;
}
catch (error) {
console.error("Error getting token balances:", error);
throw error;
}
}
/**
* @description Fetches the token balances for a given wallet address on the Solana network using the Shyft SDK.
* @param walletAddress The address of the wallet to fetch token balances for.
* @returns A promise that resolves to the portfolio for the specified wallet address.
*/
async function getSolanaTokensForWallet(walletAddress) {
try {
const shyft = await (0, config_1.InitializeShyft)(constants_1.API_KEYS.SHYFT_API_KEY);
const response = await shyft.wallet.getPortfolio({
wallet: walletAddress,
network: js_1.Network.Mainnet,
});
return response;
}
catch (error) {
console.error("Error getting token balances:", error);
throw error;
}
}
//# sourceMappingURL=portfolio.js.map