aboutsummaryrefslogtreecommitdiff
path: root/src/operations/balance.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
commitaaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf (patch)
tree9274139660f30c4857d80044eb4ac283aac1775a /src/operations/balance.ts
parent15e18440dbad55df19977a2eb7053681259afc18 (diff)
downloadwallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.tar.xz
re-format with prettier v2, fix HTML
Diffstat (limited to 'src/operations/balance.ts')
-rw-r--r--src/operations/balance.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/operations/balance.ts b/src/operations/balance.ts
index 03d1b2a9f..8858e8b43 100644
--- a/src/operations/balance.ts
+++ b/src/operations/balance.ts
@@ -34,8 +34,7 @@ export async function getBalancesInsideTransaction(
ws: InternalWalletState,
tx: TransactionHandle,
): Promise<WalletBalance> {
-
- /**
+ /**
* Add amount to a balance field, both for
* the slicing by exchange and currency.
*/
@@ -74,7 +73,7 @@ export async function getBalancesInsideTransaction(
byExchange: {},
};
- await tx.iter(Stores.coins).forEach(c => {
+ await tx.iter(Stores.coins).forEach((c) => {
if (c.suspended) {
return;
}
@@ -82,7 +81,7 @@ export async function getBalancesInsideTransaction(
addTo(balanceStore, "available", c.currentAmount, c.exchangeBaseUrl);
}
});
- await tx.iter(Stores.refreshGroups).forEach(r => {
+ await tx.iter(Stores.refreshGroups).forEach((r) => {
// Don't count finished refreshes, since the refresh already resulted
// in coins being added to the wallet.
if (r.timestampFinished) {
@@ -107,7 +106,7 @@ export async function getBalancesInsideTransaction(
}
});
- await tx.iter(Stores.withdrawalSession).forEach(wds => {
+ await tx.iter(Stores.withdrawalSession).forEach((wds) => {
let w = wds.totalCoinValue;
for (let i = 0; i < wds.planchets.length; i++) {
if (wds.withdrawn[i]) {
@@ -120,7 +119,7 @@ export async function getBalancesInsideTransaction(
addTo(balanceStore, "pendingIncoming", w, wds.exchangeBaseUrl);
});
- await tx.iter(Stores.purchases).forEach(t => {
+ await tx.iter(Stores.purchases).forEach((t) => {
if (t.timestampFirstSuccessfulPay) {
return;
}
@@ -145,14 +144,16 @@ export async function getBalances(
): Promise<WalletBalance> {
logger.trace("starting to compute balance");
- return await ws.db.runWithReadTransaction([
- Stores.coins,
- Stores.refreshGroups,
- Stores.reserves,
- Stores.purchases,
- Stores.withdrawalSession,
- ],
- async tx => {
- return getBalancesInsideTransaction(ws, tx);
- });
+ return await ws.db.runWithReadTransaction(
+ [
+ Stores.coins,
+ Stores.refreshGroups,
+ Stores.reserves,
+ Stores.purchases,
+ Stores.withdrawalSession,
+ ],
+ async (tx) => {
+ return getBalancesInsideTransaction(ws, tx);
+ },
+ );
}