aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/refresh.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/refresh.ts')
-rw-r--r--packages/taler-wallet-core/src/refresh.ts128
1 files changed, 77 insertions, 51 deletions
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts
index 99ac5737b..7800967e6 100644
--- a/packages/taler-wallet-core/src/refresh.ts
+++ b/packages/taler-wallet-core/src/refresh.ts
@@ -186,7 +186,7 @@ export class RefreshTransactionContext implements TransactionContext {
? [...baseStores, ...opts.extraStores]
: baseStores;
const transitionInfo = await this.wex.db.runReadWriteTx(
- stores,
+ { storeNames: stores },
async (tx) => {
const wgRec = await tx.refreshGroups.get(this.refreshGroupId);
let oldTxState: TransactionState;
@@ -565,7 +565,14 @@ async function refreshMelt(
): Promise<void> {
const ctx = new RefreshTransactionContext(wex, refreshGroupId);
const d = await wex.db.runReadWriteTx(
- ["refreshGroups", "refreshSessions", "coins", "denominations"],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "coins",
+ "denominations",
+ ],
+ },
async (tx) => {
const refreshGroup = await tx.refreshGroups.get(refreshGroupId);
if (!refreshGroup) {
@@ -723,7 +730,7 @@ async function refreshMelt(
refreshSession.norevealIndex = norevealIndex;
await wex.db.runReadWriteTx(
- ["refreshGroups", "refreshSessions"],
+ { storeNames: ["refreshGroups", "refreshSessions"] },
async (tx) => {
const rg = await tx.refreshGroups.get(refreshGroupId);
if (!rg) {
@@ -755,13 +762,15 @@ async function handleRefreshMeltGone(
// FIXME: Validate signature.
await ctx.wex.db.runReadWriteTx(
- [
- "refreshGroups",
- "refreshSessions",
- "coins",
- "denominations",
- "coinAvailability",
- ],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "coins",
+ "denominations",
+ "coinAvailability",
+ ],
+ },
async (tx) => {
const rg = await tx.refreshGroups.get(ctx.refreshGroupId);
if (!rg) {
@@ -832,13 +841,15 @@ async function handleRefreshMeltConflict(
// FIXME: If response seems wrong, report to auditor (in the future!);
await ctx.wex.db.runReadWriteTx(
- [
- "refreshGroups",
- "refreshSessions",
- "denominations",
- "coins",
- "coinAvailability",
- ],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "denominations",
+ "coins",
+ "coinAvailability",
+ ],
+ },
async (tx) => {
const rg = await tx.refreshGroups.get(ctx.refreshGroupId);
if (!rg) {
@@ -891,13 +902,15 @@ async function handleRefreshMeltNotFound(
): Promise<void> {
// FIXME: Validate the exchange's error response
await ctx.wex.db.runReadWriteTx(
- [
- "refreshGroups",
- "refreshSessions",
- "coins",
- "denominations",
- "coinAvailability",
- ],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "coins",
+ "denominations",
+ "coinAvailability",
+ ],
+ },
async (tx) => {
const rg = await tx.refreshGroups.get(ctx.refreshGroupId);
if (!rg) {
@@ -993,7 +1006,14 @@ async function refreshReveal(
);
const ctx = new RefreshTransactionContext(wex, refreshGroupId);
const d = await wex.db.runReadOnlyTx(
- ["refreshGroups", "refreshSessions", "coins", "denominations"],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "coins",
+ "denominations",
+ ],
+ },
async (tx) => {
const refreshGroup = await tx.refreshGroups.get(refreshGroupId);
if (!refreshGroup) {
@@ -1187,13 +1207,15 @@ async function refreshReveal(
}
await wex.db.runReadWriteTx(
- [
- "coins",
- "denominations",
- "coinAvailability",
- "refreshGroups",
- "refreshSessions",
- ],
+ {
+ storeNames: [
+ "coins",
+ "denominations",
+ "coinAvailability",
+ "refreshGroups",
+ "refreshSessions",
+ ],
+ },
async (tx) => {
const rg = await tx.refreshGroups.get(refreshGroupId);
if (!rg) {
@@ -1247,13 +1269,15 @@ async function handleRefreshRevealError(
errDetails: TalerErrorDetail,
): Promise<void> {
await ctx.wex.db.runReadWriteTx(
- [
- "refreshGroups",
- "refreshSessions",
- "coins",
- "denominations",
- "coinAvailability",
- ],
+ {
+ storeNames: [
+ "refreshGroups",
+ "refreshSessions",
+ "coins",
+ "denominations",
+ "coinAvailability",
+ ],
+ },
async (tx) => {
const rg = await tx.refreshGroups.get(ctx.refreshGroupId);
if (!rg) {
@@ -1288,7 +1312,7 @@ export async function processRefreshGroup(
logger.trace(`processing refresh group ${refreshGroupId}`);
const refreshGroup = await wex.db.runReadOnlyTx(
- ["refreshGroups"],
+ { storeNames: ["refreshGroups"] },
async (tx) => tx.refreshGroups.get(refreshGroupId),
);
if (!refreshGroup) {
@@ -1344,7 +1368,7 @@ export async function processRefreshGroup(
// status of the whole refresh group.
const transitionInfo = await wex.db.runReadWriteTx(
- ["coins", "coinAvailability", "refreshGroups"],
+ { storeNames: ["coins", "coinAvailability", "refreshGroups"] },
async (tx) => {
const rg = await tx.refreshGroups.get(refreshGroupId);
if (!rg) {
@@ -1420,7 +1444,7 @@ async function processRefreshSession(
`processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`,
);
let { refreshGroup, refreshSession } = await wex.db.runReadOnlyTx(
- ["refreshGroups", "refreshSessions"],
+ { storeNames: ["refreshGroups", "refreshSessions"] },
async (tx) => {
const rg = await tx.refreshGroups.get(refreshGroupId);
const rs = await tx.refreshSessions.get([refreshGroupId, coinIndex]);
@@ -1710,7 +1734,7 @@ export function getRefreshesForTransaction(
wex: WalletExecutionContext,
transactionId: string,
): Promise<string[]> {
- return wex.db.runReadOnlyTx(["refreshGroups"], async (tx) => {
+ return wex.db.runReadOnlyTx({ storeNames: ["refreshGroups"] }, async (tx) => {
const groups =
await tx.refreshGroups.indexes.byOriginatingTransactionId.getAll(
transactionId,
@@ -1736,13 +1760,15 @@ export async function forceRefresh(
throw Error("refusing to create empty refresh group");
}
const res = await wex.db.runReadWriteTx(
- [
- "refreshGroups",
- "coinAvailability",
- "refreshSessions",
- "denominations",
- "coins",
- ],
+ {
+ storeNames: [
+ "refreshGroups",
+ "coinAvailability",
+ "refreshSessions",
+ "denominations",
+ "coins",
+ ],
+ },
async (tx) => {
let coinPubs: CoinRefreshRequest[] = [];
for (const c of req.refreshCoinSpecs) {
@@ -1828,7 +1854,7 @@ async function internalWaitRefreshFinal(
// Check if refresh is final
const res = await ctx.wex.db.runReadOnlyTx(
- ["refreshGroups", "operationRetries"],
+ { storeNames: ["refreshGroups", "operationRetries"] },
async (tx) => {
return {
rg: await tx.refreshGroups.get(ctx.refreshGroupId),