rm api_types.ml
This commit is contained in:
parent
94a4c1e29e
commit
2968339c6d
4 changed files with 63 additions and 103 deletions
|
|
@ -1,90 +0,0 @@
|
|||
(* TODO
|
||||
number
|
||||
- number is "float", but we probably want int everywhere instead
|
||||
- numeric values capped at 2^53 -1 inclusive because json
|
||||
time
|
||||
- better types
|
||||
- issues with "never" = uint64_max *)
|
||||
open Crypto
|
||||
|
||||
module ErrorDetail = struct
|
||||
(* TODO GANA error codes
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
type t = {
|
||||
code: int;
|
||||
hint: string option;
|
||||
}
|
||||
end
|
||||
|
||||
module Timestamp = struct
|
||||
type t =
|
||||
| Seconds of float
|
||||
| Never
|
||||
|
||||
let of_ptime p = Seconds (Ptime.to_float_s p)
|
||||
end
|
||||
|
||||
module RelativeTime = struct
|
||||
type t =
|
||||
| Microseconds of float
|
||||
| Forever
|
||||
end
|
||||
|
||||
module RsaDenominationKey = struct
|
||||
type t = {
|
||||
age_mask: int;
|
||||
rsa_pub: RsaPublicKey.t;
|
||||
}
|
||||
end
|
||||
|
||||
(* not implemented *)
|
||||
module CSDenominationKey = struct
|
||||
(* Clause Schnorr *)
|
||||
type t = {
|
||||
age_mask: int;
|
||||
cs_pub: string;
|
||||
}
|
||||
end
|
||||
|
||||
module DenominationKey = struct
|
||||
type t =
|
||||
| Rsa of RsaDenominationKey.t
|
||||
| CS of CSDenominationKey.t
|
||||
end
|
||||
|
||||
module FutureSignKey = struct
|
||||
type t = {
|
||||
key: EddsaPublicKey.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire: Timestamp.t;
|
||||
stamp_end: Timestamp.t;
|
||||
signkey_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
end
|
||||
|
||||
module FutureDenom = struct
|
||||
type t = {
|
||||
section_name: string;
|
||||
value: Amount.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire_withdraw: Timestamp.t;
|
||||
stamp_expire_deposit: Timestamp.t;
|
||||
stamp_expire_legal: Timestamp.t;
|
||||
denom_pub: DenominationKey.t;
|
||||
fee_withdraw: Amount.t;
|
||||
fee_deposit: Amount.t;
|
||||
fee_refresh: Amount.t;
|
||||
fee_refund: Amount.t;
|
||||
denom_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
end
|
||||
|
||||
module FutureKeysResponse = struct
|
||||
type t = {
|
||||
future_denoms: FutureDenom.t list;
|
||||
future_signkeys: FutureSignKey.t list;
|
||||
master_pub: EddsaPublicKey.t;
|
||||
denom_secmod_public_key: EddsaPublicKey.t;
|
||||
signkey_secmod_public_key: EddsaPublicKey.t;
|
||||
}
|
||||
end
|
||||
72
src/json.ml
72
src/json.ml
|
|
@ -1,4 +1,10 @@
|
|||
open Api_types
|
||||
(* TODO
|
||||
number
|
||||
- number is "float", but we probably want int everywhere instead
|
||||
- numeric values capped at 2^53 -1 inclusive because json
|
||||
time
|
||||
- better types
|
||||
- issues with "never" = uint64_max *)
|
||||
open Crypto
|
||||
|
||||
let encode_exn jsont v = Jsont_bytesrw.encode_string jsont v |> Result.get_ok
|
||||
|
|
@ -6,7 +12,12 @@ let encode jsont v = Jsont_bytesrw.encode_string jsont v
|
|||
let decode jsont v = Jsont_bytesrw.decode_string jsont v
|
||||
|
||||
module ErrorDetail = struct
|
||||
open ErrorDetail
|
||||
(* TODO GANA error codes
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
type t = {
|
||||
code: int;
|
||||
hint: string option;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make code hint = { code; hint } in
|
||||
|
|
@ -25,7 +36,11 @@ module Amount = struct
|
|||
end
|
||||
|
||||
module Timestamp = struct
|
||||
open Timestamp
|
||||
type t =
|
||||
| Seconds of float
|
||||
| Never
|
||||
|
||||
let of_ptime p = Seconds (Ptime.to_float_s p)
|
||||
|
||||
let number_or_never_jsont =
|
||||
let never =
|
||||
|
|
@ -53,7 +68,9 @@ module Timestamp = struct
|
|||
end
|
||||
|
||||
module RelativeTime = struct
|
||||
open RelativeTime
|
||||
type t =
|
||||
| Microseconds of float
|
||||
| Forever
|
||||
|
||||
let number_or_forever_jsont =
|
||||
let forever =
|
||||
|
|
@ -81,7 +98,10 @@ module RelativeTime = struct
|
|||
end
|
||||
|
||||
module RsaDenominationKey = struct
|
||||
open RsaDenominationKey
|
||||
type t = {
|
||||
age_mask: int;
|
||||
rsa_pub: RsaPublicKey.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make age_mask rsa_pub = { age_mask; rsa_pub } in
|
||||
|
|
@ -93,8 +113,13 @@ module RsaDenominationKey = struct
|
|||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
(* not acctually implemented *)
|
||||
module CSDenominationKey = struct
|
||||
open CSDenominationKey
|
||||
(* Clause Schnorr *)
|
||||
type t = {
|
||||
age_mask: int;
|
||||
cs_pub: string;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make age_mask cs_pub = { age_mask; cs_pub } in
|
||||
|
|
@ -107,7 +132,9 @@ module CSDenominationKey = struct
|
|||
end
|
||||
|
||||
module DenominationKey = struct
|
||||
open DenominationKey
|
||||
type t =
|
||||
| Rsa of RsaDenominationKey.t
|
||||
| CS of CSDenominationKey.t
|
||||
|
||||
let rsa v = Rsa v
|
||||
let cs v = CS v
|
||||
|
|
@ -127,7 +154,13 @@ module DenominationKey = struct
|
|||
end
|
||||
|
||||
module FutureSignKey = struct
|
||||
open FutureSignKey
|
||||
type t = {
|
||||
key: EddsaPublicKey.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire: Timestamp.t;
|
||||
stamp_end: Timestamp.t;
|
||||
signkey_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make key stamp_start stamp_expire stamp_end signkey_secmod_sig =
|
||||
|
|
@ -149,7 +182,20 @@ module FutureSignKey = struct
|
|||
end
|
||||
|
||||
module FutureDenom = struct
|
||||
open FutureDenom
|
||||
type t = {
|
||||
section_name: string;
|
||||
value: Amount.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire_withdraw: Timestamp.t;
|
||||
stamp_expire_deposit: Timestamp.t;
|
||||
stamp_expire_legal: Timestamp.t;
|
||||
denom_pub: DenominationKey.t;
|
||||
fee_withdraw: Amount.t;
|
||||
fee_deposit: Amount.t;
|
||||
fee_refresh: Amount.t;
|
||||
fee_refund: Amount.t;
|
||||
denom_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make section_name value stamp_start stamp_expire_withdraw
|
||||
|
|
@ -200,7 +246,13 @@ module FutureDenom = struct
|
|||
end
|
||||
|
||||
module FutureKeysResponse = struct
|
||||
open FutureKeysResponse
|
||||
type t = {
|
||||
future_denoms: FutureDenom.t list;
|
||||
future_signkeys: FutureSignKey.t list;
|
||||
master_pub: EddsaPublicKey.t;
|
||||
denom_secmod_public_key: EddsaPublicKey.t;
|
||||
signkey_secmod_public_key: EddsaPublicKey.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make future_denoms future_signkeys master_pub denom_secmod_public_key
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
(*open Types*)
|
||||
open Api_types
|
||||
open Json
|
||||
open Devices
|
||||
|
||||
let mk_future_denom denom_key_signf
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>. *)
|
||||
|
||||
let error_detail ?hint _status =
|
||||
let open Api_types.ErrorDetail in
|
||||
let open Json in
|
||||
let code = -1 in
|
||||
let s = encode_exn ErrorDetail.jsont { code; hint } in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue