Add get unspent tokens function to base wallet
This commit is contained in:
@@ -146,6 +146,21 @@ export abstract class BaseWallet<
|
|||||||
*/
|
*/
|
||||||
abstract getUnspents(): Promise<BlockchainUTXOs>;
|
abstract getUnspents(): Promise<BlockchainUTXOs>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all unspents tokens from the blockchain belonging to this wallet.
|
||||||
|
*/
|
||||||
|
async getUnspentTokens(): Promise<BlockchainUTXOs> {
|
||||||
|
// 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.
|
* Fetch all unspents from the blockchain belonging to this wallet.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user