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
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

// This file was generated. Do not modify!
//
// To update this code, run: `cargo run --release -p diem-framework`.

//! Conversion library between a structured representation of a Move script call (`ScriptCall`) and the
//! standard BCS-compatible representation used in Diem transactions (`Script`).
//!
//! This code was generated by compiling known Script interfaces ("ABIs") with the tool `transaction-builder-generator`.

#![allow(clippy::unnecessary_wraps)]
#![allow(unused_imports)]
use diem_types::{
    account_address::AccountAddress,
    transaction::{Script, ScriptFunction, TransactionArgument, TransactionPayload, VecBytes},
};
use move_core_types::{
    ident_str,
    language_storage::{ModuleId, TypeTag},
};
use std::collections::BTreeMap as Map;

type Bytes = Vec<u8>;

/// Structured representation of a call into a known Move script.
/// ```ignore
/// impl ScriptCall {
///     pub fn encode(self) -> Script { .. }
///     pub fn decode(&Script) -> Option<ScriptCall> { .. }
/// }
/// ```
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum ScriptCall {
    /// # Summary
    /// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to
    /// send, receive, and hold `Diem::Diem<Currency>` coins. This transaction can be
    /// successfully sent by any account that is allowed to hold balances
    /// (e.g., VASP, Designated Dealer).
    ///
    /// # Technical Description
    /// After the successful execution of this transaction the sending account will have a
    /// `DiemAccount::Balance<Currency>` resource with zero balance published under it. Only
    /// accounts that can hold balances can send this transaction, the sending account cannot
    /// already have a `DiemAccount::Balance<Currency>` published under it.
    ///
    /// # Parameters
    /// | Name       | Type      | Description                                                                                                                                         |
    /// | ------     | ------    | -------------                                                                                                                                       |
    /// | `Currency` | Type      | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. |
    /// | `account`  | `&signer` | The signer of the sending account of the transaction.                                                                                               |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                             | Description                                                                |
    /// | ----------------            | --------------                           | -------------                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                  | The `Currency` is not a registered currency on-chain.                      |
    /// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances.                     |
    /// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY`   | A balance for `Currency` is already published under the sending `account`. |
    ///
    /// # Related Scripts
    /// * `Script::create_child_vasp_account`
    /// * `Script::create_parent_vasp_account`
    /// * `Script::peer_to_peer_with_metadata`
    AddCurrencyToAccount { currency: TypeTag },

    /// # Summary
    /// Stores the sending accounts ability to rotate its authentication key with a designated recovery
    /// account. Both the sending and recovery accounts need to belong to the same VASP and
    /// both be VASP accounts. After this transaction both the sending account and the
    /// specified recovery account can rotate the sender account's authentication key.
    ///
    /// # Technical Description
    /// Adds the `DiemAccount::KeyRotationCapability` for the sending account
    /// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under
    /// `recovery_address`. After this transaction has been executed successfully the account at
    /// `recovery_address` and the `to_recover_account` may rotate the authentication key of
    /// `to_recover_account` (the sender of this transaction).
    ///
    /// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key
    /// rotation capability, and must be a VASP account. The account at `recovery_address`
    /// must also be a VASP account belonging to the same VASP as the `to_recover_account`.
    /// Additionally the account at `recovery_address` must have already initialized itself as
    /// a recovery account address using the `Script::create_recovery_address` transaction script.
    ///
    /// The sending account's (`to_recover_account`) key rotation capability is
    /// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress`
    /// resource stored under the account at `recovery_address`.
    ///
    /// # Parameters
    /// | Name                 | Type      | Description                                                                                                |
    /// | ------               | ------    | -------------                                                                                              |
    /// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction.                                           |
    /// | `recovery_address`   | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                              | Description                                                                                       |
    /// | ----------------           | --------------                                            | -------------                                                                                     |
    /// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.    |
    /// | `Errors::NOT_PUBLISHED`    | `RecoveryAddress::ERECOVERY_ADDRESS`                      | `recovery_address` does not have a `RecoveryAddress` resource published under it.                 |
    /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION`       | `to_recover_account` and `recovery_address` do not belong to the same VASP.                       |
    /// | `Errors::LIMIT_EXCEEDED`   | ` RecoveryAddress::EMAX_KEYS_REGISTERED`                  | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. |
    ///
    /// # Related Scripts
    /// * `Script::create_recovery_address`
    /// * `Script::rotate_authentication_key_with_recovery_address`
    AddRecoveryRotationCapability { recovery_address: AccountAddress },

    /// # Summary
    /// Adds a validator account to the validator set, and triggers a
    /// reconfiguration of the system to admit the account to the validator set for the system. This
    /// transaction can only be successfully called by the Diem Root account.
    ///
    /// # Technical Description
    /// This script adds the account at `validator_address` to the validator set.
    /// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a
    /// reconfiguration. Once the reconfiguration triggered by this script's
    /// execution has been performed, the account at the `validator_address` is
    /// considered to be a validator in the network.
    ///
    /// This transaction script will fail if the `validator_address` address is already in the validator set
    /// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it.
    ///
    /// # Parameters
    /// | Name                | Type         | Description                                                                                                                        |
    /// | ------              | ------       | -------------                                                                                                                      |
    /// | `dr_account`        | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer.                                    |
    /// | `sliding_nonce`     | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                         |
    /// | `validator_name`    | `vector<u8>` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. |
    /// | `validator_address` | `address`    | The validator account address to be added to the validator set.                                                                    |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                                                               |
    /// | ----------------           | --------------                                | -------------                                                                                                                             |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                | A `SlidingNonce` resource is not published under `dr_account`.                                                                            |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.                                                |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                | The `sliding_nonce` is too far in the future.                                                                                             |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`       | The `sliding_nonce` has been previously recorded.                                                                                         |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                  | The sending account is not the Diem Root account.                                                                                        |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::EDIEM_ROOT`                          | The sending account is not the Diem Root account.                                                                                        |
    /// | 0                          | 0                                             | The provided `validator_name` does not match the already-recorded human name for the validator.                                           |
    /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. |
    /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR`           | The `validator_address` account is already a registered validator.                                                                        |
    /// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`            | An invalid time value was encountered in reconfiguration. Unlikely to occur.                                                              |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::register_validator_config`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    AddValidatorAndReconfigure {
        sliding_nonce: u64,
        validator_name: Bytes,
        validator_address: AccountAddress,
    },

    /// # Summary
    /// Burns all coins held in the preburn resource at the specified
    /// preburn address and removes them from the system. The sending account must
    /// be the Treasury Compliance account.
    /// The account that holds the preburn resource will normally be a Designated
    /// Dealer, but there are no enforced requirements that it be one.
    ///
    /// # Technical Description
    /// This transaction permanently destroys all the coins of `Token` type
    /// stored in the `Diem::Preburn<Token>` resource published under the
    /// `preburn_address` account address.
    ///
    /// This transaction will only succeed if the sending `account` has a
    /// `Diem::BurnCapability<Token>`, and a `Diem::Preburn<Token>` resource
    /// exists under `preburn_address`, with a non-zero `to_burn` field. After the successful execution
    /// of this transaction the `total_value` field in the
    /// `Diem::CurrencyInfo<Token>` resource published under `0xA550C18` will be
    /// decremented by the value of the `to_burn` field of the preburn resource
    /// under `preburn_address` immediately before this transaction, and the
    /// `to_burn` field of the preburn resource will have a zero value.
    ///
    /// ## Events
    /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle
    /// held in the `Diem::CurrencyInfo<Token>` resource's `burn_events` published under
    /// `0xA550C18`.
    ///
    /// # Parameters
    /// | Name              | Type      | Description                                                                                                                  |
    /// | ------            | ------    | -------------                                                                                                                |
    /// | `Token`           | Type      | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain.                |
    /// | `tc_account`      | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. |
    /// | `sliding_nonce`   | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                   |
    /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held.                                                                 |
    ///
    /// # Common Abort Conditions
    /// | Error Category                | Error Reason                            | Description                                                                                           |
    /// | ----------------              | --------------                          | -------------                                                                                         |
    /// | `Errors::NOT_PUBLISHED`       | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `account`.                                           |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.            |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                                         |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                                     |
    /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY`               | The sending `account` does not have a `Diem::BurnCapability<Token>` published under it.              |
    /// | `Errors::NOT_PUBLISHED`       | `Diem::EPREBURN`                       | The account at `preburn_address` does not have a `Diem::Preburn<Token>` resource published under it. |
    /// | `Errors::INVALID_STATE`       | `Diem::EPREBURN_EMPTY`                 | The `Diem::Preburn<Token>` resource is empty (has a value of 0).                                     |
    /// | `Errors::NOT_PUBLISHED`       | `Diem::ECURRENCY_INFO`                 | The specified `Token` is not a registered currency on-chain.                                          |
    ///
    /// # Related Scripts
    /// * `Script::burn_txn_fees`
    /// * `Script::cancel_burn`
    /// * `Script::preburn`
    Burn {
        token: TypeTag,
        sliding_nonce: u64,
        preburn_address: AccountAddress,
    },

    /// # Summary
    /// Burns the transaction fees collected in the `CoinType` currency so that the
    /// Diem association may reclaim the backing coins off-chain. May only be sent
    /// by the Treasury Compliance account.
    ///
    /// # Technical Description
    /// Burns the transaction fees collected in `CoinType` so that the
    /// association may reclaim the backing coins. Once this transaction has executed
    /// successfully all transaction fees that will have been collected in
    /// `CoinType` since the last time this script was called with that specific
    /// currency. Both `balance` and `preburn` fields in the
    /// `TransactionFee::TransactionFee<CoinType>` resource published under the `0xB1E55ED`
    /// account address will have a value of 0 after the successful execution of this script.
    ///
    /// ## Events
    /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle
    /// held in the `Diem::CurrencyInfo<CoinType>` resource's `burn_events` published under
    /// `0xA550C18`.
    ///
    /// # Parameters
    /// | Name         | Type      | Description                                                                                                                                         |
    /// | ------       | ------    | -------------                                                                                                                                       |
    /// | `CoinType`   | Type      | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. |
    /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                           |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                          | Description                                                 |
    /// | ----------------           | --------------                        | -------------                                               |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. |
    /// | `Errors::NOT_PUBLISHED`    | `TransactionFee::ETRANSACTION_FEE`    | `CoinType` is not an accepted transaction fee currency.     |
    /// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN`                        | The collected fees in `CoinType` are zero.                  |
    ///
    /// # Related Scripts
    /// * `Script::burn`
    /// * `Script::cancel_burn`
    BurnTxnFees { coin_type: TypeTag },

    /// # Summary
    /// Cancels and returns all coins held in the preburn area under
    /// `preburn_address` and returns the funds to the `preburn_address`'s balance.
    /// Can only be successfully sent by an account with Treasury Compliance role.
    ///
    /// # Technical Description
    /// Cancels and returns all coins held in the `Diem::Preburn<Token>` resource under the `preburn_address` and
    /// return the funds to the `preburn_address` account's `DiemAccount::Balance<Token>`.
    /// The transaction must be sent by an `account` with a `Diem::BurnCapability<Token>`
    /// resource published under it. The account at `preburn_address` must have a
    /// `Diem::Preburn<Token>` resource published under it, and its value must be nonzero. The transaction removes
    /// the entire balance held in the `Diem::Preburn<Token>` resource, and returns it back to the account's
    /// `DiemAccount::Balance<Token>` under `preburn_address`. Due to this, the account at
    /// `preburn_address` must already have a balance in the `Token` currency published
    /// before this script is called otherwise the transaction will fail.
    ///
    /// ## Events
    /// The successful execution of this transaction will emit:
    /// * A `Diem::CancelBurnEvent` on the event handle held in the `Diem::CurrencyInfo<Token>`
    /// resource's `burn_events` published under `0xA550C18`.
    /// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s
    /// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee`
    /// being `preburn_address`.
    ///
    /// # Parameters
    /// | Name              | Type      | Description                                                                                                                          |
    /// | ------            | ------    | -------------                                                                                                                        |
    /// | `Token`           | Type      | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. |
    /// | `account`         | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it.         |
    /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held.                                                                         |
    ///
    /// # Common Abort Conditions
    /// | Error Category                | Error Reason                                     | Description                                                                                           |
    /// | ----------------              | --------------                                   | -------------                                                                                         |
    /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY`                        | The sending `account` does not have a `Diem::BurnCapability<Token>` published under it.              |
    /// | `Errors::NOT_PUBLISHED`       | `Diem::EPREBURN`                                | The account at `preburn_address` does not have a `Diem::Preburn<Token>` resource published under it. |
    /// | `Errors::NOT_PUBLISHED`       | `Diem::ECURRENCY_INFO`                          | The specified `Token` is not a registered currency on-chain.                                          |
    /// | `Errors::INVALID_ARGUMENT`    | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO`            | The value held in the preburn resource was zero.                                                      |
    /// | `Errors::INVALID_ARGUMENT`    | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`.                         |
    /// | `Errors::LIMIT_EXCEEDED`      | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`          | The depositing of the funds held in the prebun area would exceed the `account`'s account limits.      |
    /// | `Errors::INVALID_STATE`       | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed.     |
    ///
    /// # Related Scripts
    /// * `Script::burn_txn_fees`
    /// * `Script::burn`
    /// * `Script::preburn`
    CancelBurn {
        token: TypeTag,
        preburn_address: AccountAddress,
    },

    /// # Summary
    /// Creates a Child VASP account with its parent being the sending account of the transaction.
    /// The sender of the transaction must be a Parent VASP account.
    ///
    /// # Technical Description
    /// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of
    /// `child_initial_balance` in `CoinType` and an initial authentication key of
    /// `auth_key_prefix | child_address`.
    ///
    /// If `add_all_currencies` is true, the child address will have a zero balance in all available
    /// currencies in the system.
    ///
    /// The new account will be a child account of the transaction sender, which must be a
    /// Parent VASP account. The child account will be recorded against the limit of
    /// child accounts of the creating Parent VASP account.
    ///
    /// ## Events
    /// Successful execution with a `child_initial_balance` greater than zero will emit:
    /// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address,
    /// and payee field being `child_address`. This is emitted on the Parent VASP's
    /// `DiemAccount::DiemAccount` `sent_events` handle.
    /// * A `DiemAccount::ReceivedPaymentEvent` with the  `payer` field being the Parent VASP's address,
    /// and payee field being `child_address`. This is emitted on the new Child VASPS's
    /// `DiemAccount::DiemAccount` `received_events` handle.
    ///
    /// # Parameters
    /// | Name                    | Type         | Description                                                                                                                                 |
    /// | ------                  | ------       | -------------                                                                                                                               |
    /// | `CoinType`              | Type         | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. |
    /// | `parent_vasp`           | `&signer`    | The signer reference of the sending account. Must be a Parent VASP account.                                                                 |
    /// | `child_address`         | `address`    | Address of the to-be-created Child VASP account.                                                                                            |
    /// | `auth_key_prefix`       | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                    |
    /// | `add_all_currencies`    | `bool`       | Whether to publish balance resources for all known currencies when the account is created.                                                  |
    /// | `child_initial_balance` | `u64`        | The initial balance in `CoinType` to give the child account when it's created.                                                              |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                                             | Description                                                                              |
    /// | ----------------            | --------------                                           | -------------                                                                            |
    /// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`            | The `auth_key_prefix` was not of length 32.                                              |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::EPARENT_VASP`                                    | The sending account wasn't a Parent VASP account.                                        |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                                        | The `child_address` address is already taken.                                            |
    /// | `Errors::LIMIT_EXCEEDED`    | `VASP::ETOO_MANY_CHILDREN`                               | The sending account has reached the maximum number of allowed child accounts.            |
    /// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                                  | The `CoinType` is not a registered currency on-chain.                                    |
    /// | `Errors::INVALID_STATE`     | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted.            |
    /// | `Errors::NOT_PUBLISHED`     | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`              | The sending account doesn't have a balance in `CoinType`.                                |
    /// | `Errors::LIMIT_EXCEEDED`    | `DiemAccount::EINSUFFICIENT_BALANCE`                    | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. |
    /// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED`            | The `child_address` is the reserved address 0x0.                                         |
    ///
    /// # Related Scripts
    /// * `Script::create_parent_vasp_account`
    /// * `Script::add_currency_to_account`
    /// * `Script::rotate_authentication_key`
    /// * `Script::add_recovery_rotation_capability`
    /// * `Script::create_recovery_address`
    CreateChildVaspAccount {
        coin_type: TypeTag,
        child_address: AccountAddress,
        auth_key_prefix: Bytes,
        add_all_currencies: bool,
        child_initial_balance: u64,
    },

    /// # Summary
    /// Creates a Designated Dealer account with the provided information, and initializes it with
    /// default mint tiers. The transaction can only be sent by the Treasury Compliance account.
    ///
    /// # Technical Description
    /// Creates an account with the Designated Dealer role at `addr` with authentication key
    /// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true,
    /// 0 balances for all available currencies in the system will also be added. This can only be
    /// invoked by an account with the TreasuryCompliance role.
    ///
    /// At the time of creation the account is also initialized with default mint tiers of (500_000,
    /// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the
    /// account.
    ///
    /// # Parameters
    /// | Name                 | Type         | Description                                                                                                                                         |
    /// | ------               | ------       | -------------                                                                                                                                       |
    /// | `Currency`           | Type         | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. |
    /// | `tc_account`         | `&signer`    | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                           |
    /// | `sliding_nonce`      | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                                          |
    /// | `addr`               | `address`    | Address of the to-be-created Designated Dealer account.                                                                                             |
    /// | `auth_key_prefix`    | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                            |
    /// | `human_name`         | `vector<u8>` | ASCII-encoded human name for the Designated Dealer.                                                                                                 |
    /// | `add_all_currencies` | `bool`       | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created.         |
    ///

    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::ETREASURY_COMPLIANCE`           | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                 | The `Currency` is not a registered currency on-chain.                                      |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `addr` address is already taken.                                                       |
    ///
    /// # Related Scripts
    /// * `Script::tiered_mint`
    /// * `Script::peer_to_peer_with_metadata`
    /// * `Script::rotate_dual_attestation_info`
    CreateDesignatedDealer {
        currency: TypeTag,
        sliding_nonce: u64,
        addr: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
        add_all_currencies: bool,
    },

    /// # Summary
    /// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account.
    ///
    /// # Technical Description
    /// Creates an account with the Parent VASP role at `address` with authentication key
    /// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If
    /// `add_all_currencies` is true, 0 balances for all available currencies in the system will
    /// also be added. This can only be invoked by an TreasuryCompliance account.
    /// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details.
    ///
    /// # Parameters
    /// | Name                  | Type         | Description                                                                                                                                                    |
    /// | ------                | ------       | -------------                                                                                                                                                  |
    /// | `CoinType`            | Type         | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. |
    /// | `tc_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                                      |
    /// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                                                     |
    /// | `new_account_address` | `address`    | Address of the to-be-created Parent VASP account.                                                                                                              |
    /// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                                       |
    /// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the Parent VASP.                                                                                                                  |
    /// | `add_all_currencies`  | `bool`       | Whether to publish balance resources for all known currencies when the account is created.                                                                     |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::ETREASURY_COMPLIANCE`           | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                 | The `CoinType` is not a registered currency on-chain.                                      |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
    ///
    /// # Related Scripts
    /// * `Script::create_child_vasp_account`
    /// * `Script::add_currency_to_account`
    /// * `Script::rotate_authentication_key`
    /// * `Script::add_recovery_rotation_capability`
    /// * `Script::create_recovery_address`
    /// * `Script::rotate_dual_attestation_info`
    CreateParentVaspAccount {
        coin_type: TypeTag,
        sliding_nonce: u64,
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
        add_all_currencies: bool,
    },

    /// # Summary
    /// Initializes the sending account as a recovery address that may be used by
    /// the VASP that it belongs to. The sending account must be a VASP account.
    /// Multiple recovery addresses can exist for a single VASP, but accounts in
    /// each must be disjoint.
    ///
    /// # Technical Description
    /// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then
    /// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds
    /// it to the resource. After the successful execution of this transaction
    /// other accounts may add their key rotation to this resource so that `account`
    /// may be used as a recovery account for those accounts.
    ///
    /// # Parameters
    /// | Name      | Type      | Description                                           |
    /// | ------    | ------    | -------------                                         |
    /// | `account` | `&signer` | The signer of the sending account of the transaction. |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                                               | Description                                                                                   |
    /// | ----------------            | --------------                                             | -------------                                                                                 |
    /// | `Errors::INVALID_STATE`     | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.          |
    /// | `Errors::INVALID_ARGUMENT`  | `RecoveryAddress::ENOT_A_VASP`                             | `account` is not a VASP account.                                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE`          | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. |
    /// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS`                       | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`.     |
    ///
    /// # Related Scripts
    /// * `Script::add_recovery_rotation_capability`
    /// * `Script::rotate_authentication_key_with_recovery_address`
    CreateRecoveryAddress {},

    /// # Summary
    /// Creates a Validator account. This transaction can only be sent by the Diem
    /// Root account.
    ///
    /// # Technical Description
    /// Creates an account with a Validator role at `new_account_address`, with authentication key
    /// `auth_key_prefix` | `new_account_address`. It publishes a
    /// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and
    /// `operator_account` fields. The `human_name` field of the
    /// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`.
    /// This script does not add the validator to the validator set or the system,
    /// but only creates the account.
    ///
    /// # Parameters
    /// | Name                  | Type         | Description                                                                                     |
    /// | ------                | ------       | -------------                                                                                   |
    /// | `dr_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer. |
    /// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                      |
    /// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                                 |
    /// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.        |
    /// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                                     |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
    ///
    /// # Related Scripts
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::create_validator_operator_account`
    /// * `Script::register_validator_config`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    CreateValidatorAccount {
        sliding_nonce: u64,
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
    },

    /// # Summary
    /// Creates a Validator Operator account. This transaction can only be sent by the Diem
    /// Root account.
    ///
    /// # Technical Description
    /// Creates an account with a Validator Operator role at `new_account_address`, with authentication key
    /// `auth_key_prefix` | `new_account_address`. It publishes a
    /// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`.
    /// This script does not assign the validator operator to any validator accounts but only creates the account.
    ///
    /// # Parameters
    /// | Name                  | Type         | Description                                                                                     |
    /// | ------                | ------       | -------------                                                                                   |
    /// | `dr_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer. |
    /// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                      |
    /// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                                 |
    /// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.        |
    /// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                                     |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::register_validator_config`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    CreateValidatorOperatorAccount {
        sliding_nonce: u64,
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
    },

    /// # Summary
    /// Freezes the account at `address`. The sending account of this transaction
    /// must be the Treasury Compliance account. The account being frozen cannot be
    /// the Diem Root or Treasury Compliance account. After the successful
    /// execution of this transaction no transactions may be sent from the frozen
    /// account, and the frozen account may not send or receive coins.
    ///
    /// # Technical Description
    /// Sets the `AccountFreezing::FreezingBit` to `true` and emits a
    /// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the
    /// Treasury Compliance account, but the account at `to_freeze_account` must
    /// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the
    /// Treasury Compliance address). Note that this is a per-account property
    /// e.g., freezing a Parent VASP will not effect the status any of its child
    /// accounts and vice versa.
    ///

    /// ## Events
    /// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on
    /// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published
    /// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`.
    ///
    /// # Parameters
    /// | Name                | Type      | Description                                                                                               |
    /// | ------              | ------    | -------------                                                                                             |
    /// | `tc_account`        | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
    /// | `sliding_nonce`     | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
    /// | `to_freeze_account` | `address` | The account address to be frozen.                                                                         |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                 | Description                                                                                |
    /// | ----------------           | --------------                               | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`               | A `SlidingNonce` resource is not published under `tc_account`.                             |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`               | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`               | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`      | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`        | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::ETREASURY_COMPLIANCE`                | The sending account is not the Treasury Compliance account.                                |
    /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC`         | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`).                     |
    /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`).                              |
    ///
    /// # Related Scripts
    /// * `Script::unfreeze_account`
    FreezeAccount {
        sliding_nonce: u64,
        to_freeze_account: AccountAddress,
    },

    /// # Summary
    /// Transfers a given number of coins in a specified currency from one account to another.
    /// Transfers over a specified amount defined on-chain that are between two different VASPs, or
    /// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has
    /// agreed to receive the coins.  This transaction can be sent by any account that can hold a
    /// balance, and to any account that can hold a balance. Both accounts must hold balances in the
    /// currency being transacted.
    ///
    /// # Technical Description
    ///
    /// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated
    /// `metadata` and an (optional) `metadata_signature` on the message
    /// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`.
    /// The `metadata` and `metadata_signature` parameters are only required if `amount` >=
    /// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs.
    /// However, a transaction sender can opt in to dual attestation even when it is not required
    /// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`.
    /// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`.
    ///
    /// ## Events
    /// Successful execution of this script emits two events:
    /// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and
    /// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle.
    ///
    /// # Parameters
    /// | Name                 | Type         | Description                                                                                                                  |
    /// | ------               | ------       | -------------                                                                                                                |
    /// | `Currency`           | Type         | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. |
    /// | `payer`              | `&signer`    | The signer reference of the sending account that coins are being transferred from.                                           |
    /// | `payee`              | `address`    | The address of the account the coins are being transferred to.                                                               |
    /// | `metadata`           | `vector<u8>` | Optional metadata about this payment.                                                                                        |
    /// | `metadata_signature` | `vector<u8>` | Optional signature over `metadata` and payment information. See                                                              |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                     | Description                                                                                                                         |
    /// | ----------------           | --------------                                   | -------------                                                                                                                       |
    /// | `Errors::NOT_PUBLISHED`    | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`      | `payer` doesn't hold a balance in `Currency`.                                                                                       |
    /// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EINSUFFICIENT_BALANCE`            | `amount` is greater than `payer`'s balance in `Currency`.                                                                           |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO`            | `amount` is zero.                                                                                                                   |
    /// | `Errors::NOT_PUBLISHED`    | `DiemAccount::EPAYEE_DOES_NOT_EXIST`            | No account exists at the `payee` address.                                                                                           |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`.                                                        |
    /// | `Errors::INVALID_STATE`    | `AccountFreezing::EACCOUNT_FROZEN`               | The `payee` account is frozen.                                                                                                      |
    /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes.                                                                                               |
    /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE`   | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. |
    /// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS`       | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX.                                                      |
    /// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`          | `payee` has exceeded its daily deposit limits for XDX.                                                                              |
    ///
    /// # Related Scripts
    /// * `Script::create_child_vasp_account`
    /// * `Script::create_parent_vasp_account`
    /// * `Script::add_currency_to_account`
    PeerToPeerWithMetadata {
        currency: TypeTag,
        payee: AccountAddress,
        amount: u64,
        metadata: Bytes,
        metadata_signature: Bytes,
    },

    /// # Summary
    /// Moves a specified number of coins in a given currency from the account's
    /// balance to its preburn area after which the coins may be burned. This
    /// transaction may be sent by any account that holds a balance and preburn area
    /// in the specified currency.
    ///
    /// # Technical Description
    /// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s
    /// `DiemAccount::Balance<Token>` to the `Diem::Preburn<Token>` published under the same
    /// `account`. `account` must have both of these resources published under it at the start of this
    /// transaction in order for it to execute successfully.
    ///
    /// ## Events
    /// Successful execution of this script emits two events:
    /// * `DiemAccount::SentPaymentEvent ` on `account`'s `DiemAccount::DiemAccount` `sent_events`
    /// handle with the `payee` and `payer` fields being `account`'s address; and
    /// * A `Diem::PreburnEvent` with `Token`'s currency code on the
    /// `Diem::CurrencyInfo<Token`'s `preburn_events` handle for `Token` and with
    /// `preburn_address` set to `account`'s address.
    ///
    /// # Parameters
    /// | Name      | Type      | Description                                                                                                                      |
    /// | ------    | ------    | -------------                                                                                                                    |
    /// | `Token`   | Type      | The Move type for the `Token` currency being moved to the preburn area. `Token` must be an already-registered currency on-chain. |
    /// | `account` | `&signer` | The signer reference of the sending account.                                                                                     |
    /// | `amount`  | `u64`     | The amount in `Token` to be moved to the preburn area.                                                                           |
    ///
    /// # Common Abort Conditions
    /// | Error Category           | Error Reason                                             | Description                                                                             |
    /// | ----------------         | --------------                                           | -------------                                                                           |
    /// | `Errors::NOT_PUBLISHED`  | `Diem::ECURRENCY_INFO`                                  | The `Token` is not a registered currency on-chain.                                      |
    /// | `Errors::INVALID_STATE`  | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for `account` has already been extracted.                     |
    /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE`                    | `amount` is greater than `payer`'s balance in `Token`.                                  |
    /// | `Errors::NOT_PUBLISHED`  | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`              | `account` doesn't hold a balance in `Token`.                                            |
    /// | `Errors::NOT_PUBLISHED`  | `Diem::EPREBURN`                                        | `account` doesn't have a `Diem::Preburn<Token>` resource published under it.           |
    /// | `Errors::INVALID_STATE`  | `Diem::EPREBURN_OCCUPIED`                               | The `value` field in the `Diem::Preburn<Token>` resource under the sender is non-zero. |
    /// | `Errors::NOT_PUBLISHED`  | `Roles::EROLE_ID`                                        | The `account` did not have a role assigned to it.                                       |
    /// | `Errors::REQUIRES_ROLE`  | `Roles::EDESIGNATED_DEALER`                              | The `account` did not have the role of DesignatedDealer.                                |
    ///
    /// # Related Scripts
    /// * `Script::cancel_burn`
    /// * `Script::burn`
    /// * `Script::burn_txn_fees`
    Preburn { token: TypeTag, amount: u64 },

    /// # Summary
    /// Rotates the authentication key of the sending account to the
    /// newly-specified public key and publishes a new shared authentication key
    /// under the sender's account. Any account can send this transaction.
    ///
    /// # Technical Description
    /// Rotates the authentication key of the sending account to `public_key`,
    /// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource
    /// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for
    /// `account` under `account`.
    ///
    /// # Parameters
    /// | Name         | Type         | Description                                                                               |
    /// | ------       | ------       | -------------                                                                             |
    /// | `account`    | `&signer`    | The signer reference of the sending account of the transaction.                           |
    /// | `public_key` | `vector<u8>` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                                               | Description                                                                                         |
    /// | ----------------            | --------------                                             | -------------                                                                                       |
    /// | `Errors::INVALID_STATE`     | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource.       |
    /// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY`                      | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. |
    /// | `Errors::INVALID_ARGUMENT`  | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY`            | `public_key` is an invalid ed25519 public key.                                                      |
    ///
    /// # Related Scripts
    /// * `Script::rotate_shared_ed25519_public_key`
    PublishSharedEd25519PublicKey { public_key: Bytes },

    /// # Summary
    /// Updates a validator's configuration. This does not reconfigure the system and will not update
    /// the configuration in the validator set that is seen by other validators in the network. Can
    /// only be successfully sent by a Validator Operator account that is already registered with a
    /// validator.
    ///
    /// # Technical Description
    /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig`
    /// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent`
    /// so the copy of this config held in the validator set will not be updated, and the changes are
    /// only "locally" under the `validator_account` account address.
    ///
    /// # Parameters
    /// | Name                          | Type         | Description                                                                                                                  |
    /// | ------                        | ------       | -------------                                                                                                                |
    /// | `validator_operator_account`  | `&signer`    | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. |
    /// | `validator_account`           | `address`    | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated.                                    |
    /// | `consensus_pubkey`            | `vector<u8>` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`.                                         |
    /// | `validator_network_addresses` | `vector<u8>` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                       |
    /// | `fullnode_network_addresses`  | `vector<u8>` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                        |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                   | Description                                                                                           |
    /// | ----------------           | --------------                                 | -------------                                                                                         |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`           | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it.   |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY`      | `consensus_pubkey` is not a valid ed25519 public key.                                                 |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    RegisterValidatorConfig {
        validator_account: AccountAddress,
        consensus_pubkey: Bytes,
        validator_network_addresses: Bytes,
        fullnode_network_addresses: Bytes,
    },

    /// # Summary
    /// This script removes a validator account from the validator set, and triggers a reconfiguration
    /// of the system to remove the validator from the system. This transaction can only be
    /// successfully called by the Diem Root account.
    ///
    /// # Technical Description
    /// This script removes the account at `validator_address` from the validator set. This transaction
    /// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event
    /// has been performed, the account at `validator_address` is no longer considered to be a
    /// validator in the network. This transaction will fail if the validator at `validator_address`
    /// is not in the validator set.
    ///
    /// # Parameters
    /// | Name                | Type         | Description                                                                                                                        |
    /// | ------              | ------       | -------------                                                                                                                      |
    /// | `dr_account`        | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer.                                    |
    /// | `sliding_nonce`     | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                         |
    /// | `validator_name`    | `vector<u8>` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. |
    /// | `validator_address` | `address`    | The validator account address to be removed from the validator set.                                                                |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                            | Description                                                                                     |
    /// | ----------------           | --------------                          | -------------                                                                                   |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                                  |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.      |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                                   |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                               |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | The sending account is not the Diem Root account or Treasury Compliance account                |
    /// | 0                          | 0                                       | The provided `validator_name` does not match the already-recorded human name for the validator. |
    /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set.                                        |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                              |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                              |
    /// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`      | An invalid time value was encountered in reconfiguration. Unlikely to occur.                    |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::register_validator_config`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    RemoveValidatorAndReconfigure {
        sliding_nonce: u64,
        validator_name: Bytes,
        validator_address: AccountAddress,
    },

    /// # Summary
    /// Rotates the transaction sender's authentication key to the supplied new authentication key. May
    /// be sent by any account.
    ///
    /// # Technical Description
    /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
    /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
    /// its `DiemAccount::KeyRotationCapability`.
    ///
    /// # Parameters
    /// | Name      | Type         | Description                                                 |
    /// | ------    | ------       | -------------                                               |
    /// | `account` | `&signer`    | Signer reference of the sending account of the transaction. |
    /// | `new_key` | `vector<u8>` | New ed25519 public key to be used for `account`.            |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                               | Description                                                                              |
    /// | ----------------           | --------------                                             | -------------                                                                            |
    /// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.     |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                         |
    ///
    /// # Related Scripts
    /// * `Script::rotate_authentication_key_with_nonce`
    /// * `Script::rotate_authentication_key_with_nonce_admin`
    /// * `Script::rotate_authentication_key_with_recovery_address`
    RotateAuthenticationKey { new_key: Bytes },

    /// # Summary
    /// Rotates the sender's authentication key to the supplied new authentication key. May be sent by
    /// any account that has a sliding nonce resource published under it (usually this is Treasury
    /// Compliance or Diem Root accounts).
    ///
    /// # Technical Description
    /// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
    /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
    /// its `DiemAccount::KeyRotationCapability`.
    ///
    /// # Parameters
    /// | Name            | Type         | Description                                                                |
    /// | ------          | ------       | -------------                                                              |
    /// | `account`       | `&signer`    | Signer reference of the sending account of the transaction.                |
    /// | `sliding_nonce` | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
    /// | `new_key`       | `vector<u8>` | New ed25519 public key to be used for `account`.                           |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                               | Description                                                                                |
    /// | ----------------           | --------------                                             | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                             | A `SlidingNonce` resource is not published under `account`.                                |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                             | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                             | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`                    | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.       |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                           |
    ///
    /// # Related Scripts
    /// * `Script::rotate_authentication_key`
    /// * `Script::rotate_authentication_key_with_nonce_admin`
    /// * `Script::rotate_authentication_key_with_recovery_address`
    RotateAuthenticationKeyWithNonce { sliding_nonce: u64, new_key: Bytes },

    /// # Summary
    /// Rotates the specified account's authentication key to the supplied new authentication key. May
    /// only be sent by the Diem Root account as a write set transaction.
    ///
    /// # Technical Description
    /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
    /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
    /// its `DiemAccount::KeyRotationCapability`.
    ///
    /// # Parameters
    /// | Name            | Type         | Description                                                                                                  |
    /// | ------          | ------       | -------------                                                                                                |
    /// | `dr_account`    | `&signer`    | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. |
    /// | `account`       | `&signer`    | Signer reference of account specified in the `execute_as` field of the write set transaction.                |
    /// | `sliding_nonce` | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root.                    |
    /// | `new_key`       | `vector<u8>` | New ed25519 public key to be used for `account`.                                                             |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                               | Description                                                                                                |
    /// | ----------------           | --------------                                             | -------------                                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                             | A `SlidingNonce` resource is not published under `dr_account`.                                             |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                             | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                             | The `sliding_nonce` in `dr_account` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`                    | The `sliding_nonce` in` dr_account` has been previously recorded.                                          |
    /// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.                       |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                                           |
    ///
    /// # Related Scripts
    /// * `Script::rotate_authentication_key`
    /// * `Script::rotate_authentication_key_with_nonce`
    /// * `Script::rotate_authentication_key_with_recovery_address`
    RotateAuthenticationKeyWithNonceAdmin { sliding_nonce: u64, new_key: Bytes },

    /// # Summary
    /// Rotates the authentication key of a specified account that is part of a recovery address to a
    /// new authentication key. Only used for accounts that are part of a recovery address (see
    /// `Script::add_recovery_rotation_capability` for account restrictions).
    ///
    /// # Technical Description
    /// Rotates the authentication key of the `to_recover` account to `new_key` using the
    /// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource
    /// published under `recovery_address`. This transaction can be sent either by the `to_recover`
    /// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published
    /// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`.
    ///
    /// # Parameters
    /// | Name               | Type         | Description                                                                                                                    |
    /// | ------             | ------       | -------------                                                                                                                  |
    /// | `account`          | `&signer`    | Signer reference of the sending account of the transaction.                                                                    |
    /// | `recovery_address` | `address`    | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. |
    /// | `to_recover`       | `address`    | The address of the account whose authentication key will be updated.                                                           |
    /// | `new_key`          | `vector<u8>` | New ed25519 public key to be used for the account at the `to_recover` address.                                                 |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                                                                          |
    /// | ----------------           | --------------                                | -------------                                                                                                                                        |
    /// | `Errors::NOT_PUBLISHED`    | `RecoveryAddress::ERECOVERY_ADDRESS`          | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it.                                                   |
    /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY`         | The address of `account` is not `recovery_address` or `to_recover`.                                                                                  |
    /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE`   | `to_recover`'s `DiemAccount::KeyRotationCapability`  is not in the `RecoveryAddress::RecoveryAddress`  resource published under `recovery_address`. |
    /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length.                                                                                                                     |
    ///
    /// # Related Scripts
    /// * `Script::rotate_authentication_key`
    /// * `Script::rotate_authentication_key_with_nonce`
    /// * `Script::rotate_authentication_key_with_nonce_admin`
    RotateAuthenticationKeyWithRecoveryAddress {
        recovery_address: AccountAddress,
        to_recover: AccountAddress,
        new_key: Bytes,
    },

    /// # Summary
    /// Updates the url used for off-chain communication, and the public key used to verify dual
    /// attestation on-chain. Transaction can be sent by any account that has dual attestation
    /// information published under it. In practice the only such accounts are Designated Dealers and
    /// Parent VASPs.
    ///
    /// # Technical Description
    /// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential`
    /// resource published under `account`. The `new_key` must be a valid ed25519 public key.
    ///
    /// ## Events
    /// Successful execution of this transaction emits two events:
    /// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and
    /// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential`
    /// `compliance_key_rotation_events` handle published under `account`; and
    /// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for
    /// off-chain communication, and the blockchain time at which the url was updated emitted on the
    /// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`.
    ///
    /// # Parameters
    /// | Name      | Type         | Description                                                               |
    /// | ------    | ------       | -------------                                                             |
    /// | `account` | `&signer`    | Signer reference of the sending account of the transaction.               |
    /// | `new_url` | `vector<u8>` | ASCII-encoded url to be used for off-chain communication with `account`.  |
    /// | `new_key` | `vector<u8>` | New ed25519 public key to be used for on-chain dual attestation checking. |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                           | Description                                                                |
    /// | ----------------           | --------------                         | -------------                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `DualAttestation::ECREDENTIAL`         | A `DualAttestation::Credential` resource is not published under `account`. |
    /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key.                               |
    ///
    /// # Related Scripts
    /// * `Script::create_parent_vasp_account`
    /// * `Script::create_designated_dealer`
    /// * `Script::rotate_dual_attestation_info`
    RotateDualAttestationInfo { new_url: Bytes, new_key: Bytes },

    /// # Summary
    /// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by
    /// any account that has previously published a shared ed25519 public key using
    /// `Script::publish_shared_ed25519_public_key`.
    ///
    /// # Technical Description
    /// This first rotates the public key stored in `account`'s
    /// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it
    /// rotates the authentication key using the capability stored in `account`'s
    /// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key`
    ///
    /// # Parameters
    /// | Name         | Type         | Description                                                     |
    /// | ------       | ------       | -------------                                                   |
    /// | `account`    | `&signer`    | The signer reference of the sending account of the transaction. |
    /// | `public_key` | `vector<u8>` | 32-byte Ed25519 public key.                                     |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                    | Description                                                                                   |
    /// | ----------------           | --------------                                  | -------------                                                                                 |
    /// | `Errors::NOT_PUBLISHED`    | `SharedEd25519PublicKey::ESHARED_KEY`           | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. |
    /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key.                                                |
    ///
    /// # Related Scripts
    /// * `Script::publish_shared_ed25519_public_key`
    RotateSharedEd25519PublicKey { public_key: Bytes },

    /// # Summary
    /// Updates a validator's configuration, and triggers a reconfiguration of the system to update the
    /// validator set with this new validator configuration.  Can only be successfully sent by a
    /// Validator Operator account that is already registered with a validator.
    ///
    /// # Technical Description
    /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig`
    /// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to
    /// trigger a reconfiguration of the system.  This reconfiguration will update the validator set
    /// on-chain with the updated `ValidatorConfig::ValidatorConfig`.
    ///
    /// # Parameters
    /// | Name                          | Type         | Description                                                                                                                  |
    /// | ------                        | ------       | -------------                                                                                                                |
    /// | `validator_operator_account`  | `&signer`    | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. |
    /// | `validator_account`           | `address`    | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated.                                    |
    /// | `consensus_pubkey`            | `vector<u8>` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`.                                         |
    /// | `validator_network_addresses` | `vector<u8>` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                       |
    /// | `fullnode_network_addresses`  | `vector<u8>` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                        |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                   | Description                                                                                           |
    /// | ----------------           | --------------                                 | -------------                                                                                         |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`           | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it.   |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR_OPERATOR`                   | `validator_operator_account` does not have a Validator Operator role.                                 |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY`      | `consensus_pubkey` is not a valid ed25519 public key.                                                 |
    /// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`             | An invalid time value was encountered in reconfiguration. Unlikely to occur.                          |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::register_validator_config`
    SetValidatorConfigAndReconfigure {
        validator_account: AccountAddress,
        consensus_pubkey: Bytes,
        validator_network_addresses: Bytes,
        fullnode_network_addresses: Bytes,
    },

    /// # Summary
    /// Sets the validator operator for a validator in the validator's configuration resource "locally"
    /// and does not reconfigure the system. Changes from this transaction will not picked up by the
    /// system until a reconfiguration of the system is triggered. May only be sent by an account with
    /// Validator role.
    ///
    /// # Technical Description
    /// Sets the account at `operator_account` address and with the specified `human_name` as an
    /// operator for the sending validator account. The account at `operator_account` address must have
    /// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig`
    /// resource published under it. The sending `account` must be a Validator and have a
    /// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a
    /// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script.
    ///
    /// # Parameters
    /// | Name               | Type         | Description                                                                                  |
    /// | ------             | ------       | -------------                                                                                |
    /// | `account`          | `&signer`    | The signer reference of the sending account of the transaction.                              |
    /// | `operator_name`    | `vector<u8>` | Validator operator's human name.                                                             |
    /// | `operator_account` | `address`    | Address of the validator operator account to be added as the `account` validator's operator. |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                          | Description                                                                                                                                                  |
    /// | ----------------           | --------------                                        | -------------                                                                                                                                                |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`.                                                   |
    /// | 0                          | 0                                                     | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR`                                   | `account` does not have a Validator account role.                                                                                                            |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR`          | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource.                                               |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`                  | A `ValidatorConfig::ValidatorConfig` is not published under `account`.                                                                                       |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::register_validator_config`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::set_validator_operator_with_nonce_admin`
    /// * `Script::set_validator_config_and_reconfigure`
    SetValidatorOperator {
        operator_name: Bytes,
        operator_account: AccountAddress,
    },

    /// # Summary
    /// Sets the validator operator for a validator in the validator's configuration resource "locally"
    /// and does not reconfigure the system. Changes from this transaction will not picked up by the
    /// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root
    /// account as a write set transaction.
    ///
    /// # Technical Description
    /// Sets the account at `operator_account` address and with the specified `human_name` as an
    /// operator for the validator `account`. The account at `operator_account` address must have a
    /// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource
    /// published under it. The account represented by the `account` signer must be a Validator and
    /// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of
    /// the system is initiated by this script.
    ///
    /// # Parameters
    /// | Name               | Type         | Description                                                                                                  |
    /// | ------             | ------       | -------------                                                                                                |
    /// | `dr_account`       | `&signer`    | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. |
    /// | `account`          | `&signer`    | Signer reference of account specified in the `execute_as` field of the write set transaction.                |
    /// | `sliding_nonce`    | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root.                    |
    /// | `operator_name`    | `vector<u8>` | Validator operator's human name.                                                                             |
    /// | `operator_account` | `address`    | Address of the validator operator account to be added as the `account` validator's operator.                 |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                          | Description                                                                                                                                                  |
    /// | ----------------           | --------------                                        | -------------                                                                                                                                                |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                        | A `SlidingNonce` resource is not published under `dr_account`.                                                                                               |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                        | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not.                                                   |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                        | The `sliding_nonce` in `dr_account` is too far in the future.                                                                                                |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`               | The `sliding_nonce` in` dr_account` has been previously recorded.                                                                                            |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                        | The sending account is not the Diem Root account or Treasury Compliance account                                                                             |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`.                                                   |
    /// | 0                          | 0                                                     | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR`                                   | `account` does not have a Validator account role.                                                                                                            |
    /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR`          | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource.                                               |
    /// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`                  | A `ValidatorConfig::ValidatorConfig` is not published under `account`.                                                                                       |
    ///
    /// # Related Scripts
    /// * `Script::create_validator_account`
    /// * `Script::create_validator_operator_account`
    /// * `Script::register_validator_config`
    /// * `Script::remove_validator_and_reconfigure`
    /// * `Script::add_validator_and_reconfigure`
    /// * `Script::set_validator_operator`
    /// * `Script::set_validator_config_and_reconfigure`
    SetValidatorOperatorWithNonceAdmin {
        sliding_nonce: u64,
        operator_name: Bytes,
        operator_account: AccountAddress,
    },

    /// # Summary
    /// Mints a specified number of coins in a currency to a Designated Dealer. The sending account
    /// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer
    /// account.
    ///
    /// # Technical Description
    /// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at
    /// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to
    /// check verify the off-chain approval policy, and is based in part on the on-chain tier values
    /// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to
    /// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that
    /// they support. The sending `tc_account` must be the Treasury Compliance account, and the
    /// receiver an authorized Designated Dealer account.
    ///
    /// ## Events
    /// Successful execution of the transaction will emit two events:
    /// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the
    /// `mint_event_handle` in the stored `Diem::CurrencyInfo<CoinType>` resource stored under
    /// `0xA550C18`; and
    /// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated
    /// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer`
    /// resource published under the `designated_dealer_address`.
    ///
    /// # Parameters
    /// | Name                        | Type      | Description                                                                                                |
    /// | ------                      | ------    | -------------                                                                                              |
    /// | `CoinType`                  | Type      | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. |
    /// | `tc_account`                | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.  |
    /// | `sliding_nonce`             | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                 |
    /// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to.                                              |
    /// | `mint_amount`               | `u64`     | The number of coins to be minted.                                                                          |
    /// | `tier_index`                | `u64`     | The mint tier index to use for the Designated Dealer account.                                              |
    ///
    /// # Common Abort Conditions
    /// | Error Category                | Error Reason                                 | Description                                                                                                                  |
    /// | ----------------              | --------------                               | -------------                                                                                                                |
    /// | `Errors::NOT_PUBLISHED`       | `SlidingNonce::ESLIDING_NONCE`               | A `SlidingNonce` resource is not published under `tc_account`.                                                               |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_OLD`               | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.                                   |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_NEW`               | The `sliding_nonce` is too far in the future.                                                                                |
    /// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_ALREADY_RECORDED`      | The `sliding_nonce` has been previously recorded.                                                                            |
    /// | `Errors::REQUIRES_ADDRESS`    | `CoreAddresses::ETREASURY_COMPLIANCE`        | `tc_account` is not the Treasury Compliance account.                                                                         |
    /// | `Errors::REQUIRES_ROLE`       | `Roles::ETREASURY_COMPLIANCE`                | `tc_account` is not the Treasury Compliance account.                                                                         |
    /// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_MINT_AMOUNT`     | `mint_amount` is zero.                                                                                                       |
    /// | `Errors::NOT_PUBLISHED`       | `DesignatedDealer::EDEALER`                  | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo<CoinType>` resource does not exist at `designated_dealer_address`. |
    /// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_TIER_INDEX`      | The `tier_index` is out of bounds.                                                                                           |
    /// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`.                                                           |
    /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY`                    | `tc_account` does not have a `Diem::MintCapability<CoinType>` resource published under it.                                  |
    /// | `Errors::INVALID_STATE`       | `Diem::EMINTING_NOT_ALLOWED`                | Minting is not currently allowed for `CoinType` coins.                                                                       |
    /// | `Errors::LIMIT_EXCEEDED`      | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`      | The depositing of the funds would exceed the `account`'s account limits.                                                     |
    ///
    /// # Related Scripts
    /// * `Script::create_designated_dealer`
    /// * `Script::peer_to_peer_with_metadata`
    /// * `Script::rotate_dual_attestation_info`
    TieredMint {
        coin_type: TypeTag,
        sliding_nonce: u64,
        designated_dealer_address: AccountAddress,
        mint_amount: u64,
        tier_index: u64,
    },

    /// # Summary
    /// Unfreezes the account at `address`. The sending account of this transaction must be the
    /// Treasury Compliance account. After the successful execution of this transaction transactions
    /// may be sent from the previously frozen account, and coins may be sent and received.
    ///
    /// # Technical Description
    /// Sets the `AccountFreezing::FreezingBit` to `false` and emits a
    /// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance
    /// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect
    /// the status any of its child accounts and vice versa.
    ///
    /// ## Events
    /// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with
    /// the `unfrozen_address` set the `to_unfreeze_account`'s address.
    ///
    /// # Parameters
    /// | Name                  | Type      | Description                                                                                               |
    /// | ------                | ------    | -------------                                                                                             |
    /// | `tc_account`          | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
    /// | `sliding_nonce`       | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
    /// | `to_unfreeze_account` | `address` | The account address to be frozen.                                                                         |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                            | Description                                                                                |
    /// | ----------------           | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `account`.                                |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
    ///
    /// # Related Scripts
    /// * `Script::freeze_account`
    UnfreezeAccount {
        sliding_nonce: u64,
        to_unfreeze_account: AccountAddress,
    },

    /// # Summary
    /// Updates the Diem major version that is stored on-chain and is used by the VM.  This
    /// transaction can only be sent from the Diem Root account.
    ///
    /// # Technical Description
    /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
    /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater
    /// than the current major version held on-chain. The VM reads this information and can use it to
    /// preserve backwards compatibility with previous major versions of the VM.
    ///
    /// # Parameters
    /// | Name            | Type      | Description                                                                |
    /// | ------          | ------    | -------------                                                              |
    /// | `account`       | `&signer` | Signer reference of the sending account. Must be the Diem Root account.   |
    /// | `sliding_nonce` | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
    /// | `major`         | `u64`     | The `major` version of the VM to be used from this transaction on.         |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                |
    /// | ----------------           | --------------                                | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                | A `SlidingNonce` resource is not published under `account`.                                |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`       | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                  | `account` is not the Diem Root account.                                                   |
    /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain.                |
    UpdateDiemVersion { sliding_nonce: u64, major: u64 },

    /// # Summary
    /// Update the dual attestation limit on-chain. Defined in terms of micro-XDX.  The transaction can
    /// only be sent by the Treasury Compliance account.  After this transaction all inter-VASP
    /// payments over this limit must be checked for dual attestation.
    ///
    /// # Technical Description
    /// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under
    /// `0xA550C18`. The amount is set in micro-XDX.
    ///
    /// # Parameters
    /// | Name                  | Type      | Description                                                                                               |
    /// | ------                | ------    | -------------                                                                                             |
    /// | `tc_account`          | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
    /// | `sliding_nonce`       | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
    /// | `new_micro_xdx_limit` | `u64`     | The new dual attestation limit to be used on-chain.                                                       |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                            | Description                                                                                |
    /// | ----------------           | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | `tc_account` is not the Treasury Compliance account.                                       |
    ///
    /// # Related Scripts
    /// * `Script::update_exchange_rate`
    /// * `Script::update_minting_ability`
    UpdateDualAttestationLimit {
        sliding_nonce: u64,
        new_micro_xdx_limit: u64,
    },

    /// # Summary
    /// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion
    /// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this
    /// transaction the updated exchange rate will be used for normalization of gas prices, and for
    /// dual attestation checking.
    ///
    /// # Technical Description
    /// Updates the on-chain exchange rate from the given `Currency` to micro-XDX.  The exchange rate
    /// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`.
    ///
    /// # Parameters
    /// | Name                            | Type      | Description                                                                                                                        |
    /// | ------                          | ------    | -------------                                                                                                                      |
    /// | `Currency`                      | Type      | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. |
    /// | `tc_account`                    | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                          |
    /// | `sliding_nonce`                 | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction.                                                          |
    /// | `new_exchange_rate_numerator`   | `u64`     | The numerator for the new to micro-XDX exchange rate for `Currency`.                                                               |
    /// | `new_exchange_rate_denominator` | `u64`     | The denominator for the new to micro-XDX exchange rate for `Currency`.                                                             |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                            | Description                                                                                |
    /// | ----------------           | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | `tc_account` is not the Treasury Compliance account.                                       |
    /// | `Errors::REQUIRES_ROLE`    | `Roles::ETREASURY_COMPLIANCE`           | `tc_account` is not the Treasury Compliance account.                                       |
    /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR`            | `new_exchange_rate_denominator` is zero.                                                   |
    /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE`     | The quotient is unrepresentable as a `FixedPoint32`.                                       |
    /// | `Errors::LIMIT_EXCEEDED`   | `FixedPoint32::ERATIO_OUT_OF_RANGE`     | The quotient is unrepresentable as a `FixedPoint32`.                                       |
    ///
    /// # Related Scripts
    /// * `Script::update_dual_attestation_limit`
    /// * `Script::update_minting_ability`
    UpdateExchangeRate {
        currency: TypeTag,
        sliding_nonce: u64,
        new_exchange_rate_numerator: u64,
        new_exchange_rate_denominator: u64,
    },

    /// # Summary
    /// Script to allow or disallow minting of new coins in a specified currency.  This transaction can
    /// only be sent by the Treasury Compliance account.  Turning minting off for a currency will have
    /// no effect on coins already in circulation, and coins may still be removed from the system.
    ///
    /// # Technical Description
    /// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo<Currency>` resource
    /// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if
    /// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise.
    /// This transaction needs to be sent by the Treasury Compliance account.
    ///
    /// # Parameters
    /// | Name            | Type      | Description                                                                                                                          |
    /// | ------          | ------    | -------------                                                                                                                        |
    /// | `Currency`      | Type      | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. |
    /// | `account`       | `&signer` | Signer reference of the sending account. Must be the Diem Root account.                                                             |
    /// | `allow_minting` | `bool`    | Whether to allow minting of new coins in `Currency`.                                                                                 |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                          | Description                                          |
    /// | ----------------           | --------------                        | -------------                                        |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. |
    /// | `Errors::NOT_PUBLISHED`    | `Diem::ECURRENCY_INFO`               | `Currency` is not a registered currency on-chain.    |
    ///
    /// # Related Scripts
    /// * `Script::update_dual_attestation_limit`
    /// * `Script::update_exchange_rate`
    UpdateMintingAbility {
        currency: TypeTag,
        allow_minting: bool,
    },
}

