aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-28 14:19:12 +0200
committerFlorian Dold <florian@dold.me>2024-06-28 14:19:12 +0200
commit71f9676fc9d80bccc7353487d8527af74d25a02c (patch)
treee08ae9c3c6652ad6e36eaeb87d6941b1d78bc00f /packages/taler-util
parentad98210b79f350de631e593ef520f5a57a44812e (diff)
downloadwallet-core-71f9676fc9d80bccc7353487d8527af74d25a02c.tar.xz
wallet-core: return currency specification from exchange
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/taler-types.ts3
-rw-r--r--packages/taler-util/src/taleruri.ts1
-rw-r--r--packages/taler-util/src/wallet-types.ts18
3 files changed, 22 insertions, 0 deletions
diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts
index 66f98ea9a..ac42ca278 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -723,6 +723,8 @@ export class ExchangeKeysJson {
currency: string;
+ currency_specification?: CurrencySpecification;
+
/**
* The exchange's master public key.
*/
@@ -1504,6 +1506,7 @@ export const codecForExchangeKeysJson = (): Codec<ExchangeKeysJson> =>
buildCodecForObject<ExchangeKeysJson>()
.property("base_url", codecForString())
.property("currency", codecForString())
+ .property("currency_specification", codecOptional(codecForCurrencySpecificiation()))
.property("master_public_key", codecForString())
.property("auditors", codecForList(codecForAuditor()))
.property("list_issue_date", codecForTimestamp)
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts
index b22dc3c59..d3186d2f5 100644
--- a/packages/taler-util/src/taleruri.ts
+++ b/packages/taler-util/src/taleruri.ts
@@ -29,6 +29,7 @@ import { opFixedSuccess, opKnownTalerFailure } from "./operation.js";
import { TalerErrorCode } from "./taler-error-codes.js";
import { AmountString } from "./taler-types.js";
import { URL, URLSearchParams } from "./url.js";
+
/**
* A parsed taler URI.
*/
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 2c92d9295..42c0148e7 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -558,11 +558,13 @@ export enum ScopeType {
}
export type ScopeInfoGlobal = { type: ScopeType.Global; currency: string };
+
export type ScopeInfoExchange = {
type: ScopeType.Exchange;
currency: string;
url: string;
};
+
export type ScopeInfoAuditor = {
type: ScopeType.Auditor;
currency: string;
@@ -571,6 +573,22 @@ export type ScopeInfoAuditor = {
export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor;
+/**
+ * Encode scope info as a string.
+ *
+ * Format must be stable as it's used in the database.
+ */
+export function stringifyScopeInfo(si: ScopeInfo): string {
+ switch (si.type) {
+ case ScopeType.Global:
+ return `taler-si:global/${si.currency}}`;
+ case ScopeType.Auditor:
+ return `taler-si:auditor/${si.currency}/${encodeURIComponent(si.url)}`;
+ case ScopeType.Exchange:
+ return `taler-si:exchange/${si.currency}/${encodeURIComponent(si.url)}`;
+ }
+}
+
export interface BalancesResponse {
balances: WalletBalance[];
}