commit 777337f04a5bc68889c5c8e30ea47a06624b7f8d
parent a3317d6a37f3b90b76026e9a058ae08d39b88766
Author: Iván Ávalos <avalos@disroot.org>
Date: Wed, 2 Jul 2025 20:15:25 +0200
wallet-core: attempt to resolve currency for v1 contract
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -227,6 +227,7 @@ export class PayMerchantTransactionContext implements TransactionContext {
await tx.transactionsMeta.delete(this.transactionId);
return;
}
+
await tx.transactionsMeta.put({
transactionId: this.transactionId,
status: purchaseRec.purchaseStatus,
@@ -1212,6 +1213,18 @@ async function processDownloadProposal(
contractData.version === MerchantContractVersion.V0
) {
currency = Amounts.currencyOf(contractData.amount);
+ } else if (contractData.version === MerchantContractVersion.V1) {
+ // if there is only one choice, or all choices have the same currency
+ if (contractData.choices.length === 1) {
+ currency = Amounts.currencyOf(contractData.choices[0].amount);
+ } else if (contractData.choices.length > 1) {
+ const firstCurrency = Amounts.currencyOf(contractData.choices[0].amount);
+ const allSame = contractData.choices.every((c) =>
+ Amounts.currencyOf(c.amount) === firstCurrency);
+ if (allSame) {
+ currency = firstCurrency;
+ }
+ }
}
p.download = {