From f2d4a811f48ec6540d2a2c5e32ccbaf3df9998c2 Mon Sep 17 00:00:00 2001 From: devperate Date: Sat, 9 Aug 2025 22:08:46 +0000 Subject: [PATCH] Add get unspent tokens function to base wallet --- packages/stack/src/wallet/base-wallet.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/stack/src/wallet/base-wallet.ts b/packages/stack/src/wallet/base-wallet.ts index db5637b..8c69fbe 100644 --- a/packages/stack/src/wallet/base-wallet.ts +++ b/packages/stack/src/wallet/base-wallet.ts @@ -146,6 +146,21 @@ export abstract class BaseWallet< */ abstract getUnspents(): Promise; + /** + * Fetch all unspents tokens from the blockchain belonging to this wallet. + */ + async getUnspentTokens(): Promise { + // Get the unspents. + const unspents = await this.getUnspents(); + + // Filter to get only the utxos that contain tokens + const unspentTokens = unspents.filter((utxo) => { + return Boolean(utxo.utxo.output.token); + }); + + return unspentTokens; + }; + /** * Fetch all unspents from the blockchain belonging to this wallet. *