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/deposits.ts | |
parent | 13e7a674778754c0ed641dfd428e3d6b2b71ab2d (diff) | |
download | wallet-core-48540f62644b4c2e4e96095b11e202cb62e3e93d.tar.xz |
wallet-core: introduce easier syntax for transactions
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 56 |
1 files changed, 16 insertions, 40 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index 6eed12a38..5838be765 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -83,9 +83,7 @@ export async function processDepositGroup( } = {}, ): Promise<OperationAttemptResult> { const depositGroup = await ws.db - .mktx((x) => ({ - depositGroups: x.depositGroups, - })) + .mktx((x) => [x.depositGroups]) .runReadOnly(async (tx) => { return tx.depositGroups.get(depositGroupId); }); @@ -141,7 +139,7 @@ export async function processDepositGroup( }); await readSuccessResponseJsonOrThrow(httpResp, codecForDepositSuccess()); await ws.db - .mktx((x) => ({ depositGroups: x.depositGroups })) + .mktx((x) => [x.depositGroups]) .runReadWrite(async (tx) => { const dg = await tx.depositGroups.get(depositGroupId); if (!dg) { @@ -153,9 +151,7 @@ export async function processDepositGroup( } await ws.db - .mktx((x) => ({ - depositGroups: x.depositGroups, - })) + .mktx((x) => [x.depositGroups]) .runReadWrite(async (tx) => { const dg = await tx.depositGroups.get(depositGroupId); if (!dg) { @@ -185,9 +181,7 @@ export async function trackDepositGroup( body: any; }[] = []; const depositGroup = await ws.db - .mktx((x) => ({ - depositGroups: x.depositGroups, - })) + .mktx((x) => [x.depositGroups]) .runReadOnly(async (tx) => { return tx.depositGroups.get(req.depositGroupId); }); @@ -247,10 +241,7 @@ export async function getFeeForDeposit( const exchangeInfos: { url: string; master_pub: string }[] = []; await ws.db - .mktx((x) => ({ - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - })) + .mktx((x) => [x.exchanges, x.exchangeDetails]) .runReadOnly(async (tx) => { const allExchanges = await tx.exchanges.iter().toArray(); for (const e of allExchanges) { @@ -315,10 +306,7 @@ export async function prepareDepositGroup( const exchangeInfos: { url: string; master_pub: string }[] = []; await ws.db - .mktx((x) => ({ - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - })) + .mktx((x) => [x.exchanges, x.exchangeDetails]) .runReadOnly(async (tx) => { const allExchanges = await tx.exchanges.iter().toArray(); for (const e of allExchanges) { @@ -417,10 +405,7 @@ export async function createDepositGroup( const exchangeInfos: { url: string; master_pub: string }[] = []; await ws.db - .mktx((x) => ({ - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - })) + .mktx((x) => [x.exchanges, x.exchangeDetails]) .runReadOnly(async (tx) => { const allExchanges = await tx.exchanges.iter().toArray(); for (const e of allExchanges) { @@ -532,12 +517,13 @@ export async function createDepositGroup( }; await ws.db - .mktx((x) => ({ - depositGroups: x.depositGroups, - coins: x.coins, - refreshGroups: x.refreshGroups, - denominations: x.denominations, - })) + .mktx((x) => [ + x.depositGroups, + x.coins, + x.recoupGroups, + x.denominations, + x.refreshGroups, + ]) .runReadWrite(async (tx) => { await applyCoinSpend( ws, @@ -565,12 +551,7 @@ export async function getEffectiveDepositAmount( const exchangeSet: Set<string> = new Set(); await ws.db - .mktx((x) => ({ - coins: x.coins, - denominations: x.denominations, - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - })) + .mktx((x) => [x.coins, x.denominations, x.exchanges, x.exchangeDetails]) .runReadOnly(async (tx) => { for (let i = 0; i < pcs.coinPubs.length; i++) { const coin = await tx.coins.get(pcs.coinPubs[i]); @@ -637,12 +618,7 @@ export async function getTotalFeesForDepositAmount( const exchangeSet: Set<string> = new Set(); await ws.db - .mktx((x) => ({ - coins: x.coins, - denominations: x.denominations, - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - })) + .mktx((x) => [x.coins, x.denominations, x.exchanges, x.exchangeDetails]) .runReadOnly(async (tx) => { for (let i = 0; i < pcs.coinPubs.length; i++) { const coin = await tx.coins.get(pcs.coinPubs[i]); |