From 19f3e6321d68adbaf9e8ca2d03efac6706d3fdea Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 9 Oct 2022 02:23:06 +0200 Subject: wallet-core: put contract terms into separate object store --- packages/taler-wallet-core/src/db.ts | 47 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'packages/taler-wallet-core/src/db.ts') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index b019be67a..ec11f4d47 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1085,18 +1085,16 @@ export enum PurchaseStatus { Paid = OperationStatusRange.DORMANT_START + 5, } +/** + * Partial information about the downloaded proposal. + * Only contains data that is relevant for indexing on the + * "purchases" object stores. + */ export interface ProposalDownload { - /** - * The contract that was offered by the merchant. - */ - contractTermsRaw: any; - - /** - * Extracted / parsed data from the contract terms. - * - * FIXME: Do we need to store *all* that data in duplicate? - */ - contractData: WalletContractData; + contractTermsHash: string; + fulfillmentUrl?: string; + currency: string; + contractTermsMerchantSig: string; } export interface PurchasePayInfo { @@ -1723,6 +1721,7 @@ export interface PeerPullPaymentInitiationRecord { * Contract terms for the other party. * * FIXME: Nail down type! + * FIXME: Put in contractTerms store */ contractTerms: any; } @@ -1819,6 +1818,18 @@ export interface CoinAvailabilityRecord { freshCoinCount: number; } +export interface ContractTermsRecord { + /** + * Contract terms hash. + */ + h: string; + + /** + * Contract terms JSON. + */ + contractTermsRaw: any; +} + /** * Schema definition for the IndexedDB * wallet database. @@ -1937,13 +1948,8 @@ export const WalletStoresV1 = { byStatus: describeIndex("byStatus", "purchaseStatus"), byFulfillmentUrl: describeIndex( "byFulfillmentUrl", - "download.contractData.fulfillmentUrl", + "download.fulfillmentUrl", ), - // FIXME: Deduplicate! - byMerchantUrlAndOrderId: describeIndex("byMerchantUrlAndOrderId", [ - "download.contractData.merchantBaseUrl", - "download.contractData.orderId", - ]), byUrlAndOrderId: describeIndex("byUrlAndOrderId", [ "merchantBaseUrl", "orderId", @@ -2088,6 +2094,13 @@ export const WalletStoresV1 = { }), {}, ), + contractTerms: describeStore( + "contractTerms", + describeContents({ + keyPath: "h", + }), + {}, + ), }; /** -- cgit v1.2.3