fix empty jsont object
This commit is contained in:
parent
75468691f5
commit
28d69de95a
1 changed files with 25 additions and 29 deletions
54
src/api.ml
54
src/api.ml
|
|
@ -10,17 +10,15 @@
|
|||
- "@deprecated" fields
|
||||
- "@since protocol xx"
|
||||
|
||||
better jsont cases handling:
|
||||
- factorize common fields (DenomCommon/DenomGroupCommon)
|
||||
- "+age_restricted"/CS variants
|
||||
- raise error not implemented if not RSA
|
||||
use of _monotonic_ time
|
||||
|
||||
monotonic time
|
||||
|
||||
payto_uri
|
||||
uri
|
||||
option: correct use opt_mem or Jsont.option
|
||||
number
|
||||
|
||||
better types:
|
||||
- payto_uri
|
||||
- uri
|
||||
|
||||
number:
|
||||
- number is "float", but we probably want int everywhere instead
|
||||
- numeric values capped at 2^53 -1 inclusive because json *)
|
||||
open Crypto
|
||||
|
|
@ -243,25 +241,8 @@ module RsaDenominationKey = struct
|
|||
end
|
||||
|
||||
(* ! Clause Schnorr cipher is not supported *)
|
||||
module CSDenominationKey = struct
|
||||
type t = {
|
||||
age_mask: int;
|
||||
cs_pub: B32.t;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make age_mask cs_pub = { age_mask; cs_pub } in
|
||||
let age_mask v = v.age_mask in
|
||||
let cs_pub v = v.cs_pub in
|
||||
Jsont.Object.map ~kind:"CSDenominationKey" make
|
||||
|> Jsont.Object.mem "age_mask" Jsont.int ~enc:age_mask
|
||||
|> Jsont.Object.mem "cs_pub" B32.jsont ~enc:cs_pub
|
||||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
module DenominationKey = struct
|
||||
type t = Rsa of RsaDenominationKey.t
|
||||
(*| CS of CSDenominationKey.t*)
|
||||
|
||||
let to_octets = function Rsa denom -> RsaPublicKey.to_octets denom.rsa_pub
|
||||
|
||||
|
|
@ -272,7 +253,7 @@ module DenominationKey = struct
|
|||
|
||||
let jsont =
|
||||
let rsa = Case.map "RSA" RsaDenominationKey.jsont ~dec:of_rsa in
|
||||
let cs = Case.map "CS" CSDenominationKey.jsont ~dec:of_cs in
|
||||
let cs = Case.map "CS" zero ~dec:of_cs in
|
||||
let enc_case = function Rsa v -> Case.value rsa v in
|
||||
let cases = Case.[ make rsa; make cs ] in
|
||||
map ~kind:"DenominationKey" Fun.id
|
||||
|
|
@ -1026,10 +1007,25 @@ module DenomGroup = struct
|
|||
|
||||
let of_rsa v = Rsa v
|
||||
|
||||
let of_cs _v =
|
||||
Jsont.Error.msg Jsont.Meta.none "CSDenomGroup are not supported"
|
||||
|
||||
let of_rsa_age_restricted _v =
|
||||
Jsont.Error.msg Jsont.Meta.none
|
||||
"DenomGroupRsaAgeRestricted are not supported"
|
||||
|
||||
let jsont =
|
||||
let rsa = Case.map "RSA" RsaDenomGroup.jsont ~dec:of_rsa in
|
||||
let cs = Case.map "CS" zero ~dec:of_cs in
|
||||
let rsa_age_restricted =
|
||||
Case.map "RSA+age_restricted" zero ~dec:of_rsa_age_restricted
|
||||
in
|
||||
let cs_age_restricted = Case.map "CS+age_restricted" zero ~dec:of_cs in
|
||||
let enc_case = function Rsa v -> Case.value rsa v in
|
||||
let cases = Case.[ make rsa ] in
|
||||
let cases =
|
||||
Case.
|
||||
[ make rsa; make cs; make rsa_age_restricted; make cs_age_restricted ]
|
||||
in
|
||||
map ~kind:"DenomGroup" Fun.id
|
||||
|> case_mem "cipher" Jsont.string ~enc:Fun.id ~enc_case cases
|
||||
|> finish
|
||||
|
|
@ -1102,7 +1098,7 @@ module AccountRestriction = struct
|
|||
|
||||
let jsont =
|
||||
let regex = Case.map "regex" RegexAccountRestriction.jsont ~dec:of_regex in
|
||||
let deny = Case.map "deny" Jsont.ignore ~dec:of_deny in
|
||||
let deny = Case.map "deny" zero ~dec:of_deny in
|
||||
let enc_case = function
|
||||
| Regex v -> Case.value regex v
|
||||
| Deny -> Case.value deny ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue