UNPKG

@openocean.finance/widget-sdk

Version:

OpenOcean Any-to-Any Cross-Chain-Swap SDK

28 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUTXOBalance = void 0; const widget_types_1 = require("@openocean.finance/widget-types"); const getUTXOPublicClient_js_1 = require("./getUTXOPublicClient.js"); const getUTXOBalance = async (walletAddress, tokens) => { if (tokens.length === 0) { return []; } const { chainId } = tokens[0]; for (const token of tokens) { if (token.chainId !== chainId) { console.warn('Requested tokens have to be on the same chain.'); } } const client = await (0, getUTXOPublicClient_js_1.getUTXOPublicClient)(widget_types_1.ChainId.BTC); const [balance, blockCount] = await Promise.all([ client.getBalance({ address: walletAddress }), client.getBlockCount(), ]); return tokens.map((token) => ({ ...token, amount: balance, blockNumber: BigInt(blockCount), })); }; exports.getUTXOBalance = getUTXOBalance; //# sourceMappingURL=getUTXOBalance.js.map