Source file client_proto_context_commands.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
open Protocol
open Alpha_context
open Client_proto_context
open Client_proto_contracts
open Client_proto_rollups
open Client_keys
open Client_proto_args
let save_zk_rollup ~force (cctxt : #Client_context.full) alias_name rollup =
let open Lwt_result_syntax in
let* () = EpoxyAlias.add ~force cctxt alias_name rollup in
let*! () = cctxt#message "Epoxy rollup memorized as %s" alias_name in
return_unit
let encrypted_switch =
Tezos_clic.switch ~long:"encrypted" ~doc:"encrypt the key on-disk" ()
let normalize_types_switch =
Tezos_clic.switch
~long:"normalize-types"
~doc:
"Whether types should be normalized (annotations removed, combs \
flattened) or kept as they appeared in the original script."
()
let report_michelson_errors ?(no_print_source = false) ~msg
(cctxt : #Client_context.full) =
let open Lwt_syntax in
function
| Error errs ->
let* errs =
Michelson_v1_error_reporter.enrich_runtime_errors
cctxt
~chain:cctxt#chain
~block:cctxt#block
~parsed:None
errs
in
let* () =
cctxt#warning
"%a"
(Michelson_v1_error_reporter.report_errors
~details:(not no_print_source)
~show_source:(not no_print_source)
?parsed:None)
errs
in
let* () = cctxt#error "%s" msg in
return_none
| Ok data -> return_some data
let block_hash_param =
Tezos_clic.parameter (fun (cctxt : #Client_context.full) s ->
try Lwt_result_syntax.return (Block_hash.of_b58check_exn s)
with _ -> cctxt#error "Parameter '%s' is an invalid block hash" s)
let group =
{
Tezos_clic.name = "context";
title = "Block contextual commands (see option -block)";
}
let alphanet = {Tezos_clic.name = "alphanet"; title = "Alphanet only commands"}
let binary_description =
{Tezos_clic.name = "description"; title = "Binary Description"}
let tez_of_string_exn (cctxt : #Client_context.full) index field s =
let open Lwt_result_syntax in
match Tez.of_string s with
| Some t -> return t
| None ->
cctxt#error
"Invalid \xEA\x9C\xA9 notation at entry %i, field \"%s\": %s"
index
field
s
let tez_of_opt_string_exn (cctxt : #Client_context.full) index field s =
Option.map_es (tez_of_string_exn cctxt index field) s
let check_smart_contract = Managed_contract.check_smart_contract
let commands_ro () =
let open Tezos_clic in
[
command
~group
~desc:"Access the timestamp of the block."
(args1
(switch ~doc:"output time in seconds" ~short:'s' ~long:"seconds" ()))
(fixed ["get"; "timestamp"])
(fun seconds (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* {timestamp = v; _} =
Shell_services.Blocks.Header.shell_header
cctxt
~chain:cctxt#chain
~block:cctxt#block
()
in
let*! () =
if seconds then cctxt#message "%Ld" (Time.Protocol.to_seconds v)
else cctxt#message "%s" (Time.Protocol.to_notation v)
in
return_unit);
command
~group
~desc:"Lists all non empty contracts of the block."
no_options
(fixed ["list"; "contracts"])
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* contracts =
list_contract_labels cctxt ~chain:cctxt#chain ~block:cctxt#block
in
let*! () =
List.iter_s
(fun (alias, hash, kind) -> cctxt#message "%s%s%s" hash kind alias)
contracts
in
return_unit);
command
~group
~desc:"Lists cached contracts and their age in LRU ordering."
no_options
(prefixes ["list"; "cached"; "contracts"] @@ stop)
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* keys =
cached_contracts cctxt ~chain:cctxt#chain ~block:cctxt#block
in
let*! () =
List.iter_s
(fun (key, size) -> cctxt#message "%a %d" Contract_hash.pp key size)
keys
in
return_unit);
command
~group
~desc:"Get the key rank of a cache key."
no_options
(prefixes ["get"; "cached"; "contract"; "rank"; "for"]
@@ OriginatedContractAlias.destination_param ~name:"src" ~desc:"contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* rank =
contract_rank cctxt ~chain:cctxt#chain ~block:cctxt#block contract
in
let*! () =
match rank with
| None -> cctxt#error "Invalid contract: %a" Contract_hash.pp contract
| Some rank -> cctxt#message "%d" rank
in
return_unit);
command
~group
~desc:"Get cache contract size."
no_options
(prefixes ["get"; "cache"; "contract"; "size"] @@ stop)
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* t =
contract_cache_size cctxt ~chain:cctxt#chain ~block:cctxt#block
in
let*! () = cctxt#message "%d" t in
return_unit);
command
~group
~desc:"Get cache contract size limit."
no_options
(prefixes ["get"; "cache"; "contract"; "size"; "limit"] @@ stop)
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* t =
contract_cache_size_limit cctxt ~chain:cctxt#chain ~block:cctxt#block
in
let*! () = cctxt#message "%d" t in
return_unit);
command
~group
~desc:"Get the balance of a contract."
no_options
(prefixes ["get"; "balance"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* amount =
get_balance cctxt ~chain:cctxt#chain ~block:cctxt#block contract
in
let*! () =
cctxt#answer "%a %s" Tez.pp amount Operation_result.tez_sym
in
return_unit);
command
~group
~desc:"Get the storage of a contract."
(args1 (unparsing_mode_arg ~default:"Readable"))
(prefixes ["get"; "contract"; "storage"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun unparsing_mode contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* v =
get_storage
cctxt
~chain:cctxt#chain
~block:cctxt#block
~unparsing_mode
contract
in
check_smart_contract cctxt v @@ fun storage ->
let*! () =
cctxt#answer "%a" Michelson_v1_printer.print_expr_unwrapped storage
in
return_unit);
command
~group
~desc:"Get the used storage space of a contract."
no_options
(prefixes ["get"; "contract"; "used"; "storage"; "space"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* used_space =
get_used_storage_space
cctxt
~chain:cctxt#chain
~block:cctxt#block
contract
in
check_smart_contract cctxt used_space @@ fun used_space ->
let*! () = cctxt#answer "%a" Z.pp_print used_space in
return_unit);
command
~group
~desc:"Get the paid storage space of a contract."
no_options
(prefixes ["get"; "contract"; "paid"; "storage"; "space"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* paid_space =
get_paid_storage_space
cctxt
~chain:cctxt#chain
~block:cctxt#block
contract
in
check_smart_contract cctxt paid_space @@ fun paid_space ->
let*! () = cctxt#answer "%a" Z.pp_print paid_space in
return_unit);
command
~group
~desc:
"Get the value associated to a key in the big map storage of a \
contract (deprecated)."
no_options
(prefixes ["get"; "big"; "map"; "value"; "for"]
@@ Tezos_clic.param ~name:"key" ~desc:"the key to look for" data_parameter
@@ prefixes ["of"; "type"]
@@ Tezos_clic.param ~name:"type" ~desc:"type of the key" data_parameter
@@ prefix "in"
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun () key key_type contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* v =
get_contract_big_map_value
cctxt
~chain:cctxt#chain
~block:cctxt#block
contract
(key.expanded, key_type.expanded)
in
match v with
| None -> cctxt#error "No value associated to this key."
| Some value ->
let*! () =
cctxt#answer "%a" Michelson_v1_printer.print_expr_unwrapped value
in
return_unit);
command
~group
~desc:"Get a value in a big map."
(args1 (unparsing_mode_arg ~default:"Readable"))
(prefixes ["get"; "element"]
@@ Tezos_clic.param
~name:"key"
~desc:"the key to look for"
(Tezos_clic.parameter (fun _ s ->
Lwt_result_syntax.return (Script_expr_hash.of_b58check_exn s)))
@@ prefixes ["of"; "big"; "map"]
@@ Tezos_clic.param
~name:"big_map"
~desc:"identifier of the big_map"
int_parameter
@@ stop)
(fun unparsing_mode key id (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* value =
get_big_map_value
cctxt
~chain:cctxt#chain
~block:cctxt#block
~unparsing_mode
(Big_map.Id.parse_z (Z.of_int id))
key
in
let*! () =
cctxt#answer "%a" Michelson_v1_printer.print_expr_unwrapped value
in
return_unit);
command
~group
~desc:"Get the code of a contract."
(args2 (unparsing_mode_arg ~default:"Readable") normalize_types_switch)
(prefixes ["get"; "contract"; "code"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun (unparsing_mode, normalize_types)
contract
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* v =
get_script
cctxt
~chain:cctxt#chain
~block:cctxt#block
~unparsing_mode
~normalize_types
contract
in
check_smart_contract cctxt v @@ fun {code; storage = _} ->
match Script_repr.force_decode code with
| Error errs -> cctxt#error "%a" Environment.Error_monad.pp_trace errs
| Ok code ->
let {Michelson_v1_parser.source; _} =
Michelson_v1_printer.unparse_toplevel code
in
let*! () = cctxt#answer "%s" source in
return_unit);
command
~group
~desc:"Get the `BLAKE2B` script hash of a contract."
no_options
(prefixes ["get"; "contract"; "script"; "hash"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_syntax in
let* r =
get_script_hash cctxt ~chain:cctxt#chain ~block:cctxt#block contract
in
match r with
| Error errs -> cctxt#error "%a" pp_print_trace errs
| Ok hash ->
check_smart_contract cctxt hash @@ fun hash ->
let* () = cctxt#answer "%a" Script_expr_hash.pp hash in
return_ok_unit);
command
~group
~desc:"Get the type of an entrypoint of a contract."
(args1 normalize_types_switch)
(prefixes ["get"; "contract"; "entrypoint"; "type"; "of"]
@@ Tezos_clic.param
~name:"entrypoint"
~desc:"the entrypoint to describe"
entrypoint_parameter
@@ prefixes ["for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun normalize_types
entrypoint
contract
(cctxt : Protocol_client_context.full) ->
let open Lwt_syntax in
let* t =
Michelson_v1_entrypoints.contract_entrypoint_type
cctxt
~chain:cctxt#chain
~block:cctxt#block
~contract
~entrypoint
~normalize_types
in
Michelson_v1_entrypoints.print_entrypoint_type
cctxt
~emacs:false
~contract
~entrypoint
t);
command
~group
~desc:"Get the entrypoint list of a contract."
(args1 normalize_types_switch)
(prefixes ["get"; "contract"; "entrypoints"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun normalize_types contract (cctxt : Protocol_client_context.full) ->
let open Lwt_syntax in
let* es =
Michelson_v1_entrypoints.list_contract_entrypoints
cctxt
~chain:cctxt#chain
~block:cctxt#block
~contract
~normalize_types
in
Michelson_v1_entrypoints.print_entrypoints_list
cctxt
~emacs:false
~contract
es);
command
~group
~desc:"Get the list of unreachable paths in a contract's parameter type."
no_options
(prefixes ["get"; "contract"; "unreachable"; "paths"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_syntax in
let* u =
Michelson_v1_entrypoints.list_contract_unreachables
cctxt
~chain:cctxt#chain
~block:cctxt#block
~contract
in
Michelson_v1_entrypoints.print_unreachables
cctxt
~emacs:false
~contract
u);
command
~group
~desc:"Get the delegate of a contract."
no_options
(prefixes ["get"; "delegate"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* v =
Client_proto_contracts.get_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
contract
in
match v with
| None ->
let*! () = cctxt#message "none" in
return_unit
| Some delegate ->
let* mn = Public_key_hash.rev_find cctxt delegate in
let* m = Public_key_hash.to_source delegate in
let*! () =
cctxt#message
"%s (%s)"
m
(match mn with None -> "unknown" | Some n -> "known as " ^ n)
in
return_unit);
command
~group
~desc:
"Get contract's balance of ticket with specified ticketer, content \
type, and content."
no_options
(prefixes ["get"; "ticket"; "balance"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"Source contract."
@@ prefixes ["with"; "ticketer"]
@@ ContractAlias.destination_param
~name:"ticketer"
~desc:"Ticketer contract of the ticket."
@@ prefixes ["and"; "type"]
@@ Tezos_clic.param
~name:"ticket content type"
~desc:"Type of the content of the ticket."
data_parameter
@@ prefixes ["and"; "content"]
@@ Tezos_clic.param
~name:"ticket content"
~desc:"Content of the ticket."
data_parameter
@@ stop)
(fun () contract 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;
}
in
let*! () = cctxt#answer "%a" Z.pp_print balance in
return_unit);
command
~group
~desc:"Get the complete list of tickets owned by a given contract."
no_options
(prefixes ["get"; "all"; "ticket"; "balances"; "for"]
@@ OriginatedContractAlias.destination_param
~name:"src"
~desc:"Source contract."
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* ticket_balances =
get_contract_all_ticket_balances
cctxt
~chain:cctxt#chain
~block:cctxt#block
contract
in
let pp_ticket_balance ppf
(Ticket_token.{ticketer; contents_type; contents}, amount) =
Format.fprintf
ppf
"@[<v 0>Ticketer: %a@,Content type: %a@,Content: %a@,Amount: %a@]"
Contract.pp
ticketer
Michelson_v1_printer.print_expr
contents_type
Michelson_v1_printer.print_expr
contents
Z.pp_print
amount
in
let*! () =
cctxt#answer
"%a"
(Format.pp_print_list
~pp_sep:(fun fmt () -> Format.fprintf fmt "@.@.")
pp_ticket_balance)
ticket_balances
in
return_unit);
command
~desc:"Get receipt for past operation"
(args1
(default_arg
~long:"check-previous"
~placeholder:"num_blocks"
~doc:"number of previous blocks to check"
~default:"10"
non_negative_parameter))
(prefixes ["get"; "receipt"; "for"]
@@ param
~name:"operation"
~desc:"Operation to be looked up"
(parameter (fun (cctxt : #Client_context.full) x ->
match Operation_hash.of_b58check_opt x with
| None -> cctxt#error "Invalid operation hash: '%s'" x
| Some hash -> Lwt_result_syntax.return hash))
@@ stop)
(fun predecessors operation_hash (ctxt : Protocol_client_context.full) ->
display_receipt_for_operation
ctxt
~chain:ctxt#chain
~predecessors
operation_hash);
command
~group
~desc:"Summarize the current voting period"
no_options
(fixed ["show"; "voting"; "period"])
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* info =
get_period_info ~chain:cctxt#chain ~block:cctxt#block cctxt
in
let*! () =
cctxt#message
"Current period: %a\nBlocks remaining until end of period: %ld"
Data_encoding.Json.pp
(Data_encoding.Json.construct
Alpha_context.Voting_period.kind_encoding
info.current_period_kind)
info.remaining
in
let* known_protos = Shell_services.Protocol.list cctxt in
let* props =
get_proposals ~chain:cctxt#chain ~block:cctxt#block cctxt
in
let ranks =
Environment.Protocol_hash.Map.bindings props
|> List.sort (fun (_, v1) (_, v2) -> Int64.(compare v2 v1))
in
let print_proposal = function
| None ->
cctxt#message "The current proposal has already been cleared."
| Some proposal ->
cctxt#message "Current proposal: %a" Protocol_hash.pp proposal
in
match info.current_period_kind with
| Proposal ->
let*! () =
if info.remaining <> 0l then
cctxt#answer
"Current proposals:%t"
Format.(
fun ppf ->
pp_print_cut ppf () ;
pp_open_vbox ppf 0 ;
List.iter
(fun (p, w) ->
fprintf
ppf
"* %a %a %s (%sknown by the node)@."
Protocol_hash.pp
p
Tez.pp
(Tez.of_mutez_exn w)
Operation_result.tez_sym
(if
List.mem ~equal:Protocol_hash.equal p known_protos
then ""
else "not "))
ranks ;
pp_close_box ppf ())
else cctxt#message "The proposals have already been cleared."
in
return_unit
| Exploration | Promotion ->
let*! () = print_proposal info.current_proposal in
if info.remaining <> 0l then
let* ballots_info =
get_ballots_info ~chain:cctxt#chain ~block:cctxt#block cctxt
in
let*! () =
cctxt#answer
"@[<v>Ballots:@,\
\ Yay: %a %s@,\
\ Nay: %a %s@,\
\ Pass: %a %s@,\
Current participation %.2f%%, necessary quorum %.2f%%@,\
Current in favor %a %s, needed supermajority %a %s@]"
Tez.pp
(Tez.of_mutez_exn ballots_info.ballots.yay)
Operation_result.tez_sym
Tez.pp
(Tez.of_mutez_exn ballots_info.ballots.nay)
Operation_result.tez_sym
Tez.pp
(Tez.of_mutez_exn ballots_info.ballots.pass)
Operation_result.tez_sym
(Int32.to_float ballots_info.participation /. 100.)
(Int32.to_float ballots_info.current_quorum /. 100.)
Tez.pp
(Tez.of_mutez_exn ballots_info.ballots.yay)
Operation_result.tez_sym
Tez.pp
(Tez.of_mutez_exn ballots_info.supermajority)
Operation_result.tez_sym
in
return_unit
else
let*! () =
cctxt#message "The ballots have already been cleared."
in
return_unit
| Cooldown ->
let*! () = print_proposal info.current_proposal in
return_unit
| Adoption ->
let*! () = print_proposal info.current_proposal in
return_unit);
command
~group:binary_description
~desc:"Describe unsigned block header"
no_options
(fixed ["describe"; "unsigned"; "block"; "header"])
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let*! () =
cctxt#message
"%a"
Data_encoding.Binary_schema.pp
(Data_encoding.Binary.describe
Alpha_context.Block_header.unsigned_encoding)
in
return_unit);
command
~group:binary_description
~desc:"Describe unsigned operation"
no_options
(fixed ["describe"; "unsigned"; "operation"])
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let*! () =
cctxt#message
"%a"
Data_encoding.Binary_schema.pp
(Data_encoding.Binary.describe
Alpha_context.Operation.unsigned_encoding)
in
return_unit);
command
~group
~desc:"Get the frozen deposits limit of a delegate."
no_options
(prefixes ["get"; "deposits"; "limit"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source delegate"
@@ stop)
(fun () contract (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
match contract with
| Originated _ ->
cctxt#error
"Cannot change deposits limit on contract %a. This operation is \
invalid on originated contracts."
Contract.pp
contract
| Implicit delegate ->
let* o =
get_frozen_deposits_limit
cctxt
~chain:cctxt#chain
~block:cctxt#block
delegate
in
let*! () =
match o with
| None -> cctxt#answer "unlimited"
| Some limit ->
cctxt#answer "%a %s" Tez.pp limit Operation_result.tez_sym
in
return_unit);
]
let dry_run_switch =
Tezos_clic.switch
~long:"dry-run"
~short:'D'
~doc:"don't inject the operation, just display it"
()
let verbose_signing_switch =
Tezos_clic.switch
~long:"verbose-signing"
~doc:"display extra information before signing the operation"
()
let simulate_switch =
Tezos_clic.switch
~long:"simulation"
~doc:
"Simulate the execution of the command, without needing any signatures."
()
let force_switch =
Tezos_clic.switch
~long:"force"
~doc:
"Inject the operation even if the simulation results in a failure. This \
switch requires --gas-limit, --storage-limit, and --fee."
()
let transfer_command amount (source : Contract.t) destination
(cctxt : #Client_context.printer)
( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees,
successor_level ) =
let open Lwt_result_syntax in
let check_force_dependency name = function
| None ->
cctxt#error
"When the --force switch is used, the %s option is required."
name
| _ -> Lwt.return_unit
in
let*! () =
if force && not simulation then
let*! () = check_force_dependency "--gas-limit" gas_limit in
let*! () = check_force_dependency "--storage-limit" storage_limit in
check_force_dependency "--fee" fee
else Lwt.return_unit
in
let*! r =
match source with
| Originated contract_hash ->
let contract = source in
let* source =
Managed_contract.get_contract_manager cctxt contract_hash
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
Managed_contract.transfer
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~force
~fee_parameter
?fee
~contract
~source
~src_pk
~src_sk
~destination
?entrypoint
?arg
~amount
?gas_limit
?storage_limit
?counter
()
| Implicit source ->
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
transfer
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~simulation
~force
~verbose_signing
~fee_parameter
~source
?fee
~src_pk
~src_sk
~destination
?entrypoint
?arg
~amount
?gas_limit
?storage_limit
?counter
~replace_by_fees
~successor_level
()
in
let*! (_ : (_ Injection.result * Contract_hash.t list) option) =
report_michelson_errors
~no_print_source
~msg:"transfer simulation failed"
cctxt
r
in
return_unit
let prepare_batch_operation cctxt ?arg ?fee ?gas_limit ?storage_limit
?entrypoint (source : Contract.t) index batch =
let open Lwt_result_syntax in
let* destination =
Client_proto_contracts.ContractAlias.find_destination
cctxt
batch.destination
in
let* amount = tez_of_string_exn cctxt index "amount" batch.amount in
let* batch_fee = tez_of_opt_string_exn cctxt index "fee" batch.fee in
let fee = Option.either batch_fee fee in
let arg = Option.either batch.arg arg in
let gas_limit = Option.either batch.gas_limit gas_limit in
let storage_limit = Option.either batch.storage_limit storage_limit in
let entrypoint = Option.either batch.entrypoint entrypoint in
let* parameters = parse_arg_transfer arg in
let* operation =
match source with
| Originated _ ->
Managed_contract.build_transaction_operation
cctxt
~chain:cctxt#chain
~block:cctxt#block
~contract:source
~destination
?entrypoint
?arg
~amount
?fee
?gas_limit
?storage_limit
()
| Implicit _ ->
return
(build_transaction_operation
~amount
~parameters
?entrypoint
?fee
?gas_limit
?storage_limit
destination)
in
return (Annotated_manager_operation.Annotated_manager_operation operation)
let commands_network network () =
let open Tezos_clic in
match network with
| Some `Testnet | None ->
[
command
~group
~desc:"Register and activate an Alphanet/Zeronet faucet account."
(args2 (Secret_key.force_switch ()) encrypted_switch)
(prefixes ["activate"; "account"]
@@ Secret_key.fresh_alias_param @@ prefixes ["with"]
@@ Client_proto_args.json_encoded_param
~name:"activation_key"
~desc:
"Activate an Alphanet/Zeronet faucet account from the JSON \
(file or directly inlined)."
Client_proto_context.activation_key_encoding
@@ stop)
(fun (force, encrypted) name activation_key cctxt ->
let open Lwt_result_syntax in
let* name = Secret_key.of_fresh cctxt force name in
let* _res =
activate_account
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~encrypted
~force
activation_key
name
in
return_unit);
]
| Some `Mainnet ->
[
command
~group
~desc:"Activate a fundraiser account."
(args1 dry_run_switch)
(prefixes ["activate"; "fundraiser"; "account"]
@@ Public_key_hash.alias_param @@ prefixes ["with"]
@@ param
~name:"code"
(Tezos_clic.parameter (fun (cctxt : #Client_context.full) code ->
match
Blinded_public_key_hash.activation_code_of_hex code
with
| Some c -> Lwt_result_syntax.return c
| None -> cctxt#error "Hexadecimal parsing failure"))
~desc:"Activation code obtained from the Tezos foundation."
@@ stop)
(fun dry_run (name, _pkh) code cctxt ->
let open Lwt_result_syntax in
let* _res =
activate_existing_account
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
name
code
in
return_unit);
]
let commands_rw () =
let open Client_proto_programs in
let open Tezos_micheline in
let open Tezos_clic in
[
command
~group
~desc:"Set the delegate of a contract."
(args5
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args)
(prefixes ["set"; "delegate"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ prefix "to"
@@ Public_key_hash.source_param
~name:"dlgt"
~desc:"new delegate of the contract"
@@ stop)
(fun (fee, dry_run, verbose_signing, simulation, fee_parameter)
contract
delegate
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
match contract with
| Originated contract ->
let* source =
Managed_contract.get_contract_manager cctxt contract
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let*! errors =
Managed_contract.set_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~fee_parameter
?fee
~source
~src_pk
~src_sk
contract
(Some delegate)
in
let*! (_ :
(Operation_hash.t
* _ contents
* _ Apply_results.contents_result)
option) =
report_michelson_errors
~no_print_source:true
~msg:"Setting delegate through entrypoints failed."
cctxt
errors
in
return_unit
| Implicit mgr ->
let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in
let* (_ : _ Injection.result) =
set_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~fee_parameter
?fee
mgr
(Some delegate)
~src_pk
~manager_sk
in
return_unit);
command
~group
~desc:"Withdraw the delegate from a contract."
(args4 fee_arg dry_run_switch verbose_signing_switch fee_parameter_args)
(prefixes ["withdraw"; "delegate"; "from"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ stop)
(fun (fee, dry_run, verbose_signing, fee_parameter)
contract
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
match contract with
| Originated contract ->
let* source =
Managed_contract.get_contract_manager cctxt contract
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let*! errors =
Managed_contract.set_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~fee_parameter
?fee
~source
~src_pk
~src_sk
contract
None
in
let*! (_ : _ Injection.result option) =
report_michelson_errors
~no_print_source:true
~msg:"Withdrawing delegate through entrypoints failed."
cctxt
errors
in
return_unit
| Implicit mgr ->
let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in
let*! (_ : _ Injection.result tzresult) =
set_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~fee_parameter
mgr
None
?fee
~src_pk
~manager_sk
in
return_unit);
command
~group
~desc:"Launch a smart contract on the blockchain."
(args10
fee_arg
dry_run_switch
verbose_signing_switch
gas_limit_arg
storage_limit_arg
delegate_arg
(Client_keys.force_switch ())
init_arg
no_print_source_flag
fee_parameter_args)
(prefixes ["originate"; "contract"]
@@ RawContractAlias.fresh_alias_param
~name:"new"
~desc:"name of the new contract"
@@ prefix "transferring"
@@ tez_param ~name:"qty" ~desc:"amount taken from source"
@@ prefix "from"
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "running"
@@ Program.source_param
~name:"prg"
~desc:
"script of the account\n\
Combine with -init if the storage type is not unit."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
gas_limit,
storage_limit,
delegate,
force,
initial_storage,
no_print_source,
fee_parameter )
alias_name
balance
source
program
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* alias_name = RawContractAlias.of_fresh cctxt force alias_name in
let* {expanded = code; _} =
Lwt.return (Micheline_parser.no_parsing_error program)
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let*! errors =
originate_contract
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
?fee
?gas_limit
?storage_limit
~delegate
~initial_storage
~balance
~source
~src_pk
~src_sk
~code
~fee_parameter
()
in
let*! o =
report_michelson_errors
~no_print_source
~msg:"origination simulation failed"
cctxt
errors
in
match o with
| None -> return_unit
| Some (_res, contract) ->
if dry_run then return_unit
else save_contract ~force cctxt alias_name contract);
command
~group
~desc:
"Execute multiple transfers from a single source account.\n\
If one of the transfers fails, none of them get executed."
(args13
default_fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
force_switch
default_gas_limit_arg
default_storage_limit_arg
counter_arg
default_arg_arg
no_print_source_flag
fee_parameter_args
default_entrypoint_arg
replace_by_fees_arg)
(prefixes ["multiple"; "transfers"; "from"]
@@ ContractAlias.destination_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "using"
@@ json_encoded_param
~name:"transfers.json"
~desc:
"List of operations originating from the source contract in JSON \
format (from a file or directly inlined). The input JSON must be \
an array of objects of the form: '[ {\"destination\": dst, \
\"amount\": qty (, <field>: <val> ...) } (, ...) ]', where an \
optional <field> can either be \"fee\", \"gas-limit\", \
\"storage-limit\", \"arg\", or \"entrypoint\"."
~pp_error:(fun json fmt exn ->
match (json, exn) with
| `A lj, Data_encoding.Json.Cannot_destruct ([`Index n], exn) ->
Format.fprintf
fmt
"Invalid transfer at index %i: %a %a"
n
(fun ppf -> Data_encoding.Json.print_error ppf)
exn
(Format.pp_print_option Data_encoding.Json.pp)
(List.nth_opt lj n)
| _, (Data_encoding.Json.Cannot_destruct _ as exn) ->
Format.fprintf
fmt
"Invalid transfer file: %a %a"
(fun ppf -> Data_encoding.Json.print_error ppf)
exn
Data_encoding.Json.pp
json
| _, exn -> raise exn
)
(Data_encoding.list
Client_proto_context.batch_transfer_operation_encoding)
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees )
source
operations
cctxt ->
let open Lwt_result_syntax in
let check_force_dependency name = function
| None ->
cctxt#error
"When the --force switch is used, the %s option is required."
name
| _ -> Lwt.return_unit
in
let*! () =
if force && not simulation then
let*! () = check_force_dependency "--gas-limit" gas_limit in
let*! () = check_force_dependency "--storage-limit" storage_limit in
check_force_dependency "--fee" fee
else Lwt.return_unit
in
let prepare i =
prepare_batch_operation
cctxt
?arg
?fee
?gas_limit
?storage_limit
?entrypoint
source
i
in
match operations with
| [] -> cctxt#error "Empty operation list"
| operations ->
let* source =
match source with
| Originated contract ->
Managed_contract.get_contract_manager cctxt contract
| Implicit source -> return source
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* contents = List.mapi_ep prepare operations in
let (Manager_list contents) =
Annotated_manager_operation.manager_of_list contents
in
let*! errors =
Injection.inject_manager_operation
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~force
~source
~fee:(Limit.of_option fee)
~gas_limit:(Limit.of_option gas_limit)
~storage_limit:(Limit.of_option storage_limit)
?counter
~src_pk
~src_sk
~replace_by_fees
~fee_parameter
contents
in
let*! (_ :
(Operation_hash.t
* packed_operation
* _ contents_list
* _ Apply_results.contents_result_list)
option) =
report_michelson_errors
~no_print_source
~msg:"multiple transfers simulation failed"
cctxt
errors
in
return_unit);
command
~group
~desc:"Execute an Epoxy origination operation.\n"
(args13
force_switch
default_fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
default_gas_limit_arg
default_storage_limit_arg
counter_arg
default_arg_arg
no_print_source_flag
fee_parameter_args
default_entrypoint_arg
replace_by_fees_arg)
(prefixes ["originate"; "epoxy"]
@@ EpoxyAlias.fresh_alias_param
~name:"epoxy"
~desc:"Fresh name for an Epoxy rollup"
@@ prefix "from"
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "public_parameters"
@@ param
~name:"public_parameters"
~desc:"public_parameters"
Zk_rollup_params.plonk_public_parameters_parameter
@@ prefix "init_state"
@@ param
~name:"init_state"
~desc:"init_state"
Zk_rollup_params.state_parameter
@@ prefix "circuits_info"
@@ param
~name:"circuits_info"
~desc:"circuits_info"
Zk_rollup_params.circuits_info_parameter
@@ prefix "nb_ops"
@@ param ~name:"nb_ops" ~desc:"nb_ops" int_parameter
@@ stop)
(fun ( force,
fee,
dry_run,
verbose_signing,
simulation,
gas_limit,
storage_limit,
counter,
_arg,
_no_print_source,
fee_parameter,
_entrypoint,
_replace_by_fees )
alias
source
public_parameters
init_state
circuits_info
nb_ops
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _, _, res =
zk_rollup_originate
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?gas_limit
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~public_parameters
~circuits_info
~init_state
~nb_ops
()
in
let*? res =
match res with
| Apply_results.Manager_operation_result
{
operation_result =
Apply_operation_result.Applied
(Apply_results.Zk_rollup_origination_result
{originated_zk_rollup; _});
_;
} ->
Ok originated_zk_rollup
| _ -> error_with "Epoxy rollup was not correctly originated"
in
let* alias_name = EpoxyAlias.of_fresh cctxt force alias in
save_zk_rollup ~force cctxt alias_name res);
command
~group
~desc:"Execute an Epoxy publish operation.\n"
(args12
default_fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
default_gas_limit_arg
default_storage_limit_arg
counter_arg
default_arg_arg
no_print_source_flag
fee_parameter_args
default_entrypoint_arg
replace_by_fees_arg)
(prefixes ["epoxy"; "publish"; "from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "rollup"
@@ param ~name:"rollup" ~desc:"rollup" Zk_rollup_params.address_parameter
@@ prefix "ops"
@@ param ~name:"ops" ~desc:"ops" Zk_rollup_params.operations_parameter
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
gas_limit,
storage_limit,
counter,
_arg,
_no_print_source,
fee_parameter,
_entrypoint,
_replace_by_fees )
source
zk_rollup
ops
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
zk_rollup_publish
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?gas_limit
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~zk_rollup
~ops
()
in
return_unit);
command
~group
~desc:"Execute an Epoxy update operation.\n"
(args12
default_fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
default_gas_limit_arg
default_storage_limit_arg
counter_arg
default_arg_arg
no_print_source_flag
fee_parameter_args
default_entrypoint_arg
replace_by_fees_arg)
(prefixes ["epoxy"; "update"; "from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "rollup"
@@ param ~name:"rollup" ~desc:"rollup" Zk_rollup_params.address_parameter
@@ prefix "update"
@@ param ~name:"update" ~desc:"update" Zk_rollup_params.update_parameter
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
gas_limit,
storage_limit,
counter,
_arg,
_no_print_source,
fee_parameter,
_entrypoint,
_replace_by_fees )
source
zk_rollup
update
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
zk_rollup_update
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?gas_limit
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~zk_rollup
~update
()
in
return_unit);
command
~group
~desc:"Transfer tokens / call a smart contract."
(args14
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
force_switch
gas_limit_arg
storage_limit_arg
counter_arg
arg_arg
no_print_source_flag
fee_parameter_args
entrypoint_arg
replace_by_fees_arg
successor_level_arg)
(prefixes ["transfer"]
@@ tez_param ~name:"qty" ~desc:"amount taken from source"
@@ prefix "from"
@@ ContractAlias.destination_param
~name:"src"
~desc:"name of the source contract"
@@ prefix "to"
@@ ContractAlias.destination_param
~name:"dst"
~desc:"name/literal of the destination contract"
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees,
successor_level )
amount
source
destination
cctxt ->
transfer_command
amount
source
destination
cctxt
( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees,
successor_level ));
command
~group
~desc:"Register a global constant"
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
storage_limit_arg
counter_arg)
(prefixes ["register"; "global"; "constant"]
@@ global_constant_param
~name:"expression"
~desc:
"Michelson expression to register. Note the value is not \
typechecked before registration."
@@ prefix "from"
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the account registering the global constant"
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
storage_limit,
counter )
global_constant_str
source
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let*! errors =
register_global_constant
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~constant:global_constant_str
()
in
let*! (_ : _ Injection.result option) =
report_michelson_errors
~no_print_source:false
~msg:"register global constant simulation failed"
cctxt
errors
in
return_unit);
command
~group
~desc:"Call a smart contract (same as 'transfer 0')."
(args14
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
force_switch
gas_limit_arg
storage_limit_arg
counter_arg
arg_arg
no_print_source_flag
fee_parameter_args
entrypoint_arg
replace_by_fees_arg
successor_level_arg)
(prefixes ["call"]
@@ ContractAlias.destination_param
~name:"dst"
~desc:"name/literal of the destination contract"
@@ prefix "from"
@@ ContractAlias.destination_param
~name:"src"
~desc:"name of the source contract"
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees,
successor_level )
destination
source
cctxt ->
let amount = Tez.zero in
transfer_command
amount
source
destination
cctxt
( fee,
dry_run,
verbose_signing,
simulation,
force,
gas_limit,
storage_limit,
counter,
arg,
no_print_source,
fee_parameter,
entrypoint,
replace_by_fees,
successor_level ));
command
~group
~desc:"Reveal the public key of the contract manager."
(args4 fee_arg dry_run_switch verbose_signing_switch fee_parameter_args)
(prefixes ["reveal"; "key"; "for"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"name of the source contract"
@@ stop)
(fun (fee, dry_run, verbose_signing, fee_parameter) source cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
reveal
cctxt
~dry_run
~verbose_signing
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~source
?fee
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"Register the public key hash as a delegate."
(args4 fee_arg dry_run_switch verbose_signing_switch fee_parameter_args)
(prefixes ["register"; "key"]
@@ Public_key_hash.source_param ~name:"mgr" ~desc:"the delegate key"
@@ prefixes ["as"; "delegate"]
@@ stop)
(fun (fee, dry_run, verbose_signing, fee_parameter) src_pkh cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt src_pkh in
let*! r =
register_as_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~fee_parameter
~verbose_signing
?fee
~manager_sk:src_sk
src_pk
in
match r with
| Ok _ -> return_unit
| Error
[
Environment.Ecoproto_error
Delegate_storage.Contract.Active_delegate;
] ->
let*! () = cctxt#message "Delegate already activated." in
return_unit
| Error el -> Lwt.return_error el);
command
~group
~desc:"Register the public key hash as a delegate."
(args4 fee_arg dry_run_switch verbose_signing_switch fee_parameter_args)
(prefixes ["register"; "key"]
@@ Public_key_hash.source_param ~name:"mgr" ~desc:"the delegate key"
@@ prefixes ["as"; "delegate"; "with"; "consensus"; "key"]
@@ Public_key.source_param ~name:"key" ~desc:"the consensus key"
@@ stop)
(fun (fee, dry_run, verbose_signing, fee_parameter)
src_pkh
(name_pk, consensus_pk)
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt src_pkh in
let* consensus_pk =
match consensus_pk with
| Some pk -> return pk
| None -> Client_keys.public_key name_pk
in
let*! r =
register_as_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~fee_parameter
~verbose_signing
?fee
~manager_sk:src_sk
~consensus_pk
src_pk
in
match r with
| Ok _ -> return_unit
| Error
[
Environment.Ecoproto_error
Delegate_storage.Contract.Active_delegate;
] ->
let*! () = cctxt#message "Delegate already activated." in
return_unit
| Error el -> Lwt.return_error el);
command
~group
~desc:"Update the consensus key of a delegate."
(args4 fee_arg dry_run_switch verbose_signing_switch fee_parameter_args)
(prefixes ["set"; "consensus"; "key"; "for"]
@@ Public_key_hash.source_param ~name:"mgr" ~desc:"the delegate key"
@@ prefixes ["to"]
@@ Public_key.source_param ~name:"key" ~desc:"the consensus key"
@@ stop)
(fun (fee, dry_run, verbose_signing, fee_parameter)
delegate_pkh
(name_pk, consensus_pk)
cctxt ->
let open Lwt_result_syntax in
let* _, delegate_pk, delegate_sk =
Client_keys.get_key cctxt delegate_pkh
in
let* consensus_pk =
match consensus_pk with
| Some pk -> return pk
| None -> Client_keys.public_key name_pk
in
let*! r =
update_consensus_key
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~fee_parameter
~verbose_signing
?fee
~consensus_pk
~manager_sk:delegate_sk
delegate_pk
in
match r with Ok _ -> return_unit | Error el -> Lwt.return_error el);
command
~group
~desc:"Drain all funds from a delegate."
(args2 dry_run_switch verbose_signing_switch)
(prefixes ["drain"; "delegate"]
@@ Public_key_hash.source_param ~name:"mgr" ~desc:"the delegate key"
@@ prefixes ["to"]
@@ Public_key_hash.source_param ~name:"dest" ~desc:"the consensus key"
@@ stop)
(fun (dry_run, verbose_signing) delegate_pkh consensus_pkh cctxt ->
let open Lwt_result_syntax in
let* _, _consensus_pk, consensus_sk =
Client_keys.get_key cctxt consensus_pkh
in
let*! r =
drain_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~consensus_pkh
~consensus_sk
~delegate:delegate_pkh
()
in
match r with Ok _ -> return_unit | Error el -> Lwt.return_error el);
command
~group
~desc:"Drain all funds from a delegate."
(args2 dry_run_switch verbose_signing_switch)
(prefixes ["drain"; "delegate"]
@@ Public_key_hash.source_param ~name:"mgr" ~desc:"the delegate key"
@@ prefixes ["to"]
@@ Public_key_hash.source_param ~name:"dest" ~desc:"the destination key"
@@ prefixes ["with"]
@@ Public_key_hash.source_param
~name:"consensus_key"
~desc:"the consensus key"
@@ stop)
(fun (dry_run, verbose_signing)
delegate_pkh
destination_pkh
consensus_pkh
cctxt ->
let open Lwt_result_syntax in
let* _, _consensus_pk, consensus_sk =
Client_keys.get_key cctxt consensus_pkh
in
let*! r =
drain_delegate
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~consensus_pkh
~consensus_sk
~destination:destination_pkh
~delegate:delegate_pkh
()
in
match r with Ok _ -> return_unit | Error el -> Lwt.return_error el);
command
~desc:"Wait until an operation is included in a block"
(args3
(default_arg
~long:"confirmations"
~placeholder:"num_blocks"
~doc:
"wait until 'N' additional blocks after the operation appears in \
the considered chain"
~default:"0"
non_negative_parameter)
(default_arg
~long:"check-previous"
~placeholder:"num_blocks"
~doc:"number of previous blocks to check"
~default:"10"
non_negative_parameter)
(arg
~long:"branch"
~placeholder:"block_hash"
~doc:
"hash of the oldest block where we should look for the operation"
block_hash_param))
(prefixes ["wait"; "for"]
@@ param
~name:"operation"
~desc:"Operation to be included"
(parameter (fun (cctxt : #Client_context.full) x ->
match Operation_hash.of_b58check_opt x with
| None -> cctxt#error "Invalid operation hash: '%s'" x
| Some hash -> Lwt_result_syntax.return hash))
@@ prefixes ["to"; "be"; "included"]
@@ stop)
(fun (confirmations, predecessors, branch)
operation_hash
(ctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* (_ : Block_hash.t * int * int) =
Client_confirmations.wait_for_operation_inclusion
ctxt
~chain:ctxt#chain
~confirmations
~predecessors
?branch
operation_hash
in
return_unit);
command
~group
~desc:"Submit protocol proposals"
(args3
dry_run_switch
verbose_signing_switch
(switch
~doc:
"Do not fail when the checks that try to prevent the user from \
shooting themselves in the foot do fail."
~long:"force"
()))
(prefixes ["submit"; "proposals"; "for"]
@@ Client_keys.Public_key_hash.source_param
~name:"delegate"
~desc:"the delegate who makes the proposal"
@@ seq_of_param
(param
~name:"proposal"
~desc:"the protocol hash proposal to be submitted"
(parameter (fun (cctxt : #Client_context.full) x ->
match Protocol_hash.of_b58check_opt x with
| None -> cctxt#error "Invalid proposal hash: '%s'" x
| Some hash -> Lwt_result_syntax.return hash))))
(fun (dry_run, verbose_signing, force)
src_pkh
proposals
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* src_name, _src_pk, src_sk = Client_keys.get_key cctxt src_pkh in
let* info =
get_period_info
~successor:true
~chain:cctxt#chain
~block:cctxt#block
cctxt
in
let*! () =
match info.current_period_kind with
| Proposal -> Lwt.return_unit
| _ ->
(if force then cctxt#warning else cctxt#error)
"Not in a proposal period"
in
let* known_protos = Shell_services.Protocol.list cctxt in
let* known_proposals =
get_proposals ~chain:cctxt#chain ~block:cctxt#block cctxt
in
let* has_voting_power =
let*! r =
Alpha_services.Delegate.voting_power
cctxt
(cctxt#chain, cctxt#block)
src_pkh
in
match r with
| Ok voting_power -> return (voting_power <> 0L)
| Error
(Environment.Ecoproto_error (Delegate_services.Not_registered _)
:: _) ->
return false
| Error _ as err -> Lwt.return err
in
let check_proposals proposals : bool tzresult Lwt.t =
let errors = ref [] in
let error ppf =
Format.kasprintf (fun s -> errors := s :: !errors) ppf
in
if proposals = [] then error "Empty proposal list." ;
if
Compare.List_length_with.(
proposals > Constants.max_proposals_per_delegate)
then
error
"Too many proposals: %d > %d."
(List.length proposals)
Constants.max_proposals_per_delegate ;
(match
Base.List.find_all_dups ~compare:Protocol_hash.compare proposals
with
| [] -> ()
| dups ->
error
"There %s: %a."
(if Compare.List_length_with.(dups = 1) then
"is a duplicate proposal"
else "are duplicate proposals")
Format.(
pp_print_list
~pp_sep:(fun ppf () -> pp_print_string ppf ", ")
Protocol_hash.pp)
dups) ;
List.iter
(fun (p : Protocol_hash.t) ->
if
List.mem ~equal:Protocol_hash.equal p known_protos
|| Environment.Protocol_hash.Map.mem p known_proposals
then ()
else
error "Protocol %a is not a known proposal." Protocol_hash.pp p)
proposals ;
if not has_voting_power then
error
"Public-key-hash `%a` from account `%s` does not appear to have \
voting rights."
Signature.Public_key_hash.pp
src_pkh
src_name ;
if !errors <> [] then
let*! () =
cctxt#message
"There %s with the submission:%t"
(if Compare.List_length_with.(!errors = 1) then "is an issue"
else "are issues")
Format.(
fun ppf ->
pp_print_cut ppf () ;
pp_open_vbox ppf 0 ;
List.iter
(fun msg ->
pp_open_hovbox ppf 2 ;
pp_print_string ppf "* " ;
pp_print_text ppf msg ;
pp_close_box ppf () ;
pp_print_cut ppf ())
!errors ;
pp_close_box ppf ())
in
return_false
else return_true
in
let* all_valid = check_proposals proposals in
let*! () =
if all_valid then cctxt#message "All proposals are valid."
else if force then
cctxt#message
"Some proposals are not valid, but `--force` was used."
else cctxt#error "Submission failed because of invalid proposals."
in
let*! r =
submit_proposals
~dry_run
~verbose_signing
cctxt
~chain:cctxt#chain
~block:cctxt#block
~src_sk
src_pkh
proposals
in
match r with
| Ok _res -> return_unit
| Error errs ->
let*! () =
match errs with
| [
Unregistered_error
(`O [("kind", `String "generic"); ("error", `String msg)]);
] ->
cctxt#message
"Error:@[<hov>@.%a@]"
Format.pp_print_text
(String.split_on_char ' ' msg
|> List.filter (function "" | "\n" -> false | _ -> true)
|> String.concat " "
|> String.map (function '\n' | '\t' -> ' ' | c -> c))
| el -> cctxt#message "Error:@ %a" pp_print_trace el
in
cctxt#error "Failed to submit proposals");
command
~group
~desc:"Submit a ballot"
(args3
verbose_signing_switch
dry_run_switch
(switch
~doc:
"Do not fail when the checks that try to prevent the user from \
shooting themselves in the foot do fail."
~long:"force"
()))
(prefixes ["submit"; "ballot"; "for"]
@@ Client_keys.Public_key_hash.source_param
~name:"delegate"
~desc:"the delegate who votes"
@@ param
~name:"proposal"
~desc:"the protocol hash proposal to vote for"
(parameter (fun (cctxt : #Client_context.full) x ->
match Protocol_hash.of_b58check_opt x with
| None -> cctxt#error "Invalid proposal hash: '%s'" x
| Some hash -> Lwt_result_syntax.return hash))
@@ param
~name:"ballot"
~desc:
"the ballot value (yea, nay, or pass; yay is a deprecated synonym \
for yea)"
(parameter
~autocomplete:(fun _ ->
Lwt_result_syntax.return ["yea"; "nay"; "pass"])
(fun (cctxt : #Client_context.full) s ->
let open Lwt_result_syntax in
match String.lowercase_ascii s with
| "yay" | "yea" -> return Vote.Yay
| "nay" -> return Vote.Nay
| "pass" -> return Vote.Pass
| s -> cctxt#error "Invalid ballot: '%s'" s))
@@ stop)
(fun (verbose_signing, dry_run, force)
src_pkh
proposal
ballot
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* src_name, _src_pk, src_sk = Client_keys.get_key cctxt src_pkh in
let* info =
get_period_info
~successor:true
~chain:cctxt#chain
~block:cctxt#block
cctxt
in
let* current_proposal =
Alpha_services.Voting.current_proposal cctxt (cctxt#chain, cctxt#block)
in
let* () =
match (info.current_period_kind, current_proposal) with
| (Exploration | Promotion), Some current_proposal ->
if Protocol_hash.equal proposal current_proposal then return_unit
else
let*! () =
(if force then cctxt#warning else cctxt#error)
"Unexpected proposal, expected: %a"
Protocol_hash.pp
current_proposal
in
return_unit
| _ ->
let*! () =
(if force then cctxt#warning else cctxt#error)
"Not in Exploration or Promotion period"
in
return_unit
in
let* has_voting_power =
let*! r =
Alpha_services.Delegate.voting_power
cctxt
(cctxt#chain, cctxt#block)
src_pkh
in
match r with
| Ok voting_power -> return (voting_power <> 0L)
| Error
(Environment.Ecoproto_error (Delegate_services.Not_registered _)
:: _) ->
return false
| Error _ as err -> Lwt.return err
in
let*! () =
if has_voting_power then Lwt.return_unit
else
(if force then cctxt#warning else cctxt#error)
"Public-key-hash `%a` from account `%s` does not appear to have \
voting rights."
Signature.Public_key_hash.pp
src_pkh
src_name
in
let* _res =
submit_ballot
cctxt
~chain:cctxt#chain
~block:cctxt#block
~src_sk
src_pkh
~verbose_signing
~dry_run
proposal
ballot
in
return_unit);
command
~group
~desc:"Set the deposits limit of a registered delegate."
(args5
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args)
(prefixes ["set"; "deposits"; "limit"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ prefix "to"
@@ tez_param
~name:"deposits limit"
~desc:"the maximum amount of frozen deposits"
@@ stop)
(fun (fee, dry_run, verbose_signing, simulation, fee_parameter)
contract
limit
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
match contract with
| Originated _ ->
cctxt#error
"Cannot change deposits limit on contract %a. This operation is \
invalid on originated contracts or unregistered delegate \
contracts."
Contract.pp
contract
| Implicit mgr ->
let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in
let* (_ : _ Injection.result) =
set_deposits_limit
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~fee_parameter
?fee
mgr
~src_pk
~manager_sk
(Some limit)
in
return_unit);
command
~group
~desc:"Remove the deposits limit of a registered delegate."
(args5
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args)
(prefixes ["unset"; "deposits"; "limit"; "for"]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ stop)
(fun (fee, dry_run, verbose_signing, simulation, fee_parameter)
contract
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
match contract with
| Originated _ ->
cctxt#error
"Cannot change deposits limit on contract %a. This operation is \
invalid on originated contracts or unregistered delegate \
contracts."
Contract.pp
contract
| Implicit mgr ->
let* _, src_pk, manager_sk = Client_keys.get_key cctxt mgr in
let* (_ : _ Injection.result) =
set_deposits_limit
cctxt
~chain:cctxt#chain
~block:cctxt#block
?confirmations:cctxt#confirmations
~dry_run
~verbose_signing
~simulation
~fee_parameter
?fee
mgr
~src_pk
~manager_sk
None
in
return_unit);
command
~group
~desc:"Increase the paid storage of a smart contract."
(args6
force_switch
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args)
(prefixes ["increase"; "the"; "paid"; "storage"; "of"]
@@ OriginatedContractAlias.destination_param
~name:"contract"
~desc:"name of the smart contract"
@@ prefix "by"
@@ non_negative_z_param ~name:"amount" ~desc:"amount of increase in bytes"
@@ prefixes ["bytes"; "from"]
@@ Public_key_hash.source_param
~name:"payer"
~desc:"payer of the storage increase"
@@ stop)
(fun (force, fee, dry_run, verbose_signing, simulation, fee_parameter)
contract
amount_in_bytes
payer
(cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* _, src_pk, manager_sk = Client_keys.get_key cctxt payer in
let* (_ : _ Injection.result) =
increase_paid_storage
cctxt
~chain:cctxt#chain
~block:cctxt#block
~force
~dry_run
~verbose_signing
?fee
?confirmations:cctxt#confirmations
~simulation
~source:payer
~src_pk
~manager_sk
~destination:contract
~fee_parameter
~amount_in_bytes
()
in
return_unit);
command
~group
~desc:
"Transfer tickets from an implicit account to a contract or another \
implicit account."
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
storage_limit_arg
counter_arg)
(prefix "transfer"
@@ non_negative_z_param ~name:"qty" ~desc:"Amount of tickets to transfer."
@@ prefixes ["tickets"; "from"]
@@ Client_keys.Public_key_hash.source_param
~name:"tickets owner"
~desc:"Implicit account owning the tickets."
@@ prefix "to"
@@ ContractAlias.destination_param
~name:"recipient contract"
~desc:"Contract receiving the tickets."
@@ prefixes ["with"; "entrypoint"]
@@ Tezos_clic.param
~name:"entrypoint"
~desc:
"Entrypoint to use on the receiving contract or implicit account. \
Needs to be \"default\" for implicit account destinations."
entrypoint_parameter
@@ prefixes ["and"; "contents"]
@@ Tezos_clic.param
~name:"tickets content"
~desc:"Content of the tickets."
Client_proto_args.string_parameter
@@ prefixes ["and"; "type"]
@@ Tezos_clic.param
~name:"tickets type"
~desc:"Type of the tickets."
Client_proto_args.string_parameter
@@ prefixes ["and"; "ticketer"]
@@ ContractAlias.destination_param
~name:"tickets ticketer"
~desc:"Ticketer contract of the tickets."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
storage_limit,
counter )
amount
source
destination
entrypoint
contents
ty
ticketer
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
match Ticket_amount.of_zint amount with
| Some amount ->
let* _res =
transfer_ticket
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~contents
~ty
~ticketer
~amount
~destination
~entrypoint
()
in
return_unit
| None -> cctxt#error "ticket quantity should not be zero or negative");
command
~group
~desc:"Originate a new smart rollup."
(args8
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
storage_limit_arg
counter_arg
(Client_keys.force_switch ()))
(prefixes ["originate"; "smart"; "rollup"]
@@ SoruAlias.fresh_alias_param
~name:"alias"
~desc:"name of the new smart rollup"
@@ prefix "from"
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"Name of the account originating the smart rollup."
@@ prefixes ["of"; "kind"]
@@ param
~name:"smart_rollup_kind"
~desc:"Kind of the smart rollup to be originated."
Sc_rollup_params.rollup_kind_parameter
@@ prefixes ["of"; "type"]
@@ param
~name:"parameters_type"
~desc:
"The interface of the smart rollup including its entrypoints and \
their signatures."
data_parameter
@@ prefixes ["with"; "kernel"]
@@ param
~name:"kernel"
~desc:"The kernel for the smart rollup."
Sc_rollup_params.boot_sector_parameter
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
storage_limit,
counter,
force )
alias
source
kind
parameters_ty
boot_sector
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let (Packed (module R) as pvm) = Sc_rollup.Kind.pvm_of kind in
let Michelson_v1_parser.{expanded; _} = parameters_ty in
let parameters_ty = Script.lazy_expr expanded in
let* boot_sector = boot_sector pvm in
let* _, _, res =
sc_rollup_originate
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~kind
~boot_sector
~parameters_ty
()
in
match res with
| Apply_results.Manager_operation_result
{
operation_result =
Apply_operation_result.Applied
(Apply_results.Sc_rollup_originate_result
{address = rollup_address; _});
_;
} ->
let* alias = SoruAlias.of_fresh cctxt force alias in
let* () = SoruAlias.add ~force cctxt alias rollup_address in
let*! () =
cctxt#message
{|Smart rollup %a memorized as "%s"|}
Sc_rollup.Address.pp
rollup_address
alias
in
return_unit
| _ -> return_unit);
command
~group
~desc:"Send one or more messages to a smart rollup."
(args8
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
gas_limit_arg
storage_limit_arg
counter_arg)
(prefixes ["send"; "smart"; "rollup"; "message"]
@@ param
~name:"messages"
~desc:
"The message(s) to be sent to the rollup (syntax: \
bin:<path_to_binary_file>|text:<json list of raw string \
messages>|hex:<json list of hex-encoded \
messages>|file:<json_file>)."
Sc_rollup_params.messages_parameter
@@ prefixes ["from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"Name of the source contract."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
gas_limit,
storage_limit,
counter )
messages
source
cctxt ->
let open Lwt_result_syntax in
let* messages =
match messages with
| `Bin message -> return [message]
| `Json messages -> (
match Data_encoding.(Json.destruct (list string) messages) with
| exception _ ->
cctxt#error
"Could not read list of messages (expected list of bytes)"
| "raw" :: messages -> return messages
| "hex" :: messages ->
let* messages =
List.map_es
(fun message ->
match Hex.to_string (`Hex message) with
| None ->
cctxt#error
"'%s' is not a valid hex encoded message"
message
| Some msg -> return [msg])
messages
in
return @@ List.flatten messages
| _messages -> assert false)
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
sc_rollup_add_messages
cctxt
~chain:cctxt#chain
~block:cctxt#block
?dry_run:(Some dry_run)
?verbose_signing:(Some verbose_signing)
?fee
?gas_limit
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~messages
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"Publish a commitment for a smart rollup"
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
storage_limit_arg
counter_arg
fee_parameter_args)
(prefixes ["publish"; "commitment"]
@@ prefixes ["from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"Name of the source contract."
@@ prefixes ["for"; "smart"; "rollup"]
@@ Sc_rollup_params.sc_rollup_address_param
~desc:
"The address of the smart rollup where the commitment will be \
published."
@@ prefixes ["with"; "compressed"; "state"]
@@ param
~name:"compressed_state"
~desc:"The compressed state of the smart rollup for the commitment."
Sc_rollup_params.compressed_state_parameter
@@ prefixes ["at"; "inbox"; "level"]
@@ param
~name:"inbox_level"
~desc:"The inbox level for the commitment."
raw_level_parameter
@@ prefixes ["and"; "predecessor"]
@@ param
~name:"predecessor"
~desc:"The hash of the commitment's predecessor"
Sc_rollup_params.commitment_hash_parameter
@@ prefixes ["and"; "number"; "of"; "ticks"]
@@ param
~name:"number_of_ticks"
~desc:"The number of ticks for the commitment."
Sc_rollup_params.number_of_ticks_parameter
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
storage_limit,
counter,
fee_parameter )
source
rollup
compressed_state
inbox_level
predecessor
number_of_ticks
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let commitment : Alpha_context.Sc_rollup.Commitment.t =
{compressed_state; inbox_level; predecessor; number_of_ticks}
in
let* _res =
sc_rollup_publish
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~rollup
~commitment
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"Cement a commitment for a smart rollup."
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
storage_limit_arg
counter_arg
fee_parameter_args)
(prefixes ["cement"; "commitment"]
@@ param
~name:"commitment"
~desc:"The hash of the commitment to be cemented for a smart rollup."
Sc_rollup_params.commitment_hash_parameter
@@ prefixes ["from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"Name of the source contract."
@@ prefixes ["for"; "smart"; "rollup"]
@@ Sc_rollup_params.sc_rollup_address_param
~desc:
"The address of the smart rollup of which the commitment will be \
cemented."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
storage_limit,
counter,
fee_parameter )
commitment
source
rollup
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
sc_rollup_cement
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~rollup
~commitment
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"Timeout a staker from dispute on a smart rollup."
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
storage_limit_arg
counter_arg
fee_parameter_args)
(prefixes ["timeout"; "dispute"; "on"; "smart"; "rollup"]
@@ Sc_rollup_params.sc_rollup_address_param
~desc:
"The address of the smart rollup where the staker of the dispute \
has timed-out."
@@ prefixes ["with"]
@@ Client_keys.Public_key_hash.source_param
~name:"staker1"
~desc:"The staker that has timed out."
@@ prefixes ["against"]
@@ Client_keys.Public_key_hash.source_param
~name:"staker2"
~desc:"The opponent of this staker."
@@ prefixes ["from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"Name of the source contract."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
storage_limit,
counter,
fee_parameter )
rollup
staker1
staker2
source
cctxt ->
let open Lwt_result_syntax in
let* games =
Plugin.RPC.Sc_rollup.ongoing_refutation_games
cctxt
(cctxt#chain, cctxt#block)
rollup
staker1
in
let* alice, bob =
let* answer =
List.find_es
(fun (_, alice, bob) ->
let stakers = Sc_rollup.Game.Index.make staker1 staker2 in
return
Signature.Public_key_hash.(
alice = stakers.alice && bob = stakers.bob))
games
in
match answer with
| None ->
cctxt#error
"Couldn't find an ongoing dispute for this staker on this \
rollup."
| Some (_, alice, bob) -> return (alice, bob)
in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
sc_rollup_timeout
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~rollup
~alice
~bob
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"List originated smart rollups."
no_options
(prefixes ["list"; "smart"; "rollups"] @@ stop)
(fun () (cctxt : Protocol_client_context.full) ->
let open Lwt_result_syntax in
let* rollups =
Plugin.RPC.Sc_rollup.list cctxt (cctxt#chain, cctxt#block)
in
let*! () =
List.iter_s
(fun addr ->
cctxt#message "%s" (Sc_rollup.Address.to_b58check addr))
rollups
in
return_unit);
command
~group
~desc:
"Execute a message from a smart rollup's outbox of a cemented \
commitment."
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
storage_limit_arg
counter_arg)
(prefixes ["execute"; "outbox"; "message"; "of"; "smart"; "rollup"]
@@ Sc_rollup_params.sc_rollup_address_param
~desc:"The address of the smart rollup where the message resides."
@@ prefix "from"
@@ Client_keys.Public_key_hash.source_param
~name:"source"
~desc:"The account used for executing the outbox message."
@@ prefixes ["for"; "commitment"; "hash"]
@@ param
~name:"cemented commitment"
~desc:"The hash of the cemented commitment of the rollup."
Sc_rollup_params.commitment_hash_parameter
@@ prefixes ["and"; "output"; "proof"]
@@ param
~name:"output proof"
~desc:
"The output proof containing the outbox level, index and message."
bytes_parameter
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
storage_limit,
counter )
rollup
source
cemented_commitment
output_proof
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
sc_rollup_execute_outbox_message
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~rollup
~cemented_commitment
~output_proof:(Bytes.to_string output_proof)
~src_pk
~src_sk
~fee_parameter
()
in
return_unit);
command
~group
~desc:"Recover commitment bond from a smart rollup."
(args7
fee_arg
dry_run_switch
verbose_signing_switch
simulate_switch
fee_parameter_args
storage_limit_arg
counter_arg)
(prefixes ["recover"; "bond"; "of"]
@@ Client_keys.Public_key_hash.source_param
~name:"staker"
~desc:"The implicit account that owns the frozen bond."
@@ prefixes ["for"; "smart"; "rollup"]
@@ Sc_rollup_params.sc_rollup_address_param
~desc:"The address of the smart rollup of the bond."
@@ prefixes ["from"]
@@ Client_keys.Public_key_hash.source_param
~name:"src"
~desc:"The implicit account that triggers the operation."
@@ stop)
(fun ( fee,
dry_run,
verbose_signing,
simulation,
fee_parameter,
storage_limit,
counter )
staker
sc_rollup
source
cctxt ->
let open Lwt_result_syntax in
let* _, src_pk, src_sk = Client_keys.get_key cctxt source in
let* _res =
sc_rollup_recover_bond
cctxt
~chain:cctxt#chain
~block:cctxt#block
~dry_run
~verbose_signing
?fee
?storage_limit
?counter
?confirmations:cctxt#confirmations
~simulation
~source
~src_pk
~src_sk
~fee_parameter
~sc_rollup
~staker
()
in
return_unit);
]
let commands network () =
commands_rw () @ commands_network network () @ commands_ro ()