summaryrefslogtreecommitdiff
path: root/src/headless/helpers.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-11-21 23:09:43 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-11-21 23:09:43 +0100
commitc6233094306cd264f8faa2041388dff01ff8cf01 (patch)
treef3ee839a4254c528058887c6517a76bec8919b15 /src/headless/helpers.ts
parente8f362ccfea683fe16ce68b956f068ffa0b001b1 (diff)
downloadwallet-core-c6233094306cd264f8faa2041388dff01ff8cf01.tar.gz
wallet-core-c6233094306cd264f8faa2041388dff01ff8cf01.tar.bz2
wallet-core-c6233094306cd264f8faa2041388dff01ff8cf01.zip
WIP: simplification and error handling
Diffstat (limited to 'src/headless/helpers.ts')
-rw-r--r--src/headless/helpers.ts16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/headless/helpers.ts b/src/headless/helpers.ts
index 49881d469..5e06a2f25 100644
--- a/src/headless/helpers.ts
+++ b/src/headless/helpers.ts
@@ -21,7 +21,7 @@
/**
* Imports.
*/
-import { Wallet } from "../wallet";
+import { Wallet, OperationFailedAndReportedError } from "../wallet";
import { Notifier, Badge } from "../walletTypes";
import { MemoryBackend, BridgeIDBFactory, shimIndexedDB } from "idb-bridge";
import { SynchronousCryptoWorkerFactory } from "../crypto/synchronousWorker";
@@ -139,18 +139,16 @@ export async function getDefaultNodeWallet(
const storagePath = args.persistentStoragePath;
if (storagePath) {
- console.log(`using storage path ${storagePath}`);
-
try {
const dbContentStr: string = fs.readFileSync(storagePath, { encoding: "utf-8" });
const dbContent = JSON.parse(dbContentStr);
myBackend.importDump(dbContent);
- console.log("imported wallet");
} catch (e) {
- console.log("could not read wallet file");
+ console.error("could not read wallet file");
}
myBackend.afterCommitCallback = async () => {
+ console.log("DATABASE COMMITTED");
// Allow caller to stop persisting the wallet.
if (args.persistentStoragePath === undefined) {
return;
@@ -190,8 +188,6 @@ export async function getDefaultNodeWallet(
myUnsupportedUpgrade,
);
- console.log("opened db");
-
return new Wallet(
myDb,
myHttpLib,
@@ -214,6 +210,8 @@ export async function withdrawTestBalance(
exchangeWire: "payto://unknown",
});
+ const reservePub = reserveResponse.reservePub;
+
const bank = new Bank(bankBaseUrl);
const bankUser = await bank.registerRandomUser();
@@ -228,11 +226,11 @@ export async function withdrawTestBalance(
await bank.createReserve(
bankUser,
amount,
- reserveResponse.reservePub,
+ reservePub,
exchangePaytoUri,
);
await myWallet.confirmReserve({ reservePub: reserveResponse.reservePub });
- await myWallet.processReserve(reserveResponse.reservePub);
+ await myWallet.runUntilReserveDepleted(reservePub);
}