better module for BytesXX
This commit is contained in:
parent
7c989e590a
commit
f9ebdb0a96
5 changed files with 61 additions and 13 deletions
30
src/api.ml
30
src/api.ml
|
|
@ -62,6 +62,34 @@ module B32 = struct
|
|||
~decode:B32.decode Caqti_type.string
|
||||
end
|
||||
|
||||
module Bytes32 = struct
|
||||
include Signatures.Bytes32
|
||||
|
||||
let jsont =
|
||||
let decode s = Result.bind (B32.decode s) of_octets in
|
||||
let encode b = to_octets b |> B32.encode in
|
||||
Jsont.of_of_string ~kind:"Bytes32" decode ~enc:encode
|
||||
|
||||
let caqti =
|
||||
Caqti_type.custom
|
||||
~encode:(fun v -> Ok (to_octets v))
|
||||
~decode:of_octets Caqti_type.octets
|
||||
end
|
||||
|
||||
module Bytes64 = struct
|
||||
include Signatures.Bytes64
|
||||
|
||||
let jsont =
|
||||
let decode s = Result.bind (B32.decode s) of_octets in
|
||||
let encode b = to_octets b |> B32.encode in
|
||||
Jsont.of_of_string ~kind:"Bytes64" decode ~enc:encode
|
||||
|
||||
let caqti =
|
||||
Caqti_type.custom
|
||||
~encode:(fun v -> Ok (to_octets v))
|
||||
~decode:of_octets Caqti_type.octets
|
||||
end
|
||||
|
||||
(* TODO error response
|
||||
- use GANA error codes
|
||||
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
|
||||
|
|
@ -676,7 +704,7 @@ module DrainProfitsMessage = struct
|
|||
map ~kind:"DrainProfitsMessage" make
|
||||
|> mem "debit_account_section" Jsont.string ~enc:debit_account_section
|
||||
|> mem "credit_payto_uri" Jsont.string ~enc:credit_payto_uri
|
||||
|> mem "wtid" B32.jsont ~enc:wtid
|
||||
|> mem "wtid" Bytes32.jsont ~enc:wtid
|
||||
|> mem "master_sig" MasterDrainProfit.jsont ~enc:master_sig
|
||||
|> mem "date" Timestamp.jsont ~enc:date
|
||||
|> mem "amount" Amount.jsont ~enc:amount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue