summaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-22 12:42:54 +0100
committerFlorian Dold <florian@dold.me>2024-02-22 12:42:54 +0100
commit8153c5026f3e7a100564e6dd9944e054cbb1b910 (patch)
treeb6fb4e4ba17c9642268a8040cd8803751251e641 /packages/taler-util/src
parent012ba47d0bf669c258d703606a09c5d48922a58f (diff)
downloadwallet-core-8153c5026f3e7a100564e6dd9944e054cbb1b910.tar.gz
wallet-core-8153c5026f3e7a100564e6dd9944e054cbb1b910.tar.bz2
wallet-core-8153c5026f3e7a100564e6dd9944e054cbb1b910.zip
webextension: render more info about exchanges
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/time.ts16
-rw-r--r--packages/taler-util/src/wallet-types.ts5
2 files changed, 20 insertions, 1 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts
index 5702b2947..66bde4fa2 100644
--- a/packages/taler-util/src/time.ts
+++ b/packages/taler-util/src/time.ts
@@ -639,7 +639,21 @@ export const codecForTimestamp: Codec<TalerProtocolTimestamp> = {
if (typeof t_s === "number") {
return { t_s };
}
- throw Error(`expected timestamp at ${renderContext(c)}`);
+ throw Error(`expected protocol timestamp at ${renderContext(c)}`);
+ },
+};
+
+export const codecForPreciseTimestamp: Codec<TalerPreciseTimestamp> = {
+ decode(x: any, c?: Context): TalerPreciseTimestamp {
+ const t_ms = x.t_ms;
+ if (typeof t_ms === "string") {
+ if (t_ms === "never") {
+ return { t_s: "never" };
+ }
+ } else if (typeof t_ms === "number") {
+ return { t_s: Math.floor(t_ms / 1000) };
+ }
+ throw Error(`expected precise timestamp at ${renderContext(c)}`);
},
};
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 5293fcd55..771d4d1f9 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -79,6 +79,7 @@ import {
TalerProtocolDuration,
TalerProtocolTimestamp,
codecForAbsoluteTime,
+ codecForPreciseTimestamp,
codecForTimestamp,
} from "./time.js";
import {
@@ -1342,6 +1343,8 @@ export interface ExchangeListItem {
scopeInfo: ScopeInfo | undefined;
+ lastUpdateTimestamp: TalerPreciseTimestamp | undefined;
+
/**
* Information about the last error that occurred when trying
* to update the exchange info.
@@ -1414,6 +1417,8 @@ export const codecForExchangeListItem = (): Codec<ExchangeListItem> =>
.property("exchangeUpdateStatus", codecForAny())
.property("ageRestrictionOptions", codecForList(codecForNumber()))
.property("scopeInfo", codecForScopeInfo())
+ .property("lastUpdateErrorInfo", codecForAny())
+ .property("lastUpdateTimestamp", codecOptional(codecForPreciseTimestamp))
.build("ExchangeListItem");
export const codecForExchangesListResponse = (): Codec<ExchangesListResponse> =>