aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/tip.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-13 13:25:41 +0200
committerFlorian Dold <florian@dold.me>2022-09-13 16:10:42 +0200
commit48540f62644b4c2e4e96095b11e202cb62e3e93d (patch)
tree0f1214f9b3e8d63a81b52b794bf44f9eb2a61dfc /packages/taler-wallet-core/src/operations/tip.ts
parent13e7a674778754c0ed641dfd428e3d6b2b71ab2d (diff)
downloadwallet-core-48540f62644b4c2e4e96095b11e202cb62e3e93d.tar.xz
wallet-core: introduce easier syntax for transactions
Diffstat (limited to 'packages/taler-wallet-core/src/operations/tip.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts30
1 files changed, 8 insertions, 22 deletions
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index f19be91b2..04da2b988 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -71,9 +71,7 @@ export async function prepareTip(
}
let tipRecord = await ws.db
- .mktx((x) => ({
- tips: x.tips,
- }))
+ .mktx((x) => [x.tips])
.runReadOnly(async (tx) => {
return tx.tips.indexes.byMerchantTipIdAndBaseUrl.get([
res.merchantTipId,
@@ -100,13 +98,13 @@ export async function prepareTip(
await updateExchangeFromUrl(ws, tipPickupStatus.exchange_url);
//FIXME: is this needed? withdrawDetails is not used
- // * if the intention is to update the exchange information in the database
+ // * if the intention is to update the exchange information in the database
// maybe we can use another name. `get` seems like a pure-function
const withdrawDetails = await getExchangeWithdrawalInfo(
ws,
tipPickupStatus.exchange_url,
amount,
- undefined
+ undefined,
);
const walletTipId = encodeCrock(getRandomBytes(32));
@@ -136,9 +134,7 @@ export async function prepareTip(
denomSelUid,
};
await ws.db
- .mktx((x) => ({
- tips: x.tips,
- }))
+ .mktx((x) => [x.tips])
.runReadWrite(async (tx) => {
await tx.tips.put(newTipRecord);
});
@@ -166,9 +162,7 @@ export async function processTip(
} = {},
): Promise<OperationAttemptResult> {
const tipRecord = await ws.db
- .mktx((x) => ({
- tips: x.tips,
- }))
+ .mktx((x) => [x.tips])
.runReadOnly(async (tx) => {
return tx.tips.get(walletTipId);
});
@@ -196,9 +190,7 @@ export async function processTip(
for (const dh of denomsForWithdraw.selectedDenoms) {
const denom = await ws.db
- .mktx((x) => ({
- denominations: x.denominations,
- }))
+ .mktx((x) => [x.denominations])
.runReadOnly(async (tx) => {
return tx.denominations.get([
tipRecord.exchangeBaseUrl,
@@ -324,11 +316,7 @@ export async function processTip(
}
await ws.db
- .mktx((x) => ({
- coins: x.coins,
- tips: x.tips,
- withdrawalGroups: x.withdrawalGroups,
- }))
+ .mktx((x) => [x.coins, x.tips, x.withdrawalGroups])
.runReadWrite(async (tx) => {
const tr = await tx.tips.get(walletTipId);
if (!tr) {
@@ -355,9 +343,7 @@ export async function acceptTip(
tipId: string,
): Promise<void> {
const found = await ws.db
- .mktx((x) => ({
- tips: x.tips,
- }))
+ .mktx((x) => [x.tips])
.runReadWrite(async (tx) => {
const tipRecord = await tx.tips.get(tipId);
if (!tipRecord) {