Client: add flag --dry-run to injection commands
This commit is contained in:
parent
8ff7aac5a6
commit
7e591150e0
@ -26,6 +26,7 @@ let parse_expression arg =
|
|||||||
|
|
||||||
let transfer (cctxt : #Proto_alpha.full)
|
let transfer (cctxt : #Proto_alpha.full)
|
||||||
~chain ~block ?confirmations
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~src_pk ~src_sk ~destination ?arg
|
?branch ~source ~src_pk ~src_sk ~destination ?arg
|
||||||
~amount ~fee ?gas_limit ?storage_limit () =
|
~amount ~fee ?gas_limit ?storage_limit () =
|
||||||
begin match arg with
|
begin match arg with
|
||||||
@ -38,6 +39,7 @@ let transfer (cctxt : #Proto_alpha.full)
|
|||||||
let contents = Transaction { amount ; parameters ; destination } in
|
let contents = Transaction { amount ; parameters ; destination } in
|
||||||
Injection.inject_manager_operation
|
Injection.inject_manager_operation
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~fee ?gas_limit ?storage_limit
|
?branch ~source ~fee ?gas_limit ?storage_limit
|
||||||
~src_pk ~src_sk contents >>=? fun (_oph, _op, result as res) ->
|
~src_pk ~src_sk contents >>=? fun (_oph, _op, result as res) ->
|
||||||
Lwt.return
|
Lwt.return
|
||||||
@ -46,6 +48,7 @@ let transfer (cctxt : #Proto_alpha.full)
|
|||||||
|
|
||||||
let reveal cctxt
|
let reveal cctxt
|
||||||
~chain ~block ?confirmations
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~src_pk ~src_sk ~fee () =
|
?branch ~source ~src_pk ~src_sk ~fee () =
|
||||||
Alpha_services.Contract.counter
|
Alpha_services.Contract.counter
|
||||||
cctxt (chain, block) source >>=? fun pcounter ->
|
cctxt (chain, block) source >>=? fun pcounter ->
|
||||||
@ -62,6 +65,7 @@ let reveal cctxt
|
|||||||
gas_limit = Z.zero ; storage_limit = Z.zero ;
|
gas_limit = Z.zero ; storage_limit = Z.zero ;
|
||||||
operation = Reveal src_pk }) in
|
operation = Reveal src_pk }) in
|
||||||
Injection.inject_operation cctxt ~chain ~block ?confirmations
|
Injection.inject_operation cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
||||||
match Apply_operation_result.pack_contents_list op result with
|
match Apply_operation_result.pack_contents_list op result with
|
||||||
| Apply_operation_result.Single_and_result
|
| Apply_operation_result.Single_and_result
|
||||||
@ -71,10 +75,12 @@ let reveal cctxt
|
|||||||
|
|
||||||
let originate
|
let originate
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~src_pk ~src_sk ~fee
|
?branch ~source ~src_pk ~src_sk ~fee
|
||||||
?gas_limit ?storage_limit contents =
|
?gas_limit ?storage_limit contents =
|
||||||
Injection.inject_manager_operation
|
Injection.inject_manager_operation
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~fee ?gas_limit ?storage_limit
|
?branch ~source ~fee ?gas_limit ?storage_limit
|
||||||
~src_pk ~src_sk contents >>=? fun (_oph, _op, result as res) ->
|
~src_pk ~src_sk contents >>=? fun (_oph, _op, result as res) ->
|
||||||
Lwt.return
|
Lwt.return
|
||||||
@ -87,6 +93,7 @@ let originate
|
|||||||
|
|
||||||
let originate_account
|
let originate_account
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~src_pk ~src_sk ~manager_pkh
|
?branch ~source ~src_pk ~src_sk ~manager_pkh
|
||||||
?(delegatable = false) ?delegate ~balance ~fee () =
|
?(delegatable = false) ?delegate ~balance ~fee () =
|
||||||
let origination =
|
let origination =
|
||||||
@ -99,15 +106,18 @@ let originate_account
|
|||||||
preorigination = None } in
|
preorigination = None } in
|
||||||
originate
|
originate
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~gas_limit:Z.zero ~src_pk ~src_sk ~fee origination
|
?branch ~source ~gas_limit:Z.zero ~src_pk ~src_sk ~fee origination
|
||||||
|
|
||||||
let delegate_contract cctxt
|
let delegate_contract cctxt
|
||||||
~chain ~block ?branch ?confirmations
|
~chain ~block ?branch ?confirmations
|
||||||
|
?dry_run
|
||||||
~source ~src_pk ~src_sk
|
~source ~src_pk ~src_sk
|
||||||
~fee delegate_opt =
|
~fee delegate_opt =
|
||||||
let operation = Delegation delegate_opt in
|
let operation = Delegation delegate_opt in
|
||||||
Injection.inject_manager_operation
|
Injection.inject_manager_operation
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~fee ~gas_limit:Z.zero ~storage_limit:Z.zero
|
?branch ~source ~fee ~gas_limit:Z.zero ~storage_limit:Z.zero
|
||||||
~src_pk ~src_sk operation >>=? fun res ->
|
~src_pk ~src_sk operation >>=? fun res ->
|
||||||
return res
|
return res
|
||||||
@ -152,17 +162,21 @@ let get_manager
|
|||||||
|
|
||||||
let set_delegate
|
let set_delegate
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
~fee contract ~src_pk ~manager_sk opt_delegate =
|
~fee contract ~src_pk ~manager_sk opt_delegate =
|
||||||
delegate_contract
|
delegate_contract
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
~source:contract ~src_pk ~src_sk:manager_sk ~fee opt_delegate
|
~source:contract ~src_pk ~src_sk:manager_sk ~fee opt_delegate
|
||||||
|
|
||||||
let register_as_delegate
|
let register_as_delegate
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
~fee ~manager_sk src_pk =
|
~fee ~manager_sk src_pk =
|
||||||
let source = Signature.Public_key.hash src_pk in
|
let source = Signature.Public_key.hash src_pk in
|
||||||
delegate_contract
|
delegate_contract
|
||||||
cctxt ~chain ~block ?confirmations
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
~source:(Contract.implicit_contract source) ~src_pk ~src_sk:manager_sk ~fee
|
~source:(Contract.implicit_contract source) ~src_pk ~src_sk:manager_sk ~fee
|
||||||
(Some source)
|
(Some source)
|
||||||
|
|
||||||
@ -179,7 +193,9 @@ let save_contract ~force cctxt alias_name contract =
|
|||||||
|
|
||||||
let originate_contract
|
let originate_contract
|
||||||
(cctxt : #Proto_alpha.full)
|
(cctxt : #Proto_alpha.full)
|
||||||
~chain ~block ?confirmations ?branch
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
|
?branch
|
||||||
~fee
|
~fee
|
||||||
?gas_limit
|
?gas_limit
|
||||||
?storage_limit
|
?storage_limit
|
||||||
@ -207,6 +223,7 @@ let originate_contract
|
|||||||
credit = balance ;
|
credit = balance ;
|
||||||
preorigination = None } in
|
preorigination = None } in
|
||||||
originate cctxt ~chain ~block ?confirmations
|
originate cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?branch ~source ~src_pk ~src_sk ~fee ?gas_limit ?storage_limit origination
|
?branch ~source ~src_pk ~src_sk ~fee ?gas_limit ?storage_limit origination
|
||||||
|
|
||||||
type activation_key =
|
type activation_key =
|
||||||
@ -275,11 +292,15 @@ let read_key key =
|
|||||||
return (pkh, pk, sk)
|
return (pkh, pk, sk)
|
||||||
|
|
||||||
let inject_activate_operation
|
let inject_activate_operation
|
||||||
cctxt ~chain ~block ?confirmations alias pkh activation_code =
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
|
alias pkh activation_code =
|
||||||
let contents =
|
let contents =
|
||||||
Single ( Activate_account { id = pkh ; activation_code } ) in
|
Single ( Activate_account { id = pkh ; activation_code } ) in
|
||||||
Injection.inject_operation
|
Injection.inject_operation
|
||||||
cctxt ?confirmations ~chain ~block
|
cctxt ?confirmations
|
||||||
|
?dry_run
|
||||||
|
~chain ~block
|
||||||
contents >>=? fun (oph, op, result) ->
|
contents >>=? fun (oph, op, result) ->
|
||||||
begin
|
begin
|
||||||
match confirmations with
|
match confirmations with
|
||||||
@ -304,6 +325,7 @@ let inject_activate_operation
|
|||||||
let activate_account
|
let activate_account
|
||||||
(cctxt : #Proto_alpha.full)
|
(cctxt : #Proto_alpha.full)
|
||||||
~chain ~block ?confirmations
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
?(encrypted = false) ?force key name =
|
?(encrypted = false) ?force key name =
|
||||||
read_key key >>=? fun (pkh, pk, sk) ->
|
read_key key >>=? fun (pkh, pk, sk) ->
|
||||||
fail_unless (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh))
|
fail_unless (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh))
|
||||||
@ -321,15 +343,20 @@ let activate_account
|
|||||||
end >>=? fun sk_uri ->
|
end >>=? fun sk_uri ->
|
||||||
Client_keys.register_key cctxt ?force (pkh, pk_uri, sk_uri) name >>=? fun () ->
|
Client_keys.register_key cctxt ?force (pkh, pk_uri, sk_uri) name >>=? fun () ->
|
||||||
inject_activate_operation cctxt
|
inject_activate_operation cctxt
|
||||||
~chain ~block ?confirmations name key.pkh key.activation_code
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
|
name key.pkh key.activation_code
|
||||||
|
|
||||||
let activate_existing_account
|
let activate_existing_account
|
||||||
(cctxt : #Proto_alpha.full)
|
(cctxt : #Proto_alpha.full)
|
||||||
~chain ~block ?confirmations
|
~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
alias activation_code =
|
alias activation_code =
|
||||||
Client_keys.alias_keys cctxt alias >>=? function
|
Client_keys.alias_keys cctxt alias >>=? function
|
||||||
| Some (Ed25519 pkh, _, _) ->
|
| Some (Ed25519 pkh, _, _) ->
|
||||||
inject_activate_operation
|
inject_activate_operation
|
||||||
cctxt ~chain ~block ?confirmations alias pkh activation_code
|
cctxt ~chain ~block ?confirmations
|
||||||
|
?dry_run
|
||||||
|
alias pkh activation_code
|
||||||
| Some _ -> failwith "Only Ed25519 accounts can be activated"
|
| Some _ -> failwith "Only Ed25519 accounts can be activated"
|
||||||
| None -> failwith "Unknown account"
|
| None -> failwith "Unknown account"
|
||||||
|
@ -43,6 +43,7 @@ val set_delegate:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
fee:Tez.tez ->
|
fee:Tez.tez ->
|
||||||
Contract.t ->
|
Contract.t ->
|
||||||
src_pk:public_key ->
|
src_pk:public_key ->
|
||||||
@ -55,6 +56,7 @@ val register_as_delegate:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
fee:Tez.tez ->
|
fee:Tez.tez ->
|
||||||
manager_sk:Client_keys.sk_uri ->
|
manager_sk:Client_keys.sk_uri ->
|
||||||
public_key ->
|
public_key ->
|
||||||
@ -72,6 +74,7 @@ val originate_account :
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
source:Contract.t ->
|
source:Contract.t ->
|
||||||
src_pk:public_key ->
|
src_pk:public_key ->
|
||||||
@ -95,6 +98,7 @@ val originate_contract:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
fee:Tez.t ->
|
fee:Tez.t ->
|
||||||
?gas_limit:Z.t ->
|
?gas_limit:Z.t ->
|
||||||
@ -116,6 +120,7 @@ val transfer :
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
source:Contract.t ->
|
source:Contract.t ->
|
||||||
src_pk:public_key ->
|
src_pk:public_key ->
|
||||||
@ -134,6 +139,7 @@ val reveal :
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
source:Contract.t ->
|
source:Contract.t ->
|
||||||
src_pk:public_key ->
|
src_pk:public_key ->
|
||||||
@ -157,6 +163,7 @@ val activate_account:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?encrypted:bool ->
|
?encrypted:bool ->
|
||||||
?force:bool ->
|
?force:bool ->
|
||||||
activation_key ->
|
activation_key ->
|
||||||
@ -168,6 +175,7 @@ val activate_existing_account:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
string ->
|
string ->
|
||||||
Blinded_public_key_hash.activation_code ->
|
Blinded_public_key_hash.activation_code ->
|
||||||
Kind.activate_account Injection.result tzresult Lwt.t
|
Kind.activate_account Injection.result tzresult Lwt.t
|
||||||
|
@ -326,7 +326,10 @@ let may_patch_limits
|
|||||||
|
|
||||||
let inject_operation
|
let inject_operation
|
||||||
(type kind) cctxt ~chain ~block
|
(type kind) cctxt ~chain ~block
|
||||||
?confirmations ?branch ?src_sk (contents: kind contents_list) =
|
?confirmations
|
||||||
|
?(dry_run = false)
|
||||||
|
?branch ?src_sk
|
||||||
|
(contents: kind contents_list) =
|
||||||
Client_confirmations.wait_for_bootstrapped cctxt >>=? fun () ->
|
Client_confirmations.wait_for_bootstrapped cctxt >>=? fun () ->
|
||||||
may_patch_limits
|
may_patch_limits
|
||||||
cctxt ~chain ~block ?branch contents >>=? fun contents ->
|
cctxt ~chain ~block ?branch contents >>=? fun contents ->
|
||||||
@ -344,43 +347,56 @@ let inject_operation
|
|||||||
let bytes =
|
let bytes =
|
||||||
Data_encoding.Binary.to_bytes_exn
|
Data_encoding.Binary.to_bytes_exn
|
||||||
Operation.encoding (Operation.pack op) in
|
Operation.encoding (Operation.pack op) in
|
||||||
Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph ->
|
if dry_run then
|
||||||
cctxt#message "Operation successfully injected in the node." >>= fun () ->
|
let oph = Operation_hash.hash_bytes [bytes] in
|
||||||
cctxt#message "Operation hash is '%a'." Operation_hash.pp oph >>= fun () ->
|
cctxt#message
|
||||||
begin
|
"@[<v 0>Operation: 0x%a@,\
|
||||||
match confirmations with
|
Operation hash: %a@]"
|
||||||
| None -> return result
|
MBytes.pp_hex bytes
|
||||||
| Some confirmations ->
|
Operation_hash.pp oph >>= fun () ->
|
||||||
cctxt#message "Waiting for the operation to be included..." >>= fun () ->
|
cctxt#message
|
||||||
Client_confirmations.wait_for_operation_inclusion
|
"@[<v 2>Simulation result:@,%a@]"
|
||||||
~confirmations cctxt ~chain oph >>=? fun (h, i , j) ->
|
Operation_result.pp_operation_result
|
||||||
Alpha_block_services.Operations.operation
|
(op.protocol_data.contents, result.contents) >>= fun () ->
|
||||||
cctxt ~block:(`Hash (h, 0)) i j >>=? fun op' ->
|
return (oph, op.protocol_data.contents, result.contents)
|
||||||
match op'.receipt with
|
else
|
||||||
| No_operation_metadata ->
|
Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph ->
|
||||||
failwith "Internal error: unexpected receipt."
|
cctxt#message "Operation successfully injected in the node." >>= fun () ->
|
||||||
| Operation_metadata receipt ->
|
cctxt#message "Operation hash: %a" Operation_hash.pp oph >>= fun () ->
|
||||||
match Apply_operation_result.kind_equal_list contents receipt.contents
|
begin
|
||||||
with
|
match confirmations with
|
||||||
| Some Apply_operation_result.Eq ->
|
| None -> return result
|
||||||
return (receipt : kind operation_metadata)
|
| Some confirmations ->
|
||||||
| None -> failwith "Internal error: unexpected receipt."
|
cctxt#message "Waiting for the operation to be included..." >>= fun () ->
|
||||||
end >>=? fun result ->
|
Client_confirmations.wait_for_operation_inclusion
|
||||||
cctxt#message
|
~confirmations cctxt ~chain oph >>=? fun (h, i , j) ->
|
||||||
"@[<v 2>This sequence of operations was run:@,%a@]"
|
Alpha_block_services.Operations.operation
|
||||||
Operation_result.pp_operation_result
|
cctxt ~block:(`Hash (h, 0)) i j >>=? fun op' ->
|
||||||
(op.protocol_data.contents, result.contents) >>= fun () ->
|
match op'.receipt with
|
||||||
Lwt.return (originated_contracts result.contents) >>=? fun contracts ->
|
| No_operation_metadata ->
|
||||||
Lwt_list.iter_s
|
failwith "Internal error: unexpected receipt."
|
||||||
(fun c ->
|
| Operation_metadata receipt ->
|
||||||
cctxt#message
|
match Apply_operation_result.kind_equal_list contents receipt.contents
|
||||||
"New contract %a originated."
|
with
|
||||||
Contract.pp c)
|
| Some Apply_operation_result.Eq ->
|
||||||
contracts >>= fun () ->
|
return (receipt : kind operation_metadata)
|
||||||
return (oph, op.protocol_data.contents, result.contents)
|
| None -> failwith "Internal error: unexpected receipt."
|
||||||
|
end >>=? fun result ->
|
||||||
|
cctxt#message
|
||||||
|
"@[<v 2>This sequence of operations was run:@,%a@]"
|
||||||
|
Operation_result.pp_operation_result
|
||||||
|
(op.protocol_data.contents, result.contents) >>= fun () ->
|
||||||
|
Lwt.return (originated_contracts result.contents) >>=? fun contracts ->
|
||||||
|
Lwt_list.iter_s
|
||||||
|
(fun c ->
|
||||||
|
cctxt#message
|
||||||
|
"New contract %a originated."
|
||||||
|
Contract.pp c)
|
||||||
|
contracts >>= fun () ->
|
||||||
|
return (oph, op.protocol_data.contents, result.contents)
|
||||||
|
|
||||||
let inject_manager_operation
|
let inject_manager_operation
|
||||||
cctxt ~chain ~block ?branch ?confirmations
|
cctxt ~chain ~block ?branch ?confirmations ?dry_run
|
||||||
~source ~src_pk ~src_sk ~fee ?(gas_limit = Z.minus_one) ?(storage_limit = (Z.of_int (-1)))
|
~source ~src_pk ~src_sk ~fee ?(gas_limit = Z.minus_one) ?(storage_limit = (Z.of_int (-1)))
|
||||||
(type kind) (operation : kind manager_operation)
|
(type kind) (operation : kind manager_operation)
|
||||||
: (Operation_hash.t * kind Kind.manager contents * kind Kind.manager contents_result) tzresult Lwt.t =
|
: (Operation_hash.t * kind Kind.manager contents * kind Kind.manager contents_result) tzresult Lwt.t =
|
||||||
@ -401,7 +417,7 @@ let inject_manager_operation
|
|||||||
operation = Reveal src_pk },
|
operation = Reveal src_pk },
|
||||||
Single (Manager_operation { source ; fee ; counter = Z.succ counter ;
|
Single (Manager_operation { source ; fee ; counter = Z.succ counter ;
|
||||||
gas_limit ; storage_limit ; operation })) in
|
gas_limit ; storage_limit ; operation })) in
|
||||||
inject_operation cctxt ~chain ~block ?confirmations
|
inject_operation cctxt ~chain ~block ?confirmations ?dry_run
|
||||||
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
||||||
match pack_contents_list op result with
|
match pack_contents_list op result with
|
||||||
| Cons_and_result (_, _, Single_and_result (op, result)) ->
|
| Cons_and_result (_, _, Single_and_result (op, result)) ->
|
||||||
@ -413,7 +429,7 @@ let inject_manager_operation
|
|||||||
let contents =
|
let contents =
|
||||||
Single (Manager_operation { source ; fee ; counter ;
|
Single (Manager_operation { source ; fee ; counter ;
|
||||||
gas_limit ; storage_limit ; operation }) in
|
gas_limit ; storage_limit ; operation }) in
|
||||||
inject_operation cctxt ~chain ~block ?confirmations
|
inject_operation cctxt ~chain ~block ?confirmations ?dry_run
|
||||||
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
||||||
match pack_contents_list op result with
|
match pack_contents_list op result with
|
||||||
| Single_and_result (Manager_operation _ as op, result) ->
|
| Single_and_result (Manager_operation _ as op, result) ->
|
||||||
|
@ -31,6 +31,7 @@ val inject_operation:
|
|||||||
chain:Shell_services.chain ->
|
chain:Shell_services.chain ->
|
||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
?src_sk:Client_keys.sk_uri ->
|
?src_sk:Client_keys.sk_uri ->
|
||||||
'kind contents_list ->
|
'kind contents_list ->
|
||||||
@ -45,6 +46,7 @@ val inject_manager_operation:
|
|||||||
block:Shell_services.block ->
|
block:Shell_services.block ->
|
||||||
?branch:int ->
|
?branch:int ->
|
||||||
?confirmations:int ->
|
?confirmations:int ->
|
||||||
|
?dry_run:bool ->
|
||||||
source:Contract.t ->
|
source:Contract.t ->
|
||||||
src_pk:Signature.public_key ->
|
src_pk:Signature.public_key ->
|
||||||
src_sk:Client_keys.sk_uri ->
|
src_sk:Client_keys.sk_uri ->
|
||||||
|
@ -19,7 +19,13 @@ open Client_proto_args
|
|||||||
let encrypted_switch =
|
let encrypted_switch =
|
||||||
Clic.switch
|
Clic.switch
|
||||||
~long:"encrypted"
|
~long:"encrypted"
|
||||||
~doc:("Encrypt the key on-disk") ()
|
~doc:"encrypt the key on-disk" ()
|
||||||
|
|
||||||
|
let dry_run_switch =
|
||||||
|
Clic.switch
|
||||||
|
~long:"dry-run"
|
||||||
|
~short:'D'
|
||||||
|
~doc:"don't inject the operation, just display it" ()
|
||||||
|
|
||||||
let report_michelson_errors ?(no_print_source=false) ~msg (cctxt : #Client_context.printer) = function
|
let report_michelson_errors ?(no_print_source=false) ~msg (cctxt : #Client_context.printer) = function
|
||||||
| Error errs ->
|
| Error errs ->
|
||||||
@ -148,40 +154,42 @@ let commands () =
|
|||||||
end ;
|
end ;
|
||||||
|
|
||||||
command ~group ~desc: "Set the delegate of a contract."
|
command ~group ~desc: "Set the delegate of a contract."
|
||||||
(args1 fee_arg)
|
(args2 fee_arg dry_run_switch)
|
||||||
(prefixes [ "set" ; "delegate" ; "for" ]
|
(prefixes [ "set" ; "delegate" ; "for" ]
|
||||||
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
||||||
@@ prefix "to"
|
@@ prefix "to"
|
||||||
@@ Public_key_hash.alias_param
|
@@ Public_key_hash.alias_param
|
||||||
~name: "mgr" ~desc: "new delegate of the contract"
|
~name: "mgr" ~desc: "new delegate of the contract"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun fee (_, contract) (_, delegate) (cctxt : Proto_alpha.full) ->
|
begin fun (fee, dry_run) (_, contract) (_, delegate) (cctxt : Proto_alpha.full) ->
|
||||||
source_to_keys cctxt
|
source_to_keys cctxt
|
||||||
~chain:`Main ~block:cctxt#block
|
~chain:`Main ~block:cctxt#block
|
||||||
contract >>=? fun (src_pk, manager_sk) ->
|
contract >>=? fun (src_pk, manager_sk) ->
|
||||||
set_delegate cctxt
|
set_delegate cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
contract (Some delegate) ~fee ~src_pk ~manager_sk >>=? fun _ ->
|
contract (Some delegate) ~fee ~src_pk ~manager_sk >>=? fun _ ->
|
||||||
return ()
|
return ()
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
command ~group ~desc: "Withdraw the delegate from a contract."
|
command ~group ~desc: "Withdraw the delegate from a contract."
|
||||||
(args1 fee_arg)
|
(args2 fee_arg dry_run_switch)
|
||||||
(prefixes [ "withdraw" ; "delegate" ; "from" ]
|
(prefixes [ "withdraw" ; "delegate" ; "from" ]
|
||||||
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun fee (_, contract) (cctxt : Proto_alpha.full) ->
|
begin fun (fee, dry_run) (_, contract) (cctxt : Proto_alpha.full) ->
|
||||||
source_to_keys cctxt
|
source_to_keys cctxt
|
||||||
~chain:`Main ~block:cctxt#block
|
~chain:`Main ~block:cctxt#block
|
||||||
contract >>=? fun (src_pk, manager_sk) ->
|
contract >>=? fun (src_pk, manager_sk) ->
|
||||||
set_delegate cctxt
|
set_delegate cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
contract None ~fee ~src_pk ~manager_sk >>=? fun _ ->
|
contract None ~fee ~src_pk ~manager_sk >>=? fun _ ->
|
||||||
return ()
|
return ()
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
command ~group ~desc:"Open a new account."
|
command ~group ~desc:"Open a new account."
|
||||||
(args4 fee_arg delegate_arg delegatable_switch (Client_keys.force_switch ()))
|
(args5 fee_arg dry_run_switch delegate_arg delegatable_switch (Client_keys.force_switch ()))
|
||||||
(prefixes [ "originate" ; "account" ]
|
(prefixes [ "originate" ; "account" ]
|
||||||
@@ RawContractAlias.fresh_alias_param
|
@@ RawContractAlias.fresh_alias_param
|
||||||
~name: "new" ~desc: "name of the new contract"
|
~name: "new" ~desc: "name of the new contract"
|
||||||
@ -195,7 +203,7 @@ let commands () =
|
|||||||
@@ ContractAlias.destination_param
|
@@ ContractAlias.destination_param
|
||||||
~name:"src" ~desc: "name of the source contract"
|
~name:"src" ~desc: "name of the source contract"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun (fee, delegate, delegatable, force)
|
begin fun (fee, dry_run, delegate, delegatable, force)
|
||||||
new_contract manager_pkh balance (_, source) (cctxt : Proto_alpha.full) ->
|
new_contract manager_pkh balance (_, source) (cctxt : Proto_alpha.full) ->
|
||||||
RawContractAlias.of_fresh cctxt force new_contract >>=? fun alias_name ->
|
RawContractAlias.of_fresh cctxt force new_contract >>=? fun alias_name ->
|
||||||
source_to_keys cctxt
|
source_to_keys cctxt
|
||||||
@ -203,15 +211,20 @@ let commands () =
|
|||||||
source >>=? fun (src_pk, src_sk) ->
|
source >>=? fun (src_pk, src_sk) ->
|
||||||
originate_account cctxt
|
originate_account cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
~fee ?delegate ~delegatable ~manager_pkh ~balance
|
~fee ?delegate ~delegatable ~manager_pkh ~balance
|
||||||
~source ~src_pk ~src_sk () >>=? fun (_res, contract) ->
|
~source ~src_pk ~src_sk () >>=? fun (_res, contract) ->
|
||||||
save_contract ~force cctxt alias_name contract >>=? fun () ->
|
if dry_run then
|
||||||
return ()
|
return ()
|
||||||
|
else
|
||||||
|
save_contract ~force cctxt alias_name contract >>=? fun () ->
|
||||||
|
return ()
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
command ~group ~desc: "Launch a smart contract on the blockchain."
|
command ~group ~desc: "Launch a smart contract on the blockchain."
|
||||||
(args9
|
(args10
|
||||||
fee_arg gas_limit_arg storage_limit_arg delegate_arg (Client_keys.force_switch ())
|
fee_arg
|
||||||
|
dry_run_switch gas_limit_arg storage_limit_arg delegate_arg (Client_keys.force_switch ())
|
||||||
delegatable_switch spendable_switch init_arg no_print_source_flag)
|
delegatable_switch spendable_switch init_arg no_print_source_flag)
|
||||||
(prefixes [ "originate" ; "contract" ]
|
(prefixes [ "originate" ; "contract" ]
|
||||||
@@ RawContractAlias.fresh_alias_param
|
@@ RawContractAlias.fresh_alias_param
|
||||||
@ -230,7 +243,7 @@ let commands () =
|
|||||||
~name:"prg" ~desc: "script of the account\n\
|
~name:"prg" ~desc: "script of the account\n\
|
||||||
Combine with -init if the storage type is not unit."
|
Combine with -init if the storage type is not unit."
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun (fee, gas_limit, storage_limit, delegate, force, delegatable, spendable, initial_storage, no_print_source)
|
begin fun (fee, dry_run, gas_limit, storage_limit, delegate, force, delegatable, spendable, initial_storage, no_print_source)
|
||||||
alias_name manager balance (_, source) program (cctxt : Proto_alpha.full) ->
|
alias_name manager balance (_, source) program (cctxt : Proto_alpha.full) ->
|
||||||
RawContractAlias.of_fresh cctxt force alias_name >>=? fun alias_name ->
|
RawContractAlias.of_fresh cctxt force alias_name >>=? fun alias_name ->
|
||||||
Lwt.return (Micheline_parser.no_parsing_error program) >>=? fun { expanded = code } ->
|
Lwt.return (Micheline_parser.no_parsing_error program) >>=? fun { expanded = code } ->
|
||||||
@ -239,17 +252,21 @@ let commands () =
|
|||||||
source >>=? fun (src_pk, src_sk) ->
|
source >>=? fun (src_pk, src_sk) ->
|
||||||
originate_contract cctxt
|
originate_contract cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
~fee ?gas_limit ?storage_limit ~delegate ~delegatable ~spendable ~initial_storage
|
~fee ?gas_limit ?storage_limit ~delegate ~delegatable ~spendable ~initial_storage
|
||||||
~manager ~balance ~source ~src_pk ~src_sk ~code () >>= fun errors ->
|
~manager ~balance ~source ~src_pk ~src_sk ~code () >>= fun errors ->
|
||||||
report_michelson_errors ~no_print_source ~msg:"origination simulation failed" cctxt errors >>= function
|
report_michelson_errors ~no_print_source ~msg:"origination simulation failed" cctxt errors >>= function
|
||||||
| None -> return ()
|
| None -> return ()
|
||||||
| Some (_res, contract) ->
|
| Some (_res, contract) ->
|
||||||
save_contract ~force cctxt alias_name contract >>=? fun () ->
|
if dry_run then
|
||||||
return ()
|
return ()
|
||||||
|
else
|
||||||
|
save_contract ~force cctxt alias_name contract >>=? fun () ->
|
||||||
|
return ()
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
command ~group ~desc: "Transfer tokens / call a smart contract."
|
command ~group ~desc: "Transfer tokens / call a smart contract."
|
||||||
(args5 fee_arg gas_limit_arg storage_limit_arg arg_arg no_print_source_flag)
|
(args6 fee_arg dry_run_switch gas_limit_arg storage_limit_arg arg_arg no_print_source_flag)
|
||||||
(prefixes [ "transfer" ]
|
(prefixes [ "transfer" ]
|
||||||
@@ tez_param
|
@@ tez_param
|
||||||
~name: "qty" ~desc: "amount taken from source"
|
~name: "qty" ~desc: "amount taken from source"
|
||||||
@ -260,12 +277,13 @@ let commands () =
|
|||||||
@@ ContractAlias.destination_param
|
@@ ContractAlias.destination_param
|
||||||
~name: "dst" ~desc: "name/literal of the destination contract"
|
~name: "dst" ~desc: "name/literal of the destination contract"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun (fee, gas_limit, storage_limit, arg, no_print_source) amount (_, source) (_, destination) cctxt ->
|
begin fun (fee, dry_run, gas_limit, storage_limit, arg, no_print_source) amount (_, source) (_, destination) cctxt ->
|
||||||
source_to_keys cctxt
|
source_to_keys cctxt
|
||||||
~chain:`Main ~block:cctxt#block
|
~chain:`Main ~block:cctxt#block
|
||||||
source >>=? fun (src_pk, src_sk) ->
|
source >>=? fun (src_pk, src_sk) ->
|
||||||
transfer cctxt
|
transfer cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
~source ~fee ~src_pk ~src_sk ~destination ~arg ~amount ?gas_limit ?storage_limit () >>=
|
~source ~fee ~src_pk ~src_sk ~destination ~arg ~amount ?gas_limit ?storage_limit () >>=
|
||||||
report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt >>= function
|
report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt >>= function
|
||||||
| None -> return ()
|
| None -> return ()
|
||||||
@ -290,16 +308,17 @@ let commands () =
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
command ~group ~desc: "Register the public key hash as a delegate."
|
command ~group ~desc: "Register the public key hash as a delegate."
|
||||||
(args1 fee_arg)
|
(args2 fee_arg dry_run_switch)
|
||||||
(prefixes [ "register" ; "key" ]
|
(prefixes [ "register" ; "key" ]
|
||||||
@@ Public_key_hash.source_param
|
@@ Public_key_hash.source_param
|
||||||
~name: "mgr" ~desc: "the delegate key"
|
~name: "mgr" ~desc: "the delegate key"
|
||||||
@@ prefixes [ "as" ; "delegate" ]
|
@@ prefixes [ "as" ; "delegate" ]
|
||||||
@@ stop)
|
@@ stop)
|
||||||
begin fun fee src_pkh cctxt ->
|
begin fun (fee, dry_run) src_pkh cctxt ->
|
||||||
Client_keys.get_key cctxt src_pkh >>=? fun (_, src_pk, src_sk) ->
|
Client_keys.get_key cctxt src_pkh >>=? fun (_, src_pk, src_sk) ->
|
||||||
register_as_delegate cctxt
|
register_as_delegate cctxt
|
||||||
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
~chain:`Main ~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
~fee ~manager_sk:src_sk src_pk >>=? fun _res ->
|
~fee ~manager_sk:src_sk src_pk >>=? fun _res ->
|
||||||
return ()
|
return ()
|
||||||
end;
|
end;
|
||||||
@ -334,7 +353,7 @@ let commands () =
|
|||||||
);
|
);
|
||||||
|
|
||||||
command ~group ~desc:"Activate a fundraiser account."
|
command ~group ~desc:"Activate a fundraiser account."
|
||||||
no_options
|
(args1 dry_run_switch)
|
||||||
(prefixes [ "activate" ; "fundraiser" ; "account" ]
|
(prefixes [ "activate" ; "fundraiser" ; "account" ]
|
||||||
@@ Public_key_hash.alias_param
|
@@ Public_key_hash.alias_param
|
||||||
@@ prefixes [ "with" ]
|
@@ prefixes [ "with" ]
|
||||||
@ -344,9 +363,10 @@ let commands () =
|
|||||||
return (Blinded_public_key_hash.activation_code_of_hex code))))
|
return (Blinded_public_key_hash.activation_code_of_hex code))))
|
||||||
~desc:"Activation code obtained from the Tezos foundation."
|
~desc:"Activation code obtained from the Tezos foundation."
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun () (name, _pkh) code cctxt ->
|
(fun dry_run (name, _pkh) code cctxt ->
|
||||||
activate_existing_account cctxt ~chain:`Main
|
activate_existing_account cctxt ~chain:`Main
|
||||||
~block:cctxt#block ?confirmations:cctxt#confirmations
|
~block:cctxt#block ?confirmations:cctxt#confirmations
|
||||||
|
~dry_run
|
||||||
name code >>=? fun _res ->
|
name code >>=? fun _res ->
|
||||||
return ()
|
return ()
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user