From 085fbbde54612075bf66b848d4e173b477df8aa6 Mon Sep 17 00:00:00 2001 From: swrup Date: Sat, 7 Feb 2026 21:03:21 +0100 Subject: [PATCH] --- src/api.ml | 56 ++++++++++++++++++++++++++++++++++++++++-------- src/http_keys.ml | 1 - src/mte.ml | 9 +++++++- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/api.ml b/src/api.ml index 519cfb38..6a767310 100644 --- a/src/api.ml +++ b/src/api.ml @@ -178,41 +178,42 @@ end module ExchangeVersionResponse = struct type t = { version: string; - (* todo: const string - name: "taler-exchange";*) + (* todo jsont const string + `name: "taler-exchange"` *) + name: string; implementation: string option; currency: string; shopping_url: string option; open_banking_gateway: string option; currency_specification: CurrencySpecification.t; - supported_kyc_requirements: string list; aml_spa_dialect: string option; } let jsont = - let make version implementation currency shopping_url open_banking_gateway - currency_specification supported_kyc_requirements aml_spa_dialect = + let make version name implementation currency shopping_url + open_banking_gateway currency_specification aml_spa_dialect = { version; + name; implementation; currency; shopping_url; open_banking_gateway; currency_specification; - supported_kyc_requirements; aml_spa_dialect; } in let version v = v.version in + let name v = v.name in let implementation v = v.implementation in let currency v = v.currency in let shopping_url v = v.shopping_url in let open_banking_gateway v = v.open_banking_gateway in let currency_specification v = v.currency_specification in - let supported_kyc_requirements v = v.supported_kyc_requirements in let aml_spa_dialect v = v.aml_spa_dialect in map ~kind:"ExchangeVersionResponse" make |> mem "version" Jsont.string ~enc:version + |> mem "name" Jsont.string ~enc:name |> mem "implementation" (Jsont.option Jsont.string) ~enc:implementation |> mem "currency" Jsont.string ~enc:currency |> mem "shopping_url" (Jsont.option Jsont.string) ~enc:shopping_url @@ -221,12 +222,49 @@ module ExchangeVersionResponse = struct ~enc:open_banking_gateway |> mem "currency_specification" CurrencySpecification.jsont ~enc:currency_specification - |> mem "supported_kyc_requirements" (Jsont.list Jsont.string) - ~enc:supported_kyc_requirements |> mem "aml_spa_dialect" (Jsont.option Jsont.string) ~enc:aml_spa_dialect |> finish end +let config = + let currency_specification = + let Config.Currency. + { + enabled= _; + code= _; + name; + fractional_input_digits; + fractional_normal_digits; + fractional_trailing_zero_digits; + alt_unit_names; + } = + Config.Currency.v + in + let alt_unit_names = + Parse_config.Alt_unit_names.encode_exn alt_unit_names + in + CurrencySpecification. + { + name; + num_fractional_input_digits= fractional_input_digits; + num_fractional_normal_digits= fractional_normal_digits; + num_fractional_trailing_zero_digits= fractional_trailing_zero_digits; + alt_unit_names; + common_amounts= []; + } + in + ExchangeVersionResponse. + { + version= protocol_version; + name= "taler-exchange"; + currency= Config.currency; + currency_specification; + implementation= None; + shopping_url= None; + open_banking_gateway= None; + aml_spa_dialect= None; + } + module RsaDenominationKey = struct type t = { age_mask: int; diff --git a/src/http_keys.ml b/src/http_keys.ml index dd0c36c5..760e6cbe 100644 --- a/src/http_keys.ml +++ b/src/http_keys.ml @@ -239,7 +239,6 @@ let mk_keys ~db_conn (module Sm : Secmod.S) ~last_issue_date = let jsont = ExchangeKeysResponse.jsont -(* TODO query param ?last_issue_date *) let f req server _env = Logs.info (fun m -> m "GET /keys"); let db_conn = Vif.Server.device Devices.db_connection server in diff --git a/src/mte.ml b/src/mte.ml index f98ee88f..e2d14d79 100644 --- a/src/mte.ml +++ b/src/mte.ml @@ -13,6 +13,11 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . *) +let config req _server _env = + Logs.info (fun m -> m "GET /config"); + let s = Api.(encode_exn ExchangeVersionResponse.jsont config) in + Respond_util.respond_with_ok_json s req + let hello req _server _env = let open Vif.Response in let open Syntax in @@ -33,7 +38,9 @@ let routes = get_ (v "privacy") --> Static.privacy; ] in - let status_info = [ get_ (rel / "keys") --> Http_keys.f ] in + let status_info = + [ get_ (rel / "config") --> config; get_ (rel / "keys") --> Http_keys.f ] + in let management = let open Http_management in let v s = rel / "management" / s in