Alpha: adds a command to get the storage of a contract
This commit is contained in:
parent
a8e984c1af
commit
26a5338b86
@ -17,6 +17,9 @@ module Ed25519 = Environment.Ed25519
|
||||
let get_balance cctxt block contract =
|
||||
Client_proto_rpcs.Context.Contract.balance cctxt block contract
|
||||
|
||||
let get_storage cctxt block contract =
|
||||
Client_proto_rpcs.Context.Contract.storage cctxt block contract
|
||||
|
||||
let rec find_predecessor rpc_config h n =
|
||||
if n <= 0 then
|
||||
return (`Hash h)
|
||||
@ -260,6 +263,19 @@ let commands () =
|
||||
return ()
|
||||
end ;
|
||||
|
||||
command ~group ~desc: "get the storage of a contract" begin
|
||||
prefixes [ "get" ; "storage" ; "for" ]
|
||||
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
||||
@@ stop
|
||||
end begin fun (_, contract) cctxt ->
|
||||
get_storage cctxt.rpc_config cctxt.config.block contract >>=? function
|
||||
| None ->
|
||||
cctxt.error "This is not a smart contract."
|
||||
| Some storage ->
|
||||
cctxt.answer "%a" Client_proto_programs.print_storage storage >>= fun () ->
|
||||
return ()
|
||||
end ;
|
||||
|
||||
command ~group ~desc: "get the manager of a contract" begin
|
||||
prefixes [ "get" ; "manager" ; "for" ]
|
||||
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
|
||||
|
@ -83,6 +83,9 @@ and print_expr locations ppf = function
|
||||
Format.fprintf ppf "(%a)" (print_expr_unwrapped locations) expr
|
||||
| expr -> print_expr_unwrapped locations ppf expr
|
||||
|
||||
let print_storage ppf ({ storage } : Script.storage) =
|
||||
print_expr no_locations ppf storage
|
||||
|
||||
let print_stack ppf = function
|
||||
| [] -> Format.fprintf ppf "[]"
|
||||
| more ->
|
||||
|
@ -16,6 +16,8 @@ val parse_program: string -> Script.code parsed tzresult Lwt.t
|
||||
val parse_data: string -> Script.expr parsed tzresult Lwt.t
|
||||
val parse_data_type: string -> Script.expr parsed tzresult Lwt.t
|
||||
|
||||
val print_storage: Format.formatter -> Script.storage -> unit
|
||||
|
||||
module Program : Client_aliases.Alias with type t = Script.code parsed
|
||||
|
||||
val commands: unit -> Client_commands.command list
|
||||
|
@ -132,6 +132,8 @@ module Context = struct
|
||||
call_error_service2 cctxt Services.Context.Contract.delegatable b c ()
|
||||
let script cctxt b c =
|
||||
call_error_service2 cctxt Services.Context.Contract.script b c ()
|
||||
let storage cctxt b c =
|
||||
call_error_service2 cctxt Services.Context.Contract.storage b c ()
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -135,6 +135,9 @@ module Context : sig
|
||||
val script:
|
||||
Client_rpcs.config ->
|
||||
block -> Contract.t -> Script.t option tzresult Lwt.t
|
||||
val storage:
|
||||
Client_rpcs.config ->
|
||||
block -> Contract.t -> Script.storage option tzresult Lwt.t
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user