/// Structured representation of a call into a known Move script function.
/// ```ignore
/// impl ScriptFunctionCall {
///     pub fn encode(self) -> TransactionPayload { .. }
///     pub fn decode(&TransactionPayload) -> Option<ScriptFunctionCall> { .. }
/// }
/// ```
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))]
#[cfg_attr(feature = "fuzzing", proptest(no_params))]
pub enum ScriptFunctionCall {
    CreateAccount {
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
    },

    /// # Summary
    /// Creates a Validator account. This transaction can only be sent by the Diem
    /// Root account.
    ///
    /// # Technical Description
    /// Creates an account with a Validator role at `new_account_address`, with authentication key
    /// `auth_key_prefix` | `new_account_address`. It publishes a
    /// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and
    /// `operator_account` fields. The `human_name` field of the
    /// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`.
    /// This script does not add the validator to the validator set or the system,
    /// but only creates the account.
    /// Authentication keys, prefixes, and how to construct them from an ed25519 public key are described
    /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys).
    ///
    /// # Events
    /// Successful execution will emit:
    /// * A `ExperimentalAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
    /// and the `rold_id` field being `Roles::VALIDATOR_ROLE_ID`. This is emitted on the
    /// `ExperimentalAccount::AccountOperationsCapability` `creation_events` handle.
    ///
    /// # Parameters
    /// | Name                  | Type         | Description                                                                              |
    /// | ------                | ------       | -------------                                                                            |
    /// | `dr_account`          | `signer`     | The signer of the sending account of this transaction. Must be the Diem Root signer.     |
    /// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.               |
    /// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                          |
    /// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account. |
    /// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                              |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
    ///
    /// # Related Scripts
    /// * `AccountCreationScripts::create_validator_operator_account`
    /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure`
    /// * `ValidatorAdministrationScripts::register_validator_config`
    /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure`
    /// * `ValidatorAdministrationScripts::set_validator_operator`
    /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin`
    /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure`
    CreateValidatorAccount {
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
    },

    /// # Summary
    /// Creates a Validator Operator account. This transaction can only be sent by the Diem
    /// Root account.
    ///
    /// # Technical Description
    /// Creates an account with a Validator Operator role at `new_account_address`, with authentication key
    /// `auth_key_prefix` | `new_account_address`. It publishes a
    /// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`.
    /// This script does not assign the validator operator to any validator accounts but only creates the account.
    /// Authentication key prefixes, and how to construct them from an ed25519 public key are described
    /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys).
    ///
    /// # Events
    /// Successful execution will emit:
    /// * A `ExperimentalAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
    /// and the `rold_id` field being `Roles::VALIDATOR_OPERATOR_ROLE_ID`. This is emitted on the
    /// `ExperimentalAccount::AccountOperationsCapability` `creation_events` handle.
    ///
    /// # Parameters
    /// | Name                  | Type         | Description                                                                              |
    /// | ------                | ------       | -------------                                                                            |
    /// | `dr_account`          | `signer`     | The signer of the sending account of this transaction. Must be the Diem Root signer.     |
    /// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.               |
    /// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                          |
    /// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account. |
    /// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                              |
    ///
    /// # Common Abort Conditions
    /// | Error Category              | Error Reason                            | Description                                                                                |
    /// | ----------------            | --------------                          | -------------                                                                              |
    /// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
    /// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
    /// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
    /// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
    /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
    ///
    /// # Related Scripts
    /// * `AccountCreationScripts::create_validator_account`
    /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure`
    /// * `ValidatorAdministrationScripts::register_validator_config`
    /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure`
    /// * `ValidatorAdministrationScripts::set_validator_operator`
    /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin`
    /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure`
    CreateValidatorOperatorAccount {
        new_account_address: AccountAddress,
        auth_key_prefix: Bytes,
        human_name: Bytes,
    },

    /// gc_ballots deletes all the expired ballots of the type `Proposal`
    /// under the provided address `addr`. The signer can be anybody
    /// and does not need to have the same address as `addr`
    GcBallots {
        proposal: TypeTag,
        addr: AccountAddress,
    },

    /// # Summary
    /// Initializes the Diem consensus config that is stored on-chain.  This
    /// transaction can only be sent from the Diem Root account.
    ///
    /// # Technical Description
    /// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via
    /// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`.
    ///
    /// # Parameters
    /// | Name            | Type      | Description                                                                |
    /// | ------          | ------    | -------------                                                              |
    /// | `account`       | `signer` | Signer of the sending account. Must be the Diem Root account.               |
    /// | `_sliding_nonce` | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                |
    /// | ----------------           | --------------                                | -------------                                                                              |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
    InitializeDiemConsensusConfig { _sliding_nonce: u64 },

    /// BARS account mints `amount` copies of BARS tokens to the artist's account.
    MintBars {
        artist: AccountAddress,
        artist_name: Bytes,
        content_uri: Bytes,
        amount: u64,
    },

    /// Initialize this module
    NftInitialize {},

    /// Call this function to set up relevant resources in order to
    /// mint and receive tokens.
    /// Note that this also gives BARS account a capability to mint BARS NFTs on behalf of the user.
    /// (the NFTs of other types cannot be created by BARS account).
    RegisterBarsUser {},

    /// # Summary
    /// Updates the gas constants stored on chain and used by the VM for gas
    /// metering. This transaction can only be sent from the Diem Root account.
    ///
    /// # Technical Description
    /// Updates the on-chain config holding the `DiemVMConfig` and emits a
    /// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system.
    ///
    /// # Parameters
    /// | Name                                | Type     | Description                                                                                            |
    /// | ------                              | ------   | -------------                                                                                          |
    /// | `account`                           | `signer` | Signer of the sending account. Must be the Diem Root account.                                          |
    /// | `_sliding_nonce`                     | `u64`    | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                             |
    /// | `global_memory_per_byte_cost`       | `u64`    | The new cost to read global memory per-byte to be used for gas metering.                               |
    /// | `global_memory_per_byte_write_cost` | `u64`    | The new cost to write global memory per-byte to be used for gas metering.                              |
    /// | `min_transaction_gas_units`         | `u64`    | The new flat minimum amount of gas required for any transaction.                                       |
    /// | `large_transaction_cutoff`          | `u64`    | The new size over which an additional charge will be assessed for each additional byte.                |
    /// | `intrinsic_gas_per_byte`            | `u64`    | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`.    |
    /// | `maximum_number_of_gas_units`       | `u64`    | The new maximum number of gas units that can be set in a transaction.                                  |
    /// | `min_price_per_gas_unit`            | `u64`    | The new minimum gas price that can be set for a transaction.                                           |
    /// | `max_price_per_gas_unit`            | `u64`    | The new maximum gas price that can be set for a transaction.                                           |
    /// | `max_transaction_size_in_bytes`     | `u64`    | The new maximum size of a transaction that can be processed.                                           |
    /// | `gas_unit_scaling_factor`           | `u64`    | The new scaling factor to use when scaling between external and internal gas units.                    |
    /// | `default_account_size`              | `u64`    | The new default account size to use when assessing final costs for reads and writes to global storage. |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                | Description                                                                                |
    /// | ----------------           | --------------                              | -------------                                                                              |
    /// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent.                                               |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                 | `account` is not the Diem Root account.                                                    |
    SetGasConstants {
        _sliding_nonce: u64,
        global_memory_per_byte_cost: u64,
        global_memory_per_byte_write_cost: u64,
        min_transaction_gas_units: u64,
        large_transaction_cutoff: u64,
        intrinsic_gas_per_byte: u64,
        maximum_number_of_gas_units: u64,
        min_price_per_gas_unit: u64,
        max_price_per_gas_unit: u64,
        max_transaction_size_in_bytes: u64,
        gas_unit_scaling_factor: u64,
        default_account_size: u64,
    },

    /// Transfer `amount` of token with id `GUID::id(creator, creation_num)` from `owner`'s
    /// balance to `to`'s balance. This operation has to be done by either the owner or an
    /// approved operator of the owner.
    TransferMultiTokenBetweenGalleries {
        token_type: TypeTag,
        to: AccountAddress,
        amount: u64,
        creator: AccountAddress,
        creation_num: u64,
    },

    /// Transfer `amount` of token with id `GUID::id(creator, creation_num)` from `owner`'s
    /// balance to `to`'s balance. This operation has to be done by either the owner or an
    /// approved operator of the owner.
    TransferTokenBetweenGalleries {
        token_type: TypeTag,
        to: AccountAddress,
        amount: u64,
        creator: AccountAddress,
        creation_num: u64,
    },

    /// # Summary
    /// Updates the Diem consensus config that is stored on-chain and is used by the Consensus.  This
    /// transaction can only be sent from the Diem Root account.
    ///
    /// # Technical Description
    /// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
    /// a reconfiguration of the system.
    ///
    /// # Parameters
    /// | Name            | Type          | Description                                                                |
    /// | ------          | ------        | -------------                                                              |
    /// | `account`       | `signer`      | Signer of the sending account. Must be the Diem Root account.              |
    /// | `_sliding_nonce` | `u64`         | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
    /// | `config`        | `vector<u8>`  | The serialized bytes of consensus config.                                  |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                |
    /// | ----------------           | --------------                                | -------------                                                                              |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
    UpdateDiemConsensusConfig { _sliding_nonce: u64, config: Bytes },

    /// # Summary
    /// Updates the Diem major version that is stored on-chain and is used by the VM.  This
    /// transaction can only be sent from the Diem Root account.
    ///
    /// # Technical Description
    /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
    /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater
    /// than the current major version held on-chain. The VM reads this information and can use it to
    /// preserve backwards compatibility with previous major versions of the VM.
    ///
    /// # Parameters
    /// | Name            | Type     | Description                                                                |
    /// | ------          | ------   | -------------                                                              |
    /// | `account`       | `signer` | Signer of the sending account. Must be the Diem Root account.              |
    /// | `_sliding_nonce` | `u64`    | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
    /// | `major`         | `u64`    | The `major` version of the VM to be used from this transaction on.         |
    ///
    /// # Common Abort Conditions
    /// | Error Category             | Error Reason                                  | Description                                                                                |
    /// | ----------------           | --------------                                | -------------                                                                              |
    /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
    /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER`  | `major` is less-than or equal to the current major version stored on-chain.                |
    UpdateDiemVersion { _sliding_nonce: u64, major: u64 },
}

impl ScriptCall {
    /// Build a Diem `Script` from a structured object `ScriptCall`.
    pub fn encode(self) -> Script {
        use ScriptCall::*;
        match self {
            AddCurrencyToAccount { currency } => encode_add_currency_to_account_script(currency),
            AddRecoveryRotationCapability { recovery_address } => {
                encode_add_recovery_rotation_capability_script(recovery_address)
            }
            AddValidatorAndReconfigure {
                sliding_nonce,
                validator_name,
                validator_address,
            } => encode_add_validator_and_reconfigure_script(
                sliding_nonce,
                validator_name,
                validator_address,
            ),
            Burn {
                token,
                sliding_nonce,
                preburn_address,
            } => encode_burn_script(token, sliding_nonce, preburn_address),
            BurnTxnFees { coin_type } => encode_burn_txn_fees_script(coin_type),
            CancelBurn {
                token,
                preburn_address,
            } => encode_cancel_burn_script(token, preburn_address),
            CreateChildVaspAccount {
                coin_type,
                child_address,
                auth_key_prefix,
                add_all_currencies,
                child_initial_balance,
            } => encode_create_child_vasp_account_script(
                coin_type,
                child_address,
                auth_key_prefix,
                add_all_currencies,
                child_initial_balance,
            ),
            CreateDesignatedDealer {
                currency,
                sliding_nonce,
                addr,
                auth_key_prefix,
                human_name,
                add_all_currencies,
            } => encode_create_designated_dealer_script(
                currency,
                sliding_nonce,
                addr,
                auth_key_prefix,
                human_name,
                add_all_currencies,
            ),
            CreateParentVaspAccount {
                coin_type,
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
                add_all_currencies,
            } => encode_create_parent_vasp_account_script(
                coin_type,
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
                add_all_currencies,
            ),
            CreateRecoveryAddress {} => encode_create_recovery_address_script(),
            CreateValidatorAccount {
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
            } => encode_create_validator_account_script(
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
            ),
            CreateValidatorOperatorAccount {
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
            } => encode_create_validator_operator_account_script(
                sliding_nonce,
                new_account_address,
                auth_key_prefix,
                human_name,
            ),
            FreezeAccount {
                sliding_nonce,
                to_freeze_account,
            } => encode_freeze_account_script(sliding_nonce, to_freeze_account),
            PeerToPeerWithMetadata {
                currency,
                payee,
                amount,
                metadata,
                metadata_signature,
            } => encode_peer_to_peer_with_metadata_script(
                currency,
                payee,
                amount,
                metadata,
                metadata_signature,
            ),
            Preburn { token, amount } => encode_preburn_script(token, amount),
            PublishSharedEd25519PublicKey { public_key } => {
                encode_publish_shared_ed25519_public_key_script(public_key)
            }
            RegisterValidatorConfig {
                validator_account,
                consensus_pubkey,
                validator_network_addresses,
                fullnode_network_addresses,
            } => encode_register_validator_config_script(
                validator_account,
                consensus_pubkey,
                validator_network_addresses,
                fullnode_network_addresses,
            ),
            RemoveValidatorAndReconfigure {
                sliding_nonce,
                validator_name,
                validator_address,
            } => encode_remove_validator_and_reconfigure_script(
                sliding_nonce,
                validator_name,
                validator_address,
            ),
            RotateAuthenticationKey { new_key } => encode_rotate_authentication_key_script(new_key),
            RotateAuthenticationKeyWithNonce {
                sliding_nonce,
                new_key,
            } => encode_rotate_authentication_key_with_nonce_script(sliding_nonce, new_key),
            RotateAuthenticationKeyWithNonceAdmin {
                sliding_nonce,
                new_key,
            } => encode_rotate_authentication_key_with_nonce_admin_script(sliding_nonce, new_key),
            RotateAuthenticationKeyWithRecoveryAddress {
                recovery_address,
                to_recover,
                new_key,
            } => encode_rotate_authentication_key_with_recovery_address_script(
                recovery_address,
                to_recover,
                new_key,
            ),
            RotateDualAttestationInfo { new_url, new_key } => {
                encode_rotate_dual_attestation_info_script(new_url, new_key)
            }
            RotateSharedEd25519PublicKey { public_key } => {
                encode_rotate_shared_ed25519_public_key_script(public_key)
            }
            SetValidatorConfigAndReconfigure {
                validator_account,
                consensus_pubkey,
                validator_network_addresses,
                fullnode_network_addresses,
            } => encode_set_validator_config_and_reconfigure_script(
                validator_account,
                consensus_pubkey,
                validator_network_addresses,
                fullnode_network_addresses,
            ),
            SetValidatorOperator {
                operator_name,
                operator_account,
            } => encode_set_validator_operator_script(operator_name, operator_account),
            SetValidatorOperatorWithNonceAdmin {
                sliding_nonce,
                operator_name,
                operator_account,
            } => encode_set_validator_operator_with_nonce_admin_script(
                sliding_nonce,
                operator_name,
                operator_account,
            ),
            TieredMint {
                coin_type,
                sliding_nonce,
                designated_dealer_address,
                mint_amount,
                tier_index,
            } => encode_tiered_mint_script(
                coin_type,
                sliding_nonce,
                designated_dealer_address,
                mint_amount,
                tier_index,
            ),
            UnfreezeAccount {
                sliding_nonce,
                to_unfreeze_account,
            } => encode_unfreeze_account_script(sliding_nonce, to_unfreeze_account),
            UpdateDiemVersion {
                sliding_nonce,
                major,
            } => encode_update_diem_version_script(sliding_nonce, major),
            UpdateDualAttestationLimit {
                sliding_nonce,
                new_micro_xdx_limit,
            } => encode_update_dual_attestation_limit_script(sliding_nonce, new_micro_xdx_limit),
            UpdateExchangeRate {
                currency,
                sliding_nonce,
                new_exchange_rate_numerator,
                new_exchange_rate_denominator,
            } => encode_update_exchange_rate_script(
                currency,
                sliding_nonce,
                new_exchange_rate_numerator,
                new_exchange_rate_denominator,
            ),
            UpdateMintingAbility {
                currency,
                allow_minting,
            } => encode_update_minting_ability_script(currency, allow_minting),
        }
    }

    /// Try to recognize a Diem `Script` and convert it into a structured object `ScriptCall`.
    pub fn decode(script: &Script) -> Option<ScriptCall> {
        match TRANSACTION_SCRIPT_DECODER_MAP.get(script.code()) {
            Some(decoder) => decoder(script),
            None => None,
        }
    }

    /// Return the name of a Diem `Script` from a structured object `ScriptCall`.
    pub fn name(&self) -> &'static str {
        use ScriptCall::*;
        match self {
            AddCurrencyToAccount { .. } => "add_currency_to_account",
            AddRecoveryRotationCapability { .. } => "add_recovery_rotation_capability",
            AddValidatorAndReconfigure { .. } => "add_validator_and_reconfigure",
            Burn { .. } => "burn",
            BurnTxnFees { .. } => "burn_txn_fees",
            CancelBurn { .. } => "cancel_burn",
            CreateChildVaspAccount { .. } => "create_child_vasp_account",
            CreateDesignatedDealer { .. } => "create_designated_dealer",
            CreateParentVaspAccount { .. } => "create_parent_vasp_account",
            CreateRecoveryAddress { .. } => "create_recovery_address",
            CreateValidatorAccount { .. } => "create_validator_account",
            CreateValidatorOperatorAccount { .. } => "create_validator_operator_account",
            FreezeAccount { .. } => "freeze_account",
            PeerToPeerWithMetadata { .. } => "peer_to_peer_with_metadata",
            Preburn { .. } => "preburn",
            PublishSharedEd25519PublicKey { .. } => "publish_shared_ed25519_public_key",
            RegisterValidatorConfig { .. } => "register_validator_config",
            RemoveValidatorAndReconfigure { .. } => "remove_validator_and_reconfigure",
            RotateAuthenticationKey { .. } => "rotate_authentication_key",
            RotateAuthenticationKeyWithNonce { .. } => "rotate_authentication_key_with_nonce",
            RotateAuthenticationKeyWithNonceAdmin { .. } => {
                "rotate_authentication_key_with_nonce_admin"
            }
            RotateAuthenticationKeyWithRecoveryAddress { .. } => {
                "rotate_authentication_key_with_recovery_address"
            }
            RotateDualAttestationInfo { .. } => "rotate_dual_attestation_info",
            RotateSharedEd25519PublicKey { .. } => "rotate_shared_ed25519_public_key",
            SetValidatorConfigAndReconfigure { .. } => "set_validator_config_and_reconfigure",
            SetValidatorOperator { .. } => "set_validator_operator",
            SetValidatorOperatorWithNonceAdmin { .. } => "set_validator_operator_with_nonce_admin",
            TieredMint { .. } => "tiered_mint",
            UnfreezeAccount { .. } => "unfreeze_account",
            UpdateDiemVersion { .. } => "update_diem_version",
            UpdateDualAttestationLimit { .. } => "update_dual_attestation_limit",
            UpdateExchangeRate { .. } => "update_exchange_rate",
            UpdateMintingAbility { .. } => "update_minting_ability",
        }
    }
}

impl ScriptFunctionCall {
    /// Build a Diem `TransactionPayload` from a structured object `ScriptFunctionCall`.
    pub fn encode(self) -> TransactionPayload {
        use ScriptFunctionCall::*;
        match self {
            CreateAccount {
                new_account_address,
                auth_key_prefix,
            } => encode_create_account_script_function(new_account_address, auth_key_prefix),
            CreateValidatorAccount {
                new_account_address,
                auth_key_prefix,
                human_name,
            } => encode_create_validator_account_script_function(
                new_account_address,
                auth_key_prefix,
                human_name,
            ),
            CreateValidatorOperatorAccount {
                new_account_address,
                auth_key_prefix,
                human_name,
            } => encode_create_validator_operator_account_script_function(
                new_account_address,
                auth_key_prefix,
                human_name,
            ),
            GcBallots { proposal, addr } => encode_gc_ballots_script_function(proposal, addr),
            InitializeDiemConsensusConfig { _sliding_nonce } => {
                encode_initialize_diem_consensus_config_script_function(_sliding_nonce)
            }
            MintBars {
                artist,
                artist_name,
                content_uri,
                amount,
            } => encode_mint_bars_script_function(artist, artist_name, content_uri, amount),
            NftInitialize {} => encode_nft_initialize_script_function(),
            RegisterBarsUser {} => encode_register_bars_user_script_function(),
            SetGasConstants {
                _sliding_nonce,
                global_memory_per_byte_cost,
                global_memory_per_byte_write_cost,
                min_transaction_gas_units,
                large_transaction_cutoff,
                intrinsic_gas_per_byte,
                maximum_number_of_gas_units,
                min_price_per_gas_unit,
                max_price_per_gas_unit,
                max_transaction_size_in_bytes,
                gas_unit_scaling_factor,
                default_account_size,
            } => encode_set_gas_constants_script_function(
                _sliding_nonce,
                global_memory_per_byte_cost,
                global_memory_per_byte_write_cost,
                min_transaction_gas_units,
                large_transaction_cutoff,
                intrinsic_gas_per_byte,
                maximum_number_of_gas_units,
                min_price_per_gas_unit,
                max_price_per_gas_unit,
                max_transaction_size_in_bytes,
                gas_unit_scaling_factor,
                default_account_size,
            ),
            TransferMultiTokenBetweenGalleries {
                token_type,
                to,
                amount,
                creator,
                creation_num,
            } => encode_transfer_multi_token_between_galleries_script_function(
                token_type,
                to,
                amount,
                creator,
                creation_num,
            ),
            TransferTokenBetweenGalleries {
                token_type,
                to,
                amount,
                creator,
                creation_num,
            } => encode_transfer_token_between_galleries_script_function(
                token_type,
                to,
                amount,
                creator,
                creation_num,
            ),
            UpdateDiemConsensusConfig {
                _sliding_nonce,
                config,
            } => encode_update_diem_consensus_config_script_function(_sliding_nonce, config),
            UpdateDiemVersion {
                _sliding_nonce,
                major,
            } => encode_update_diem_version_script_function(_sliding_nonce, major),
        }
    }

    /// Try to recognize a Diem `TransactionPayload` and convert it into a structured object `ScriptFunctionCall`.
    pub fn decode(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
        if let TransactionPayload::ScriptFunction(script) = payload {
            match SCRIPT_FUNCTION_DECODER_MAP.get(&format!(
                "{}{}",
                script.module().name(),
                script.function()
            )) {
                Some(decoder) => decoder(payload),
                None => None,
            }
        } else {
            None
        }
    }
}

pub fn encode_create_account_script_function(
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("AccountCreationScripts").to_owned(),
        ),
        ident_str!("create_account").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&new_account_address).unwrap(),
            bcs::to_bytes(&auth_key_prefix).unwrap(),
        ],
    ))
}

/// # Summary
/// Creates a Validator account. This transaction can only be sent by the Diem
/// Root account.
///
/// # Technical Description
/// Creates an account with a Validator role at `new_account_address`, with authentication key
/// `auth_key_prefix` | `new_account_address`. It publishes a
/// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and
/// `operator_account` fields. The `human_name` field of the
/// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`.
/// This script does not add the validator to the validator set or the system,
/// but only creates the account.
/// Authentication keys, prefixes, and how to construct them from an ed25519 public key are described
/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys).
///
/// # Events
/// Successful execution will emit:
/// * A `ExperimentalAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
/// and the `rold_id` field being `Roles::VALIDATOR_ROLE_ID`. This is emitted on the
/// `ExperimentalAccount::AccountOperationsCapability` `creation_events` handle.
///
/// # Parameters
/// | Name                  | Type         | Description                                                                              |
/// | ------                | ------       | -------------                                                                            |
/// | `dr_account`          | `signer`     | The signer of the sending account of this transaction. Must be the Diem Root signer.     |
/// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.               |
/// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                          |
/// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account. |
/// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                              |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
/// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
///
/// # Related Scripts
/// * `AccountCreationScripts::create_validator_operator_account`
/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure`
/// * `ValidatorAdministrationScripts::register_validator_config`
/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure`
/// * `ValidatorAdministrationScripts::set_validator_operator`
/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin`
/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure`
pub fn encode_create_validator_account_script_function(
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("AccountCreationScripts").to_owned(),
        ),
        ident_str!("create_validator_account").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&new_account_address).unwrap(),
            bcs::to_bytes(&auth_key_prefix).unwrap(),
            bcs::to_bytes(&human_name).unwrap(),
        ],
    ))
}

