@@ -9,15 +9,8 @@ open Lwt.Infix
9
9
open Dune_Network_Lib.Stdlib
10
10
open Dune_Network_Lib.Crypto (* for crypto *)
11
11
12
- module Liquidity = LiquidityLang
13
-
14
- type liquidity_datatype = Liquidity .datatype Lazy_superposed .t
15
- type liquidity_const = Liquidity .const Lazy_superposed .t
16
- type liquidity_contract = Liquidity .contract Lazy_superposed .t
17
-
18
-
19
12
module Make (L : LANG ) = struct
20
-
13
+
21
14
module L = L
22
15
module RPC = LiquidClientRPCs. Make (L )
23
16
module E = RPC. E
@@ -28,11 +21,17 @@ module Make (L : LANG) = struct
28
21
open T
29
22
open RPC
30
23
24
+ type source_datatype = Source .datatype Lazy_superposed .t
25
+ type source_const = Source .const Lazy_superposed .t
26
+ type source_contract = Source .contract Lazy_superposed .t
27
+
31
28
type target_datatype = Target .datatype Lazy_superposed .t
32
29
type target_const = Target .const Lazy_superposed .t
33
30
type target_contract = Target .contract Lazy_superposed .t
34
31
35
- type liq_big_map_diff = (bm_id , Liquidity .const ) Big_map_diff .t
32
+ type liq_big_map_diff = (bm_id , Source .const ) Big_map_diff .t
33
+
34
+ module SourceOperation = OperationMake (Source )
36
35
37
36
let get_private_key ?private_key () =
38
37
match private_key, ! LiquidOptions. private_key with
@@ -68,7 +67,7 @@ module Make (L : LANG) = struct
68
67
| Some counter -> Lwt. return counter
69
68
70
69
let big_map_info storage storage_ty id =
71
- Liquidity . list_big_maps storage storage_ty
70
+ Source . list_big_maps storage storage_ty
72
71
|> List. find_opt (fun ((Bm_id i | Bm_name (i , _ )), _ , _ ) -> i = id)
73
72
74
73
let id_of_info id info = match info with
@@ -153,11 +152,14 @@ module Make (L : LANG) = struct
153
152
| None -> get_head ()
154
153
155
154
let run_pre ?(debug =false ) ?(amount = ! LiquidOptions. amount)
156
- source_contract target_contract loc_table ?source entry_name input storage =
155
+ source_contract
156
+ target_contract
157
+ loc_table
158
+ ?source entry_name input storage =
157
159
let rpc = if debug then RPC. trace else RPC. run in
158
- let storage_ty = Liquidity . storage source_contract in
160
+ let storage_ty = Source . storage source_contract in
159
161
let input_ty =
160
- match List. assoc_opt entry_name (Liquidity . entries source_contract) with
162
+ match List. assoc_opt entry_name (Source . entries source_contract) with
161
163
| Some ty -> ty
162
164
| None -> failwith (" Contract has no entry point " ^ entry_name) in
163
165
let input = compile_const ~ty: input_ty input in
@@ -204,7 +206,7 @@ module Make (L : LANG) = struct
204
206
let get_storage contract address =
205
207
let _ = compile_contract contract in
206
208
RPC. get_storage address > |= fun storage ->
207
- try decompile_const storage ~ty: (Liquidity . storage contract)
209
+ try decompile_const storage ~ty: (Source . storage contract)
208
210
with _ ->
209
211
Format. eprintf " Could not convert constant to contract storage type.@." ;
210
212
decompile_const storage
@@ -248,13 +250,13 @@ module Make (L : LANG) = struct
248
250
249
251
let build_big_map_subst const const_ty big_map_diff =
250
252
let open Big_map_diff in
251
- Liquidity . list_big_maps const const_ty |>
253
+ Source . list_big_maps const const_ty |>
252
254
List. map (fun ((Bm_id i | Bm_name (i , _ )), _ , _ ) ->
253
255
i, big_map_elements i big_map_diff
254
256
)
255
257
256
258
let replace_init_big_maps big_map_diff storage storage_ty =
257
- Liquidity . apply_big_map_subst
259
+ Source . apply_big_map_subst
258
260
(build_big_map_subst storage storage_ty big_map_diff)
259
261
storage
260
262
@@ -264,7 +266,7 @@ module Make (L : LANG) = struct
264
266
try Some (get_source ?source () )
265
267
with _ -> None in
266
268
match comp_init, init_params with
267
- | Liquidity .No_init , [c]
269
+ | Source .No_init , [c]
268
270
| Init_constant c , [] -> Lwt. return c
269
271
270
272
| No_init , [] ->
@@ -281,9 +283,9 @@ module Make (L : LANG) = struct
281
283
" init_storage: init storage needs %d arguments, but was given %d"
282
284
l_req l_giv ;
283
285
let param = match init_params with
284
- | [] -> Liquidity .unit
286
+ | [] -> Source .unit
285
287
| [x] -> x
286
- | _ -> Liquidity . tuple init_params
288
+ | _ -> Source . tuple init_params
287
289
in
288
290
Lwt. return param
289
291
@@ -295,13 +297,13 @@ module Make (L : LANG) = struct
295
297
l_req l_giv;
296
298
let eval_input_storage =
297
299
try
298
- Liquidity . default_empty_const (Liquidity . storage contract)
300
+ Source . default_empty_const (Source . storage contract)
299
301
with Not_found -> failwith " could not construct dummy storage for eval"
300
302
in
301
303
let eval_input_parameter = match init_params with
302
- | [] -> Liquidity .unit
304
+ | [] -> Source .unit
303
305
| [x] -> x
304
- | _ -> Liquidity . tuple init_params
306
+ | _ -> Source . tuple init_params
305
307
in
306
308
307
309
let ct, _, loc_table = compile_contract c in
@@ -310,7 +312,7 @@ module Make (L : LANG) = struct
310
312
>> = fun (_ , eval_init_storage , big_map_diff , _ ) ->
311
313
(* Add elements of big map *)
312
314
let eval_init_storage =
313
- replace_init_big_maps big_map_diff eval_init_storage (Liquidity . storage contract) in
315
+ replace_init_big_maps big_map_diff eval_init_storage (Source . storage contract) in
314
316
Lwt. return eval_init_storage
315
317
316
318
@@ -320,11 +322,11 @@ module Make (L : LANG) = struct
320
322
let ty = match comp_init with
321
323
| Init_components args_tys ->
322
324
(match args_tys with
323
- | [] -> Tunit
325
+ | [] -> Source. tunit
324
326
| [_, ty] -> ty
325
- | _ -> Ttuple (List. map snd args_tys)
327
+ | _ -> Source. ttuple (List. map snd args_tys)
326
328
)
327
- | _ -> Liquidity . storage contract in
329
+ | _ -> Source . storage contract in
328
330
compile_const ~ty init
329
331
330
332
@@ -571,7 +573,7 @@ module Make (L : LANG) = struct
571
573
~loc_table address ?contract entry_name input =
572
574
let input_ty = match contract with
573
575
| None -> None
574
- | Some c -> match List. assoc_opt entry_name (Liquidity . entries c) with
576
+ | Some c -> match List. assoc_opt entry_name (Source . entries c) with
575
577
| None -> failwith (" Contract has no entry point " ^ entry_name)
576
578
| ty -> ty in
577
579
let input_t = compile_const ?ty:input_ty input in
@@ -687,11 +689,11 @@ module Make (L : LANG) = struct
687
689
let open Big_map_diff in
688
690
function
689
691
| Big_map_add { id; key_hash; key; value } ->
690
- let key = Liquidity . const#ast key in
691
- let value = Liquidity . const#ast value in
692
+ let key = Source . const#ast key in
693
+ let value = Source . const#ast value in
692
694
Big_map_add { id; key_hash; key; value }
693
695
| Big_map_remove { id; key_hash; key } ->
694
- let key = Liquidity . const#ast key in
696
+ let key = Source . const#ast key in
695
697
Big_map_remove { id; key_hash; key }
696
698
| Big_map_delete { id } ->
697
699
Big_map_delete { id }
@@ -719,59 +721,59 @@ module Make (L : LANG) = struct
719
721
type 'a t
720
722
val init_storage :
721
723
?source : string ->
722
- liquidity_contract ->
723
- liquidity_const list -> target_const t
724
+ source_contract ->
725
+ source_const list -> target_const t
724
726
val run :
725
727
?amount : LiquidNumber .tez ->
726
- liquidity_contract ->
728
+ source_contract ->
727
729
string ->
728
- liquidity_const ->
729
- liquidity_const ->
730
- (LiquidityOperation .internal list * liquidity_const *
731
- (bm_id , liquidity_const ) Big_map_diff .item
730
+ source_const ->
731
+ source_const ->
732
+ (SourceOperation .internal list * source_const *
733
+ (bm_id , source_const ) Big_map_diff .item
732
734
list )
733
735
t
734
736
val run_debug :
735
737
?amount : LiquidNumber .tez ->
736
- liquidity_contract ->
738
+ source_contract ->
737
739
string ->
738
- liquidity_const ->
739
- liquidity_const ->
740
- (LiquidityOperation .internal list * liquidity_const *
741
- (bm_id , liquidity_const ) Big_map_diff .item
740
+ source_const ->
741
+ source_const ->
742
+ (SourceOperation .internal list * source_const *
743
+ (bm_id , source_const ) Big_map_diff .item
742
744
list *
743
- (Liquidity .location , liquidity_const ) Trace .trace_item list )
745
+ (Source .location , source_const ) Trace .trace_item list )
744
746
t
745
747
val deploy :
746
748
?balance : LiquidNumber .tez ->
747
- liquidity_contract ->
748
- liquidity_const list -> (string * string ) t
749
+ source_contract ->
750
+ source_const list -> (string * string ) t
749
751
val get_storage :
750
- liquidity_contract -> string -> liquidity_const t
752
+ source_contract -> string -> source_const t
751
753
val get_big_map_value :
752
- bm_id * liquidity_datatype * liquidity_datatype ->
753
- liquidity_const -> liquidity_const option t
754
+ bm_id * source_datatype * source_datatype ->
755
+ source_const -> source_const option t
754
756
val call :
755
- ?contract : liquidity_contract ->
757
+ ?contract : source_contract ->
756
758
?amount : LiquidNumber .tez ->
757
- address :string -> entry :string -> liquidity_const -> string t
759
+ address :string -> entry :string -> source_const -> string t
758
760
val activate : secret :string -> string t
759
761
val inject : operation :bytes -> signature :string -> string t
760
762
val pack :
761
- const :liquidity_const -> ty :liquidity_datatype -> bytes t
763
+ const :source_const -> ty :source_datatype -> bytes t
762
764
val forge_deploy :
763
765
?head : Header .t ->
764
766
?source : string ->
765
767
?public_key : string ->
766
768
?balance : LiquidNumber .tez ->
767
- liquidity_contract -> liquidity_const list -> bytes t
769
+ source_contract -> source_const list -> bytes t
768
770
val forge_call :
769
771
?head : Header .t ->
770
772
?source : string ->
771
773
?public_key : string ->
772
- ?contract : liquidity_contract ->
774
+ ?contract : source_contract ->
773
775
?amount : LiquidNumber .tez ->
774
- address :string -> entry :string -> liquidity_const -> bytes t
776
+ address :string -> entry :string -> source_const -> bytes t
775
777
end
776
778
777
779
(* Withoud optional argument head *)
@@ -784,21 +786,25 @@ module Make (L : LANG) = struct
784
786
> |= fun storage ->
785
787
Target. const#ast storage
786
788
787
- let run ?amount contract entry_name input storage =
789
+ let run ?amount contract entry_name input storage :
790
+ (SourceOperation. internal list * source_const *
791
+ (LiquidClientUtils. bm_id , source_const )
792
+ LiquidClientTypes.Big_map_diff. item list )
793
+ Lwt. t =
788
794
let contract = contract#ast in
789
795
let input = input#ast in
790
796
let storage = storage#ast in
791
797
run ?amount contract entry_name input storage
792
798
> |= fun (ops , storage , bm ) ->
793
- (ops, Liquidity . const#ast storage, print_big_map_diff bm)
799
+ (ops, Source . const#ast storage, print_big_map_diff bm)
794
800
795
801
let run_debug ?amount contract entry_name input storage =
796
802
let contract = contract#ast in
797
803
let input = input#ast in
798
804
let storage = storage#ast in
799
805
run_debug ?amount contract entry_name input storage
800
806
> |= fun (ops , storage , bm , trace ) ->
801
- (ops, Liquidity . const#ast storage, print_big_map_diff bm, print_trace trace)
807
+ (ops, Source . const#ast storage, print_big_map_diff bm, print_trace trace)
802
808
803
809
let deploy ?balance contract args =
804
810
let contract = contract#ast in
@@ -809,15 +815,15 @@ module Make (L : LANG) = struct
809
815
let contract = contract#ast in
810
816
get_storage contract address
811
817
> |= fun storage ->
812
- Liquidity . const#ast storage
818
+ Source . const#ast storage
813
819
814
820
let get_big_map_value (id , tk , tv ) key =
815
821
let id = id, tk#ast, tv#ast in
816
822
let key = key#ast in
817
823
get_big_map_value id key
818
824
> |= function
819
825
| None -> None
820
- | Some v -> Some (Liquidity . const#ast v)
826
+ | Some v -> Some (Source . const#ast v)
821
827
822
828
let call ?contract ?amount ~address ~entry parameter =
823
829
let contract = match contract with
0 commit comments