aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-10-21 09:26:53 -0300
committerSebastian <sebasjm@gmail.com>2022-10-21 09:26:53 -0300
commit683c89ab71a71fbd26bda58457ba5792e79d577f (patch)
treee406e8a2f309e65e4ea86416a196c43618d5289f
parent414b1b84e8d1805d4bdb8844a6e5bdd50a3613c2 (diff)
workaround: Failed transaction was started here
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts52
1 files changed, 46 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 6e8ebc4f4..fea165588 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -188,7 +188,12 @@ export async function getTransactionById(
} else if (type === TransactionType.Payment) {
const proposalId = rest[0];
return await ws.db
- .mktx((x) => [x.purchases, x.tombstones, x.operationRetries])
+ .mktx((x) => [
+ x.purchases,
+ x.tombstones,
+ x.operationRetries,
+ x.contractTerms,
+ ])
.runReadWrite(async (tx) => {
const purchase = await tx.purchases.get(proposalId);
if (!purchase) throw Error("not found");
@@ -207,13 +212,28 @@ export async function getTransactionById(
}),
);
- const download = await expectProposalDownload(ws, purchase);
+ // const download = await expectProposalDownload(ws, purchase);
+ // FIXME: this is what expectProposalDownload, but nested tx is not supported
+ if (!purchase.download) {
+ throw Error("expected proposal to be downloaded");
+ }
+ const contractTerms = await tx.contractTerms.get(
+ purchase.download.contractTermsHash,
+ );
+ if (!contractTerms) {
+ throw Error("contract terms not found");
+ }
+ const contractData = extractContractData(
+ contractTerms.contractTermsRaw,
+ purchase.download.contractTermsHash,
+ purchase.download.contractTermsMerchantSig,
+ );
const cleanRefunds = filteredRefunds.filter(
(x): x is WalletRefundItem => !!x,
);
- const contractData = download.contractData;
+ // const contractData = download.contractData;
const refunds = mergeRefundByExecutionTime(
cleanRefunds,
Amounts.getZero(contractData.amount.currency),
@@ -263,7 +283,12 @@ export async function getTransactionById(
const executionTimeStr = rest[1];
return await ws.db
- .mktx((x) => [x.operationRetries, x.purchases, x.tombstones])
+ .mktx((x) => [
+ x.operationRetries,
+ x.purchases,
+ x.tombstones,
+ x.contractTerms,
+ ])
.runReadWrite(async (tx) => {
const purchase = await tx.purchases.get(proposalId);
if (!purchase) throw Error("not found");
@@ -281,8 +306,23 @@ export async function getTransactionById(
),
);
if (t) throw Error("deleted");
- const download = await expectProposalDownload(ws, purchase);
- const contractData = download.contractData;
+ // const download = await expectProposalDownload(ws, purchase);
+ // const contractData = download.contractData;
+ // FIXME: this is what expectProposalDownload, but nested tx is not supported
+ if (!purchase.download) {
+ throw Error("expected proposal to be downloaded");
+ }
+ const contractTerms = await tx.contractTerms.get(
+ purchase.download.contractTermsHash,
+ );
+ if (!contractTerms) {
+ throw Error("contract terms not found");
+ }
+ const contractData = extractContractData(
+ contractTerms.contractTermsRaw,
+ purchase.download.contractTermsHash,
+ purchase.download.contractTermsMerchantSig,
+ );
const refunds = mergeRefundByExecutionTime(
[theRefund],
Amounts.getZero(contractData.amount.currency),