diff options
author | Florian Dold <florian@dold.me> | 2024-02-22 12:42:54 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-02-22 12:42:54 +0100 |
commit | 8153c5026f3e7a100564e6dd9944e054cbb1b910 (patch) | |
tree | b6fb4e4ba17c9642268a8040cd8803751251e641 /packages/taler-util/src | |
parent | 012ba47d0bf669c258d703606a09c5d48922a58f (diff) | |
download | wallet-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.ts | 16 | ||||
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 5 |
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> => |