diff options
author | Florian Dold <florian@dold.me> | 2021-06-02 13:23:51 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-02 13:24:28 +0200 |
commit | 02f1d4b08116c24f0af1f32cb6d82be292fa6d10 (patch) | |
tree | 1fbcc1675e09584a74896909e1d4d0882d10be8e /packages/taler-wallet-core/src/db.ts | |
parent | c6c17a1c0aaa2c76616ec93df3ebe6621b547cd9 (diff) | |
download | wallet-core-02f1d4b08116c24f0af1f32cb6d82be292fa6d10.tar.xz |
support multiple exchange details per base URL
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 135 |
1 files changed, 72 insertions, 63 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 0ff34d3c7..c457d0ffc 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -513,20 +513,32 @@ export interface DenominationRecord { exchangeBaseUrl: string; } -/** - * Details about the exchange that we only know after - * querying /keys and /wire. - */ -export interface ExchangeDetails { +export enum ExchangeUpdateStatus { + FetchKeys = "fetch-keys", + FetchWire = "fetch-wire", + FetchTerms = "fetch-terms", + FinalizeUpdate = "finalize-update", + Finished = "finished", +} + +export interface ExchangeBankAccount { + payto_uri: string; + master_sig: string; +} + +export enum ExchangeUpdateReason { + Initial = "initial", + Forced = "forced", + Scheduled = "scheduled", +} + +export interface ExchangeDetailsRecord { /** * Master public key of the exchange. */ masterPublicKey: string; - /** - * Auditors (partially) auditing the exchange. - */ - auditors: Auditor[]; + exchangeBaseUrl: string; /** * Currency that the exchange offers. @@ -534,6 +546,11 @@ export interface ExchangeDetails { currency: string; /** + * Auditors (partially) auditing the exchange. + */ + auditors: Auditor[]; + + /** * Last observed protocol version. */ protocolVersion: string; @@ -547,6 +564,23 @@ export interface ExchangeDetails { signingKeys: ExchangeSignKeyJson[]; /** + * Terms of service text or undefined if not downloaded yet. + * + * This is just used as a cache of the last downloaded ToS. + */ + termsOfServiceText: string | undefined; + + /** + * ETag for last terms of service download. + */ + termsOfServiceLastEtag: string | undefined; + + /** + * ETag for last terms of service download. + */ + termsOfServiceAcceptedEtag: string | undefined; + + /** * Timestamp for last update. */ lastUpdateTime: Timestamp; @@ -555,30 +589,25 @@ export interface ExchangeDetails { * When should we next update the information about the exchange? */ nextUpdateTime: Timestamp; -} -export enum ExchangeUpdateStatus { - FetchKeys = "fetch-keys", - FetchWire = "fetch-wire", - FetchTerms = "fetch-terms", - FinalizeUpdate = "finalize-update", - Finished = "finished", + wireInfo: WireInfo; } -export interface ExchangeBankAccount { - payto_uri: string; - master_sig: string; -} - -export interface ExchangeWireInfo { +export interface WireInfo { feesForType: { [wireMethod: string]: WireFee[] }; + accounts: ExchangeBankAccount[]; } -export enum ExchangeUpdateReason { - Initial = "initial", - Forced = "forced", - Scheduled = "scheduled", +export interface ExchangeDetailsPointer { + masterPublicKey: string; + currency: string; + + /** + * Timestamp when the (masterPublicKey, currency) pointer + * has been updated. + */ + updateClock: Timestamp; } /** @@ -590,10 +619,7 @@ export interface ExchangeRecord { */ baseUrl: string; - /** - * Did we finish adding the exchange? - */ - addComplete: boolean; + detailsPointer: ExchangeDetailsPointer | undefined; /** * Is this a permanent or temporary exchange record? @@ -601,38 +627,6 @@ export interface ExchangeRecord { permanent: boolean; /** - * Was the exchange added as a built-in exchange? - */ - builtIn: boolean; - - /** - * Details, once known. - */ - details: ExchangeDetails | undefined; - - /** - * Mapping from wire method type to the wire fee. - */ - wireInfo: ExchangeWireInfo | undefined; - - /** - * Terms of service text or undefined if not downloaded yet. - * - * This is just used as a cache of the last downloaded ToS. - */ - termsOfServiceText: string | undefined; - - /** - * ETag for last terms of service download. - */ - termsOfServiceLastEtag: string | undefined; - - /** - * ETag for last terms of service download. - */ - termsOfServiceAcceptedEtag: string | undefined; - - /** * Time when the update to the exchange has been started or * undefined if no update is in progress. */ @@ -640,6 +634,9 @@ export interface ExchangeRecord { /** * Status of updating the info about the exchange. + * + * FIXME: Adapt this to recent changes regarding how + * updating exchange details works. */ updateStatus: ExchangeUpdateStatus; @@ -1548,7 +1545,7 @@ export interface BackupProviderTerms { export interface BackupProviderRecord { /** * Base URL of the provider. - * + * * Primary key for the record. */ baseUrl: string; @@ -1692,6 +1689,17 @@ class ExchangesStore extends Store<"exchanges", ExchangeRecord> { } } +class ExchangeDetailsStore extends Store< + "exchangeDetails", + ExchangeDetailsRecord +> { + constructor() { + super("exchangeDetails", { + keyPath: ["exchangeBaseUrl", "currency", "masterPublicKey"], + }); + } +} + class CoinsStore extends Store<"coins", CoinRecord> { constructor() { super("coins", { keyPath: "coinPub" }); @@ -1924,6 +1932,7 @@ export const Stores = { exchangeTrustStore: new ExchangeTrustStore(), denominations: new DenominationsStore(), exchanges: new ExchangesStore(), + exchangeDetails: new ExchangeDetailsStore(), proposals: new ProposalsStore(), refreshGroups: new Store<"refreshGroups", RefreshGroupRecord>( "refreshGroups", |