diff options
author | Sebastian <sebasjm@gmail.com> | 2022-08-08 13:53:04 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-08-08 13:53:04 -0300 |
commit | 4409d8384b77401489c2a92d3de20f79959ae34a (patch) | |
tree | 6483e7cc0a70dbbfcf9b16a7ce43576a4aef2c08 /packages | |
parent | 88bdcae030ae845f412957f6455e44b009b490e2 (diff) |
add delivery info in the parse contract terms and a function to get info from a proposalId
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 3 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/backup/import.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 23 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 3 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 6 |
5 files changed, 39 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index e4f4ba255..f763aae6b 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -43,6 +43,7 @@ import { AgeCommitmentProof, PayCoinSelection, PeerContractTerms, + Location, } from "@gnu-taler/taler-util"; import { RetryInfo } from "./util/retries.js"; import { Event, IDBDatabase } from "@gnu-taler/idb-bridge"; @@ -1170,6 +1171,8 @@ export interface WalletContractData { wireInfoHash: string; maxDepositFee: AmountJson; minimumAge?: number; + deliveryDate: TalerProtocolTimestamp | undefined; + deliveryLocation: Location | undefined; } export enum AbortStatus { diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts index e4eaf8913..e099fae57 100644 --- a/packages/taler-wallet-core/src/operations/backup/import.ts +++ b/packages/taler-wallet-core/src/operations/backup/import.ts @@ -600,6 +600,8 @@ export async function importBackup( merchant: parsedContractTerms.merchant, products: parsedContractTerms.products, summaryI18n: parsedContractTerms.summary_i18n, + deliveryDate: parsedContractTerms.delivery_date, + deliveryLocation: parsedContractTerms.delivery_location, }, contractTermsRaw: backupProposal.contract_terms_raw, }; @@ -740,6 +742,8 @@ export async function importBackup( merchant: parsedContractTerms.merchant, products: parsedContractTerms.products, summaryI18n: parsedContractTerms.summary_i18n, + deliveryDate: parsedContractTerms.delivery_date, + deliveryLocation: parsedContractTerms.delivery_location, }, contractTermsRaw: backupPurchase.contract_terms_raw, }; diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index 55b8f513d..d41a20e71 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -662,6 +662,8 @@ export function extractContractData( products: parsedContractTerms.products, summaryI18n: parsedContractTerms.summary_i18n, minimumAge: parsedContractTerms.minimum_age, + deliveryDate: parsedContractTerms.delivery_date, + deliveryLocation: parsedContractTerms.delivery_location, }; } @@ -1318,6 +1320,27 @@ export async function checkPaymentByProposalId( } } +export async function getContractTermsDetails( + ws: InternalWalletState, + proposalId: string, +): Promise<WalletContractData> { + const proposal = await ws.db + .mktx((x) => ({ proposals: x.proposals })) + .runReadOnly(async (tx) => { + return tx.proposals.get(proposalId); + }); + + if (!proposal) { + throw Error(`proposal with id ${proposalId} not found`); + } + + if (!proposal.download || !proposal.download.contractData) { + throw Error("proposal is in invalid state"); + } + + return proposal.download.contractData +} + /** * Check if a payment for the given taler://pay/ URI is possible. * diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 1ac2bd042..ebc223b23 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -448,6 +448,9 @@ export async function getTransactions( tipRecord.walletTipId, ), merchantBaseUrl: tipRecord.merchantBaseUrl, + // merchant: { + // name: tipRecord.merchantBaseUrl, + // }, error: tipRecord.lastError, }); }); diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index b56e9402d..066f91a30 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -43,6 +43,7 @@ import { codecForCreateDepositGroupRequest, codecForDeleteTransactionRequest, codecForForceRefreshRequest, + codecForGetContractTermsDetails, codecForGetExchangeTosRequest, codecForGetExchangeWithdrawalInfo, codecForGetFeeForDeposit, @@ -142,6 +143,7 @@ import { import { getMerchantInfo } from "./operations/merchants.js"; import { confirmPay, + getContractTermsDetails, preparePayForUri, processDownloadProposal, processPurchasePay, @@ -868,6 +870,10 @@ async function dispatchRequestInternal( const req = codecForGetExchangeTosRequest().decode(payload); return getExchangeTos(ws, req.exchangeBaseUrl, req.acceptedFormat); } + case "getContractTermsDetails": { + const req = codecForGetContractTermsDetails().decode(payload); + return getContractTermsDetails(ws, req.proposalId); + } case "retryPendingNow": { await runPending(ws, true); return {}; |