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
// 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 {}
/// 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 {
/// # 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
/// * `AccountCreationScripts::create_child_vasp_account`
/// * `AccountCreationScripts::create_parent_vasp_account`
/// * `PaymentScripts::peer_to_peer_with_metadata`
AddCurrencyToAccount {
currency: TypeTag,
},
/// # Summary
/// Burns the coins held in a preburn resource in the preburn queue at the
/// specified preburn address, which are equal to the `amount` specified in the
/// transaction. Finds the first relevant outstanding preburn request with
/// matching amount and removes the contained coins from the system. The sending
/// account must be the Treasury Compliance account.
/// The account that holds the preburn queue 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 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. |
/// | `amount` | `u64` | The amount to be burned. |
///
/// # 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::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue<Token>` resource under `preburn_address` does not contain a preburn request with a value matching `amount`. |
/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN_QUEUE` | The account at `preburn_address` does not have a `Diem::PreburnQueue<Token>` resource published under it. |
/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. |
///
/// # Related Scripts
/// * `TreasuryComplianceScripts::burn_txn_fees`
/// * `TreasuryComplianceScripts::cancel_burn_with_amount`
/// * `TreasuryComplianceScripts::preburn`
BurnWithAmount {
token: TypeTag,
sliding_nonce: u64,
preburn_address: AccountAddress,
amount: u64,
},
/// # Summary
/// Cancels and returns the coins held in the preburn area under
/// `preburn_address`, which are equal to the `amount` specified in the transaction. Finds the first preburn
/// resource with the matching amount 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 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. |
/// | `amount` | `u64` | The amount to be cancelled. |
///
/// # 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::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue<Token>` resource under `preburn_address` does not contain a preburn request with a value matching `amount`. |
/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN_QUEUE` | The account at `preburn_address` does not have a `Diem::PreburnQueue<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::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
/// * `TreasuryComplianceScripts::burn_txn_fees`
/// * `TreasuryComplianceScripts::burn_with_amount`
/// * `TreasuryComplianceScripts::preburn`
CancelBurnWithAmount {
token: TypeTag,
preburn_address: AccountAddress,
amount: 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.
/// 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).
///
/// 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.
///
/// # Events
/// Successful execution will emit:
/// * A `DiemAccount::CreateAccountEvent` with the `created` field being `addr`,
/// and the `rold_id` field being `Roles::DESIGNATED_DEALER_ROLE_ID`. This is emitted on the
/// `DiemAccount::AccountOperationsCapability` `creation_events` handle.
///
/// # 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 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
/// * `TreasuryComplianceScripts::tiered_mint`
/// * `PaymentScripts::peer_to_peer_with_metadata`
/// * `AccountAdministrationScripts::rotate_dual_attestation_info`
CreateDesignatedDealer {
currency: TypeTag,
sliding_nonce: u64,
addr: AccountAddress,
auth_key_prefix: Bytes,
human_name: Bytes,
add_all_currencies: bool,
},
/// Create a regular account
CreateRegularAccount {
currency: TypeTag,
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 `DiemAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
/// and the `rold_id` field being `Roles::VALIDATOR_ROLE_ID`. This is emitted on the
/// `DiemAccount::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 {
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.
/// 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 `DiemAccount::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
/// `DiemAccount::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 {
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 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
/// * `TreasuryComplianceScripts::unfreeze_account`
FreezeAccount {
sliding_nonce: u64,
to_freeze_account: AccountAddress,
},
MintCoin {
amount: u64,
},
/// # 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 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
/// * `TreasuryComplianceScripts::cancel_burn_with_amount`
/// * `TreasuryComplianceScripts::burn_with_amount`
/// * `TreasuryComplianceScripts::burn_txn_fees`
Preburn {
token: TypeTag,
amount: u64,
},
/// # Summary
/// Rotates the `account`'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 authentication key that
/// corresponds to an ed25519 public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `account` | `signer` | Signer of the sending account of the transaction. |
/// | `new_key` | `vector<u8>` | New authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin`
/// * `AccountAdministrationScripts::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 authentication key that
/// corresponds to an ed25519 public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `account` | `signer` | Signer 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 authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin`
/// * `AccountAdministrationScripts::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 authentication key that corresponds to an ed25519
/// public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `dr_account` | `signer` | The signer of the sending account of the write set transaction. May only be the Diem Root signer. |
/// | `account` | `signer` | Signer 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 authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address`
RotateAuthenticationKeyWithNonceAdmin {
sliding_nonce: u64,
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 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
/// * `AccountCreationScripts::create_parent_vasp_account`
/// * `AccountCreationScripts::create_designated_dealer`
/// * `AccountAdministrationScripts::rotate_dual_attestation_info`
RotateDualAttestationInfo {
new_url: Bytes,
new_key: Bytes,
},
/// # 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 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` | [Deprecated] The mint tier index to use for the Designated Dealer account. Will be ignored |
///
/// # 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::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
/// * `AccountCreationScripts::create_designated_dealer`
/// * `PaymentScripts::peer_to_peer_with_metadata`
/// * `AccountAdministrationScripts::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 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
/// * `TreasuryComplianceScripts::freeze_account`
UnfreezeAccount {
sliding_nonce: u64,
to_unfreeze_account: AccountAddress,
},
/// # 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 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
/// * `TreasuryComplianceScripts::update_exchange_rate`
/// * `TreasuryComplianceScripts::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 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
/// * `TreasuryComplianceScripts::update_dual_attestation_limit`
/// * `TreasuryComplianceScripts::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 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
/// * `TreasuryComplianceScripts::update_dual_attestation_limit`
/// * `TreasuryComplianceScripts::update_exchange_rate`
UpdateMintingAbility {
currency: TypeTag,
allow_minting: bool,
},
}
impl ScriptFunctionCall {
/// Build a Diem `TransactionPayload` from a structured object `ScriptFunctionCall`.
pub fn encode(self) -> TransactionPayload {
use ScriptFunctionCall::*;
match self {
AddCurrencyToAccount { currency } => {
encode_add_currency_to_account_script_function(currency)
}
BurnWithAmount {
token,
sliding_nonce,
preburn_address,
amount,
} => encode_burn_with_amount_script_function(
token,
sliding_nonce,
preburn_address,
amount,
),
CancelBurnWithAmount {
token,
preburn_address,
amount,
} => encode_cancel_burn_with_amount_script_function(token, preburn_address, amount),
CreateDesignatedDealer {
currency,
sliding_nonce,
addr,
auth_key_prefix,
human_name,
add_all_currencies,
} => encode_create_designated_dealer_script_function(
currency,
sliding_nonce,
addr,
auth_key_prefix,
human_name,
add_all_currencies,
),
CreateRegularAccount {
currency,
new_account_address,
auth_key_prefix,
} => encode_create_regular_account_script_function(
currency,
new_account_address,
auth_key_prefix,
),
CreateValidatorAccount {
sliding_nonce,
new_account_address,
auth_key_prefix,
human_name,
} => encode_create_validator_account_script_function(
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_function(
sliding_nonce,
new_account_address,
auth_key_prefix,
human_name,
),
FreezeAccount {
sliding_nonce,
to_freeze_account,
} => encode_freeze_account_script_function(sliding_nonce, to_freeze_account),
MintCoin { amount } => encode_mint_coin_script_function(amount),
Preburn { token, amount } => encode_preburn_script_function(token, amount),
RotateAuthenticationKey { new_key } => {
encode_rotate_authentication_key_script_function(new_key)
}
RotateAuthenticationKeyWithNonce {
sliding_nonce,
new_key,
} => {
encode_rotate_authentication_key_with_nonce_script_function(sliding_nonce, new_key)
}
RotateAuthenticationKeyWithNonceAdmin {
sliding_nonce,
new_key,
} => encode_rotate_authentication_key_with_nonce_admin_script_function(
sliding_nonce,
new_key,
),
RotateDualAttestationInfo { new_url, new_key } => {
encode_rotate_dual_attestation_info_script_function(new_url, new_key)
}
TieredMint {
coin_type,
sliding_nonce,
designated_dealer_address,
mint_amount,
tier_index,
} => encode_tiered_mint_script_function(
coin_type,
sliding_nonce,
designated_dealer_address,
mint_amount,
tier_index,
),
UnfreezeAccount {
sliding_nonce,
to_unfreeze_account,
} => encode_unfreeze_account_script_function(sliding_nonce, to_unfreeze_account),
UpdateDualAttestationLimit {
sliding_nonce,
new_micro_xdx_limit,
} => encode_update_dual_attestation_limit_script_function(
sliding_nonce,
new_micro_xdx_limit,
),
UpdateExchangeRate {
currency,
sliding_nonce,
new_exchange_rate_numerator,
new_exchange_rate_denominator,
} => encode_update_exchange_rate_script_function(
currency,
sliding_nonce,
new_exchange_rate_numerator,
new_exchange_rate_denominator,
),
UpdateMintingAbility {
currency,
allow_minting,
} => encode_update_minting_ability_script_function(currency, allow_minting),
}
}
/// 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
}
}
}
/// # 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
/// * `AccountCreationScripts::create_child_vasp_account`
/// * `AccountCreationScripts::create_parent_vasp_account`
/// * `PaymentScripts::peer_to_peer_with_metadata`
pub fn encode_add_currency_to_account_script_function(currency: TypeTag) -> 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!("AccountAdministrationScripts").to_owned(),
),
ident_str!("add_currency_to_account").to_owned(),
vec![currency],
vec![],
))
}
/// # Summary
/// Burns the coins held in a preburn resource in the preburn queue at the
/// specified preburn address, which are equal to the `amount` specified in the
/// transaction. Finds the first relevant outstanding preburn request with
/// matching amount and removes the contained coins from the system. The sending
/// account must be the Treasury Compliance account.
/// The account that holds the preburn queue 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 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. |
/// | `amount` | `u64` | The amount to be burned. |
///
/// # 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::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue<Token>` resource under `preburn_address` does not contain a preburn request with a value matching `amount`. |
/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN_QUEUE` | The account at `preburn_address` does not have a `Diem::PreburnQueue<Token>` resource published under it. |
/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. |
///
/// # Related Scripts
/// * `TreasuryComplianceScripts::burn_txn_fees`
/// * `TreasuryComplianceScripts::cancel_burn_with_amount`
/// * `TreasuryComplianceScripts::preburn`
pub fn encode_burn_with_amount_script_function(
token: TypeTag,
sliding_nonce: u64,
preburn_address: AccountAddress,
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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("burn_with_amount").to_owned(),
vec![token],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&preburn_address).unwrap(),
bcs::to_bytes(&amount).unwrap(),
],
))
}
/// # Summary
/// Cancels and returns the coins held in the preburn area under
/// `preburn_address`, which are equal to the `amount` specified in the transaction. Finds the first preburn
/// resource with the matching amount 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 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. |
/// | `amount` | `u64` | The amount to be cancelled. |
///
/// # 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::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue<Token>` resource under `preburn_address` does not contain a preburn request with a value matching `amount`. |
/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN_QUEUE` | The account at `preburn_address` does not have a `Diem::PreburnQueue<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::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
/// * `TreasuryComplianceScripts::burn_txn_fees`
/// * `TreasuryComplianceScripts::burn_with_amount`
/// * `TreasuryComplianceScripts::preburn`
pub fn encode_cancel_burn_with_amount_script_function(
token: TypeTag,
preburn_address: AccountAddress,
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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("cancel_burn_with_amount").to_owned(),
vec![token],
vec![
bcs::to_bytes(&preburn_address).unwrap(),
bcs::to_bytes(&amount).unwrap(),
],
))
}
/// # 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.
/// 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).
///
/// 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.
///
/// # Events
/// Successful execution will emit:
/// * A `DiemAccount::CreateAccountEvent` with the `created` field being `addr`,
/// and the `rold_id` field being `Roles::DESIGNATED_DEALER_ROLE_ID`. This is emitted on the
/// `DiemAccount::AccountOperationsCapability` `creation_events` handle.
///
/// # 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 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
/// * `TreasuryComplianceScripts::tiered_mint`
/// * `PaymentScripts::peer_to_peer_with_metadata`
/// * `AccountAdministrationScripts::rotate_dual_attestation_info`
pub fn encode_create_designated_dealer_script_function(
currency: TypeTag,
sliding_nonce: u64,
addr: AccountAddress,
auth_key_prefix: Vec<u8>,
human_name: Vec<u8>,
add_all_currencies: bool,
) -> 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_designated_dealer").to_owned(),
vec![currency],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&addr).unwrap(),
bcs::to_bytes(&auth_key_prefix).unwrap(),
bcs::to_bytes(&human_name).unwrap(),
bcs::to_bytes(&add_all_currencies).unwrap(),
],
))
}
/// Create a regular account
pub fn encode_create_regular_account_script_function(
currency: TypeTag,
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_regular_account").to_owned(),
vec![currency],
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 `DiemAccount::CreateAccountEvent` with the `created` field being `new_account_address`,
/// and the `rold_id` field being `Roles::VALIDATOR_ROLE_ID`. This is emitted on the
/// `DiemAccount::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(
sliding_nonce: u64,
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(&sliding_nonce).unwrap(),
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 `DiemAccount::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
/// `DiemAccount::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(
sliding_nonce: u64,
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(&sliding_nonce).unwrap(),
bcs::to_bytes(&new_account_address).unwrap(),
bcs::to_bytes(&auth_key_prefix).unwrap(),
bcs::to_bytes(&human_name).unwrap(),
],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::unfreeze_account`
pub fn encode_freeze_account_script_function(
sliding_nonce: u64,
to_freeze_account: 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("freeze_account").to_owned(),
vec![],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&to_freeze_account).unwrap(),
],
))
}
pub fn encode_mint_coin_script_function(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!("SampleModule").to_owned(),
),
ident_str!("mint_coin").to_owned(),
vec![],
vec![bcs::to_bytes(&amount).unwrap()],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::cancel_burn_with_amount`
/// * `TreasuryComplianceScripts::burn_with_amount`
/// * `TreasuryComplianceScripts::burn_txn_fees`
pub fn encode_preburn_script_function(token: TypeTag, 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("preburn").to_owned(),
vec![token],
vec![bcs::to_bytes(&amount).unwrap()],
))
}
/// # Summary
/// Rotates the `account`'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 authentication key that
/// corresponds to an ed25519 public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `account` | `signer` | Signer of the sending account of the transaction. |
/// | `new_key` | `vector<u8>` | New authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_script_function(new_key: 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!("AccountAdministrationScripts").to_owned(),
),
ident_str!("rotate_authentication_key").to_owned(),
vec![],
vec![bcs::to_bytes(&new_key).unwrap()],
))
}
/// # 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 authentication key that
/// corresponds to an ed25519 public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `account` | `signer` | Signer 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 authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_with_nonce_script_function(
sliding_nonce: u64,
new_key: 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!("AccountAdministrationScripts").to_owned(),
),
ident_str!("rotate_authentication_key_with_nonce").to_owned(),
vec![],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&new_key).unwrap(),
],
))
}
/// # 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 authentication key that corresponds to an ed25519
/// public key as described [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys),
/// and `account` must not have previously delegated its `DiemAccount::KeyRotationCapability`.
///
/// # Parameters
/// | Name | Type | Description |
/// | ------ | ------ | ------------- |
/// | `dr_account` | `signer` | The signer of the sending account of the write set transaction. May only be the Diem Root signer. |
/// | `account` | `signer` | Signer 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 authentication 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
/// * `AccountAdministrationScripts::rotate_authentication_key`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce`
/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address`
pub fn encode_rotate_authentication_key_with_nonce_admin_script_function(
sliding_nonce: u64,
new_key: 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!("AccountAdministrationScripts").to_owned(),
),
ident_str!("rotate_authentication_key_with_nonce_admin").to_owned(),
vec![],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&new_key).unwrap(),
],
))
}
/// # 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 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
/// * `AccountCreationScripts::create_parent_vasp_account`
/// * `AccountCreationScripts::create_designated_dealer`
/// * `AccountAdministrationScripts::rotate_dual_attestation_info`
pub fn encode_rotate_dual_attestation_info_script_function(
new_url: Vec<u8>,
new_key: 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!("AccountAdministrationScripts").to_owned(),
),
ident_str!("rotate_dual_attestation_info").to_owned(),
vec![],
vec![
bcs::to_bytes(&new_url).unwrap(),
bcs::to_bytes(&new_key).unwrap(),
],
))
}
/// # 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 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` | [Deprecated] The mint tier index to use for the Designated Dealer account. Will be ignored |
///
/// # 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::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
/// * `AccountCreationScripts::create_designated_dealer`
/// * `PaymentScripts::peer_to_peer_with_metadata`
/// * `AccountAdministrationScripts::rotate_dual_attestation_info`
pub fn encode_tiered_mint_script_function(
coin_type: TypeTag,
sliding_nonce: u64,
designated_dealer_address: AccountAddress,
mint_amount: u64,
tier_index: 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("tiered_mint").to_owned(),
vec![coin_type],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&designated_dealer_address).unwrap(),
bcs::to_bytes(&mint_amount).unwrap(),
bcs::to_bytes(&tier_index).unwrap(),
],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::freeze_account`
pub fn encode_unfreeze_account_script_function(
sliding_nonce: u64,
to_unfreeze_account: 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("unfreeze_account").to_owned(),
vec![],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&to_unfreeze_account).unwrap(),
],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::update_exchange_rate`
/// * `TreasuryComplianceScripts::update_minting_ability`
pub fn encode_update_dual_attestation_limit_script_function(
sliding_nonce: u64,
new_micro_xdx_limit: 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("update_dual_attestation_limit").to_owned(),
vec![],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&new_micro_xdx_limit).unwrap(),
],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::update_dual_attestation_limit`
/// * `TreasuryComplianceScripts::update_minting_ability`
pub fn encode_update_exchange_rate_script_function(
currency: TypeTag,
sliding_nonce: u64,
new_exchange_rate_numerator: u64,
new_exchange_rate_denominator: 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("update_exchange_rate").to_owned(),
vec![currency],
vec![
bcs::to_bytes(&sliding_nonce).unwrap(),
bcs::to_bytes(&new_exchange_rate_numerator).unwrap(),
bcs::to_bytes(&new_exchange_rate_denominator).unwrap(),
],
))
}
/// # 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 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
/// * `TreasuryComplianceScripts::update_dual_attestation_limit`
/// * `TreasuryComplianceScripts::update_exchange_rate`
pub fn encode_update_minting_ability_script_function(
currency: TypeTag,
allow_minting: bool,
) -> 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!("TreasuryComplianceScripts").to_owned(),
),
ident_str!("update_minting_ability").to_owned(),
vec![currency],
vec![bcs::to_bytes(&allow_minting).unwrap()],
))
}
fn decode_add_currency_to_account_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::AddCurrencyToAccount {
currency: script.ty_args().get(0)?.clone(),
})
} else {
None
}
}
fn decode_burn_with_amount_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::BurnWithAmount {
token: script.ty_args().get(0)?.clone(),
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
preburn_address: bcs::from_bytes(script.args().get(1)?).ok()?,
amount: bcs::from_bytes(script.args().get(2)?).ok()?,
})
} else {
None
}
}
fn decode_cancel_burn_with_amount_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::CancelBurnWithAmount {
token: script.ty_args().get(0)?.clone(),
preburn_address: bcs::from_bytes(script.args().get(0)?).ok()?,
amount: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_create_designated_dealer_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::CreateDesignatedDealer {
currency: script.ty_args().get(0)?.clone(),
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
addr: bcs::from_bytes(script.args().get(1)?).ok()?,
auth_key_prefix: bcs::from_bytes(script.args().get(2)?).ok()?,
human_name: bcs::from_bytes(script.args().get(3)?).ok()?,
add_all_currencies: bcs::from_bytes(script.args().get(4)?).ok()?,
})
} else {
None
}
}
fn decode_create_regular_account_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::CreateRegularAccount {
currency: script.ty_args().get(0)?.clone(),
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 {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_account_address: bcs::from_bytes(script.args().get(1)?).ok()?,
auth_key_prefix: bcs::from_bytes(script.args().get(2)?).ok()?,
human_name: bcs::from_bytes(script.args().get(3)?).ok()?,
})
} else {
None
}
}
fn decode_create_validator_operator_account_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::CreateValidatorOperatorAccount {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_account_address: bcs::from_bytes(script.args().get(1)?).ok()?,
auth_key_prefix: bcs::from_bytes(script.args().get(2)?).ok()?,
human_name: bcs::from_bytes(script.args().get(3)?).ok()?,
})
} else {
None
}
}
fn decode_freeze_account_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::FreezeAccount {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
to_freeze_account: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_mint_coin_script_function(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::MintCoin {
amount: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}
fn decode_preburn_script_function(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::Preburn {
token: script.ty_args().get(0)?.clone(),
amount: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}
fn decode_rotate_authentication_key_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::RotateAuthenticationKey {
new_key: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}
fn decode_rotate_authentication_key_with_nonce_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonce {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_key: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_rotate_authentication_key_with_nonce_admin_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonceAdmin {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_key: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_rotate_dual_attestation_info_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::RotateDualAttestationInfo {
new_url: bcs::from_bytes(script.args().get(0)?).ok()?,
new_key: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_tiered_mint_script_function(payload: &TransactionPayload) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::TieredMint {
coin_type: script.ty_args().get(0)?.clone(),
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
designated_dealer_address: bcs::from_bytes(script.args().get(1)?).ok()?,
mint_amount: bcs::from_bytes(script.args().get(2)?).ok()?,
tier_index: bcs::from_bytes(script.args().get(3)?).ok()?,
})
} else {
None
}
}
fn decode_unfreeze_account_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::UnfreezeAccount {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
to_unfreeze_account: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_update_dual_attestation_limit_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::UpdateDualAttestationLimit {
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_micro_xdx_limit: bcs::from_bytes(script.args().get(1)?).ok()?,
})
} else {
None
}
}
fn decode_update_exchange_rate_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::UpdateExchangeRate {
currency: script.ty_args().get(0)?.clone(),
sliding_nonce: bcs::from_bytes(script.args().get(0)?).ok()?,
new_exchange_rate_numerator: bcs::from_bytes(script.args().get(1)?).ok()?,
new_exchange_rate_denominator: bcs::from_bytes(script.args().get(2)?).ok()?,
})
} else {
None
}
}
fn decode_update_minting_ability_script_function(
payload: &TransactionPayload,
) -> Option<ScriptFunctionCall> {
if let TransactionPayload::ScriptFunction(script) = payload {
Some(ScriptFunctionCall::UpdateMintingAbility {
currency: script.ty_args().get(0)?.clone(),
allow_minting: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}
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(
"AccountAdministrationScriptsadd_currency_to_account".to_string(),
Box::new(decode_add_currency_to_account_script_function),
);
map.insert(
"TreasuryComplianceScriptsburn_with_amount".to_string(),
Box::new(decode_burn_with_amount_script_function),
);
map.insert(
"TreasuryComplianceScriptscancel_burn_with_amount".to_string(),
Box::new(decode_cancel_burn_with_amount_script_function),
);
map.insert(
"AccountCreationScriptscreate_designated_dealer".to_string(),
Box::new(decode_create_designated_dealer_script_function),
);
map.insert(
"AccountCreationScriptscreate_regular_account".to_string(),
Box::new(decode_create_regular_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(
"TreasuryComplianceScriptsfreeze_account".to_string(),
Box::new(decode_freeze_account_script_function),
);
map.insert(
"SampleModulemint_coin".to_string(),
Box::new(decode_mint_coin_script_function),
);
map.insert(
"TreasuryComplianceScriptspreburn".to_string(),
Box::new(decode_preburn_script_function),
);
map.insert(
"AccountAdministrationScriptsrotate_authentication_key".to_string(),
Box::new(decode_rotate_authentication_key_script_function),
);
map.insert(
"AccountAdministrationScriptsrotate_authentication_key_with_nonce".to_string(),
Box::new(decode_rotate_authentication_key_with_nonce_script_function),
);
map.insert(
"AccountAdministrationScriptsrotate_authentication_key_with_nonce_admin".to_string(),
Box::new(decode_rotate_authentication_key_with_nonce_admin_script_function),
);
map.insert(
"AccountAdministrationScriptsrotate_dual_attestation_info".to_string(),
Box::new(decode_rotate_dual_attestation_info_script_function),
);
map.insert(
"TreasuryComplianceScriptstiered_mint".to_string(),
Box::new(decode_tiered_mint_script_function),
);
map.insert(
"TreasuryComplianceScriptsunfreeze_account".to_string(),
Box::new(decode_unfreeze_account_script_function),
);
map.insert(
"TreasuryComplianceScriptsupdate_dual_attestation_limit".to_string(),
Box::new(decode_update_dual_attestation_limit_script_function),
);
map.insert(
"TreasuryComplianceScriptsupdate_exchange_rate".to_string(),
Box::new(decode_update_exchange_rate_script_function),
);
map.insert(
"TreasuryComplianceScriptsupdate_minting_ability".to_string(),
Box::new(decode_update_minting_ability_script_function),
);
map
});