/// # Summary
/// Creates a Validator Operator account. This transaction can only be sent by the Diem
/// Root account.
///
/// # Technical Description
/// Creates an account with a Validator Operator role at `new_account_address`, with authentication key
/// `auth_key_prefix` | `new_account_address`. It publishes a
/// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`.
/// This script does not assign the validator operator to any validator accounts but only creates the account.
/// Authentication key prefixes, and how to construct them from an ed25519 public key are described
/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys).
///
/// # Events
/// Successful execution will emit:
/// * A `ExperimentalAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
/// and the `rold_id` field being `Roles::VALIDATOR_OPERATOR_ROLE_ID`. This is emitted on the
/// `ExperimentalAccount::AccountOperationsCapability` `creation_events` handle.
///
/// # Parameters
/// | Name                  | Type         | Description                                                                              |
/// | ------                | ------       | -------------                                                                            |
/// | `dr_account`          | `signer`     | The signer of the sending account of this transaction. Must be the Diem Root signer.     |
/// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.               |
/// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                          |
/// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account. |
/// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                              |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
/// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
///
/// # Related Scripts
/// * `AccountCreationScripts::create_validator_account`
/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure`
/// * `ValidatorAdministrationScripts::register_validator_config`
/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure`
/// * `ValidatorAdministrationScripts::set_validator_operator`
/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin`
/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure`
pub fn encode_create_validator_operator_account_script_function(
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("AccountCreationScripts").to_owned(),
        ),
        ident_str!("create_validator_operator_account").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&new_account_address).unwrap(),
            bcs::to_bytes(&auth_key_prefix).unwrap(),
            bcs::to_bytes(&human_name).unwrap(),
        ],
    ))
}

/// gc_ballots deletes all the expired ballots of the type `Proposal`
/// under the provided address `addr`. The signer can be anybody
/// and does not need to have the same address as `addr`
pub fn encode_gc_ballots_script_function(
    proposal: TypeTag,
    addr: AccountAddress,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("Vote").to_owned(),
        ),
        ident_str!("gc_ballots").to_owned(),
        vec![proposal],
        vec![bcs::to_bytes(&addr).unwrap()],
    ))
}

/// # Summary
/// Initializes the Diem consensus config that is stored on-chain.  This
/// transaction can only be sent from the Diem Root account.
///
/// # Technical Description
/// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via
/// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`.
///
/// # Parameters
/// | Name            | Type      | Description                                                                |
/// | ------          | ------    | -------------                                                              |
/// | `account`       | `signer` | Signer of the sending account. Must be the Diem Root account.               |
/// | `_sliding_nonce` | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                |
/// | ----------------           | --------------                                | -------------                                                                              |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
pub fn encode_initialize_diem_consensus_config_script_function(
    _sliding_nonce: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("SystemAdministrationScripts").to_owned(),
        ),
        ident_str!("initialize_diem_consensus_config").to_owned(),
        vec![],
        vec![bcs::to_bytes(&_sliding_nonce).unwrap()],
    ))
}

/// BARS account mints `amount` copies of BARS tokens to the artist's account.
pub fn encode_mint_bars_script_function(
    artist: AccountAddress,
    artist_name: Vec<u8>,
    content_uri: Vec<u8>,
    amount: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("BARSToken").to_owned(),
        ),
        ident_str!("mint_bars").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&artist).unwrap(),
            bcs::to_bytes(&artist_name).unwrap(),
            bcs::to_bytes(&content_uri).unwrap(),
            bcs::to_bytes(&amount).unwrap(),
        ],
    ))
}

/// Initialize this module
pub fn encode_nft_initialize_script_function() -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("NFT").to_owned(),
        ),
        ident_str!("nft_initialize").to_owned(),
        vec![],
        vec![],
    ))
}

/// Call this function to set up relevant resources in order to
/// mint and receive tokens.
/// Note that this also gives BARS account a capability to mint BARS NFTs on behalf of the user.
/// (the NFTs of other types cannot be created by BARS account).
pub fn encode_register_bars_user_script_function() -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("BARSToken").to_owned(),
        ),
        ident_str!("register_bars_user").to_owned(),
        vec![],
        vec![],
    ))
}

/// # Summary
/// Updates the gas constants stored on chain and used by the VM for gas
/// metering. This transaction can only be sent from the Diem Root account.
///
/// # Technical Description
/// Updates the on-chain config holding the `DiemVMConfig` and emits a
/// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system.
///
/// # Parameters
/// | Name                                | Type     | Description                                                                                            |
/// | ------                              | ------   | -------------                                                                                          |
/// | `account`                           | `signer` | Signer of the sending account. Must be the Diem Root account.                                          |
/// | `_sliding_nonce`                     | `u64`    | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                             |
/// | `global_memory_per_byte_cost`       | `u64`    | The new cost to read global memory per-byte to be used for gas metering.                               |
/// | `global_memory_per_byte_write_cost` | `u64`    | The new cost to write global memory per-byte to be used for gas metering.                              |
/// | `min_transaction_gas_units`         | `u64`    | The new flat minimum amount of gas required for any transaction.                                       |
/// | `large_transaction_cutoff`          | `u64`    | The new size over which an additional charge will be assessed for each additional byte.                |
/// | `intrinsic_gas_per_byte`            | `u64`    | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`.    |
/// | `maximum_number_of_gas_units`       | `u64`    | The new maximum number of gas units that can be set in a transaction.                                  |
/// | `min_price_per_gas_unit`            | `u64`    | The new minimum gas price that can be set for a transaction.                                           |
/// | `max_price_per_gas_unit`            | `u64`    | The new maximum gas price that can be set for a transaction.                                           |
/// | `max_transaction_size_in_bytes`     | `u64`    | The new maximum size of a transaction that can be processed.                                           |
/// | `gas_unit_scaling_factor`           | `u64`    | The new scaling factor to use when scaling between external and internal gas units.                    |
/// | `default_account_size`              | `u64`    | The new default account size to use when assessing final costs for reads and writes to global storage. |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                | Description                                                                                |
/// | ----------------           | --------------                              | -------------                                                                              |
/// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent.                                               |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                 | `account` is not the Diem Root account.                                                    |
pub fn encode_set_gas_constants_script_function(
    _sliding_nonce: u64,
    global_memory_per_byte_cost: u64,
    global_memory_per_byte_write_cost: u64,
    min_transaction_gas_units: u64,
    large_transaction_cutoff: u64,
    intrinsic_gas_per_byte: u64,
    maximum_number_of_gas_units: u64,
    min_price_per_gas_unit: u64,
    max_price_per_gas_unit: u64,
    max_transaction_size_in_bytes: u64,
    gas_unit_scaling_factor: u64,
    default_account_size: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("SystemAdministrationScripts").to_owned(),
        ),
        ident_str!("set_gas_constants").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&_sliding_nonce).unwrap(),
            bcs::to_bytes(&global_memory_per_byte_cost).unwrap(),
            bcs::to_bytes(&global_memory_per_byte_write_cost).unwrap(),
            bcs::to_bytes(&min_transaction_gas_units).unwrap(),
            bcs::to_bytes(&large_transaction_cutoff).unwrap(),
            bcs::to_bytes(&intrinsic_gas_per_byte).unwrap(),
            bcs::to_bytes(&maximum_number_of_gas_units).unwrap(),
            bcs::to_bytes(&min_price_per_gas_unit).unwrap(),
            bcs::to_bytes(&max_price_per_gas_unit).unwrap(),
            bcs::to_bytes(&max_transaction_size_in_bytes).unwrap(),
            bcs::to_bytes(&gas_unit_scaling_factor).unwrap(),
            bcs::to_bytes(&default_account_size).unwrap(),
        ],
    ))
}

/// Transfer `amount` of token with id `GUID::id(creator, creation_num)` from `owner`'s
/// balance to `to`'s balance. This operation has to be done by either the owner or an
/// approved operator of the owner.
pub fn encode_transfer_multi_token_between_galleries_script_function(
    token_type: TypeTag,
    to: AccountAddress,
    amount: u64,
    creator: AccountAddress,
    creation_num: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("MultiTokenBalance").to_owned(),
        ),
        ident_str!("transfer_multi_token_between_galleries").to_owned(),
        vec![token_type],
        vec![
            bcs::to_bytes(&to).unwrap(),
            bcs::to_bytes(&amount).unwrap(),
            bcs::to_bytes(&creator).unwrap(),
            bcs::to_bytes(&creation_num).unwrap(),
        ],
    ))
}

/// Transfer `amount` of token with id `GUID::id(creator, creation_num)` from `owner`'s
/// balance to `to`'s balance. This operation has to be done by either the owner or an
/// approved operator of the owner.
pub fn encode_transfer_token_between_galleries_script_function(
    token_type: TypeTag,
    to: AccountAddress,
    amount: u64,
    creator: AccountAddress,
    creation_num: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("NFTGallery").to_owned(),
        ),
        ident_str!("transfer_token_between_galleries").to_owned(),
        vec![token_type],
        vec![
            bcs::to_bytes(&to).unwrap(),
            bcs::to_bytes(&amount).unwrap(),
            bcs::to_bytes(&creator).unwrap(),
            bcs::to_bytes(&creation_num).unwrap(),
        ],
    ))
}

/// # Summary
/// Updates the Diem consensus config that is stored on-chain and is used by the Consensus.  This
/// transaction can only be sent from the Diem Root account.
///
/// # Technical Description
/// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
/// a reconfiguration of the system.
///
/// # Parameters
/// | Name            | Type          | Description                                                                |
/// | ------          | ------        | -------------                                                              |
/// | `account`       | `signer`      | Signer of the sending account. Must be the Diem Root account.              |
/// | `_sliding_nonce` | `u64`         | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
/// | `config`        | `vector<u8>`  | The serialized bytes of consensus config.                                  |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                |
/// | ----------------           | --------------                                | -------------                                                                              |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
pub fn encode_update_diem_consensus_config_script_function(
    _sliding_nonce: u64,
    config: Vec<u8>,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("SystemAdministrationScripts").to_owned(),
        ),
        ident_str!("update_diem_consensus_config").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&_sliding_nonce).unwrap(),
            bcs::to_bytes(&config).unwrap(),
        ],
    ))
}

/// # Summary
/// Updates the Diem major version that is stored on-chain and is used by the VM.  This
/// transaction can only be sent from the Diem Root account.
///
/// # Technical Description
/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater
/// than the current major version held on-chain. The VM reads this information and can use it to
/// preserve backwards compatibility with previous major versions of the VM.
///
/// # Parameters
/// | Name            | Type     | Description                                                                |
/// | ------          | ------   | -------------                                                              |
/// | `account`       | `signer` | Signer of the sending account. Must be the Diem Root account.              |
/// | `_sliding_nonce` | `u64`    | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
/// | `major`         | `u64`    | The `major` version of the VM to be used from this transaction on.         |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                |
/// | ----------------           | --------------                                | -------------                                                                              |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                   | `account` is not the Diem Root account.                                                    |
/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER`  | `major` is less-than or equal to the current major version stored on-chain.                |
pub fn encode_update_diem_version_script_function(
    _sliding_nonce: u64,
    major: u64,
) -> TransactionPayload {
    TransactionPayload::ScriptFunction(ScriptFunction::new(
        ModuleId::new(
            AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
            ident_str!("SystemAdministrationScripts").to_owned(),
        ),
        ident_str!("update_diem_version").to_owned(),
        vec![],
        vec![
            bcs::to_bytes(&_sliding_nonce).unwrap(),
            bcs::to_bytes(&major).unwrap(),
        ],
    ))
}

/// # Summary
/// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to
/// send, receive, and hold `Diem::Diem<Currency>` coins. This transaction can be
/// successfully sent by any account that is allowed to hold balances
/// (e.g., VASP, Designated Dealer).
///
/// # Technical Description
/// After the successful execution of this transaction the sending account will have a
/// `DiemAccount::Balance<Currency>` resource with zero balance published under it. Only
/// accounts that can hold balances can send this transaction, the sending account cannot
/// already have a `DiemAccount::Balance<Currency>` published under it.
///
/// # Parameters
/// | Name       | Type      | Description                                                                                                                                         |
/// | ------     | ------    | -------------                                                                                                                                       |
/// | `Currency` | Type      | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. |
/// | `account`  | `&signer` | The signer of the sending account of the transaction.                                                                                               |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                             | Description                                                                |
/// | ----------------            | --------------                           | -------------                                                              |
/// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                  | The `Currency` is not a registered currency on-chain.                      |
/// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances.                     |
/// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY`   | A balance for `Currency` is already published under the sending `account`. |
///
/// # Related Scripts
/// * `Script::create_child_vasp_account`
/// * `Script::create_parent_vasp_account`
/// * `Script::peer_to_peer_with_metadata`
pub fn encode_add_currency_to_account_script(currency: TypeTag) -> Script {
    Script::new(
        ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(),
        vec![currency],
        vec![],
    )
}

