have api.ml not depends on config.ml
This commit is contained in:
parent
5532798ea5
commit
f3483594ac
3 changed files with 63 additions and 79 deletions
59
src/api.ml
59
src/api.ml
|
|
@ -135,12 +135,41 @@ module ErrorDetail = struct
|
|||
end
|
||||
|
||||
module CurrencySpecification = struct
|
||||
module Alt_unit_names = struct
|
||||
open Syntax
|
||||
module Int_map = Map.Make (Int)
|
||||
module String_map = Map.Make (String)
|
||||
|
||||
type t = string Int_map.t
|
||||
|
||||
let jsont =
|
||||
let of_string_map str_map =
|
||||
str_map
|
||||
|> String_map.to_list
|
||||
|> list_map (fun (k, v) ->
|
||||
match int_of_string_opt k with
|
||||
| None -> Error "not an integer"
|
||||
| Some k -> Ok (k, v))
|
||||
|> function
|
||||
| Error e -> Jsont.Error.msg Jsont.Meta.none e
|
||||
| Ok l -> Int_map.of_list l
|
||||
in
|
||||
let to_string_map int_map =
|
||||
int_map
|
||||
|> Int_map.to_list
|
||||
|> List.map (fun (k, v) -> (string_of_int k, v))
|
||||
|> String_map.of_list
|
||||
in
|
||||
let string_map_jsont = Jsont.Object.as_string_map Jsont.string in
|
||||
Jsont.map ~dec:of_string_map ~enc:to_string_map string_map_jsont
|
||||
end
|
||||
|
||||
type t = {
|
||||
name: string;
|
||||
num_fractional_input_digits: int;
|
||||
num_fractional_normal_digits: int;
|
||||
num_fractional_trailing_zero_digits: int;
|
||||
alt_unit_names: Config.Currency.Alt_unit_names.t;
|
||||
alt_unit_names: Alt_unit_names.t;
|
||||
common_amounts: Amount.t list;
|
||||
}
|
||||
|
||||
|
|
@ -172,8 +201,7 @@ module CurrencySpecification = struct
|
|||
~enc:num_fractional_normal_digits
|
||||
|> mem "num_fractional_trailing_zero_digits" Jsont.int
|
||||
~enc:num_fractional_trailing_zero_digits
|
||||
|> mem "alt_unit_names" Config.Currency.Alt_unit_names.jsont
|
||||
~enc:alt_unit_names
|
||||
|> mem "alt_unit_names" Alt_unit_names.jsont ~enc:alt_unit_names
|
||||
|> mem "common_amounts" (Jsont.list Amount.jsont) ~enc:common_amounts
|
||||
|> finish
|
||||
end
|
||||
|
|
@ -227,31 +255,6 @@ module ExchangeVersionResponse = struct
|
|||
|> finish
|
||||
end
|
||||
|
||||
let currency_specification =
|
||||
let open Config.Currency in
|
||||
CurrencySpecification.
|
||||
{
|
||||
name= v.name;
|
||||
num_fractional_input_digits= v.fractional_input_digits;
|
||||
num_fractional_normal_digits= v.fractional_normal_digits;
|
||||
num_fractional_trailing_zero_digits= v.fractional_trailing_zero_digits;
|
||||
alt_unit_names= Config.Currency.v.alt_unit_names;
|
||||
common_amounts= [];
|
||||
}
|
||||
|
||||
let config =
|
||||
ExchangeVersionResponse.
|
||||
{
|
||||
version= Libtool_version.mte_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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue