Skip to content

Commit

Permalink
feat(wallet): add balance interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mkazlauskas committed Oct 14, 2021
1 parent 4f9b13f commit 48a820f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/wallet/src/BalanceTracker.ts
@@ -0,0 +1,39 @@
import { Ogmios } from '@cardano-sdk/core';

export interface Balance extends Ogmios.Value {
rewards: Ogmios.Lovelace;
}

export interface Balances {
total: Balance;
available: Balance;
}

export interface BalanceTrackerEvents {
balanceChanged: Balances;
}

// export class BalanceTracker extends Emittery<BalanceTrackerEvents> implements Balances {
// total: Balance;
// available: Balance;

// constructor(utxoRepository: UtxoRepository) {
// super();
// const totalValue = this.#getBalance(utxoRepository.allUtxos);
// const availableValue = this.#getBalance(utxoRepository.availableUtxos);
// const totalRewards = utxoRepository.rewards;
// const availableRewards = utxoRepository.availableRewards;
// }

// #getBalance(utxo: Utxo): Ogmios.Value {
// return Ogmios.util.coalesceValueQuantities(
// utxo.map(([_, txOut]) => {
// const { coins, assets } = txOut.value;
// return {
// coins: BigInt(coins),
// assets
// };
// })
// );
// }
// }

0 comments on commit 48a820f

Please sign in to comment.