/// # Summary
/// Stores the sending accounts ability to rotate its authentication key with a designated recovery
/// account. Both the sending and recovery accounts need to belong to the same VASP and
/// both be VASP accounts. After this transaction both the sending account and the
/// specified recovery account can rotate the sender account's authentication key.
///
/// # Technical Description
/// Adds the `DiemAccount::KeyRotationCapability` for the sending account
/// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under
/// `recovery_address`. After this transaction has been executed successfully the account at
/// `recovery_address` and the `to_recover_account` may rotate the authentication key of
/// `to_recover_account` (the sender of this transaction).
///
/// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key
/// rotation capability, and must be a VASP account. The account at `recovery_address`
/// must also be a VASP account belonging to the same VASP as the `to_recover_account`.
/// Additionally the account at `recovery_address` must have already initialized itself as
/// a recovery account address using the `Script::create_recovery_address` transaction script.
///
/// The sending account's (`to_recover_account`) key rotation capability is
/// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress`
/// resource stored under the account at `recovery_address`.
///
/// # Parameters
/// | Name                 | Type      | Description                                                                                                |
/// | ------               | ------    | -------------                                                                                              |
/// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction.                                           |
/// | `recovery_address`   | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                              | Description                                                                                       |
/// | ----------------           | --------------                                            | -------------                                                                                     |
/// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.    |
/// | `Errors::NOT_PUBLISHED`    | `RecoveryAddress::ERECOVERY_ADDRESS`                      | `recovery_address` does not have a `RecoveryAddress` resource published under it.                 |
/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION`       | `to_recover_account` and `recovery_address` do not belong to the same VASP.                       |
/// | `Errors::LIMIT_EXCEEDED`   | ` RecoveryAddress::EMAX_KEYS_REGISTERED`                  | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. |
///
/// # Related Scripts
/// * `Script::create_recovery_address`
/// * `Script::rotate_authentication_key_with_recovery_address`
pub fn encode_add_recovery_rotation_capability_script(recovery_address: AccountAddress) -> Script {
    Script::new(
        ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(),
        vec![],
        vec![TransactionArgument::Address(recovery_address)],
    )
}

/// # Summary
/// Adds a validator account to the validator set, and triggers a
/// reconfiguration of the system to admit the account to the validator set for the system. This
/// transaction can only be successfully called by the Diem Root account.
///
/// # Technical Description
/// This script adds the account at `validator_address` to the validator set.
/// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a
/// reconfiguration. Once the reconfiguration triggered by this script's
/// execution has been performed, the account at the `validator_address` is
/// considered to be a validator in the network.
///
/// This transaction script will fail if the `validator_address` address is already in the validator set
/// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it.
///
/// # Parameters
/// | Name                | Type         | Description                                                                                                                        |
/// | ------              | ------       | -------------                                                                                                                      |
/// | `dr_account`        | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer.                                    |
/// | `sliding_nonce`     | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                         |
/// | `validator_name`    | `vector<u8>` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. |
/// | `validator_address` | `address`    | The validator account address to be added to the validator set.                                                                    |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                                                               |
/// | ----------------           | --------------                                | -------------                                                                                                                             |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                | A `SlidingNonce` resource is not published under `dr_account`.                                                                            |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.                                                |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                | The `sliding_nonce` is too far in the future.                                                                                             |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`       | The `sliding_nonce` has been previously recorded.                                                                                         |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                  | The sending account is not the Diem Root account.                                                                                        |
/// | `Errors::REQUIRES_ROLE`    | `Roles::EDIEM_ROOT`                          | The sending account is not the Diem Root account.                                                                                        |
/// | 0                          | 0                                             | The provided `validator_name` does not match the already-recorded human name for the validator.                                           |
/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. |
/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR`           | The `validator_address` account is already a registered validator.                                                                        |
/// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`            | An invalid time value was encountered in reconfiguration. Unlikely to occur.                                                              |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::register_validator_config`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_add_validator_and_reconfigure_script(
    sliding_nonce: u64,
    validator_name: Vec<u8>,
    validator_address: AccountAddress,
) -> Script {
    Script::new(
        ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U8Vector(validator_name),
            TransactionArgument::Address(validator_address),
        ],
    )
}

/// # Summary
/// Burns all coins held in the preburn resource at the specified
/// preburn address and removes them from the system. The sending account must
/// be the Treasury Compliance account.
/// The account that holds the preburn resource will normally be a Designated
/// Dealer, but there are no enforced requirements that it be one.
///
/// # Technical Description
/// This transaction permanently destroys all the coins of `Token` type
/// stored in the `Diem::Preburn<Token>` resource published under the
/// `preburn_address` account address.
///
/// This transaction will only succeed if the sending `account` has a
/// `Diem::BurnCapability<Token>`, and a `Diem::Preburn<Token>` resource
/// exists under `preburn_address`, with a non-zero `to_burn` field. After the successful execution
/// of this transaction the `total_value` field in the
/// `Diem::CurrencyInfo<Token>` resource published under `0xA550C18` will be
/// decremented by the value of the `to_burn` field of the preburn resource
/// under `preburn_address` immediately before this transaction, and the
/// `to_burn` field of the preburn resource will have a zero value.
///
/// ## Events
/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle
/// held in the `Diem::CurrencyInfo<Token>` resource's `burn_events` published under
/// `0xA550C18`.
///
/// # Parameters
/// | Name              | Type      | Description                                                                                                                  |
/// | ------            | ------    | -------------                                                                                                                |
/// | `Token`           | Type      | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain.                |
/// | `tc_account`      | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. |
/// | `sliding_nonce`   | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                   |
/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held.                                                                 |
///
/// # Common Abort Conditions
/// | Error Category                | Error Reason                            | Description                                                                                           |
/// | ----------------              | --------------                          | -------------                                                                                         |
/// | `Errors::NOT_PUBLISHED`       | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `account`.                                           |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.            |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                                         |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                                     |
/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY`               | The sending `account` does not have a `Diem::BurnCapability<Token>` published under it.              |
/// | `Errors::NOT_PUBLISHED`       | `Diem::EPREBURN`                       | The account at `preburn_address` does not have a `Diem::Preburn<Token>` resource published under it. |
/// | `Errors::INVALID_STATE`       | `Diem::EPREBURN_EMPTY`                 | The `Diem::Preburn<Token>` resource is empty (has a value of 0).                                     |
/// | `Errors::NOT_PUBLISHED`       | `Diem::ECURRENCY_INFO`                 | The specified `Token` is not a registered currency on-chain.                                          |
///
/// # Related Scripts
/// * `Script::burn_txn_fees`
/// * `Script::cancel_burn`
/// * `Script::preburn`
pub fn encode_burn_script(
    token: TypeTag,
    sliding_nonce: u64,
    preburn_address: AccountAddress,
) -> Script {
    Script::new(
        BURN_CODE.to_vec(),
        vec![token],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(preburn_address),
        ],
    )
}

/// # Summary
/// Burns the transaction fees collected in the `CoinType` currency so that the
/// Diem association may reclaim the backing coins off-chain. May only be sent
/// by the Treasury Compliance account.
///
/// # Technical Description
/// Burns the transaction fees collected in `CoinType` so that the
/// association may reclaim the backing coins. Once this transaction has executed
/// successfully all transaction fees that will have been collected in
/// `CoinType` since the last time this script was called with that specific
/// currency. Both `balance` and `preburn` fields in the
/// `TransactionFee::TransactionFee<CoinType>` resource published under the `0xB1E55ED`
/// account address will have a value of 0 after the successful execution of this script.
///
/// ## Events
/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle
/// held in the `Diem::CurrencyInfo<CoinType>` resource's `burn_events` published under
/// `0xA550C18`.
///
/// # Parameters
/// | Name         | Type      | Description                                                                                                                                         |
/// | ------       | ------    | -------------                                                                                                                                       |
/// | `CoinType`   | Type      | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. |
/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                           |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                          | Description                                                 |
/// | ----------------           | --------------                        | -------------                                               |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. |
/// | `Errors::NOT_PUBLISHED`    | `TransactionFee::ETRANSACTION_FEE`    | `CoinType` is not an accepted transaction fee currency.     |
/// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN`                        | The collected fees in `CoinType` are zero.                  |
///
/// # Related Scripts
/// * `Script::burn`
/// * `Script::cancel_burn`
pub fn encode_burn_txn_fees_script(coin_type: TypeTag) -> Script {
    Script::new(BURN_TXN_FEES_CODE.to_vec(), vec![coin_type], vec![])
}

/// # Summary
/// Cancels and returns all coins held in the preburn area under
/// `preburn_address` and returns the funds to the `preburn_address`'s balance.
/// Can only be successfully sent by an account with Treasury Compliance role.
///
/// # Technical Description
/// Cancels and returns all coins held in the `Diem::Preburn<Token>` resource under the `preburn_address` and
/// return the funds to the `preburn_address` account's `DiemAccount::Balance<Token>`.
/// The transaction must be sent by an `account` with a `Diem::BurnCapability<Token>`
/// resource published under it. The account at `preburn_address` must have a
/// `Diem::Preburn<Token>` resource published under it, and its value must be nonzero. The transaction removes
/// the entire balance held in the `Diem::Preburn<Token>` resource, and returns it back to the account's
/// `DiemAccount::Balance<Token>` under `preburn_address`. Due to this, the account at
/// `preburn_address` must already have a balance in the `Token` currency published
/// before this script is called otherwise the transaction will fail.
///
/// ## Events
/// The successful execution of this transaction will emit:
/// * A `Diem::CancelBurnEvent` on the event handle held in the `Diem::CurrencyInfo<Token>`
/// resource's `burn_events` published under `0xA550C18`.
/// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s
/// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee`
/// being `preburn_address`.
///
/// # Parameters
/// | Name              | Type      | Description                                                                                                                          |
/// | ------            | ------    | -------------                                                                                                                        |
/// | `Token`           | Type      | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. |
/// | `account`         | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it.         |
/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held.                                                                         |
///
/// # Common Abort Conditions
/// | Error Category                | Error Reason                                     | Description                                                                                           |
/// | ----------------              | --------------                                   | -------------                                                                                         |
/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY`                        | The sending `account` does not have a `Diem::BurnCapability<Token>` published under it.              |
/// | `Errors::NOT_PUBLISHED`       | `Diem::EPREBURN`                                | The account at `preburn_address` does not have a `Diem::Preburn<Token>` resource published under it. |
/// | `Errors::NOT_PUBLISHED`       | `Diem::ECURRENCY_INFO`                          | The specified `Token` is not a registered currency on-chain.                                          |
/// | `Errors::INVALID_ARGUMENT`    | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO`            | The value held in the preburn resource was zero.                                                      |
/// | `Errors::INVALID_ARGUMENT`    | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`.                         |
/// | `Errors::LIMIT_EXCEEDED`      | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`          | The depositing of the funds held in the prebun area would exceed the `account`'s account limits.      |
/// | `Errors::INVALID_STATE`       | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed.     |
///
/// # Related Scripts
/// * `Script::burn_txn_fees`
/// * `Script::burn`
/// * `Script::preburn`
pub fn encode_cancel_burn_script(token: TypeTag, preburn_address: AccountAddress) -> Script {
    Script::new(
        CANCEL_BURN_CODE.to_vec(),
        vec![token],
        vec![TransactionArgument::Address(preburn_address)],
    )
}

/// # Summary
/// Creates a Child VASP account with its parent being the sending account of the transaction.
/// The sender of the transaction must be a Parent VASP account.
///
/// # Technical Description
/// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of
/// `child_initial_balance` in `CoinType` and an initial authentication key of
/// `auth_key_prefix | child_address`.
///
/// If `add_all_currencies` is true, the child address will have a zero balance in all available
/// currencies in the system.
///
/// The new account will be a child account of the transaction sender, which must be a
/// Parent VASP account. The child account will be recorded against the limit of
/// child accounts of the creating Parent VASP account.
///
/// ## Events
/// Successful execution with a `child_initial_balance` greater than zero will emit:
/// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address,
/// and payee field being `child_address`. This is emitted on the Parent VASP's
/// `DiemAccount::DiemAccount` `sent_events` handle.
/// * A `DiemAccount::ReceivedPaymentEvent` with the  `payer` field being the Parent VASP's address,
/// and payee field being `child_address`. This is emitted on the new Child VASPS's
/// `DiemAccount::DiemAccount` `received_events` handle.
///
/// # Parameters
/// | Name                    | Type         | Description                                                                                                                                 |
/// | ------                  | ------       | -------------                                                                                                                               |
/// | `CoinType`              | Type         | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. |
/// | `parent_vasp`           | `&signer`    | The signer reference of the sending account. Must be a Parent VASP account.                                                                 |
/// | `child_address`         | `address`    | Address of the to-be-created Child VASP account.                                                                                            |
/// | `auth_key_prefix`       | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                    |
/// | `add_all_currencies`    | `bool`       | Whether to publish balance resources for all known currencies when the account is created.                                                  |
/// | `child_initial_balance` | `u64`        | The initial balance in `CoinType` to give the child account when it's created.                                                              |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                                             | Description                                                                              |
/// | ----------------            | --------------                                           | -------------                                                                            |
/// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`            | The `auth_key_prefix` was not of length 32.                                              |
/// | `Errors::REQUIRES_ROLE`     | `Roles::EPARENT_VASP`                                    | The sending account wasn't a Parent VASP account.                                        |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                                        | The `child_address` address is already taken.                                            |
/// | `Errors::LIMIT_EXCEEDED`    | `VASP::ETOO_MANY_CHILDREN`                               | The sending account has reached the maximum number of allowed child accounts.            |
/// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                                  | The `CoinType` is not a registered currency on-chain.                                    |
/// | `Errors::INVALID_STATE`     | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted.            |
/// | `Errors::NOT_PUBLISHED`     | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`              | The sending account doesn't have a balance in `CoinType`.                                |
/// | `Errors::LIMIT_EXCEEDED`    | `DiemAccount::EINSUFFICIENT_BALANCE`                    | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. |
/// | `Errors::INVALID_ARGUMENT`  | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED`            | The `child_address` is the reserved address 0x0.                                         |
///
/// # Related Scripts
/// * `Script::create_parent_vasp_account`
/// * `Script::add_currency_to_account`
/// * `Script::rotate_authentication_key`
/// * `Script::add_recovery_rotation_capability`
/// * `Script::create_recovery_address`
pub fn encode_create_child_vasp_account_script(
    coin_type: TypeTag,
    child_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    add_all_currencies: bool,
    child_initial_balance: u64,
) -> Script {
    Script::new(
        CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(),
        vec![coin_type],
        vec![
            TransactionArgument::Address(child_address),
            TransactionArgument::U8Vector(auth_key_prefix),
            TransactionArgument::Bool(add_all_currencies),
            TransactionArgument::U64(child_initial_balance),
        ],
    )
}

/// # Summary
/// Creates a Designated Dealer account with the provided information, and initializes it with
/// default mint tiers. The transaction can only be sent by the Treasury Compliance account.
///
/// # Technical Description
/// Creates an account with the Designated Dealer role at `addr` with authentication key
/// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true,
/// 0 balances for all available currencies in the system will also be added. This can only be
/// invoked by an account with the TreasuryCompliance role.
///
/// At the time of creation the account is also initialized with default mint tiers of (500_000,
/// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the
/// account.
///
/// # Parameters
/// | Name                 | Type         | Description                                                                                                                                         |
/// | ------               | ------       | -------------                                                                                                                                       |
/// | `Currency`           | Type         | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. |
/// | `tc_account`         | `&signer`    | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                           |
/// | `sliding_nonce`      | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                                          |
/// | `addr`               | `address`    | Address of the to-be-created Designated Dealer account.                                                                                             |
/// | `auth_key_prefix`    | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                            |
/// | `human_name`         | `vector<u8>` | ASCII-encoded human name for the Designated Dealer.                                                                                                 |
/// | `add_all_currencies` | `bool`       | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created.         |
///

/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::REQUIRES_ROLE`     | `Roles::ETREASURY_COMPLIANCE`           | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                 | The `Currency` is not a registered currency on-chain.                                      |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `addr` address is already taken.                                                       |
///
/// # Related Scripts
/// * `Script::tiered_mint`
/// * `Script::peer_to_peer_with_metadata`
/// * `Script::rotate_dual_attestation_info`
pub fn encode_create_designated_dealer_script(
    currency: TypeTag,
    sliding_nonce: u64,
    addr: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
    add_all_currencies: bool,
) -> Script {
    Script::new(
        CREATE_DESIGNATED_DEALER_CODE.to_vec(),
        vec![currency],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(addr),
            TransactionArgument::U8Vector(auth_key_prefix),
            TransactionArgument::U8Vector(human_name),
            TransactionArgument::Bool(add_all_currencies),
        ],
    )
}

/// # Summary
/// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account.
///
/// # Technical Description
/// Creates an account with the Parent VASP role at `address` with authentication key
/// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If
/// `add_all_currencies` is true, 0 balances for all available currencies in the system will
/// also be added. This can only be invoked by an TreasuryCompliance account.
/// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details.
///
/// # Parameters
/// | Name                  | Type         | Description                                                                                                                                                    |
/// | ------                | ------       | -------------                                                                                                                                                  |
/// | `CoinType`            | Type         | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. |
/// | `tc_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                                                      |
/// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                                                     |
/// | `new_account_address` | `address`    | Address of the to-be-created Parent VASP account.                                                                                                              |
/// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.                                                                       |
/// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the Parent VASP.                                                                                                                  |
/// | `add_all_currencies`  | `bool`       | Whether to publish balance resources for all known currencies when the account is created.                                                                     |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::REQUIRES_ROLE`     | `Roles::ETREASURY_COMPLIANCE`           | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::NOT_PUBLISHED`     | `Diem::ECURRENCY_INFO`                 | The `CoinType` is not a registered currency on-chain.                                      |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
///
/// # Related Scripts
/// * `Script::create_child_vasp_account`
/// * `Script::add_currency_to_account`
/// * `Script::rotate_authentication_key`
/// * `Script::add_recovery_rotation_capability`
/// * `Script::create_recovery_address`
/// * `Script::rotate_dual_attestation_info`
pub fn encode_create_parent_vasp_account_script(
    coin_type: TypeTag,
    sliding_nonce: u64,
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
    add_all_currencies: bool,
) -> Script {
    Script::new(
        CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(),
        vec![coin_type],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(new_account_address),
            TransactionArgument::U8Vector(auth_key_prefix),
            TransactionArgument::U8Vector(human_name),
            TransactionArgument::Bool(add_all_currencies),
        ],
    )
}

/// # Summary
/// Initializes the sending account as a recovery address that may be used by
/// the VASP that it belongs to. The sending account must be a VASP account.
/// Multiple recovery addresses can exist for a single VASP, but accounts in
/// each must be disjoint.
///
/// # Technical Description
/// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then
/// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds
/// it to the resource. After the successful execution of this transaction
/// other accounts may add their key rotation to this resource so that `account`
/// may be used as a recovery account for those accounts.
///
/// # Parameters
/// | Name      | Type      | Description                                           |
/// | ------    | ------    | -------------                                         |
/// | `account` | `&signer` | The signer of the sending account of the transaction. |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                                               | Description                                                                                   |
/// | ----------------            | --------------                                             | -------------                                                                                 |
/// | `Errors::INVALID_STATE`     | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.          |
/// | `Errors::INVALID_ARGUMENT`  | `RecoveryAddress::ENOT_A_VASP`                             | `account` is not a VASP account.                                                              |
/// | `Errors::INVALID_ARGUMENT`  | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE`          | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. |
/// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS`                       | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`.     |
///
/// # Related Scripts
/// * `Script::add_recovery_rotation_capability`
/// * `Script::rotate_authentication_key_with_recovery_address`
pub fn encode_create_recovery_address_script() -> Script {
    Script::new(CREATE_RECOVERY_ADDRESS_CODE.to_vec(), vec![], vec![])
}

/// # Summary
/// Creates a Validator account. This transaction can only be sent by the Diem
/// Root account.
///
/// # Technical Description
/// Creates an account with a Validator role at `new_account_address`, with authentication key
/// `auth_key_prefix` | `new_account_address`. It publishes a
/// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and
/// `operator_account` fields. The `human_name` field of the
/// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`.
/// This script does not add the validator to the validator set or the system,
/// but only creates the account.
///
/// # Parameters
/// | Name                  | Type         | Description                                                                                     |
/// | ------                | ------       | -------------                                                                                   |
/// | `dr_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer. |
/// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                      |
/// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                                 |
/// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.        |
/// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                                     |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
/// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
///
/// # Related Scripts
/// * `Script::add_validator_and_reconfigure`
/// * `Script::create_validator_operator_account`
/// * `Script::register_validator_config`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_create_validator_account_script(
    sliding_nonce: u64,
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
) -> Script {
    Script::new(
        CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(new_account_address),
            TransactionArgument::U8Vector(auth_key_prefix),
            TransactionArgument::U8Vector(human_name),
        ],
    )
}

/// # Summary
/// Creates a Validator Operator account. This transaction can only be sent by the Diem
/// Root account.
///
/// # Technical Description
/// Creates an account with a Validator Operator role at `new_account_address`, with authentication key
/// `auth_key_prefix` | `new_account_address`. It publishes a
/// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`.
/// This script does not assign the validator operator to any validator accounts but only creates the account.
///
/// # Parameters
/// | Name                  | Type         | Description                                                                                     |
/// | ------                | ------       | -------------                                                                                   |
/// | `dr_account`          | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer. |
/// | `sliding_nonce`       | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                      |
/// | `new_account_address` | `address`    | Address of the to-be-created Validator account.                                                 |
/// | `auth_key_prefix`     | `vector<u8>` | The authentication key prefix that will be used initially for the newly created account.        |
/// | `human_name`          | `vector<u8>` | ASCII-encoded human name for the validator.                                                     |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                            | Description                                                                                |
/// | ----------------            | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`     | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                             |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT`  | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS`  | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                         |
/// | `Errors::REQUIRES_ROLE`     | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                         |
/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID`                       | The `new_account_address` address is already taken.                                        |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::register_validator_config`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_create_validator_operator_account_script(
    sliding_nonce: u64,
    new_account_address: AccountAddress,
    auth_key_prefix: Vec<u8>,
    human_name: Vec<u8>,
) -> Script {
    Script::new(
        CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(new_account_address),
            TransactionArgument::U8Vector(auth_key_prefix),
            TransactionArgument::U8Vector(human_name),
        ],
    )
}

/// # Summary
/// Freezes the account at `address`. The sending account of this transaction
/// must be the Treasury Compliance account. The account being frozen cannot be
/// the Diem Root or Treasury Compliance account. After the successful
/// execution of this transaction no transactions may be sent from the frozen
/// account, and the frozen account may not send or receive coins.
///
/// # Technical Description
/// Sets the `AccountFreezing::FreezingBit` to `true` and emits a
/// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the
/// Treasury Compliance account, but the account at `to_freeze_account` must
/// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the
/// Treasury Compliance address). Note that this is a per-account property
/// e.g., freezing a Parent VASP will not effect the status any of its child
/// accounts and vice versa.
///

/// ## Events
/// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on
/// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published
/// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`.
///
/// # Parameters
/// | Name                | Type      | Description                                                                                               |
/// | ------              | ------    | -------------                                                                                             |
/// | `tc_account`        | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
/// | `sliding_nonce`     | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
/// | `to_freeze_account` | `address` | The account address to be frozen.                                                                         |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                 | Description                                                                                |
/// | ----------------           | --------------                               | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`               | A `SlidingNonce` resource is not published under `tc_account`.                             |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`               | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`               | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`      | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`        | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::REQUIRES_ROLE`    | `Roles::ETREASURY_COMPLIANCE`                | The sending account is not the Treasury Compliance account.                                |
/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC`         | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`).                     |
/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`).                              |
///
/// # Related Scripts
/// * `Script::unfreeze_account`
pub fn encode_freeze_account_script(
    sliding_nonce: u64,
    to_freeze_account: AccountAddress,
) -> Script {
    Script::new(
        FREEZE_ACCOUNT_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(to_freeze_account),
        ],
    )
}

/// # Summary
/// Transfers a given number of coins in a specified currency from one account to another.
/// Transfers over a specified amount defined on-chain that are between two different VASPs, or
/// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has
/// agreed to receive the coins.  This transaction can be sent by any account that can hold a
/// balance, and to any account that can hold a balance. Both accounts must hold balances in the
/// currency being transacted.
///
/// # Technical Description
///
/// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated
/// `metadata` and an (optional) `metadata_signature` on the message
/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`.
/// The `metadata` and `metadata_signature` parameters are only required if `amount` >=
/// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs.
/// However, a transaction sender can opt in to dual attestation even when it is not required
/// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`.
/// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`.
///
/// ## Events
/// Successful execution of this script emits two events:
/// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and
/// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle.
///
/// # Parameters
/// | Name                 | Type         | Description                                                                                                                  |
/// | ------               | ------       | -------------                                                                                                                |
/// | `Currency`           | Type         | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. |
/// | `payer`              | `&signer`    | The signer reference of the sending account that coins are being transferred from.                                           |
/// | `payee`              | `address`    | The address of the account the coins are being transferred to.                                                               |
/// | `metadata`           | `vector<u8>` | Optional metadata about this payment.                                                                                        |
/// | `metadata_signature` | `vector<u8>` | Optional signature over `metadata` and payment information. See                                                              |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                     | Description                                                                                                                         |
/// | ----------------           | --------------                                   | -------------                                                                                                                       |
/// | `Errors::NOT_PUBLISHED`    | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`      | `payer` doesn't hold a balance in `Currency`.                                                                                       |
/// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EINSUFFICIENT_BALANCE`            | `amount` is greater than `payer`'s balance in `Currency`.                                                                           |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO`            | `amount` is zero.                                                                                                                   |
/// | `Errors::NOT_PUBLISHED`    | `DiemAccount::EPAYEE_DOES_NOT_EXIST`            | No account exists at the `payee` address.                                                                                           |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`.                                                        |
/// | `Errors::INVALID_STATE`    | `AccountFreezing::EACCOUNT_FROZEN`               | The `payee` account is frozen.                                                                                                      |
/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes.                                                                                               |
/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE`   | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. |
/// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS`       | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX.                                                      |
/// | `Errors::LIMIT_EXCEEDED`   | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`          | `payee` has exceeded its daily deposit limits for XDX.                                                                              |
///
/// # Related Scripts
/// * `Script::create_child_vasp_account`
/// * `Script::create_parent_vasp_account`
/// * `Script::add_currency_to_account`
pub fn encode_peer_to_peer_with_metadata_script(
    currency: TypeTag,
    payee: AccountAddress,
    amount: u64,
    metadata: Vec<u8>,
    metadata_signature: Vec<u8>,
) -> Script {
    Script::new(
        PEER_TO_PEER_WITH_METADATA_CODE.to_vec(),
        vec![currency],
        vec![
            TransactionArgument::Address(payee),
            TransactionArgument::U64(amount),
            TransactionArgument::U8Vector(metadata),
            TransactionArgument::U8Vector(metadata_signature),
        ],
    )
}

/// # Summary
/// Moves a specified number of coins in a given currency from the account's
/// balance to its preburn area after which the coins may be burned. This
/// transaction may be sent by any account that holds a balance and preburn area
/// in the specified currency.
///
/// # Technical Description
/// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s
/// `DiemAccount::Balance<Token>` to the `Diem::Preburn<Token>` published under the same
/// `account`. `account` must have both of these resources published under it at the start of this
/// transaction in order for it to execute successfully.
///
/// ## Events
/// Successful execution of this script emits two events:
/// * `DiemAccount::SentPaymentEvent ` on `account`'s `DiemAccount::DiemAccount` `sent_events`
/// handle with the `payee` and `payer` fields being `account`'s address; and
/// * A `Diem::PreburnEvent` with `Token`'s currency code on the
/// `Diem::CurrencyInfo<Token`'s `preburn_events` handle for `Token` and with
/// `preburn_address` set to `account`'s address.
///
/// # Parameters
/// | Name      | Type      | Description                                                                                                                      |
/// | ------    | ------    | -------------                                                                                                                    |
/// | `Token`   | Type      | The Move type for the `Token` currency being moved to the preburn area. `Token` must be an already-registered currency on-chain. |
/// | `account` | `&signer` | The signer reference of the sending account.                                                                                     |
/// | `amount`  | `u64`     | The amount in `Token` to be moved to the preburn area.                                                                           |
///
/// # Common Abort Conditions
/// | Error Category           | Error Reason                                             | Description                                                                             |
/// | ----------------         | --------------                                           | -------------                                                                           |
/// | `Errors::NOT_PUBLISHED`  | `Diem::ECURRENCY_INFO`                                  | The `Token` is not a registered currency on-chain.                                      |
/// | `Errors::INVALID_STATE`  | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for `account` has already been extracted.                     |
/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE`                    | `amount` is greater than `payer`'s balance in `Token`.                                  |
/// | `Errors::NOT_PUBLISHED`  | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY`              | `account` doesn't hold a balance in `Token`.                                            |
/// | `Errors::NOT_PUBLISHED`  | `Diem::EPREBURN`                                        | `account` doesn't have a `Diem::Preburn<Token>` resource published under it.           |
/// | `Errors::INVALID_STATE`  | `Diem::EPREBURN_OCCUPIED`                               | The `value` field in the `Diem::Preburn<Token>` resource under the sender is non-zero. |
/// | `Errors::NOT_PUBLISHED`  | `Roles::EROLE_ID`                                        | The `account` did not have a role assigned to it.                                       |
/// | `Errors::REQUIRES_ROLE`  | `Roles::EDESIGNATED_DEALER`                              | The `account` did not have the role of DesignatedDealer.                                |
///
/// # Related Scripts
/// * `Script::cancel_burn`
/// * `Script::burn`
/// * `Script::burn_txn_fees`
pub fn encode_preburn_script(token: TypeTag, amount: u64) -> Script {
    Script::new(
        PREBURN_CODE.to_vec(),
        vec![token],
        vec![TransactionArgument::U64(amount)],
    )
}

/// # Summary
/// Rotates the authentication key of the sending account to the
/// newly-specified public key and publishes a new shared authentication key
/// under the sender's account. Any account can send this transaction.
///
/// # Technical Description
/// Rotates the authentication key of the sending account to `public_key`,
/// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource
/// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for
/// `account` under `account`.
///
/// # Parameters
/// | Name         | Type         | Description                                                                               |
/// | ------       | ------       | -------------                                                                             |
/// | `account`    | `&signer`    | The signer reference of the sending account of the transaction.                           |
/// | `public_key` | `vector<u8>` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. |
///
/// # Common Abort Conditions
/// | Error Category              | Error Reason                                               | Description                                                                                         |
/// | ----------------            | --------------                                             | -------------                                                                                       |
/// | `Errors::INVALID_STATE`     | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource.       |
/// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY`                      | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. |
/// | `Errors::INVALID_ARGUMENT`  | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY`            | `public_key` is an invalid ed25519 public key.                                                      |
///
/// # Related Scripts
/// * `Script::rotate_shared_ed25519_public_key`
pub fn encode_publish_shared_ed25519_public_key_script(public_key: Vec<u8>) -> Script {
    Script::new(
        PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(),
        vec![],
        vec![TransactionArgument::U8Vector(public_key)],
    )
}

/// # Summary
/// Updates a validator's configuration. This does not reconfigure the system and will not update
/// the configuration in the validator set that is seen by other validators in the network. Can
/// only be successfully sent by a Validator Operator account that is already registered with a
/// validator.
///
/// # Technical Description
/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig`
/// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent`
/// so the copy of this config held in the validator set will not be updated, and the changes are
/// only "locally" under the `validator_account` account address.
///
/// # Parameters
/// | Name                          | Type         | Description                                                                                                                  |
/// | ------                        | ------       | -------------                                                                                                                |
/// | `validator_operator_account`  | `&signer`    | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. |
/// | `validator_account`           | `address`    | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated.                                    |
/// | `consensus_pubkey`            | `vector<u8>` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`.                                         |
/// | `validator_network_addresses` | `vector<u8>` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                       |
/// | `fullnode_network_addresses`  | `vector<u8>` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                        |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                   | Description                                                                                           |
/// | ----------------           | --------------                                 | -------------                                                                                         |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`           | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it.   |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY`      | `consensus_pubkey` is not a valid ed25519 public key.                                                 |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_register_validator_config_script(
    validator_account: AccountAddress,
    consensus_pubkey: Vec<u8>,
    validator_network_addresses: Vec<u8>,
    fullnode_network_addresses: Vec<u8>,
) -> Script {
    Script::new(
        REGISTER_VALIDATOR_CONFIG_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::Address(validator_account),
            TransactionArgument::U8Vector(consensus_pubkey),
            TransactionArgument::U8Vector(validator_network_addresses),
            TransactionArgument::U8Vector(fullnode_network_addresses),
        ],
    )
}

/// # Summary
/// This script removes a validator account from the validator set, and triggers a reconfiguration
/// of the system to remove the validator from the system. This transaction can only be
/// successfully called by the Diem Root account.
///
/// # Technical Description
/// This script removes the account at `validator_address` from the validator set. This transaction
/// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event
/// has been performed, the account at `validator_address` is no longer considered to be a
/// validator in the network. This transaction will fail if the validator at `validator_address`
/// is not in the validator set.
///
/// # Parameters
/// | Name                | Type         | Description                                                                                                                        |
/// | ------              | ------       | -------------                                                                                                                      |
/// | `dr_account`        | `&signer`    | The signer reference of the sending account of this transaction. Must be the Diem Root signer.                                    |
/// | `sliding_nonce`     | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                                         |
/// | `validator_name`    | `vector<u8>` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. |
/// | `validator_address` | `address`    | The validator account address to be removed from the validator set.                                                                |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                            | Description                                                                                     |
/// | ----------------           | --------------                          | -------------                                                                                   |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `dr_account`.                                  |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.      |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                                   |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                               |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | The sending account is not the Diem Root account or Treasury Compliance account                |
/// | 0                          | 0                                       | The provided `validator_name` does not match the already-recorded human name for the validator. |
/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set.                                        |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`            | The sending account is not the Diem Root account.                                              |
/// | `Errors::REQUIRES_ROLE`    | `Roles::EDIEM_ROOT`                    | The sending account is not the Diem Root account.                                              |
/// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`      | An invalid time value was encountered in reconfiguration. Unlikely to occur.                    |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::register_validator_config`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_remove_validator_and_reconfigure_script(
    sliding_nonce: u64,
    validator_name: Vec<u8>,
    validator_address: AccountAddress,
) -> Script {
    Script::new(
        REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U8Vector(validator_name),
            TransactionArgument::Address(validator_address),
        ],
    )
}

/// # Summary
/// Rotates the transaction sender's authentication key to the supplied new authentication key. May
/// be sent by any account.
///
/// # Technical Description
/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
/// its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name      | Type         | Description                                                 |
/// | ------    | ------       | -------------                                               |
/// | `account` | `&signer`    | Signer reference of the sending account of the transaction. |
/// | `new_key` | `vector<u8>` | New ed25519 public key to be used for `account`.            |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                               | Description                                                                              |
/// | ----------------           | --------------                                             | -------------                                                                            |
/// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.     |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                         |
///
/// # Related Scripts
/// * `Script::rotate_authentication_key_with_nonce`
/// * `Script::rotate_authentication_key_with_nonce_admin`
/// * `Script::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_script(new_key: Vec<u8>) -> Script {
    Script::new(
        ROTATE_AUTHENTICATION_KEY_CODE.to_vec(),
        vec![],
        vec![TransactionArgument::U8Vector(new_key)],
    )
}

/// # Summary
/// Rotates the sender's authentication key to the supplied new authentication key. May be sent by
/// any account that has a sliding nonce resource published under it (usually this is Treasury
/// Compliance or Diem Root accounts).
///
/// # Technical Description
/// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
/// its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name            | Type         | Description                                                                |
/// | ------          | ------       | -------------                                                              |
/// | `account`       | `&signer`    | Signer reference of the sending account of the transaction.                |
/// | `sliding_nonce` | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
/// | `new_key`       | `vector<u8>` | New ed25519 public key to be used for `account`.                           |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                               | Description                                                                                |
/// | ----------------           | --------------                                             | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                             | A `SlidingNonce` resource is not published under `account`.                                |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                             | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                             | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`                    | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.       |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                           |
///
/// # Related Scripts
/// * `Script::rotate_authentication_key`
/// * `Script::rotate_authentication_key_with_nonce_admin`
/// * `Script::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_with_nonce_script(
    sliding_nonce: u64,
    new_key: Vec<u8>,
) -> Script {
    Script::new(
        ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U8Vector(new_key),
        ],
    )
}

/// # Summary
/// Rotates the specified account's authentication key to the supplied new authentication key. May
/// only be sent by the Diem Root account as a write set transaction.
///
/// # Technical Description
/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`.
/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated
/// its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name            | Type         | Description                                                                                                  |
/// | ------          | ------       | -------------                                                                                                |
/// | `dr_account`    | `&signer`    | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. |
/// | `account`       | `&signer`    | Signer reference of account specified in the `execute_as` field of the write set transaction.                |
/// | `sliding_nonce` | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root.                    |
/// | `new_key`       | `vector<u8>` | New ed25519 public key to be used for `account`.                                                             |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                               | Description                                                                                                |
/// | ----------------           | --------------                                             | -------------                                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                             | A `SlidingNonce` resource is not published under `dr_account`.                                             |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                             | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                             | The `sliding_nonce` in `dr_account` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`                    | The `sliding_nonce` in` dr_account` has been previously recorded.                                          |
/// | `Errors::INVALID_STATE`    | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`.                       |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY`              | `new_key` was an invalid length.                                                                           |
///
/// # Related Scripts
/// * `Script::rotate_authentication_key`
/// * `Script::rotate_authentication_key_with_nonce`
/// * `Script::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_with_nonce_admin_script(
    sliding_nonce: u64,
    new_key: Vec<u8>,
) -> Script {
    Script::new(
        ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U8Vector(new_key),
        ],
    )
}

/// # Summary
/// Rotates the authentication key of a specified account that is part of a recovery address to a
/// new authentication key. Only used for accounts that are part of a recovery address (see
/// `Script::add_recovery_rotation_capability` for account restrictions).
///
/// # Technical Description
/// Rotates the authentication key of the `to_recover` account to `new_key` using the
/// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource
/// published under `recovery_address`. This transaction can be sent either by the `to_recover`
/// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published
/// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name               | Type         | Description                                                                                                                    |
/// | ------             | ------       | -------------                                                                                                                  |
/// | `account`          | `&signer`    | Signer reference of the sending account of the transaction.                                                                    |
/// | `recovery_address` | `address`    | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. |
/// | `to_recover`       | `address`    | The address of the account whose authentication key will be updated.                                                           |
/// | `new_key`          | `vector<u8>` | New ed25519 public key to be used for the account at the `to_recover` address.                                                 |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                                                                          |
/// | ----------------           | --------------                                | -------------                                                                                                                                        |
/// | `Errors::NOT_PUBLISHED`    | `RecoveryAddress::ERECOVERY_ADDRESS`          | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it.                                                   |
/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY`         | The address of `account` is not `recovery_address` or `to_recover`.                                                                                  |
/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE`   | `to_recover`'s `DiemAccount::KeyRotationCapability`  is not in the `RecoveryAddress::RecoveryAddress`  resource published under `recovery_address`. |
/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length.                                                                                                                     |
///
/// # Related Scripts
/// * `Script::rotate_authentication_key`
/// * `Script::rotate_authentication_key_with_nonce`
/// * `Script::rotate_authentication_key_with_nonce_admin`
pub fn encode_rotate_authentication_key_with_recovery_address_script(
    recovery_address: AccountAddress,
    to_recover: AccountAddress,
    new_key: Vec<u8>,
) -> Script {
    Script::new(
        ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::Address(recovery_address),
            TransactionArgument::Address(to_recover),
            TransactionArgument::U8Vector(new_key),
        ],
    )
}

/// # Summary
/// Updates the url used for off-chain communication, and the public key used to verify dual
/// attestation on-chain. Transaction can be sent by any account that has dual attestation
/// information published under it. In practice the only such accounts are Designated Dealers and
/// Parent VASPs.
///
/// # Technical Description
/// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential`
/// resource published under `account`. The `new_key` must be a valid ed25519 public key.
///
/// ## Events
/// Successful execution of this transaction emits two events:
/// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and
/// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential`
/// `compliance_key_rotation_events` handle published under `account`; and
/// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for
/// off-chain communication, and the blockchain time at which the url was updated emitted on the
/// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`.
///
/// # Parameters
/// | Name      | Type         | Description                                                               |
/// | ------    | ------       | -------------                                                             |
/// | `account` | `&signer`    | Signer reference of the sending account of the transaction.               |
/// | `new_url` | `vector<u8>` | ASCII-encoded url to be used for off-chain communication with `account`.  |
/// | `new_key` | `vector<u8>` | New ed25519 public key to be used for on-chain dual attestation checking. |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                           | Description                                                                |
/// | ----------------           | --------------                         | -------------                                                              |
/// | `Errors::NOT_PUBLISHED`    | `DualAttestation::ECREDENTIAL`         | A `DualAttestation::Credential` resource is not published under `account`. |
/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key.                               |
///
/// # Related Scripts
/// * `Script::create_parent_vasp_account`
/// * `Script::create_designated_dealer`
/// * `Script::rotate_dual_attestation_info`
pub fn encode_rotate_dual_attestation_info_script(new_url: Vec<u8>, new_key: Vec<u8>) -> Script {
    Script::new(
        ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U8Vector(new_url),
            TransactionArgument::U8Vector(new_key),
        ],
    )
}

/// # Summary
/// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by
/// any account that has previously published a shared ed25519 public key using
/// `Script::publish_shared_ed25519_public_key`.
///
/// # Technical Description
/// This first rotates the public key stored in `account`'s
/// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it
/// rotates the authentication key using the capability stored in `account`'s
/// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key`
///
/// # Parameters
/// | Name         | Type         | Description                                                     |
/// | ------       | ------       | -------------                                                   |
/// | `account`    | `&signer`    | The signer reference of the sending account of the transaction. |
/// | `public_key` | `vector<u8>` | 32-byte Ed25519 public key.                                     |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                    | Description                                                                                   |
/// | ----------------           | --------------                                  | -------------                                                                                 |
/// | `Errors::NOT_PUBLISHED`    | `SharedEd25519PublicKey::ESHARED_KEY`           | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. |
/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key.                                                |
///
/// # Related Scripts
/// * `Script::publish_shared_ed25519_public_key`
pub fn encode_rotate_shared_ed25519_public_key_script(public_key: Vec<u8>) -> Script {
    Script::new(
        ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(),
        vec![],
        vec![TransactionArgument::U8Vector(public_key)],
    )
}

/// # Summary
/// Updates a validator's configuration, and triggers a reconfiguration of the system to update the
/// validator set with this new validator configuration.  Can only be successfully sent by a
/// Validator Operator account that is already registered with a validator.
///
/// # Technical Description
/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig`
/// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to
/// trigger a reconfiguration of the system.  This reconfiguration will update the validator set
/// on-chain with the updated `ValidatorConfig::ValidatorConfig`.
///
/// # Parameters
/// | Name                          | Type         | Description                                                                                                                  |
/// | ------                        | ------       | -------------                                                                                                                |
/// | `validator_operator_account`  | `&signer`    | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. |
/// | `validator_account`           | `address`    | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated.                                    |
/// | `consensus_pubkey`            | `vector<u8>` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`.                                         |
/// | `validator_network_addresses` | `vector<u8>` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                       |
/// | `fullnode_network_addresses`  | `vector<u8>` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`.                        |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                   | Description                                                                                           |
/// | ----------------           | --------------                                 | -------------                                                                                         |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`           | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it.   |
/// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR_OPERATOR`                   | `validator_operator_account` does not have a Validator Operator role.                                 |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY`      | `consensus_pubkey` is not a valid ed25519 public key.                                                 |
/// | `Errors::INVALID_STATE`    | `DiemConfig::EINVALID_BLOCK_TIME`             | An invalid time value was encountered in reconfiguration. Unlikely to occur.                          |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::register_validator_config`
pub fn encode_set_validator_config_and_reconfigure_script(
    validator_account: AccountAddress,
    consensus_pubkey: Vec<u8>,
    validator_network_addresses: Vec<u8>,
    fullnode_network_addresses: Vec<u8>,
) -> Script {
    Script::new(
        SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::Address(validator_account),
            TransactionArgument::U8Vector(consensus_pubkey),
            TransactionArgument::U8Vector(validator_network_addresses),
            TransactionArgument::U8Vector(fullnode_network_addresses),
        ],
    )
}

/// # Summary
/// Sets the validator operator for a validator in the validator's configuration resource "locally"
/// and does not reconfigure the system. Changes from this transaction will not picked up by the
/// system until a reconfiguration of the system is triggered. May only be sent by an account with
/// Validator role.
///
/// # Technical Description
/// Sets the account at `operator_account` address and with the specified `human_name` as an
/// operator for the sending validator account. The account at `operator_account` address must have
/// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig`
/// resource published under it. The sending `account` must be a Validator and have a
/// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a
/// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script.
///
/// # Parameters
/// | Name               | Type         | Description                                                                                  |
/// | ------             | ------       | -------------                                                                                |
/// | `account`          | `&signer`    | The signer reference of the sending account of the transaction.                              |
/// | `operator_name`    | `vector<u8>` | Validator operator's human name.                                                             |
/// | `operator_account` | `address`    | Address of the validator operator account to be added as the `account` validator's operator. |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                          | Description                                                                                                                                                  |
/// | ----------------           | --------------                                        | -------------                                                                                                                                                |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`.                                                   |
/// | 0                          | 0                                                     | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. |
/// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR`                                   | `account` does not have a Validator account role.                                                                                                            |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR`          | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource.                                               |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`                  | A `ValidatorConfig::ValidatorConfig` is not published under `account`.                                                                                       |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::register_validator_config`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::set_validator_operator_with_nonce_admin`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_set_validator_operator_script(
    operator_name: Vec<u8>,
    operator_account: AccountAddress,
) -> Script {
    Script::new(
        SET_VALIDATOR_OPERATOR_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U8Vector(operator_name),
            TransactionArgument::Address(operator_account),
        ],
    )
}

/// # Summary
/// Sets the validator operator for a validator in the validator's configuration resource "locally"
/// and does not reconfigure the system. Changes from this transaction will not picked up by the
/// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root
/// account as a write set transaction.
///
/// # Technical Description
/// Sets the account at `operator_account` address and with the specified `human_name` as an
/// operator for the validator `account`. The account at `operator_account` address must have a
/// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource
/// published under it. The account represented by the `account` signer must be a Validator and
/// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of
/// the system is initiated by this script.
///
/// # Parameters
/// | Name               | Type         | Description                                                                                                  |
/// | ------             | ------       | -------------                                                                                                |
/// | `dr_account`       | `&signer`    | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. |
/// | `account`          | `&signer`    | Signer reference of account specified in the `execute_as` field of the write set transaction.                |
/// | `sliding_nonce`    | `u64`        | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root.                    |
/// | `operator_name`    | `vector<u8>` | Validator operator's human name.                                                                             |
/// | `operator_account` | `address`    | Address of the validator operator account to be added as the `account` validator's operator.                 |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                          | Description                                                                                                                                                  |
/// | ----------------           | --------------                                        | -------------                                                                                                                                                |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                        | A `SlidingNonce` resource is not published under `dr_account`.                                                                                               |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                        | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not.                                                   |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                        | The `sliding_nonce` in `dr_account` is too far in the future.                                                                                                |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`               | The `sliding_nonce` in` dr_account` has been previously recorded.                                                                                            |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                        | The sending account is not the Diem Root account or Treasury Compliance account                                                                             |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`.                                                   |
/// | 0                          | 0                                                     | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. |
/// | `Errors::REQUIRES_ROLE`    | `Roles::EVALIDATOR`                                   | `account` does not have a Validator account role.                                                                                                            |
/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR`          | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource.                                               |
/// | `Errors::NOT_PUBLISHED`    | `ValidatorConfig::EVALIDATOR_CONFIG`                  | A `ValidatorConfig::ValidatorConfig` is not published under `account`.                                                                                       |
///
/// # Related Scripts
/// * `Script::create_validator_account`
/// * `Script::create_validator_operator_account`
/// * `Script::register_validator_config`
/// * `Script::remove_validator_and_reconfigure`
/// * `Script::add_validator_and_reconfigure`
/// * `Script::set_validator_operator`
/// * `Script::set_validator_config_and_reconfigure`
pub fn encode_set_validator_operator_with_nonce_admin_script(
    sliding_nonce: u64,
    operator_name: Vec<u8>,
    operator_account: AccountAddress,
) -> Script {
    Script::new(
        SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U8Vector(operator_name),
            TransactionArgument::Address(operator_account),
        ],
    )
}

/// # Summary
/// Mints a specified number of coins in a currency to a Designated Dealer. The sending account
/// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer
/// account.
///
/// # Technical Description
/// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at
/// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to
/// check verify the off-chain approval policy, and is based in part on the on-chain tier values
/// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to
/// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that
/// they support. The sending `tc_account` must be the Treasury Compliance account, and the
/// receiver an authorized Designated Dealer account.
///
/// ## Events
/// Successful execution of the transaction will emit two events:
/// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the
/// `mint_event_handle` in the stored `Diem::CurrencyInfo<CoinType>` resource stored under
/// `0xA550C18`; and
/// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated
/// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer`
/// resource published under the `designated_dealer_address`.
///
/// # Parameters
/// | Name                        | Type      | Description                                                                                                |
/// | ------                      | ------    | -------------                                                                                              |
/// | `CoinType`                  | Type      | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. |
/// | `tc_account`                | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.  |
/// | `sliding_nonce`             | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                 |
/// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to.                                              |
/// | `mint_amount`               | `u64`     | The number of coins to be minted.                                                                          |
/// | `tier_index`                | `u64`     | The mint tier index to use for the Designated Dealer account.                                              |
///
/// # Common Abort Conditions
/// | Error Category                | Error Reason                                 | Description                                                                                                                  |
/// | ----------------              | --------------                               | -------------                                                                                                                |
/// | `Errors::NOT_PUBLISHED`       | `SlidingNonce::ESLIDING_NONCE`               | A `SlidingNonce` resource is not published under `tc_account`.                                                               |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_OLD`               | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not.                                   |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_TOO_NEW`               | The `sliding_nonce` is too far in the future.                                                                                |
/// | `Errors::INVALID_ARGUMENT`    | `SlidingNonce::ENONCE_ALREADY_RECORDED`      | The `sliding_nonce` has been previously recorded.                                                                            |
/// | `Errors::REQUIRES_ADDRESS`    | `CoreAddresses::ETREASURY_COMPLIANCE`        | `tc_account` is not the Treasury Compliance account.                                                                         |
/// | `Errors::REQUIRES_ROLE`       | `Roles::ETREASURY_COMPLIANCE`                | `tc_account` is not the Treasury Compliance account.                                                                         |
/// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_MINT_AMOUNT`     | `mint_amount` is zero.                                                                                                       |
/// | `Errors::NOT_PUBLISHED`       | `DesignatedDealer::EDEALER`                  | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo<CoinType>` resource does not exist at `designated_dealer_address`. |
/// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_TIER_INDEX`      | The `tier_index` is out of bounds.                                                                                           |
/// | `Errors::INVALID_ARGUMENT`    | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`.                                                           |
/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY`                    | `tc_account` does not have a `Diem::MintCapability<CoinType>` resource published under it.                                  |
/// | `Errors::INVALID_STATE`       | `Diem::EMINTING_NOT_ALLOWED`                | Minting is not currently allowed for `CoinType` coins.                                                                       |
/// | `Errors::LIMIT_EXCEEDED`      | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS`      | The depositing of the funds would exceed the `account`'s account limits.                                                     |
///
/// # Related Scripts
/// * `Script::create_designated_dealer`
/// * `Script::peer_to_peer_with_metadata`
/// * `Script::rotate_dual_attestation_info`
pub fn encode_tiered_mint_script(
    coin_type: TypeTag,
    sliding_nonce: u64,
    designated_dealer_address: AccountAddress,
    mint_amount: u64,
    tier_index: u64,
) -> Script {
    Script::new(
        TIERED_MINT_CODE.to_vec(),
        vec![coin_type],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(designated_dealer_address),
            TransactionArgument::U64(mint_amount),
            TransactionArgument::U64(tier_index),
        ],
    )
}

/// # Summary
/// Unfreezes the account at `address`. The sending account of this transaction must be the
/// Treasury Compliance account. After the successful execution of this transaction transactions
/// may be sent from the previously frozen account, and coins may be sent and received.
///
/// # Technical Description
/// Sets the `AccountFreezing::FreezingBit` to `false` and emits a
/// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance
/// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect
/// the status any of its child accounts and vice versa.
///
/// ## Events
/// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with
/// the `unfrozen_address` set the `to_unfreeze_account`'s address.
///
/// # Parameters
/// | Name                  | Type      | Description                                                                                               |
/// | ------                | ------    | -------------                                                                                             |
/// | `tc_account`          | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
/// | `sliding_nonce`       | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
/// | `to_unfreeze_account` | `address` | The account address to be frozen.                                                                         |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                            | Description                                                                                |
/// | ----------------           | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `account`.                                |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | The sending account is not the Treasury Compliance account.                                |
///
/// # Related Scripts
/// * `Script::freeze_account`
pub fn encode_unfreeze_account_script(
    sliding_nonce: u64,
    to_unfreeze_account: AccountAddress,
) -> Script {
    Script::new(
        UNFREEZE_ACCOUNT_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::Address(to_unfreeze_account),
        ],
    )
}

/// # Summary
/// Updates the Diem major version that is stored on-chain and is used by the VM.  This
/// transaction can only be sent from the Diem Root account.
///
/// # Technical Description
/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger
/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater
/// than the current major version held on-chain. The VM reads this information and can use it to
/// preserve backwards compatibility with previous major versions of the VM.
///
/// # Parameters
/// | Name            | Type      | Description                                                                |
/// | ------          | ------    | -------------                                                              |
/// | `account`       | `&signer` | Signer reference of the sending account. Must be the Diem Root account.   |
/// | `sliding_nonce` | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. |
/// | `major`         | `u64`     | The `major` version of the VM to be used from this transaction on.         |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                                  | Description                                                                                |
/// | ----------------           | --------------                                | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`                | A `SlidingNonce` resource is not published under `account`.                                |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`                | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`                | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED`       | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT`                  | `account` is not the Diem Root account.                                                   |
/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain.                |
pub fn encode_update_diem_version_script(sliding_nonce: u64, major: u64) -> Script {
    Script::new(
        UPDATE_DIEM_VERSION_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U64(major),
        ],
    )
}

/// # Summary
/// Update the dual attestation limit on-chain. Defined in terms of micro-XDX.  The transaction can
/// only be sent by the Treasury Compliance account.  After this transaction all inter-VASP
/// payments over this limit must be checked for dual attestation.
///
/// # Technical Description
/// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under
/// `0xA550C18`. The amount is set in micro-XDX.
///
/// # Parameters
/// | Name                  | Type      | Description                                                                                               |
/// | ------                | ------    | -------------                                                                                             |
/// | `tc_account`          | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. |
/// | `sliding_nonce`       | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction.                                |
/// | `new_micro_xdx_limit` | `u64`     | The new dual attestation limit to be used on-chain.                                                       |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                            | Description                                                                                |
/// | ----------------           | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | `tc_account` is not the Treasury Compliance account.                                       |
///
/// # Related Scripts
/// * `Script::update_exchange_rate`
/// * `Script::update_minting_ability`
pub fn encode_update_dual_attestation_limit_script(
    sliding_nonce: u64,
    new_micro_xdx_limit: u64,
) -> Script {
    Script::new(
        UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(),
        vec![],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U64(new_micro_xdx_limit),
        ],
    )
}

/// # Summary
/// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion
/// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this
/// transaction the updated exchange rate will be used for normalization of gas prices, and for
/// dual attestation checking.
///
/// # Technical Description
/// Updates the on-chain exchange rate from the given `Currency` to micro-XDX.  The exchange rate
/// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`.
///
/// # Parameters
/// | Name                            | Type      | Description                                                                                                                        |
/// | ------                          | ------    | -------------                                                                                                                      |
/// | `Currency`                      | Type      | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. |
/// | `tc_account`                    | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account.                          |
/// | `sliding_nonce`                 | `u64`     | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction.                                                          |
/// | `new_exchange_rate_numerator`   | `u64`     | The numerator for the new to micro-XDX exchange rate for `Currency`.                                                               |
/// | `new_exchange_rate_denominator` | `u64`     | The denominator for the new to micro-XDX exchange rate for `Currency`.                                                             |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                            | Description                                                                                |
/// | ----------------           | --------------                          | -------------                                                                              |
/// | `Errors::NOT_PUBLISHED`    | `SlidingNonce::ESLIDING_NONCE`          | A `SlidingNonce` resource is not published under `tc_account`.                             |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD`          | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW`          | The `sliding_nonce` is too far in the future.                                              |
/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded.                                          |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE`   | `tc_account` is not the Treasury Compliance account.                                       |
/// | `Errors::REQUIRES_ROLE`    | `Roles::ETREASURY_COMPLIANCE`           | `tc_account` is not the Treasury Compliance account.                                       |
/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR`            | `new_exchange_rate_denominator` is zero.                                                   |
/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE`     | The quotient is unrepresentable as a `FixedPoint32`.                                       |
/// | `Errors::LIMIT_EXCEEDED`   | `FixedPoint32::ERATIO_OUT_OF_RANGE`     | The quotient is unrepresentable as a `FixedPoint32`.                                       |
///
/// # Related Scripts
/// * `Script::update_dual_attestation_limit`
/// * `Script::update_minting_ability`
pub fn encode_update_exchange_rate_script(
    currency: TypeTag,
    sliding_nonce: u64,
    new_exchange_rate_numerator: u64,
    new_exchange_rate_denominator: u64,
) -> Script {
    Script::new(
        UPDATE_EXCHANGE_RATE_CODE.to_vec(),
        vec![currency],
        vec![
            TransactionArgument::U64(sliding_nonce),
            TransactionArgument::U64(new_exchange_rate_numerator),
            TransactionArgument::U64(new_exchange_rate_denominator),
        ],
    )
}

/// # Summary
/// Script to allow or disallow minting of new coins in a specified currency.  This transaction can
/// only be sent by the Treasury Compliance account.  Turning minting off for a currency will have
/// no effect on coins already in circulation, and coins may still be removed from the system.
///
/// # Technical Description
/// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo<Currency>` resource
/// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if
/// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise.
/// This transaction needs to be sent by the Treasury Compliance account.
///
/// # Parameters
/// | Name            | Type      | Description                                                                                                                          |
/// | ------          | ------    | -------------                                                                                                                        |
/// | `Currency`      | Type      | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. |
/// | `account`       | `&signer` | Signer reference of the sending account. Must be the Diem Root account.                                                             |
/// | `allow_minting` | `bool`    | Whether to allow minting of new coins in `Currency`.                                                                                 |
///
/// # Common Abort Conditions
/// | Error Category             | Error Reason                          | Description                                          |
/// | ----------------           | --------------                        | -------------                                        |
/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. |
/// | `Errors::NOT_PUBLISHED`    | `Diem::ECURRENCY_INFO`               | `Currency` is not a registered currency on-chain.    |
///
/// # Related Scripts
/// * `Script::update_dual_attestation_limit`
/// * `Script::update_exchange_rate`
pub fn encode_update_minting_ability_script(currency: TypeTag, allow_minting: bool) -> Script {
    Script::new(
        UPDATE_MINTING_ABILITY_CODE.to_vec(),
        vec![currency],
        vec![TransactionArgument::Bool(allow_minting)],
    )
}

