diff options
author | Florian Dold <florian@dold.me> | 2022-10-09 02:23:06 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-09 02:23:06 +0200 |
commit | 19f3e6321d68adbaf9e8ca2d03efac6706d3fdea (patch) | |
tree | d5b5999de159db9ccf6496c61a92e51323c4e51c /packages/taler-wallet-core/src/operations/backup/import.ts | |
parent | 8ac5080607d28f8dcd84a949221a551a3f66cea8 (diff) | |
download | wallet-core-19f3e6321d68adbaf9e8ca2d03efac6706d3fdea.tar.xz |
wallet-core: put contract terms into separate object store
Diffstat (limited to 'packages/taler-wallet-core/src/operations/backup/import.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/backup/import.ts | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts index bb5fe56e2..3ee3680fe 100644 --- a/packages/taler-wallet-core/src/operations/backup/import.ts +++ b/packages/taler-wallet-core/src/operations/backup/import.ts @@ -64,6 +64,7 @@ import { checkLogicInvariant } from "../../util/invariants.js"; import { GetReadOnlyAccess, GetReadWriteAccess } from "../../util/query.js"; import { makeCoinAvailable, makeEventId, TombstoneTag } from "../common.js"; import { getExchangeDetails } from "../exchanges.js"; +import { extractContractData } from "../pay-merchant.js"; import { provideBackupState } from "./state.js"; const logger = new Logger("operations/backup/import.ts"); @@ -630,49 +631,25 @@ export async function importBackup( maxWireFee = Amounts.getZero(amount.currency); } const download: ProposalDownload = { - contractData: { - amount, - contractTermsHash: contractTermsHash, - fulfillmentUrl: parsedContractTerms.fulfillment_url ?? "", - merchantBaseUrl: parsedContractTerms.merchant_base_url, - merchantPub: parsedContractTerms.merchant_pub, - merchantSig: backupPurchase.merchant_sig!, - orderId: parsedContractTerms.order_id, - summary: parsedContractTerms.summary, - autoRefund: parsedContractTerms.auto_refund, - maxWireFee, - payDeadline: parsedContractTerms.pay_deadline, - refundDeadline: parsedContractTerms.refund_deadline, - wireFeeAmortization: - parsedContractTerms.wire_fee_amortization || 1, - allowedAuditors: parsedContractTerms.auditors.map((x) => ({ - auditorBaseUrl: x.url, - auditorPub: x.auditor_pub, - })), - allowedExchanges: parsedContractTerms.exchanges.map((x) => ({ - exchangeBaseUrl: x.url, - exchangePub: x.master_pub, - })), - timestamp: parsedContractTerms.timestamp, - wireMethod: parsedContractTerms.wire_method, - wireInfoHash: parsedContractTerms.h_wire, - maxDepositFee: Amounts.parseOrThrow(parsedContractTerms.max_fee), - merchant: parsedContractTerms.merchant, - products: parsedContractTerms.products, - summaryI18n: parsedContractTerms.summary_i18n, - deliveryDate: parsedContractTerms.delivery_date, - deliveryLocation: parsedContractTerms.delivery_location, - }, - contractTermsRaw: backupPurchase.contract_terms_raw, + contractTermsHash, + contractTermsMerchantSig: backupPurchase.merchant_sig!, + currency: amount.currency, + fulfillmentUrl: backupPurchase.contract_terms_raw.fulfillment_url, }; + const contractData = extractContractData( + backupPurchase.contract_terms_raw, + contractTermsHash, + download.contractTermsMerchantSig, + ); + let payInfo: PurchasePayInfo | undefined = undefined; if (backupPurchase.pay_info) { payInfo = { coinDepositPermissions: undefined, payCoinSelection: await recoverPayCoinSelection( tx, - download.contractData, + contractData, backupPurchase.pay_info, ), payCoinSelectionUid: backupPurchase.pay_info.pay_coins_uid, |