Alpha: explicit operation for key revelation
This commit is contained in:
parent
fc2cd7ce5c
commit
86561363b2
@ -561,7 +561,6 @@ and sourced_operations =
|
|||||||
}
|
}
|
||||||
| Manager_operations of {
|
| Manager_operations of {
|
||||||
source: Contract.contract ;
|
source: Contract.contract ;
|
||||||
public_key: Ed25519.Public_key.t option ;
|
|
||||||
fee: Tez.t ;
|
fee: Tez.t ;
|
||||||
counter: counter ;
|
counter: counter ;
|
||||||
operations: manager_operation list ;
|
operations: manager_operation list ;
|
||||||
@ -587,6 +586,7 @@ and amendment_operation =
|
|||||||
}
|
}
|
||||||
|
|
||||||
and manager_operation =
|
and manager_operation =
|
||||||
|
| Reveal of Ed25519.Public_key.t
|
||||||
| Transaction of {
|
| Transaction of {
|
||||||
amount: Tez.t ;
|
amount: Tez.t ;
|
||||||
parameters: Script.expr option ;
|
parameters: Script.expr option ;
|
||||||
|
@ -138,6 +138,7 @@ let apply_amendment_operation_content ctxt delegate = function
|
|||||||
|
|
||||||
let apply_manager_operation_content
|
let apply_manager_operation_content
|
||||||
ctxt origination_nonce source = function
|
ctxt origination_nonce source = function
|
||||||
|
| Reveal _ -> return (ctxt, origination_nonce, None)
|
||||||
| Transaction { amount ; parameters ; destination } -> begin
|
| Transaction { amount ; parameters ; destination } -> begin
|
||||||
Contract.spend ctxt source amount >>=? fun ctxt ->
|
Contract.spend ctxt source amount >>=? fun ctxt ->
|
||||||
Contract.credit ctxt destination amount >>=? fun ctxt ->
|
Contract.credit ctxt destination amount >>=? fun ctxt ->
|
||||||
@ -224,7 +225,12 @@ let apply_sourced_operation
|
|||||||
ctxt baker_contract pred_block block_prio
|
ctxt baker_contract pred_block block_prio
|
||||||
operation origination_nonce ops =
|
operation origination_nonce ops =
|
||||||
match ops with
|
match ops with
|
||||||
| Manager_operations { source ; public_key ; fee ; counter ; operations = contents } ->
|
| Manager_operations { source ; fee ; counter ; operations = contents } ->
|
||||||
|
let public_key =
|
||||||
|
List.fold_left (fun acc op ->
|
||||||
|
match op with
|
||||||
|
| Reveal pk -> Some pk
|
||||||
|
| _ -> acc) None contents in
|
||||||
Contract.must_exist ctxt source >>=? fun () ->
|
Contract.must_exist ctxt source >>=? fun () ->
|
||||||
Contract.update_manager_key ctxt source public_key >>=? fun (ctxt,public_key) ->
|
Contract.update_manager_key ctxt source public_key >>=? fun (ctxt,public_key) ->
|
||||||
Operation.check_signature public_key operation >>=? fun () ->
|
Operation.check_signature public_key operation >>=? fun () ->
|
||||||
|
@ -305,8 +305,12 @@ module Forge = struct
|
|||||||
|
|
||||||
let operations ctxt
|
let operations ctxt
|
||||||
block ~branch ~source ?sourcePubKey ~counter ~fee operations =
|
block ~branch ~source ?sourcePubKey ~counter ~fee operations =
|
||||||
|
let operations =
|
||||||
|
match sourcePubKey with
|
||||||
|
| None -> operations
|
||||||
|
| Some pk -> Reveal pk :: operations in
|
||||||
let ops =
|
let ops =
|
||||||
Manager_operations { source ; public_key = sourcePubKey ;
|
Manager_operations { source ;
|
||||||
counter ; operations ; fee } in
|
counter ; operations ; fee } in
|
||||||
(RPC_context.make_call0 S.operations ctxt block
|
(RPC_context.make_call0 S.operations ctxt block
|
||||||
() ({ branch }, Sourced_operations ops))
|
() ({ branch }, Sourced_operations ops))
|
||||||
@ -459,8 +463,13 @@ module Parse = struct
|
|||||||
match contents with
|
match contents with
|
||||||
| Anonymous_operations _ -> return ()
|
| Anonymous_operations _ -> return ()
|
||||||
| Sourced_operations (Manager_operations op) ->
|
| Sourced_operations (Manager_operations op) ->
|
||||||
|
let public_key =
|
||||||
|
List.fold_left (fun acc op ->
|
||||||
|
match op with
|
||||||
|
| Reveal pk -> Some pk
|
||||||
|
| _ -> acc) None op.operations in
|
||||||
begin
|
begin
|
||||||
match op.public_key with
|
match public_key with
|
||||||
| Some key -> return key
|
| Some key -> return key
|
||||||
| None ->
|
| None ->
|
||||||
Contract.get_manager ctxt op.source >>=? fun manager ->
|
Contract.get_manager ctxt op.source >>=? fun manager ->
|
||||||
|
@ -45,7 +45,6 @@ and sourced_operations =
|
|||||||
}
|
}
|
||||||
| Manager_operations of {
|
| Manager_operations of {
|
||||||
source: Contract_repr.contract ;
|
source: Contract_repr.contract ;
|
||||||
public_key: Ed25519.Public_key.t option ;
|
|
||||||
fee: Tez_repr.tez ;
|
fee: Tez_repr.tez ;
|
||||||
counter: counter ;
|
counter: counter ;
|
||||||
operations: manager_operation list ;
|
operations: manager_operation list ;
|
||||||
@ -71,6 +70,7 @@ and amendment_operation =
|
|||||||
}
|
}
|
||||||
|
|
||||||
and manager_operation =
|
and manager_operation =
|
||||||
|
| Reveal of Ed25519.Public_key.t
|
||||||
| Transaction of {
|
| Transaction of {
|
||||||
amount: Tez_repr.tez ;
|
amount: Tez_repr.tez ;
|
||||||
parameters: Script_repr.expr option ;
|
parameters: Script_repr.expr option ;
|
||||||
@ -96,6 +96,18 @@ module Encoding = struct
|
|||||||
|
|
||||||
open Data_encoding
|
open Data_encoding
|
||||||
|
|
||||||
|
let reveal_encoding =
|
||||||
|
(obj2
|
||||||
|
(req "kind" (constant "reveal"))
|
||||||
|
(req "public_key" Ed25519.Public_key.encoding))
|
||||||
|
|
||||||
|
let reveal_case tag =
|
||||||
|
case tag reveal_encoding
|
||||||
|
(function
|
||||||
|
| Reveal pkh -> Some ((), pkh)
|
||||||
|
| _ -> None)
|
||||||
|
(fun ((), pkh) -> Reveal pkh)
|
||||||
|
|
||||||
let transaction_encoding =
|
let transaction_encoding =
|
||||||
(obj4
|
(obj4
|
||||||
(req "kind" (constant "transaction"))
|
(req "kind" (constant "transaction"))
|
||||||
@ -149,27 +161,27 @@ module Encoding = struct
|
|||||||
(fun ((), key) -> Delegation key)
|
(fun ((), key) -> Delegation key)
|
||||||
|
|
||||||
let manager_kind_encoding =
|
let manager_kind_encoding =
|
||||||
(obj6
|
(obj5
|
||||||
(req "kind" (constant "manager"))
|
(req "kind" (constant "manager"))
|
||||||
(req "source" Contract_repr.encoding)
|
(req "source" Contract_repr.encoding)
|
||||||
(opt "public_key" Ed25519.Public_key.encoding)
|
|
||||||
(req "fee" Tez_repr.encoding)
|
(req "fee" Tez_repr.encoding)
|
||||||
(req "counter" int32)
|
(req "counter" int32)
|
||||||
(req "operations"
|
(req "operations"
|
||||||
(list (union ~tag_size:`Uint8 [
|
(list (union ~tag_size:`Uint8 [
|
||||||
transaction_case (Tag 0) ;
|
reveal_case (Tag 0) ;
|
||||||
origination_case (Tag 1) ;
|
transaction_case (Tag 1) ;
|
||||||
delegation_case (Tag 2) ;
|
origination_case (Tag 2) ;
|
||||||
|
delegation_case (Tag 3) ;
|
||||||
]))))
|
]))))
|
||||||
|
|
||||||
let manager_kind_case tag =
|
let manager_kind_case tag =
|
||||||
case tag manager_kind_encoding
|
case tag manager_kind_encoding
|
||||||
(function
|
(function
|
||||||
| Manager_operations { source; public_key ; fee ; counter ;operations } ->
|
| Manager_operations { source; fee ; counter ;operations } ->
|
||||||
Some ((), source, public_key, fee, counter, operations)
|
Some ((), source, fee, counter, operations)
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun ((), source, public_key, fee, counter, operations) ->
|
(fun ((), source, fee, counter, operations) ->
|
||||||
Manager_operations { source; public_key ; fee ; counter ; operations })
|
Manager_operations { source; fee ; counter ; operations })
|
||||||
|
|
||||||
let endorsement_encoding =
|
let endorsement_encoding =
|
||||||
(obj4
|
(obj4
|
||||||
|
@ -45,7 +45,6 @@ and sourced_operations =
|
|||||||
}
|
}
|
||||||
| Manager_operations of {
|
| Manager_operations of {
|
||||||
source: Contract_repr.contract ;
|
source: Contract_repr.contract ;
|
||||||
public_key: Ed25519.Public_key.t option ;
|
|
||||||
fee: Tez_repr.tez ;
|
fee: Tez_repr.tez ;
|
||||||
counter: counter ;
|
counter: counter ;
|
||||||
operations: manager_operation list ;
|
operations: manager_operation list ;
|
||||||
@ -71,6 +70,7 @@ and amendment_operation =
|
|||||||
}
|
}
|
||||||
|
|
||||||
and manager_operation =
|
and manager_operation =
|
||||||
|
| Reveal of Ed25519.Public_key.t
|
||||||
| Transaction of {
|
| Transaction of {
|
||||||
amount: Tez_repr.tez ;
|
amount: Tez_repr.tez ;
|
||||||
parameters: Script_repr.expr option ;
|
parameters: Script_repr.expr option ;
|
||||||
|
@ -20,10 +20,9 @@ let manager (src : Helpers_account.t) ?(fee = Tez.zero) operations context =
|
|||||||
return @@
|
return @@
|
||||||
Manager_operations {
|
Manager_operations {
|
||||||
source = src.contract ;
|
source = src.contract ;
|
||||||
public_key = Some src.pub ;
|
|
||||||
fee ;
|
fee ;
|
||||||
counter ;
|
counter ;
|
||||||
operations
|
operations = Reveal src.pub :: operations ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user