[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: currency hint fo
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: currency hint for preset exchanges |
Date: |
Mon, 02 Oct 2023 23:24:09 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 8e70b8959 wallet-core: currency hint for preset exchanges
8e70b8959 is described below
commit 8e70b89593a375bb19432e6521daed618ae779f5
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Oct 2 23:24:06 2023 +0200
wallet-core: currency hint for preset exchanges
---
packages/taler-wallet-core/src/db.ts | 6 ++++++
packages/taler-wallet-core/src/operations/common.ts | 2 +-
packages/taler-wallet-core/src/operations/exchanges.ts | 4 +++-
packages/taler-wallet-core/src/wallet-api-types.ts | 7 ++++++-
packages/taler-wallet-core/src/wallet.ts | 18 ++++++++++++------
5 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index 156651cc6..d59085dcc 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -620,6 +620,12 @@ export interface ExchangeEntryRecord {
*/
baseUrl: string;
+ /**
+ * Currency hint for a preset exchange, relevant
+ * when we didn't contact a preset exchange yet.
+ */
+ presetCurrencyHint?: string;
+
/**
* When did we confirm the last withdrawal from this exchange?
*
diff --git a/packages/taler-wallet-core/src/operations/common.ts
b/packages/taler-wallet-core/src/operations/common.ts
index e8e492c08..b28a5363d 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -593,7 +593,7 @@ export function makeExchangeListItem(
return {
exchangeBaseUrl: r.baseUrl,
- currency: exchangeDetails?.currency,
+ currency: exchangeDetails?.currency ?? r.presetCurrencyHint,
exchangeUpdateStatus,
exchangeEntryStatus,
tosStatus: exchangeDetails
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 5e966b719..82d7b42bf 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -309,6 +309,7 @@ export async function downloadExchangeInfo(
export async function addPresetExchangeEntry(
tx: WalletDbReadWriteTransaction<"exchanges">,
exchangeBaseUrl: string,
+ currencyHint?: string,
): Promise<void> {
let exchange = await tx.exchanges.get(exchangeBaseUrl);
if (!exchange) {
@@ -316,6 +317,7 @@ export async function addPresetExchangeEntry(
entryStatus: ExchangeEntryDbRecordStatus.Preset,
updateStatus: ExchangeEntryDbUpdateStatus.Initial,
baseUrl: exchangeBaseUrl,
+ presetCurrencyHint: currencyHint,
detailsPointer: undefined,
lastUpdate: undefined,
lastKeysEtag: undefined,
@@ -330,7 +332,7 @@ export async function addPresetExchangeEntry(
}
}
-export async function provideExchangeRecordInTx(
+async function provideExchangeRecordInTx(
ws: InternalWalletState,
tx: GetReadWriteAccess<{
exchanges: typeof WalletStoresV1.exchanges;
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts
b/packages/taler-wallet-core/src/wallet-api-types.ts
index 26e86f43f..375e0a1b2 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -254,6 +254,11 @@ export type GetVersionOp = {
*/
export type WalletConfigParameter = RecursivePartial<WalletConfig>;
+export interface BuiltinExchange {
+ exchangeBaseUrl: string;
+ currencyHint?: string;
+}
+
export interface WalletConfig {
/**
* Initialization values useful for a complete startup.
@@ -261,7 +266,7 @@ export interface WalletConfig {
* These are values may be overridden by different wallets
*/
builtin: {
- exchanges: string[];
+ exchanges: BuiltinExchange[];
};
/**
diff --git a/packages/taler-wallet-core/src/wallet.ts
b/packages/taler-wallet-core/src/wallet.ts
index 44076667d..203adec0f 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -200,7 +200,6 @@ import {
downloadTosFromAcceptedFormat,
getExchangeDetails,
getExchangeRequestTimeout,
- provideExchangeRecordInTx,
updateExchangeFromUrl,
updateExchangeFromUrlHandler,
} from "./operations/exchanges.js";
@@ -535,10 +534,12 @@ async function fillDefaults(ws: InternalWalletState):
Promise<void> {
logger.trace("defaults already applied");
return;
}
- for (const baseUrl of ws.config.builtin.exchanges) {
- await addPresetExchangeEntry(tx, baseUrl);
- const now = AbsoluteTime.now();
- provideExchangeRecordInTx(ws, tx, baseUrl, now);
+ for (const exch of ws.config.builtin.exchanges) {
+ await addPresetExchangeEntry(
+ tx,
+ exch.exchangeBaseUrl,
+ exch.currencyHint,
+ );
}
await tx.config.put({
key: ConfigRecordKey.CurrencyDefaultsApplied,
@@ -1672,7 +1673,12 @@ export class Wallet {
public static defaultConfig: Readonly<WalletConfig> = {
builtin: {
- exchanges: ["https://exchange.demo.taler.net/"],
+ exchanges: [
+ {
+ exchangeBaseUrl: "https://exchange.demo.taler.net/",
+ currencyHint: "KUDOS",
+ },
+ ],
},
features: {
allowHttp: false,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: currency hint for preset exchanges,
gnunet <=