UNPKG

@ledgerhq/coin-algorand

Version:
35 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBalance = getBalance; const network_1 = require("../network"); const common_1 = require("./common"); /** * Get the balance of an Algorand account * @param address - The account address * @returns Array of balances (native ALGO + ASA tokens) */ async function getBalance(address) { const account = await (0, network_1.getAccount)(address); const nbAssets = account.assets.length; // min balance can be increased if user deployed apps, not supported yet const minimumBalance = (0, common_1.computeMinimumBalance)(nbAssets); const balances = [ { value: BigInt(account.balance.toFixed()), asset: { type: "native" }, locked: minimumBalance, }, ]; // Add ASA token balances for (const asset of account.assets) { balances.push({ value: BigInt(asset.balance.toFixed()), asset: { type: "asa", assetReference: asset.assetId, }, }); } return balances; } //# sourceMappingURL=getBalance.js.map