From 63b43cec7675252f6de09e78956f1e9082f3493d Mon Sep 17 00:00:00 2001 From: Emma Turner Date: Mon, 4 Mar 2024 11:38:06 +0000 Subject: [PATCH 1/3] Proto/client: retrieve ticket balances for smart rollups Currently, one can use the client command for retrieving the ticket balance of an implicit & originated account, but cannot retrieve the balance of a smart rollup address. --- .../lib_client/client_proto_context.ml | 5 +++ .../lib_client/client_proto_context.mli | 10 +++++ .../lib_client/client_proto_contracts.ml | 30 +++++++++++++ .../lib_client/client_proto_contracts.mli | 12 +++++ .../client_proto_context_commands.ml | 45 +++++++++++++------ 5 files changed, 88 insertions(+), 14 deletions(-) diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 300cecb8778a..9a071294f152 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -1355,6 +1356,10 @@ let sc_rollup_timeout (cctxt : #full) ~chain ~block ?confirmations ?dry_run | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> return (oph, op, result) +let get_smart_rollup_ticket_balance (rpc : #rpc_context) ~chain ~block contract + key = + Plugin.RPC.Sc_rollup.get_ticket_balance rpc (chain, block) contract key + let zk_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?safety_guard ?storage_limit ?counter ~source ~public_parameters ~circuits_info ~init_state ~nb_ops diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index e79d7c30fda8..cf4b7046e68f 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -896,6 +897,15 @@ val sc_rollup_timeout : tzresult Lwt.t +(** Calls {!Tezos_protocol_plugin_alpha.Plugin.RPC.Sc_rollup.get_ticket_balance}. *) +val get_smart_rollup_ticket_balance : + #Protocol_client_context.rpc_context -> + chain:Shell_services.chain -> + block:Shell_services.block -> + Sc_rollup.t -> + Ticket_token.unparsed_token -> + Z.t tzresult Lwt.t + val zk_rollup_originate : #Protocol_client_context.full -> chain:Chain_services.chain -> diff --git a/src/proto_alpha/lib_client/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml index c8a4a6dc1f88..0b880123c786 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client/client_proto_contracts.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -212,6 +213,35 @@ module Contract_alias = struct | Some name -> return name end +module Destination_alias = struct + let contract_parameter () = + Tezos_clic.map_parameter + ~f:(fun c -> Destination.Contract c) + (Contract_alias.destination_parameter ()) + + let smart_rollup_parameter () = + Tezos_clic.map_parameter + ~f:(fun sc -> Destination.Sc_rollup sc) + (Smart_rollup_alias.Address.parameter ()) + + let destination_parameter () = + Tezos_clic.compose_parameters + (contract_parameter ()) + (smart_rollup_parameter ()) + + let destination_param ?(name = "dst") ?(desc = "destination address") next = + let desc = + String.concat + "\n" + [ + desc; + "Can be a literal, an alias, or a key (autodetected in order).\n\ + Use 'text:', 'alias:', 'key:' to force."; + ] + in + Tezos_clic.param ~name ~desc (destination_parameter ()) next +end + let list_contracts cctxt = let open Lwt_result_syntax in let* raw_contracts = Raw_contract_alias.load cctxt in diff --git a/src/proto_alpha/lib_client/client_proto_contracts.mli b/src/proto_alpha/lib_client/client_proto_contracts.mli index 02ca6d397a79..a342408ec37e 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.mli +++ b/src/proto_alpha/lib_client/client_proto_contracts.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -79,6 +80,17 @@ module Contract_alias : sig val autocomplete : #Client_context.wallet -> string list tzresult Lwt.t end +module Destination_alias : sig + val destination_parameter : + unit -> (Destination.t, #Client_context.wallet) Tezos_clic.parameter + + val destination_param : + ?name:string -> + ?desc:string -> + ('a, (#Client_context.wallet as 'wallet)) Tezos_clic.params -> + (Destination.t -> 'a, 'wallet) Tezos_clic.params +end + (** [list_contracts cctxt] returns the concatenation of [contracts] and [accounts] where [contracts] is the result of [Raw_contract_alias.load cctxt] and [accounts] the list of accounts (implicit contracts of identities) diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 5a485d15ab3c..2d710acb6c62 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -3,7 +3,7 @@ (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) (* Copyright (c) 2019-2022 Nomadic Labs *) -(* Copyright (c) 2022 TriliTech *) +(* Copyright (c) 2022-2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -580,7 +580,7 @@ let commands_ro () = type, and content." no_options (prefixes ["get"; "ticket"; "balance"; "for"] - @@ Contract_alias.destination_param ~name:"src" ~desc:"Source contract." + @@ Destination_alias.destination_param ~name:"src" ~desc:"Source address." @@ prefixes ["with"; "ticketer"] @@ Contract_alias.destination_param ~name:"ticketer" @@ -596,20 +596,37 @@ let commands_ro () = ~desc:"Content of the ticket." data_parameter @@ stop) - (fun () contract ticketer content_type content cctxt -> + (fun () destination ticketer content_type content cctxt -> let open Lwt_result_syntax in let* balance = - get_contract_ticket_balance - cctxt - ~chain:cctxt#chain - ~block:cctxt#block - contract - Ticket_token. - { - ticketer; - contents_type = content_type.expanded; - contents = content.expanded; - } + match destination with + | Contract contract -> + get_contract_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + contract + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | Sc_rollup smart_rollup -> + get_smart_rollup_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + smart_rollup + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | _ -> + cctxt#error + "Invalid address, must be a contract or smart rollup address" in let*! () = cctxt#answer "%a" Z.pp_print balance in return_unit); -- GitLab From 92cbb6036fcbe03cb4eb29f8caf6162e4f49dd1f Mon Sep 17 00:00:00 2001 From: Emma Turner Date: Thu, 7 Mar 2024 09:25:01 +0000 Subject: [PATCH 2/3] Proto/client(paris): retrieve ticket balances for smart rollups Currently, one can use the client command for retrieving the ticket balance of an implicit & originated account, but cannot retrieve the balance of a smart rollup address. --- .../lib_client/client_proto_context.ml | 5 +++ .../lib_client/client_proto_context.mli | 10 +++++ .../lib_client/client_proto_contracts.ml | 30 +++++++++++++ .../lib_client/client_proto_contracts.mli | 12 +++++ .../client_proto_context_commands.ml | 45 +++++++++++++------ 5 files changed, 88 insertions(+), 14 deletions(-) diff --git a/src/proto_019_PtParisA/lib_client/client_proto_context.ml b/src/proto_019_PtParisA/lib_client/client_proto_context.ml index 300cecb8778a..9a071294f152 100644 --- a/src/proto_019_PtParisA/lib_client/client_proto_context.ml +++ b/src/proto_019_PtParisA/lib_client/client_proto_context.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -1355,6 +1356,10 @@ let sc_rollup_timeout (cctxt : #full) ~chain ~block ?confirmations ?dry_run | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> return (oph, op, result) +let get_smart_rollup_ticket_balance (rpc : #rpc_context) ~chain ~block contract + key = + Plugin.RPC.Sc_rollup.get_ticket_balance rpc (chain, block) contract key + let zk_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?safety_guard ?storage_limit ?counter ~source ~public_parameters ~circuits_info ~init_state ~nb_ops diff --git a/src/proto_019_PtParisA/lib_client/client_proto_context.mli b/src/proto_019_PtParisA/lib_client/client_proto_context.mli index e79d7c30fda8..cf4b7046e68f 100644 --- a/src/proto_019_PtParisA/lib_client/client_proto_context.mli +++ b/src/proto_019_PtParisA/lib_client/client_proto_context.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -896,6 +897,15 @@ val sc_rollup_timeout : tzresult Lwt.t +(** Calls {!Tezos_protocol_plugin_alpha.Plugin.RPC.Sc_rollup.get_ticket_balance}. *) +val get_smart_rollup_ticket_balance : + #Protocol_client_context.rpc_context -> + chain:Shell_services.chain -> + block:Shell_services.block -> + Sc_rollup.t -> + Ticket_token.unparsed_token -> + Z.t tzresult Lwt.t + val zk_rollup_originate : #Protocol_client_context.full -> chain:Chain_services.chain -> diff --git a/src/proto_019_PtParisA/lib_client/client_proto_contracts.ml b/src/proto_019_PtParisA/lib_client/client_proto_contracts.ml index c8a4a6dc1f88..0b880123c786 100644 --- a/src/proto_019_PtParisA/lib_client/client_proto_contracts.ml +++ b/src/proto_019_PtParisA/lib_client/client_proto_contracts.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -212,6 +213,35 @@ module Contract_alias = struct | Some name -> return name end +module Destination_alias = struct + let contract_parameter () = + Tezos_clic.map_parameter + ~f:(fun c -> Destination.Contract c) + (Contract_alias.destination_parameter ()) + + let smart_rollup_parameter () = + Tezos_clic.map_parameter + ~f:(fun sc -> Destination.Sc_rollup sc) + (Smart_rollup_alias.Address.parameter ()) + + let destination_parameter () = + Tezos_clic.compose_parameters + (contract_parameter ()) + (smart_rollup_parameter ()) + + let destination_param ?(name = "dst") ?(desc = "destination address") next = + let desc = + String.concat + "\n" + [ + desc; + "Can be a literal, an alias, or a key (autodetected in order).\n\ + Use 'text:', 'alias:', 'key:' to force."; + ] + in + Tezos_clic.param ~name ~desc (destination_parameter ()) next +end + let list_contracts cctxt = let open Lwt_result_syntax in let* raw_contracts = Raw_contract_alias.load cctxt in diff --git a/src/proto_019_PtParisA/lib_client/client_proto_contracts.mli b/src/proto_019_PtParisA/lib_client/client_proto_contracts.mli index 02ca6d397a79..a342408ec37e 100644 --- a/src/proto_019_PtParisA/lib_client/client_proto_contracts.mli +++ b/src/proto_019_PtParisA/lib_client/client_proto_contracts.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -79,6 +80,17 @@ module Contract_alias : sig val autocomplete : #Client_context.wallet -> string list tzresult Lwt.t end +module Destination_alias : sig + val destination_parameter : + unit -> (Destination.t, #Client_context.wallet) Tezos_clic.parameter + + val destination_param : + ?name:string -> + ?desc:string -> + ('a, (#Client_context.wallet as 'wallet)) Tezos_clic.params -> + (Destination.t -> 'a, 'wallet) Tezos_clic.params +end + (** [list_contracts cctxt] returns the concatenation of [contracts] and [accounts] where [contracts] is the result of [Raw_contract_alias.load cctxt] and [accounts] the list of accounts (implicit contracts of identities) diff --git a/src/proto_019_PtParisA/lib_client_commands/client_proto_context_commands.ml b/src/proto_019_PtParisA/lib_client_commands/client_proto_context_commands.ml index aed69a798ad1..f73387073244 100644 --- a/src/proto_019_PtParisA/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_019_PtParisA/lib_client_commands/client_proto_context_commands.ml @@ -3,7 +3,7 @@ (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) (* Copyright (c) 2019-2022 Nomadic Labs *) -(* Copyright (c) 2022 TriliTech *) +(* Copyright (c) 2022-2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -580,7 +580,7 @@ let commands_ro () = type, and content." no_options (prefixes ["get"; "ticket"; "balance"; "for"] - @@ Contract_alias.destination_param ~name:"src" ~desc:"Source contract." + @@ Destination_alias.destination_param ~name:"src" ~desc:"Source address." @@ prefixes ["with"; "ticketer"] @@ Contract_alias.destination_param ~name:"ticketer" @@ -596,20 +596,37 @@ let commands_ro () = ~desc:"Content of the ticket." data_parameter @@ stop) - (fun () contract ticketer content_type content cctxt -> + (fun () destination ticketer content_type content cctxt -> let open Lwt_result_syntax in let* balance = - get_contract_ticket_balance - cctxt - ~chain:cctxt#chain - ~block:cctxt#block - contract - Ticket_token. - { - ticketer; - contents_type = content_type.expanded; - contents = content.expanded; - } + match destination with + | Contract contract -> + get_contract_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + contract + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | Sc_rollup smart_rollup -> + get_smart_rollup_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + smart_rollup + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | _ -> + cctxt#error + "Invalid address, must be a contract or smart rollup address" in let*! () = cctxt#answer "%a" Z.pp_print balance in return_unit); -- GitLab From 3e647d4afac7388444d498ee1140a2fbe4751b81 Mon Sep 17 00:00:00 2001 From: Emma Turner Date: Mon, 4 Mar 2024 13:46:47 +0000 Subject: [PATCH 3/3] Proto/client(oxford): retrieve ticket balances for smart rollups Currently, one can use the client command for retrieving the ticket balance of an implicit & originated account, but cannot retrieve the balance of a smart rollup address. --- .../lib_client/client_proto_context.ml | 5 +++ .../lib_client/client_proto_context.mli | 10 +++++ .../lib_client/client_proto_contracts.ml | 30 +++++++++++++ .../lib_client/client_proto_contracts.mli | 12 +++++ .../client_proto_context_commands.ml | 45 +++++++++++++------ 5 files changed, 88 insertions(+), 14 deletions(-) diff --git a/src/proto_018_Proxford/lib_client/client_proto_context.ml b/src/proto_018_Proxford/lib_client/client_proto_context.ml index f35493a0de98..38dd59f19f6a 100644 --- a/src/proto_018_Proxford/lib_client/client_proto_context.ml +++ b/src/proto_018_Proxford/lib_client/client_proto_context.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -1354,6 +1355,10 @@ let sc_rollup_timeout (cctxt : #full) ~chain ~block ?confirmations ?dry_run | Apply_results.Single_and_result ((Manager_operation _ as op), result) -> return (oph, op, result) +let get_smart_rollup_ticket_balance (rpc : #rpc_context) ~chain ~block contract + key = + Plugin.RPC.Sc_rollup.get_ticket_balance rpc (chain, block) contract key + let zk_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?safety_guard ?storage_limit ?counter ~source ~public_parameters ~circuits_info ~init_state ~nb_ops diff --git a/src/proto_018_Proxford/lib_client/client_proto_context.mli b/src/proto_018_Proxford/lib_client/client_proto_context.mli index 6b1b86eb5f2c..8b910325a2eb 100644 --- a/src/proto_018_Proxford/lib_client/client_proto_context.mli +++ b/src/proto_018_Proxford/lib_client/client_proto_context.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -896,6 +897,15 @@ val sc_rollup_timeout : tzresult Lwt.t +(** Calls {!Tezos_protocol_plugin_alpha.Plugin.RPC.Sc_rollup.get_ticket_balance}. *) +val get_smart_rollup_ticket_balance : + #Protocol_client_context.rpc_context -> + chain:Shell_services.chain -> + block:Shell_services.block -> + Sc_rollup.t -> + Ticket_token.unparsed_token -> + Z.t tzresult Lwt.t + val zk_rollup_originate : #Protocol_client_context.full -> chain:Chain_services.chain -> diff --git a/src/proto_018_Proxford/lib_client/client_proto_contracts.ml b/src/proto_018_Proxford/lib_client/client_proto_contracts.ml index d252eb051cd5..3d90523e2316 100644 --- a/src/proto_018_Proxford/lib_client/client_proto_contracts.ml +++ b/src/proto_018_Proxford/lib_client/client_proto_contracts.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -210,6 +211,35 @@ module Contract_alias = struct | Some name -> return name end +module Destination_alias = struct + let contract_parameter () = + Tezos_clic.map_parameter + ~f:(fun c -> Destination.Contract c) + (Contract_alias.destination_parameter ()) + + let smart_rollup_parameter () = + Tezos_clic.map_parameter + ~f:(fun sc -> Destination.Sc_rollup sc) + (Smart_rollup_alias.Address.parameter ()) + + let destination_parameter () = + Tezos_clic.compose_parameters + (contract_parameter ()) + (smart_rollup_parameter ()) + + let destination_param ?(name = "dst") ?(desc = "destination address") next = + let desc = + String.concat + "\n" + [ + desc; + "Can be a literal, an alias, or a key (autodetected in order).\n\ + Use 'text:', 'alias:', 'key:' to force."; + ] + in + Tezos_clic.param ~name ~desc (destination_parameter ()) next +end + let list_contracts cctxt = let open Lwt_result_syntax in let* raw_contracts = Raw_contract_alias.load cctxt in diff --git a/src/proto_018_Proxford/lib_client/client_proto_contracts.mli b/src/proto_018_Proxford/lib_client/client_proto_contracts.mli index 02ca6d397a79..a342408ec37e 100644 --- a/src/proto_018_Proxford/lib_client/client_proto_contracts.mli +++ b/src/proto_018_Proxford/lib_client/client_proto_contracts.mli @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2024 Trilitech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -79,6 +80,17 @@ module Contract_alias : sig val autocomplete : #Client_context.wallet -> string list tzresult Lwt.t end +module Destination_alias : sig + val destination_parameter : + unit -> (Destination.t, #Client_context.wallet) Tezos_clic.parameter + + val destination_param : + ?name:string -> + ?desc:string -> + ('a, (#Client_context.wallet as 'wallet)) Tezos_clic.params -> + (Destination.t -> 'a, 'wallet) Tezos_clic.params +end + (** [list_contracts cctxt] returns the concatenation of [contracts] and [accounts] where [contracts] is the result of [Raw_contract_alias.load cctxt] and [accounts] the list of accounts (implicit contracts of identities) diff --git a/src/proto_018_Proxford/lib_client_commands/client_proto_context_commands.ml b/src/proto_018_Proxford/lib_client_commands/client_proto_context_commands.ml index 15303fe07692..a3268ed11fa3 100644 --- a/src/proto_018_Proxford/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_018_Proxford/lib_client_commands/client_proto_context_commands.ml @@ -3,7 +3,7 @@ (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) (* Copyright (c) 2019-2022 Nomadic Labs *) -(* Copyright (c) 2022 TriliTech *) +(* Copyright (c) 2022-2024 TriliTech *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -580,7 +580,7 @@ let commands_ro () = type, and content." no_options (prefixes ["get"; "ticket"; "balance"; "for"] - @@ Contract_alias.destination_param ~name:"src" ~desc:"Source contract." + @@ Destination_alias.destination_param ~name:"src" ~desc:"Source address." @@ prefixes ["with"; "ticketer"] @@ Contract_alias.destination_param ~name:"ticketer" @@ -596,20 +596,37 @@ let commands_ro () = ~desc:"Content of the ticket." data_parameter @@ stop) - (fun () contract ticketer content_type content cctxt -> + (fun () destination ticketer content_type content cctxt -> let open Lwt_result_syntax in let* balance = - get_contract_ticket_balance - cctxt - ~chain:cctxt#chain - ~block:cctxt#block - contract - Ticket_token. - { - ticketer; - contents_type = content_type.expanded; - contents = content.expanded; - } + match destination with + | Contract contract -> + get_contract_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + contract + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | Sc_rollup smart_rollup -> + get_smart_rollup_ticket_balance + cctxt + ~chain:cctxt#chain + ~block:cctxt#block + smart_rollup + Ticket_token. + { + ticketer; + contents_type = content_type.expanded; + contents = content.expanded; + } + | _ -> + cctxt#error + "Invalid address, must be a contract or smart rollup address" in let*! () = cctxt#answer "%a" Z.pp_print balance in return_unit); -- GitLab