diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-07-29 14:33:59 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-07-29 14:33:59 +0530 |
commit | 7e34b6699a77620b148b167e6aa12d50cc7456e5 (patch) | |
tree | ced77a5d6eac157ea4234b574c5856e0e7451e70 /src | |
parent | 08c3209dbc06329b4566ddd8d1dd7ab1c7e28ed7 (diff) |
test cases
Diffstat (limited to 'src')
-rw-r--r-- | src/operations/balance.ts | 36 | ||||
-rw-r--r-- | src/operations/transactions.ts | 10 |
2 files changed, 23 insertions, 23 deletions
diff --git a/src/operations/balance.ts b/src/operations/balance.ts index b503b7546..26f0aaeee 100644 --- a/src/operations/balance.ts +++ b/src/operations/balance.ts @@ -40,7 +40,6 @@ export async function getBalancesInsideTransaction( ws: InternalWalletState, tx: TransactionHandle, ): Promise<BalancesResponse> { - const balanceStore: Record<string, WalletBalance> = {}; /** @@ -57,11 +56,17 @@ export async function getBalancesInsideTransaction( }; } return balanceStore[currency]; - } + }; // Initialize balance to zero, even if we didn't start withdrawing yet. await tx.iter(Stores.reserves).forEach((r) => { - initBalance(r.currency); + const b = initBalance(r.currency); + if (!r.initialWithdrawalStarted) { + b.pendingIncoming = Amounts.add( + b.pendingIncoming, + r.initialDenomSel.totalCoinValue, + ).amount; + } }); await tx.iter(Stores.coins).forEach((c) => { @@ -95,23 +100,28 @@ export async function getBalancesInsideTransaction( return; } const b = initBalance(wds.denomsSel.totalWithdrawCost.currency); - b.pendingIncoming = Amounts.add(b.pendingIncoming, wds.denomsSel.totalCoinValue).amount; + b.pendingIncoming = Amounts.add( + b.pendingIncoming, + wds.denomsSel.totalCoinValue, + ).amount; }); const balancesResponse: BalancesResponse = { balances: [], }; - Object.keys(balanceStore).sort().forEach((c) => { - const v = balanceStore[c]; - balancesResponse.balances.push({ - available: Amounts.stringify(v.available), - pendingIncoming: Amounts.stringify(v.pendingIncoming), - pendingOutgoing: Amounts.stringify(v.pendingOutgoing), - hasPendingTransactions: false, - requiresUserInput: false, + Object.keys(balanceStore) + .sort() + .forEach((c) => { + const v = balanceStore[c]; + balancesResponse.balances.push({ + available: Amounts.stringify(v.available), + pendingIncoming: Amounts.stringify(v.pendingIncoming), + pendingOutgoing: Amounts.stringify(v.pendingOutgoing), + hasPendingTransactions: false, + requiresUserInput: false, + }); }); - }) return balancesResponse; } diff --git a/src/operations/transactions.ts b/src/operations/transactions.ts index fb0629660..647949d22 100644 --- a/src/operations/transactions.ts +++ b/src/operations/transactions.ts @@ -20,8 +20,6 @@ import { InternalWalletState } from "./state"; import { Stores, - ReserveRecordStatus, - PurchaseRecord, WithdrawalSourceType, } from "../types/dbTypes"; import { Amounts, AmountJson } from "../util/amounts"; @@ -182,14 +180,6 @@ export async function getTransactions( if (shouldSkipSearch(transactionsRequest, [])) { return; } - switch (r.reserveStatus) { - case ReserveRecordStatus.WAIT_CONFIRM_BANK: - break; - case ReserveRecordStatus.WITHDRAWING: - break; - default: - return; - } if (r.initialWithdrawalStarted) { return; } |