summaryrefslogtreecommitdiff
path: root/src/operations/withdraw.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/withdraw.ts
parent15e18440dbad55df19977a2eb7053681259afc18 (diff)
downloadwallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.tar.gz
wallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.tar.bz2
wallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.zip
re-format with prettier v2, fix HTML
Diffstat (limited to 'src/operations/withdraw.ts')
-rw-r--r--src/operations/withdraw.ts66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts
index 37993023e..4d8af9fc0 100644
--- a/src/operations/withdraw.ts
+++ b/src/operations/withdraw.ts
@@ -144,7 +144,7 @@ async function getPossibleDenoms(
): Promise<DenominationRecord[]> {
return await ws.db
.iterIndex(Stores.denominations.exchangeBaseUrlIndex, exchangeBaseUrl)
- .filter(d => {
+ .filter((d) => {
return (
(d.status === DenominationStatus.Unverified ||
d.status === DenominationStatus.VerifiedGood) &&
@@ -248,7 +248,7 @@ async function processPlanchet(
const success = await ws.db.runWithWriteTransaction(
[Stores.coins, Stores.withdrawalSession, Stores.reserves],
- async tx => {
+ async (tx) => {
const ws = await tx.get(Stores.withdrawalSession, withdrawalSessionId);
if (!ws) {
return false;
@@ -429,17 +429,20 @@ async function makePlanchet(
reservePub: r.reservePub,
withdrawSig: r.withdrawSig,
};
- await ws.db.runWithWriteTransaction([Stores.withdrawalSession], async tx => {
- const myWs = await tx.get(Stores.withdrawalSession, withdrawalSessionId);
- if (!myWs) {
- return;
- }
- if (myWs.planchets[coinIndex]) {
- return;
- }
- myWs.planchets[coinIndex] = newPlanchet;
- await tx.put(Stores.withdrawalSession, myWs);
- });
+ await ws.db.runWithWriteTransaction(
+ [Stores.withdrawalSession],
+ async (tx) => {
+ const myWs = await tx.get(Stores.withdrawalSession, withdrawalSessionId);
+ if (!myWs) {
+ return;
+ }
+ if (myWs.planchets[coinIndex]) {
+ return;
+ }
+ myWs.planchets[coinIndex] = newPlanchet;
+ await tx.put(Stores.withdrawalSession, myWs);
+ },
+ );
}
async function processWithdrawCoin(
@@ -483,19 +486,22 @@ async function incrementWithdrawalRetry(
withdrawalSessionId: string,
err: OperationError | undefined,
): Promise<void> {
- await ws.db.runWithWriteTransaction([Stores.withdrawalSession], async tx => {
- const wsr = await tx.get(Stores.withdrawalSession, withdrawalSessionId);
- if (!wsr) {
- return;
- }
- if (!wsr.retryInfo) {
- return;
- }
- wsr.retryInfo.retryCounter++;
- updateRetryInfoTimeout(wsr.retryInfo);
- wsr.lastError = err;
- await tx.put(Stores.withdrawalSession, wsr);
- });
+ await ws.db.runWithWriteTransaction(
+ [Stores.withdrawalSession],
+ async (tx) => {
+ const wsr = await tx.get(Stores.withdrawalSession, withdrawalSessionId);
+ if (!wsr) {
+ return;
+ }
+ if (!wsr.retryInfo) {
+ return;
+ }
+ wsr.retryInfo.retryCounter++;
+ updateRetryInfoTimeout(wsr.retryInfo);
+ wsr.lastError = err;
+ await tx.put(Stores.withdrawalSession, wsr);
+ },
+ );
ws.notify({ type: NotificationType.WithdrawOperationError });
}
@@ -516,7 +522,7 @@ async function resetWithdrawSessionRetry(
ws: InternalWalletState,
withdrawalSessionId: string,
) {
- await ws.db.mutate(Stores.withdrawalSession, withdrawalSessionId, x => {
+ await ws.db.mutate(Stores.withdrawalSession, withdrawalSessionId, (x) => {
if (x.retryInfo.active) {
x.retryInfo = initRetryInfo();
}
@@ -594,12 +600,14 @@ export async function getExchangeWithdrawalInfo(
const possibleDenoms = await ws.db
.iterIndex(Stores.denominations.exchangeBaseUrlIndex, baseUrl)
- .filter(d => d.isOffered);
+ .filter((d) => d.isOffered);
const trustedAuditorPubs = [];
const currencyRecord = await ws.db.get(Stores.currencies, amount.currency);
if (currencyRecord) {
- trustedAuditorPubs.push(...currencyRecord.auditors.map(a => a.auditorPub));
+ trustedAuditorPubs.push(
+ ...currencyRecord.auditors.map((a) => a.auditorPub),
+ );
}
let versionMatch;