aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-08-15 13:47:29 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-08-15 13:47:29 +0200
commit819949d7f2cfcce8d334cbfdb701255daac64951 (patch)
tree592043554f59ec209f9afc1c31c20c4fb585c3ca /packages/taler-util/src
parent77ea209ddb6d457db0ce113f91247207cc29fbd8 (diff)
parentadb0e70f151e63d103f27852312319520f4d0a84 (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/taleruri.ts2
-rw-r--r--packages/taler-util/src/wallet-types.ts65
2 files changed, 62 insertions, 5 deletions
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts
index 777cb5245..fff1ca833 100644
--- a/packages/taler-util/src/taleruri.ts
+++ b/packages/taler-util/src/taleruri.ts
@@ -767,7 +767,7 @@ function getUrlInfo(
const qp = new URLSearchParams();
let withParams = false;
Object.entries(params).forEach(([name, value]) => {
- if (value) {
+ if (value !== undefined) {
withParams = true;
qp.append(name, value);
}
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 38e5787ba..3179cd6f3 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -379,6 +379,54 @@ export interface Balance {
requiresUserInput: boolean;
}
+export const codecForScopeInfoGlobal = (): Codec<ScopeInfoGlobal> =>
+ buildCodecForObject<ScopeInfoGlobal>()
+ .property("currency", codecForString())
+ .property("type", codecForConstString(ScopeType.Global))
+ .build("ScopeInfoGlobal");
+
+export const codecForScopeInfoExchange = (): Codec<ScopeInfoExchange> =>
+ buildCodecForObject<ScopeInfoExchange>()
+ .property("currency", codecForString())
+ .property("type", codecForConstString(ScopeType.Exchange))
+ .property("url", codecForString())
+ .build("ScopeInfoExchange");
+
+export const codecForScopeInfoAuditor = (): Codec<ScopeInfoAuditor> =>
+ buildCodecForObject<ScopeInfoAuditor>()
+ .property("currency", codecForString())
+ .property("type", codecForConstString(ScopeType.Auditor))
+ .property("url", codecForString())
+ .build("ScopeInfoAuditor");
+
+export const codecForScopeInfo = (): Codec<ScopeInfo> =>
+ buildCodecForUnion<ScopeInfo>()
+ .discriminateOn("type")
+ .alternative(ScopeType.Global, codecForScopeInfoGlobal())
+ .alternative(ScopeType.Exchange, codecForScopeInfoExchange())
+ .alternative(ScopeType.Auditor, codecForScopeInfoAuditor())
+ .build("ScopeInfo");
+
+export interface GetCurrencyInfoRequest {
+ scope: ScopeInfo;
+}
+
+export const codecForGetCurrencyInfoRequest =
+ (): Codec<GetCurrencyInfoRequest> =>
+ buildCodecForObject<GetCurrencyInfoRequest>()
+ .property("scope", codecForScopeInfo())
+ .build("GetCurrencyInfoRequest");
+
+export interface GetCurrencyInfoResponse {
+ decimalSeparator: string;
+ numFractionalDigits: number;
+ numTinyDigits: number;
+ /**
+ * Is the currency name leading or trailing?
+ */
+ isCurrencyNameLeading: boolean;
+}
+
export interface InitRequest {
skipDefaults?: boolean;
}
@@ -393,10 +441,19 @@ export enum ScopeType {
Auditor = "auditor",
}
-export type ScopeInfo =
- | { type: ScopeType.Global; currency: string }
- | { type: ScopeType.Exchange; currency: string; url: string }
- | { type: ScopeType.Auditor; currency: string; url: string };
+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;
+ url: string;
+};
+
+export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor;
export interface BalancesResponse {
balances: Balance[];