From 7b76aae9f7425b6b5cf6ea733fdbffa20325c0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 5 Dec 2023 22:31:27 +0100 Subject: [PATCH] Proto/Michelson: add operation constructor primitives This commit adds a new Data constructor primitive for each case of `operation`. These primitives are not used in this commit but only reserved for later use to define a readable unparsing of values of type `operation`. --- .../lib_protocol/alpha_context.mli | 4 ++++ .../lib_protocol/michelson_v1_primitives.ml | 23 +++++++++++++++++-- .../lib_protocol/michelson_v1_primitives.mli | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index e306f8e24ed2..e4b743d75fb0 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -557,6 +557,10 @@ module Script : sig | D_True | D_Unit | D_Lambda_rec + | D_Transfer_tokens + | D_Set_delegate + | D_Create_contract + | D_Emit | I_PACK | I_UNPACK | I_BLAKE2B diff --git a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml index 8c198be16e91..60e0fb178120 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml +++ b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml @@ -50,6 +50,10 @@ type prim = | D_True | D_Unit | D_Lambda_rec + | D_Transfer_tokens + | D_Set_delegate + | D_Create_contract + | D_Emit | I_PACK | I_UNPACK | I_BLAKE2B @@ -206,7 +210,8 @@ type namespace = let namespace = function | K_code | K_view | K_parameter | K_storage -> Keyword_namespace | D_Elt | D_False | D_Left | D_None | D_Pair | D_Right | D_Some | D_True - | D_Unit | D_Lambda_rec -> + | D_Unit | D_Lambda_rec | D_Transfer_tokens | D_Set_delegate + | D_Create_contract | D_Emit -> Constant_namespace | I_ABS | I_ADD | I_ADDRESS | I_AMOUNT | I_AND | I_APPLY | I_BALANCE | I_BLAKE2B | I_CAR | I_CAST | I_CDR | I_CHAIN_ID | I_CHECK_SIGNATURE @@ -263,6 +268,10 @@ let string_of_prim = function | D_True -> "True" | D_Unit -> "Unit" | D_Lambda_rec -> "Lambda_rec" + | D_Transfer_tokens -> "Transfer_tokens" + | D_Set_delegate -> "Set_delegate" + | D_Create_contract -> "Create_contract" + | D_Emit -> "Emit" | I_PACK -> "PACK" | I_UNPACK -> "UNPACK" | I_BLAKE2B -> "BLAKE2B" @@ -424,6 +433,10 @@ let prim_of_string = | "True" -> return D_True | "Unit" -> return D_Unit | "Lambda_rec" -> return D_Lambda_rec + | "Transfer_tokens" -> return D_Transfer_tokens + | "Set_delegate" -> return D_Set_delegate + | "Create_contract" -> return D_Create_contract + | "Emit" -> return D_Emit | "PACK" -> return I_PACK | "UNPACK" -> return I_UNPACK | "BLAKE2B" -> return I_BLAKE2B @@ -792,7 +805,13 @@ let prim_encoding = ("LAMBDA_REC", I_LAMBDA_REC); ("TICKET", I_TICKET); ("BYTES", I_BYTES); - ("NAT", I_NAT) + ("NAT", I_NAT); + (* /!\ NEW INSTRUCTIONS MUST BE ADDED AT THE END OF THE STRING_ENUM, FOR BACKWARD COMPATIBILITY OF THE ENCODING. *) + (* Alpha_019 addtitions *) + ("Transfer_tokens", D_Transfer_tokens); + ("Set_delegate", D_Set_delegate); + ("Create_contract", D_Create_contract); + ("Emit", D_Emit) (* New instructions must be added here, for backward compatibility of the encoding. *) (* Keep the comment above at the end of the list *); ] diff --git a/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli index 761631190aba..f92bf18f64ac 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli +++ b/src/proto_alpha/lib_protocol/michelson_v1_primitives.mli @@ -62,6 +62,10 @@ type prim = | D_True | D_Unit | D_Lambda_rec + | D_Transfer_tokens + | D_Set_delegate + | D_Create_contract + | D_Emit | I_PACK | I_UNPACK | I_BLAKE2B -- GitLab