summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-06-17 21:06:45 +0200
committerFlorian Dold <florian@dold.me>2021-06-17 21:06:54 +0200
commit99550b001178965cae6d5e204783f8d2fd0adc1f (patch)
tree12eef418c6712b51297df2b62b956b91344098cb /packages/taler-wallet-webextension
parent954ed23911cf7e5d4dae30d56a74358bf571342b (diff)
downloadwallet-core-99550b001178965cae6d5e204783f8d2fd0adc1f.tar.gz
wallet-core-99550b001178965cae6d5e204783f8d2fd0adc1f.tar.bz2
wallet-core-99550b001178965cae6d5e204783f8d2fd0adc1f.zip
hide internal wallet state, keep it internal to package
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r--packages/taler-wallet-webextension/src/wxBackend.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts
index 9c01f4c0c..c8b2dbd78 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -37,6 +37,8 @@ import {
runRetryLoop,
handleNotifyReserve,
InternalWalletState,
+ Wallet,
+ WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import {
classifyTalerUri,
@@ -52,8 +54,10 @@ import { BrowserCryptoWorkerFactory } from "./browserCryptoWorkerFactory";
/**
* Currently active wallet instance. Might be unloaded and
* re-instantiated when the database is reset.
+ *
+ * FIXME: Maybe move the wallet reseting into the Wallet class?
*/
-let currentWallet: InternalWalletState | undefined;
+let currentWallet: Wallet | undefined;
let currentDatabase: DbAccess<typeof WalletStoresV1> | undefined;
@@ -170,7 +174,7 @@ async function dispatch(
};
break;
}
- r = await handleCoreApiRequest(w, req.operation, req.id, req.payload);
+ r = await w.handleCoreApiRequest(req.operation, req.id, req.payload);
break;
}
}
@@ -256,7 +260,7 @@ async function reinitWallet(): Promise<void> {
}
const http = new BrowserHttpLib();
console.log("setting wallet");
- const wallet = new InternalWalletState(
+ const wallet = await Wallet.create(
currentDatabase,
http,
new BrowserCryptoWorkerFactory(),
@@ -270,7 +274,7 @@ async function reinitWallet(): Promise<void> {
}
}
});
- runRetryLoop(wallet).catch((e) => {
+ wallet.runRetryLoop().catch((e) => {
console.log("error during wallet retry loop", e);
});
// Useful for debugging in the background page.
@@ -360,7 +364,8 @@ function headerListener(
if (!w) {
return;
}
- handleNotifyReserve(w);
+ // FIXME: Is this still useful?
+ // handleNotifyReserve(w);
});
break;
default:
@@ -451,4 +456,3 @@ export async function wxMain(): Promise<void> {
setupHeaderListener();
});
}
-