Alpha: use 'dft' field for boolean flag

This simplifies the binary encoding without changing the semantics of
the JSON objects.
This commit is contained in:
Grégoire Henry 2018-05-31 17:41:45 +02:00 committed by Benjamin Canou
parent ce79dc5383
commit b7ca0a1e1e

View File

@ -240,8 +240,8 @@ module Encoding = struct
(obj6 (obj6
(req "managerPubkey" Signature.Public_key_hash.encoding) (req "managerPubkey" Signature.Public_key_hash.encoding)
(req "balance" Tez_repr.encoding) (req "balance" Tez_repr.encoding)
(opt "spendable" bool) (dft "spendable" bool true)
(opt "delegatable" bool) (dft "delegatable" bool true)
(opt "delegate" Signature.Public_key_hash.encoding) (opt "delegate" Signature.Public_key_hash.encoding)
(opt "script" Script_repr.encoding)) ; (opt "script" Script_repr.encoding)) ;
select = select =
@ -256,14 +256,10 @@ module Encoding = struct
(* the hash is only used internally (* the hash is only used internally
when originating from smart when originating from smart
contracts, don't serialize it *) } -> contracts, don't serialize it *) } ->
(manager, credit, Some spendable, (manager, credit, spendable,
Some delegatable, delegate, script)) ; delegatable, delegate, script)) ;
inj = inj =
(fun (manager, credit, spendable, delegatable, delegate, script) -> (fun (manager, credit, spendable, delegatable, delegate, script) ->
let delegatable =
match delegatable with None -> true | Some b -> b in
let spendable =
match spendable with None -> true | Some b -> b in
Origination Origination
{manager ; credit ; spendable ; delegatable ; {manager ; credit ; spendable ; delegatable ;
delegate ; script ; preorigination = None }) delegate ; script ; preorigination = None })