diff options
author | Florian Dold <florian@dold.me> | 2022-09-13 13:25:41 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-09-13 16:10:42 +0200 |
commit | 48540f62644b4c2e4e96095b11e202cb62e3e93d (patch) | |
tree | 0f1214f9b3e8d63a81b52b794bf44f9eb2a61dfc /packages/taler-wallet-core/src/operations/refund.ts | |
parent | 13e7a674778754c0ed641dfd428e3d6b2b71ab2d (diff) |
wallet-core: introduce easier syntax for transactions
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refund.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refund.ts | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index bc8c185db..5ee0680d7 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -78,9 +78,7 @@ export async function prepareRefund( } const purchase = await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadOnly(async (tx) => { return tx.purchases.indexes.byMerchantUrlAndOrderId.get([ parseResult.merchantBaseUrl, @@ -335,12 +333,7 @@ async function acceptRefunds( const now = TalerProtocolTimestamp.now(); await ws.db - .mktx((x) => ({ - purchases: x.purchases, - coins: x.coins, - denominations: x.denominations, - refreshGroups: x.refreshGroups, - })) + .mktx((x) => [x.purchases, x.coins, x.denominations, x.refreshGroups]) .runReadWrite(async (tx) => { const p = await tx.purchases.get(proposalId); if (!p) { @@ -517,9 +510,7 @@ export async function applyRefund( } const purchase = await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadOnly(async (tx) => { return tx.purchases.indexes.byMerchantUrlAndOrderId.get([ parseResult.merchantBaseUrl, @@ -544,9 +535,7 @@ export async function applyRefundFromPurchaseId( logger.info("processing purchase for refund"); const success = await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadWrite(async (tx) => { const p = await tx.purchases.get(proposalId); if (!p) { @@ -569,9 +558,7 @@ export async function applyRefundFromPurchaseId( } const purchase = await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadOnly(async (tx) => { return tx.purchases.get(proposalId); }); @@ -642,7 +629,7 @@ async function queryAndSaveAwaitingRefund( Amounts.cmp(refundAwaiting, purchase.refundAwaiting) !== 0 ) { await ws.db - .mktx((x) => ({ purchases: x.purchases })) + .mktx((x) => [x.purchases]) .runReadWrite(async (tx) => { const p = await tx.purchases.get(purchase.proposalId); if (!p) { @@ -667,9 +654,7 @@ export async function processPurchaseQueryRefund( ): Promise<OperationAttemptResult> { const waitForAutoRefund = options.waitForAutoRefund ?? false; const purchase = await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadOnly(async (tx) => { return tx.purchases.get(proposalId); }); @@ -729,9 +714,7 @@ export async function processPurchaseQueryRefund( const abortingCoins: AbortingCoin[] = []; await ws.db - .mktx((x) => ({ - coins: x.coins, - })) + .mktx((x) => [x.coins]) .runReadOnly(async (tx) => { for (let i = 0; i < purchase.payCoinSelection.coinPubs.length; i++) { const coinPub = purchase.payCoinSelection.coinPubs[i]; @@ -796,9 +779,7 @@ export async function abortFailedPayWithRefund( proposalId: string, ): Promise<void> { await ws.db - .mktx((x) => ({ - purchases: x.purchases, - })) + .mktx((x) => [x.purchases]) .runReadWrite(async (tx) => { const purchase = await tx.purchases.get(proposalId); if (!purchase) { |