fn decode_create_account_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::CreateAccount {
            new_account_address: bcs::from_bytes(script.args().get(0)?).ok()?,
            auth_key_prefix: bcs::from_bytes(script.args().get(1)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_create_validator_account_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::CreateValidatorAccount {
            new_account_address: bcs::from_bytes(script.args().get(0)?).ok()?,
            auth_key_prefix: bcs::from_bytes(script.args().get(1)?).ok()?,
            human_name: bcs::from_bytes(script.args().get(2)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_create_validator_operator_account_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::CreateValidatorOperatorAccount {
            new_account_address: bcs::from_bytes(script.args().get(0)?).ok()?,
            auth_key_prefix: bcs::from_bytes(script.args().get(1)?).ok()?,
            human_name: bcs::from_bytes(script.args().get(2)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_gc_ballots_script_function(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::GcBallots {
            proposal: script.ty_args().get(0)?.clone(),
            addr: bcs::from_bytes(script.args().get(0)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_initialize_diem_consensus_config_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::InitializeDiemConsensusConfig {
            _sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_mint_bars_script_function(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::MintBars {
            artist: bcs::from_bytes(script.args().get(0)?).ok()?,
            artist_name: bcs::from_bytes(script.args().get(1)?).ok()?,
            content_uri: bcs::from_bytes(script.args().get(2)?).ok()?,
            amount: bcs::from_bytes(script.args().get(3)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_nft_initialize_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(_script) = payload {
        Some(ScriptFunctionCall::NftInitialize {})
    } else {
        None
    }
}

fn decode_register_bars_user_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(_script) = payload {
        Some(ScriptFunctionCall::RegisterBarsUser {})
    } else {
        None
    }
}

fn decode_set_gas_constants_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::SetGasConstants {
            _sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
            global_memory_per_byte_cost: bcs::from_bytes(script.args().get(1)?).ok()?,
            global_memory_per_byte_write_cost: bcs::from_bytes(script.args().get(2)?).ok()?,
            min_transaction_gas_units: bcs::from_bytes(script.args().get(3)?).ok()?,
            large_transaction_cutoff: bcs::from_bytes(script.args().get(4)?).ok()?,
            intrinsic_gas_per_byte: bcs::from_bytes(script.args().get(5)?).ok()?,
            maximum_number_of_gas_units: bcs::from_bytes(script.args().get(6)?).ok()?,
            min_price_per_gas_unit: bcs::from_bytes(script.args().get(7)?).ok()?,
            max_price_per_gas_unit: bcs::from_bytes(script.args().get(8)?).ok()?,
            max_transaction_size_in_bytes: bcs::from_bytes(script.args().get(9)?).ok()?,
            gas_unit_scaling_factor: bcs::from_bytes(script.args().get(10)?).ok()?,
            default_account_size: bcs::from_bytes(script.args().get(11)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_transfer_multi_token_between_galleries_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::TransferMultiTokenBetweenGalleries {
            token_type: script.ty_args().get(0)?.clone(),
            to: bcs::from_bytes(script.args().get(0)?).ok()?,
            amount: bcs::from_bytes(script.args().get(1)?).ok()?,
            creator: bcs::from_bytes(script.args().get(2)?).ok()?,
            creation_num: bcs::from_bytes(script.args().get(3)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_transfer_token_between_galleries_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::TransferTokenBetweenGalleries {
            token_type: script.ty_args().get(0)?.clone(),
            to: bcs::from_bytes(script.args().get(0)?).ok()?,
            amount: bcs::from_bytes(script.args().get(1)?).ok()?,
            creator: bcs::from_bytes(script.args().get(2)?).ok()?,
            creation_num: bcs::from_bytes(script.args().get(3)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_update_diem_consensus_config_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::UpdateDiemConsensusConfig {
            _sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
            config: bcs::from_bytes(script.args().get(1)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_update_diem_version_script_function(
    payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
    if let TransactionPayload::ScriptFunction(script) = payload {
        Some(ScriptFunctionCall::UpdateDiemVersion {
            _sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
            major: bcs::from_bytes(script.args().get(1)?).ok()?,
        })
    } else {
        None
    }
}

fn decode_add_currency_to_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::AddCurrencyToAccount {
        currency: script.ty_args().get(0)?.clone(),
    })
}

fn decode_add_recovery_rotation_capability_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::AddRecoveryRotationCapability {
        recovery_address: decode_address_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_add_validator_and_reconfigure_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::AddValidatorAndReconfigure {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?,
        validator_address: decode_address_argument(script.args().get(2)?.clone())?,
    })
}

fn decode_burn_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::Burn {
        token: script.ty_args().get(0)?.clone(),
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        preburn_address: decode_address_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_burn_txn_fees_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::BurnTxnFees {
        coin_type: script.ty_args().get(0)?.clone(),
    })
}

fn decode_cancel_burn_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CancelBurn {
        token: script.ty_args().get(0)?.clone(),
        preburn_address: decode_address_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_create_child_vasp_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateChildVaspAccount {
        coin_type: script.ty_args().get(0)?.clone(),
        child_address: decode_address_argument(script.args().get(0)?.clone())?,
        auth_key_prefix: decode_u8vector_argument(script.args().get(1)?.clone())?,
        add_all_currencies: decode_bool_argument(script.args().get(2)?.clone())?,
        child_initial_balance: decode_u64_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_create_designated_dealer_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateDesignatedDealer {
        currency: script.ty_args().get(0)?.clone(),
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        addr: decode_address_argument(script.args().get(1)?.clone())?,
        auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?,
        human_name: decode_u8vector_argument(script.args().get(3)?.clone())?,
        add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?,
    })
}

fn decode_create_parent_vasp_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateParentVaspAccount {
        coin_type: script.ty_args().get(0)?.clone(),
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_account_address: decode_address_argument(script.args().get(1)?.clone())?,
        auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?,
        human_name: decode_u8vector_argument(script.args().get(3)?.clone())?,
        add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?,
    })
}

fn decode_create_recovery_address_script(_script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateRecoveryAddress {})
}

fn decode_create_validator_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateValidatorAccount {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_account_address: decode_address_argument(script.args().get(1)?.clone())?,
        auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?,
        human_name: decode_u8vector_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_create_validator_operator_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::CreateValidatorOperatorAccount {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_account_address: decode_address_argument(script.args().get(1)?.clone())?,
        auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?,
        human_name: decode_u8vector_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_freeze_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::FreezeAccount {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        to_freeze_account: decode_address_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_peer_to_peer_with_metadata_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::PeerToPeerWithMetadata {
        currency: script.ty_args().get(0)?.clone(),
        payee: decode_address_argument(script.args().get(0)?.clone())?,
        amount: decode_u64_argument(script.args().get(1)?.clone())?,
        metadata: decode_u8vector_argument(script.args().get(2)?.clone())?,
        metadata_signature: decode_u8vector_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_preburn_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::Preburn {
        token: script.ty_args().get(0)?.clone(),
        amount: decode_u64_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_publish_shared_ed25519_public_key_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::PublishSharedEd25519PublicKey {
        public_key: decode_u8vector_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_register_validator_config_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RegisterValidatorConfig {
        validator_account: decode_address_argument(script.args().get(0)?.clone())?,
        consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?,
        validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?,
        fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_remove_validator_and_reconfigure_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RemoveValidatorAndReconfigure {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?,
        validator_address: decode_address_argument(script.args().get(2)?.clone())?,
    })
}

fn decode_rotate_authentication_key_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RotateAuthenticationKey {
        new_key: decode_u8vector_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_rotate_authentication_key_with_nonce_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RotateAuthenticationKeyWithNonce {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_key: decode_u8vector_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_rotate_authentication_key_with_nonce_admin_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RotateAuthenticationKeyWithNonceAdmin {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_key: decode_u8vector_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_rotate_authentication_key_with_recovery_address_script(
    script: &Script,
) -> Option<ScriptCall> {
    Some(ScriptCall::RotateAuthenticationKeyWithRecoveryAddress {
        recovery_address: decode_address_argument(script.args().get(0)?.clone())?,
        to_recover: decode_address_argument(script.args().get(1)?.clone())?,
        new_key: decode_u8vector_argument(script.args().get(2)?.clone())?,
    })
}

fn decode_rotate_dual_attestation_info_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RotateDualAttestationInfo {
        new_url: decode_u8vector_argument(script.args().get(0)?.clone())?,
        new_key: decode_u8vector_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_rotate_shared_ed25519_public_key_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::RotateSharedEd25519PublicKey {
        public_key: decode_u8vector_argument(script.args().get(0)?.clone())?,
    })
}

fn decode_set_validator_config_and_reconfigure_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::SetValidatorConfigAndReconfigure {
        validator_account: decode_address_argument(script.args().get(0)?.clone())?,
        consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?,
        validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?,
        fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_set_validator_operator_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::SetValidatorOperator {
        operator_name: decode_u8vector_argument(script.args().get(0)?.clone())?,
        operator_account: decode_address_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_set_validator_operator_with_nonce_admin_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::SetValidatorOperatorWithNonceAdmin {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        operator_name: decode_u8vector_argument(script.args().get(1)?.clone())?,
        operator_account: decode_address_argument(script.args().get(2)?.clone())?,
    })
}

fn decode_tiered_mint_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::TieredMint {
        coin_type: script.ty_args().get(0)?.clone(),
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        designated_dealer_address: decode_address_argument(script.args().get(1)?.clone())?,
        mint_amount: decode_u64_argument(script.args().get(2)?.clone())?,
        tier_index: decode_u64_argument(script.args().get(3)?.clone())?,
    })
}

fn decode_unfreeze_account_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::UnfreezeAccount {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        to_unfreeze_account: decode_address_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_update_diem_version_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::UpdateDiemVersion {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        major: decode_u64_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_update_dual_attestation_limit_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::UpdateDualAttestationLimit {
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_micro_xdx_limit: decode_u64_argument(script.args().get(1)?.clone())?,
    })
}

fn decode_update_exchange_rate_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::UpdateExchangeRate {
        currency: script.ty_args().get(0)?.clone(),
        sliding_nonce: decode_u64_argument(script.args().get(0)?.clone())?,
        new_exchange_rate_numerator: decode_u64_argument(script.args().get(1)?.clone())?,
        new_exchange_rate_denominator: decode_u64_argument(script.args().get(2)?.clone())?,
    })
}

fn decode_update_minting_ability_script(script: &Script) -> Option<ScriptCall> {
    Some(ScriptCall::UpdateMintingAbility {
        currency: script.ty_args().get(0)?.clone(),
        allow_minting: decode_bool_argument(script.args().get(0)?.clone())?,
    })
}

type TransactionScriptDecoderMap = std::collections::HashMap<
    Vec<u8>,
    Box<dyn Fn(&Script) -> Option<ScriptCall> + std::marker::Sync + std::marker::Send>,
>;

static TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy<TransactionScriptDecoderMap> =
    once_cell::sync::Lazy::new(|| {
        let mut map: TransactionScriptDecoderMap = std::collections::HashMap::new();
        map.insert(
            ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(),
            Box::new(decode_add_currency_to_account_script),
        );
        map.insert(
            ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(),
            Box::new(decode_add_recovery_rotation_capability_script),
        );
        map.insert(
            ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(),
            Box::new(decode_add_validator_and_reconfigure_script),
        );
        map.insert(BURN_CODE.to_vec(), Box::new(decode_burn_script));
        map.insert(
            BURN_TXN_FEES_CODE.to_vec(),
            Box::new(decode_burn_txn_fees_script),
        );
        map.insert(
            CANCEL_BURN_CODE.to_vec(),
            Box::new(decode_cancel_burn_script),
        );
        map.insert(
            CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(),
            Box::new(decode_create_child_vasp_account_script),
        );
        map.insert(
            CREATE_DESIGNATED_DEALER_CODE.to_vec(),
            Box::new(decode_create_designated_dealer_script),
        );
        map.insert(
            CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(),
            Box::new(decode_create_parent_vasp_account_script),
        );
        map.insert(
            CREATE_RECOVERY_ADDRESS_CODE.to_vec(),
            Box::new(decode_create_recovery_address_script),
        );
        map.insert(
            CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(),
            Box::new(decode_create_validator_account_script),
        );
        map.insert(
            CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(),
            Box::new(decode_create_validator_operator_account_script),
        );
        map.insert(
            FREEZE_ACCOUNT_CODE.to_vec(),
            Box::new(decode_freeze_account_script),
        );
        map.insert(
            PEER_TO_PEER_WITH_METADATA_CODE.to_vec(),
            Box::new(decode_peer_to_peer_with_metadata_script),
        );
        map.insert(PREBURN_CODE.to_vec(), Box::new(decode_preburn_script));
        map.insert(
            PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(),
            Box::new(decode_publish_shared_ed25519_public_key_script),
        );
        map.insert(
            REGISTER_VALIDATOR_CONFIG_CODE.to_vec(),
            Box::new(decode_register_validator_config_script),
        );
        map.insert(
            REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(),
            Box::new(decode_remove_validator_and_reconfigure_script),
        );
        map.insert(
            ROTATE_AUTHENTICATION_KEY_CODE.to_vec(),
            Box::new(decode_rotate_authentication_key_script),
        );
        map.insert(
            ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(),
            Box::new(decode_rotate_authentication_key_with_nonce_script),
        );
        map.insert(
            ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(),
            Box::new(decode_rotate_authentication_key_with_nonce_admin_script),
        );
        map.insert(
            ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(),
            Box::new(decode_rotate_authentication_key_with_recovery_address_script),
        );
        map.insert(
            ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(),
            Box::new(decode_rotate_dual_attestation_info_script),
        );
        map.insert(
            ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(),
            Box::new(decode_rotate_shared_ed25519_public_key_script),
        );
        map.insert(
            SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(),
            Box::new(decode_set_validator_config_and_reconfigure_script),
        );
        map.insert(
            SET_VALIDATOR_OPERATOR_CODE.to_vec(),
            Box::new(decode_set_validator_operator_script),
        );
        map.insert(
            SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(),
            Box::new(decode_set_validator_operator_with_nonce_admin_script),
        );
        map.insert(
            TIERED_MINT_CODE.to_vec(),
            Box::new(decode_tiered_mint_script),
        );
        map.insert(
            UNFREEZE_ACCOUNT_CODE.to_vec(),
            Box::new(decode_unfreeze_account_script),
        );
        map.insert(
            UPDATE_DIEM_VERSION_CODE.to_vec(),
            Box::new(decode_update_diem_version_script),
        );
        map.insert(
            UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(),
            Box::new(decode_update_dual_attestation_limit_script),
        );
        map.insert(
            UPDATE_EXCHANGE_RATE_CODE.to_vec(),
            Box::new(decode_update_exchange_rate_script),
        );
        map.insert(
            UPDATE_MINTING_ABILITY_CODE.to_vec(),
            Box::new(decode_update_minting_ability_script),
        );
        map
    });

type ScriptFunctionDecoderMap = std::collections::HashMap<
    String,
    Box<
        dyn Fn(&TransactionPayload) -> Option<ScriptFunctionCall>
            + std::marker::Sync
            + std::marker::Send,
    >,
>;

static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<ScriptFunctionDecoderMap> =
    once_cell::sync::Lazy::new(|| {
        let mut map: ScriptFunctionDecoderMap = std::collections::HashMap::new();
        map.insert(
            "AccountCreationScriptscreate_account".to_string(),
            Box::new(decode_create_account_script_function),
        );
        map.insert(
            "AccountCreationScriptscreate_validator_account".to_string(),
            Box::new(decode_create_validator_account_script_function),
        );
        map.insert(
            "AccountCreationScriptscreate_validator_operator_account".to_string(),
            Box::new(decode_create_validator_operator_account_script_function),
        );
        map.insert(
            "Votegc_ballots".to_string(),
            Box::new(decode_gc_ballots_script_function),
        );
        map.insert(
            "SystemAdministrationScriptsinitialize_diem_consensus_config".to_string(),
            Box::new(decode_initialize_diem_consensus_config_script_function),
        );
        map.insert(
            "BARSTokenmint_bars".to_string(),
            Box::new(decode_mint_bars_script_function),
        );
        map.insert(
            "NFTnft_initialize".to_string(),
            Box::new(decode_nft_initialize_script_function),
        );
        map.insert(
            "BARSTokenregister_bars_user".to_string(),
            Box::new(decode_register_bars_user_script_function),
        );
        map.insert(
            "SystemAdministrationScriptsset_gas_constants".to_string(),
            Box::new(decode_set_gas_constants_script_function),
        );
        map.insert(
            "MultiTokenBalancetransfer_multi_token_between_galleries".to_string(),
            Box::new(decode_transfer_multi_token_between_galleries_script_function),
        );
        map.insert(
            "NFTGallerytransfer_token_between_galleries".to_string(),
            Box::new(decode_transfer_token_between_galleries_script_function),
        );
        map.insert(
            "SystemAdministrationScriptsupdate_diem_consensus_config".to_string(),
            Box::new(decode_update_diem_consensus_config_script_function),
        );
        map.insert(
            "SystemAdministrationScriptsupdate_diem_version".to_string(),
            Box::new(decode_update_diem_version_script_function),
        );
        map
    });

fn decode_bool_argument(arg: TransactionArgument) -> Option<bool> {
    match arg {
        TransactionArgument::Bool(value) => Some(value),
        _ => None,
    }
}

fn decode_u64_argument(arg: TransactionArgument) -> Option<u64> {
    match arg {
        TransactionArgument::U64(value) => Some(value),
        _ => None,
    }
}

fn decode_address_argument(arg: TransactionArgument) -> Option<AccountAddress> {
    match arg {
        TransactionArgument::Address(value) => Some(value),
        _ => None,
    }
}

fn decode_u8vector_argument(arg: TransactionArgument) -> Option<Vec<u8>> {
    match arg {
        TransactionArgument::U8Vector(value) => Some(value),
        _ => None,
    }
}

const ADD_CURRENCY_TO_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0,
    0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117,
    110, 116, 12, 97, 100, 100, 95, 99, 117, 114, 114, 101, 110, 99, 121, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2,
];

const ADD_RECOVERY_ROTATION_CAPABILITY_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 15, 7, 33, 106, 8, 139, 1,
    16, 0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 8, 0, 5, 0, 2,
    6, 12, 5, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118,
    101, 114, 121, 65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105,
    111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116,
    95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105,
    108, 105, 116, 121, 23, 97, 100, 100, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97,
    112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 3,
    5, 11, 0, 17, 0, 10, 1, 17, 1, 2,
];

const ADD_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 91, 8, 136, 1, 16, 0, 0,
    0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6,
    12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12,
    83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116,
    111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99,
    101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110,
    95, 110, 97, 109, 101, 13, 97, 100, 100, 95, 118, 97, 108, 105, 100, 97, 116, 111, 114, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10, 3, 17, 1, 11,
    2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10, 3, 17, 2, 2,
];

const BURN_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 17, 7, 34, 45, 8, 79, 16,
    0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 2, 6, 12, 5, 3, 6, 12, 3, 5,
    1, 9, 0, 4, 68, 105, 101, 109, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21,
    114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114,
    116, 4, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 7, 10,
    0, 10, 1, 17, 0, 11, 0, 10, 2, 56, 0, 2,
];

const BURN_TXN_FEES_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0,
    0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 14, 84, 114, 97, 110, 115, 97, 99, 116, 105,
    111, 110, 70, 101, 101, 9, 98, 117, 114, 110, 95, 102, 101, 101, 115, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2,
];

const CANCEL_BURN_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 24, 8, 42, 16, 0,
    0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 5, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111,
    117, 110, 116, 11, 99, 97, 110, 99, 101, 108, 95, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2,
];

const CREATE_CHILD_VASP_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 8, 1, 0, 2, 2, 2, 4, 3, 6, 22, 4, 28, 4, 5, 32, 35, 7, 67, 122,
    8, 189, 1, 16, 6, 205, 1, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 1, 1, 0, 3, 2, 3, 0, 0, 4, 4, 1, 1,
    1, 0, 5, 3, 1, 0, 0, 6, 2, 6, 4, 6, 12, 5, 10, 2, 1, 0, 1, 6, 12, 1, 8, 0, 5, 6, 8, 0, 5, 3,
    10, 2, 10, 2, 5, 6, 12, 5, 10, 2, 1, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117,
    110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105, 116,
    121, 25, 99, 114, 101, 97, 116, 101, 95, 99, 104, 105, 108, 100, 95, 118, 97, 115, 112, 95, 97,
    99, 99, 111, 117, 110, 116, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100,
    114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95, 102, 114,
    111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95,
    99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    10, 2, 1, 0, 1, 1, 5, 3, 25, 10, 0, 10, 1, 11, 2, 10, 3, 56, 0, 10, 4, 6, 0, 0, 0, 0, 0, 0, 0,
    0, 36, 3, 10, 5, 22, 11, 0, 17, 1, 12, 5, 14, 5, 10, 1, 10, 4, 7, 0, 7, 0, 56, 1, 11, 5, 17, 3,
    5, 24, 11, 0, 1, 2,
];

const CREATE_DESIGNATED_DEALER_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 72, 8, 116, 16,
    0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2,
    1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110,
    116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114,
    100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97,
    116, 101, 95, 100, 101, 115, 105, 103, 110, 97, 116, 101, 100, 95, 100, 101, 97, 108, 101, 114,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0, 11, 0, 10,
    2, 11, 3, 11, 4, 10, 5, 56, 0, 2,
];

const CREATE_PARENT_VASP_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 74, 8, 118, 16,
    0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2,
    1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110,
    116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114,
    100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 26, 99, 114, 101, 97,
    116, 101, 95, 112, 97, 114, 101, 110, 116, 95, 118, 97, 115, 112, 95, 97, 99, 99, 111, 117,
    110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0,
    11, 0, 10, 2, 11, 3, 11, 4, 10, 5, 56, 0, 2,
];

const CREATE_RECOVERY_ADDRESS_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 12, 7, 30, 90, 8, 120, 16,
    0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 12, 8, 0, 0, 11,
    68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118, 101, 114, 121,
    65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67,
    97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101,
    121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116,
    121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    3, 5, 10, 0, 11, 0, 17, 0, 17, 1, 2,
];

const CREATE_VALIDATOR_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 72, 8, 108, 16, 0, 0, 0,
    1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10,
    2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105,
    110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101,
    95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105,
    100, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11, 0, 10, 2, 11, 3, 11, 4, 17, 1, 2,
];

const CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 81, 8, 117, 16, 0, 0, 0,
    1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10,
    2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105,
    110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101,
    95, 111, 114, 95, 97, 98, 111, 114, 116, 33, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105,
    100, 97, 116, 111, 114, 95, 111, 112, 101, 114, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117,
    110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11,
    0, 10, 2, 11, 3, 11, 4, 17, 1, 2,
];

const FREEZE_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 66, 8, 94, 16, 0, 0, 0,
    1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99,
    111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110,
    103, 78, 111, 110, 99, 101, 14, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111, 117, 110,
    116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98,
    111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10, 1, 17, 1,
    11, 0, 10, 2, 17, 0, 2,
];

const PEER_TO_PEER_WITH_METADATA_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 29, 7, 53, 96, 8,
    149, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12,
    1, 8, 0, 5, 6, 8, 0, 5, 3, 10, 2, 10, 2, 0, 5, 6, 12, 5, 3, 10, 2, 10, 2, 1, 9, 0, 11, 68, 105,
    101, 109, 65, 99, 99, 111, 117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97,
    112, 97, 98, 105, 108, 105, 116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116,
    104, 100, 114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95,
    102, 114, 111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114,
    97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 1, 1, 1, 4, 1, 12, 11, 0, 17, 0, 12, 5, 14, 5, 10, 1, 10, 2, 11, 3, 11, 4, 56, 0, 11,
    5, 17, 2, 2,
];

const PREBURN_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 21, 7, 45, 95, 8,
    140, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12,
    1, 8, 0, 3, 6, 12, 6, 8, 0, 3, 0, 2, 6, 12, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111,
    117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105,
    116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95,
    99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 7, 112, 114, 101, 98, 117, 114, 110, 27, 114,
    101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, 99, 97, 112, 97,
    98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 4, 1, 10,
    10, 0, 17, 0, 12, 2, 11, 0, 14, 2, 10, 1, 56, 0, 11, 2, 17, 2, 2,
];

const PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 31, 8, 44, 16, 0, 0, 0, 1,
    0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80,
    117, 98, 108, 105, 99, 75, 101, 121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2,
];

const REGISTER_VALIDATOR_CONFIG_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 11, 7, 18, 27, 8, 45, 16, 0, 0, 0, 1,
    0, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67,
    111, 110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 7, 11, 0, 10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 2,
];

const REMOVE_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 94, 8, 139, 1, 16, 0, 0,
    0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6,
    12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12,
    83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116,
    111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99,
    101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110,
    95, 110, 97, 109, 101, 16, 114, 101, 109, 111, 118, 101, 95, 118, 97, 108, 105, 100, 97, 116,
    111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10,
    3, 17, 1, 11, 2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10,
    3, 17, 2, 2,
];

const ROTATE_AUTHENTICATION_KEY_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 2, 2, 4, 3, 6, 15, 5, 21, 18, 7, 39, 124, 8, 163, 1,
    16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 1, 2, 0, 0, 4, 3, 2, 0, 1, 6, 12, 1, 8, 0, 0, 2, 6,
    8, 0, 10, 2, 2, 6, 12, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 21, 75,
    101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121,
    31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111,
    110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115, 116, 111, 114, 101,
    95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105,
    108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105,
    99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    0, 4, 1, 9, 11, 0, 17, 0, 12, 2, 14, 2, 11, 1, 17, 2, 11, 2, 17, 1, 2,
];

const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 23, 7, 51, 159, 1, 8, 210,
    1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2,
    6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 3, 6, 12, 3, 10, 2, 11, 68, 105, 101, 109,
    65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101,
    21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111,
    114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105,
    108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116,
    97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115,
    116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97,
    112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104,
    101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 10, 0, 10, 1, 17, 0, 11, 0, 17, 1, 12, 3, 14, 3, 11, 2, 17,
    3, 11, 3, 17, 2, 2,
];

const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 25, 7, 53, 159, 1, 8, 212,
    1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2,
    6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 4, 6, 12, 6, 12, 3, 10, 2, 11, 68, 105, 101,
    109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99,
    101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98,
    111, 114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98,
    105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111,
    116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101,
    115, 116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99,
    97, 112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116,
    104, 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 11, 0, 10, 2, 17, 0, 11, 1, 17, 1, 12, 4, 14, 4, 11, 3,
    17, 3, 11, 4, 17, 2, 2,
];

const ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 8, 7, 15, 42, 8, 57, 16, 0, 0, 0, 1,
    0, 1, 0, 4, 6, 12, 5, 5, 10, 2, 0, 15, 82, 101, 99, 111, 118, 101, 114, 121, 65, 100, 100, 114,
    101, 115, 115, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105, 99,
    97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
    0, 1, 6, 11, 0, 10, 1, 10, 2, 11, 3, 17, 0, 2,
];

const ROTATE_DUAL_ATTESTATION_INFO_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 10, 5, 12, 13, 7, 25, 61, 8, 86, 16, 0, 0, 0,
    1, 0, 1, 0, 0, 2, 0, 1, 0, 2, 6, 12, 10, 2, 0, 3, 6, 12, 10, 2, 10, 2, 15, 68, 117, 97, 108,
    65, 116, 116, 101, 115, 116, 97, 116, 105, 111, 110, 15, 114, 111, 116, 97, 116, 101, 95, 98,
    97, 115, 101, 95, 117, 114, 108, 28, 114, 111, 116, 97, 116, 101, 95, 99, 111, 109, 112, 108,
    105, 97, 110, 99, 101, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 11, 1, 17, 0, 11, 0, 11, 2, 17, 1, 2,
];

const ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 34, 8, 47, 16, 0, 0, 0, 1,
    0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80,
    117, 98, 108, 105, 99, 75, 101, 121, 10, 114, 111, 116, 97, 116, 101, 95, 107, 101, 121, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2,
];

const SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 15, 7, 29, 68, 8, 97, 16, 0, 0, 0,
    1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 2, 6, 12, 5, 10, 68, 105,
    101, 109, 83, 121, 115, 116, 101, 109, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111,
    110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 29, 117, 112, 100, 97,
    116, 101, 95, 99, 111, 110, 102, 105, 103, 95, 97, 110, 100, 95, 114, 101, 99, 111, 110, 102,
    105, 103, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 10, 10, 0,
    10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 11, 0, 10, 1, 17, 1, 2,
];

const SET_VALIDATOR_OPERATOR_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 19, 7, 33, 68, 8, 101, 16, 0, 0, 0,
    1, 1, 2, 0, 1, 0, 0, 3, 2, 3, 0, 1, 5, 1, 10, 2, 2, 6, 12, 5, 0, 3, 6, 12, 10, 2, 5, 2, 1, 3,
    15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23, 86, 97, 108,
    105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103,
    14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101, 12, 115, 101, 116, 95,
    111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 5,
    15, 10, 2, 17, 0, 11, 1, 33, 12, 3, 11, 3, 3, 11, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11,
    0, 10, 2, 17, 1, 2,
];

const SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 26, 7, 47, 103, 8, 150, 1, 16, 0, 0,
    0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 4, 2, 3, 0, 1, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6,
    12, 5, 5, 6, 12, 6, 12, 3, 10, 2, 5, 2, 1, 3, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111,
    110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23,
    86, 97, 108, 105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110,
    102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95,
    97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101,
    12, 115, 101, 116, 95, 111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 1, 0, 5, 6, 18, 11, 0, 10, 2, 17, 0, 10, 4, 17, 1, 11, 3, 33, 12, 5, 11, 5, 3, 14,
    11, 1, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 1, 10, 4, 17, 2, 2,
];

const TIERED_MINT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 21, 7, 38, 59, 8, 97, 16,
    0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 4, 6, 12, 5, 3, 3, 5, 6, 12,
    3, 5, 3, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105,
    100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110,
    99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 11, 116, 105, 101, 114, 101, 100, 95, 109,
    105, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 9, 10, 0, 10, 1, 17,
    0, 11, 0, 10, 2, 10, 3, 10, 4, 56, 0, 2,
];

const UNFREEZE_ACCOUNT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 68, 8, 96, 16, 0, 0, 0,
    1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99,
    111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110,
    103, 78, 111, 110, 99, 101, 16, 117, 110, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111,
    117, 110, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95,
    97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10,
    1, 17, 1, 11, 0, 10, 2, 17, 0, 2,
];

const UPDATE_DIEM_VERSION_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 51, 8, 75, 16, 0, 0, 0,
    1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 11, 68, 105, 101, 109, 86,
    101, 114, 115, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 3,
    115, 101, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95,
    97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10,
    1, 17, 1, 11, 0, 10, 2, 17, 0, 2,
];

const UPDATE_DUAL_ATTESTATION_LIMIT_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 71, 8, 95, 16, 0, 0, 0,
    1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 15, 68, 117, 97, 108, 65, 116,
    116, 101, 115, 116, 97, 116, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110,
    99, 101, 19, 115, 101, 116, 95, 109, 105, 99, 114, 111, 100, 105, 101, 109, 95, 108, 105, 109,
    105, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97,
    98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10, 1,
    17, 1, 11, 0, 10, 2, 17, 0, 2,
];

const UPDATE_EXCHANGE_RATE_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 6, 2, 6, 4, 3, 10, 16, 4, 26, 2, 5, 28, 25, 7, 53, 99,
    8, 152, 1, 16, 0, 0, 0, 1, 0, 2, 1, 1, 2, 0, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 3, 1, 1, 2,
    6, 2, 3, 3, 1, 8, 0, 2, 6, 12, 3, 0, 2, 6, 12, 8, 0, 4, 6, 12, 3, 3, 3, 1, 9, 0, 4, 68, 105,
    101, 109, 12, 70, 105, 120, 101, 100, 80, 111, 105, 110, 116, 51, 50, 12, 83, 108, 105, 100,
    105, 110, 103, 78, 111, 110, 99, 101, 20, 99, 114, 101, 97, 116, 101, 95, 102, 114, 111, 109,
    95, 114, 97, 116, 105, 111, 110, 97, 108, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110,
    99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 117, 112, 100, 97, 116, 101, 95, 120,
    100, 120, 95, 101, 120, 99, 104, 97, 110, 103, 101, 95, 114, 97, 116, 101, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 1, 11, 10, 0, 10, 1, 17, 1, 10, 2, 10, 3, 17, 0, 12, 4, 11,
    0, 11, 4, 56, 0, 2,
];

const UPDATE_MINTING_ABILITY_CODE: &[u8] = &[
    161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 28, 8, 46, 16, 0,
    0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 1, 0, 1, 9, 0, 4, 68, 105, 101, 109, 22, 117, 112, 100,
    97, 116, 101, 95, 109, 105, 110, 116, 105, 110, 103, 95, 97, 98, 105, 108, 105, 116, 121, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2,
];