diff --git a/.github/actions/build_env/action.yaml b/.github/actions/build_env/action.yaml index 28f86aeae..54c7fc8e2 100644 --- a/.github/actions/build_env/action.yaml +++ b/.github/actions/build_env/action.yaml @@ -34,12 +34,6 @@ runs: shell: bash run: rustup component add rustfmt clippy - - name: also rust cache - uses: Swatinem/rust-cache@v2.7.0 - with: - shared-key: "libra" - cache-on-failure: "true" - # call own action for libra_cli # known issue with needing to hard code the @version # https://github.com/orgs/community/discussions/41927 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 10c46fb94..f6d110041 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,12 +47,13 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - # fail fast if types doesnt compile, everything else will fail. + # fail fast if types doesn't compile, everything else will fail. - name: types working-directory: ./types run: cargo test --no-fail-fast @@ -67,10 +68,11 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - name: wallet if: always() @@ -94,10 +96,11 @@ jobs: name: framework-build path: framework/ - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true # Check test suite meta tests - name: smoke-tests # NOTE: needs working DIEM_FORGE_NODE_BIN_PATH @@ -114,10 +117,11 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - uses: actions/download-artifact@v4.1.2 with: @@ -140,10 +144,11 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - uses: actions/download-artifact@v4.1.2 with: @@ -165,10 +170,11 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - uses: actions/download-artifact@v4.1.2 with: @@ -204,10 +210,14 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.7 - uses: actions/download-artifact@v4.1.2 with: @@ -258,17 +268,20 @@ jobs: - uses: actions/checkout@v3 - name: setup env - # if: ${{runner.environment == 'self-hosted'}} uses: ./.github/actions/build_env + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "libra-framework" + cache-all-crates: true + cache-on-failure: true + - uses: actions/download-artifact@v4.1.2 - # if: ${{runner.environment == 'self-hosted'}} with: name: framework-build path: framework/ - name: rescue if: always() - # if: ${{runner.environment == 'self-hosted'}} working-directory: ./tools/rescue run: RUST_MIN_STACK=104857600 cargo test --no-fail-fast -- --test-threads=1 storage: @@ -277,16 +290,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true + - name: storage working-directory: ./tools/storage - # TODO: not testing the V6 file parsing run: cargo test --no-fail-fast twin-testsuite: @@ -295,13 +310,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true + - name: twin working-directory: ./testsuites/twin run: cargo test --no-fail-fast diff --git a/.github/workflows/cleanliness.yaml b/.github/workflows/cleanliness.yaml index a355d226e..7062dd639 100644 --- a/.github/workflows/cleanliness.yaml +++ b/.github/workflows/cleanliness.yaml @@ -25,10 +25,11 @@ jobs: - name: setup env uses: ./.github/actions/build_env - - uses: Swatinem/rust-cache@v2.7.3 + - uses: Swatinem/rust-cache@v2 with: shared-key: "libra-framework" cache-all-crates: true + cache-on-failure: true - name: format uses: actions-rs/cargo@v1 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 3d4f4a6f7..1d44d1ca9 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,8 +9,7 @@ on: jobs: publish: - permissions: - write-all + permissions: write-all name: publish runs-on: ubuntu-latest steps: diff --git a/Cargo.lock b/Cargo.lock index e24b10a1a..6dd70bd6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,19 +10,13 @@ checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -146,9 +140,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -161,43 +155,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" dependencies = [ "backtrace", ] @@ -284,7 +278,7 @@ checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits 0.2.19", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -320,7 +314,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -358,9 +352,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -385,9 +379,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -396,24 +390,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -429,9 +423,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" @@ -444,9 +438,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", "itoa", "matchit", "memchr", @@ -454,9 +448,9 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustversion", - "serde 1.0.209", + "serde 1.0.214", "sync_wrapper", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", ] @@ -470,8 +464,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -480,17 +474,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -528,7 +522,7 @@ name = "bcs" version = "0.1.4" source = "git+https://github.com/aptos-labs/bcs.git?rev=d31fab9d81748e2594be5cd5cdf845786a30562d#d31fab9d81748e2594be5cd5cdf845786a30562d" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] @@ -538,7 +532,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b6598a2f5d564fb7855dc6b06fd1c38cff5a72bd8b863a4d021938497b440a" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] @@ -557,23 +551,23 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3deeecb812ca5300b7d3f66f730cc2ebd3511c3d36c691dd79c165d5b19a26e3" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] [[package]] name = "bigdecimal" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d712318a27c7150326677b321a5fa91b55f6d9034ffd67f20319e147d40cee" +checksum = "8f850665a0385e070b64c38d2354e6c104c8479c59868d1e48a0c13ee2c7a1c1" dependencies = [ "autocfg", "libm", "num-bigint", "num-integer", "num-traits 0.2.19", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -582,7 +576,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -598,12 +592,12 @@ dependencies = [ "lazycell", "peeking_take_while", "prettyplease", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "regex", "rustc-hash", "shlex", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -720,8 +714,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.7", - "serde 1.0.209", + "regex-automata 0.4.8", + "serde 1.0.214", ] [[package]] @@ -738,9 +732,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -750,9 +744,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bzip2-sys" @@ -793,9 +787,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.1.16" +version = "1.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" dependencies = [ "jobserver", "libc", @@ -833,7 +827,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits 0.2.19", - "serde 1.0.209", + "serde 1.0.214", "wasm-bindgen", "windows-targets 0.52.6", ] @@ -930,19 +924,19 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", - "clap_derive 4.5.13", + "clap_derive 4.5.18", ] [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -952,11 +946,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.26" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" +checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2" dependencies = [ - "clap 4.5.17", + "clap 4.5.20", ] [[package]] @@ -967,21 +961,21 @@ checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" dependencies = [ "heck 0.4.1", "proc-macro-error", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1006,7 +1000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3362992a0d9f1dd7c3d0e89e0ab2bb540b7a95fea8cd798090e758fda2899b5e" dependencies = [ "codespan-reporting", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -1015,7 +1009,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "termcolor", "unicode-width", ] @@ -1028,9 +1022,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" @@ -1053,7 +1047,7 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.12", + "tokio-util", ] [[package]] @@ -1065,7 +1059,7 @@ dependencies = [ "lazy_static 1.5.0", "nom 5.1.3", "rust-ini", - "serde 1.0.209", + "serde 1.0.214", "serde-hjson", "serde_json", "toml 0.5.11", @@ -1093,22 +1087,22 @@ checksum = "373e9fafaa20882876db20562275ff58d50e0caa2590077fe7ce7bef90211d0d" [[package]] name = "const_format" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "unicode-xid 0.2.5", + "unicode-xid 0.2.6", ] [[package]] @@ -1141,17 +1135,28 @@ dependencies = [ "version_check", ] +[[package]] +name = "cookie" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + [[package]] name = "cookie_store" -version = "0.16.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d606d0fba62e13cf04db20536c05cb7f13673c161cb47a47a82b9b9e7d3f1daa" +checksum = "387461abbc748185c3a6e1673d826918b450b87ff22639429c694619a83b6cf6" dependencies = [ - "cookie", - "idna 0.2.3", + "cookie 0.17.0", + "idna 0.3.0", "log", "publicsuffix", - "serde 1.0.209", + "serde 1.0.214", "serde_derive", "serde_json", "time", @@ -1176,9 +1181,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1257,7 +1262,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot 0.12.3", "signal-hook", "signal-hook-mio", @@ -1273,7 +1278,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot 0.12.3", "signal-hook", "signal-hook-mio", @@ -1318,9 +1323,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ "generic-array", "subtle", @@ -1335,7 +1340,7 @@ dependencies = [ "csv-core", "itoa", "ryu", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -1358,9 +1363,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest 0.9.0", @@ -1397,7 +1402,7 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "strsim 0.10.0", "syn 1.0.109", @@ -1411,10 +1416,10 @@ checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "strsim 0.11.1", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1436,7 +1441,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1466,6 +1471,12 @@ dependencies = [ "parking_lot_core 0.9.10", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "datatest-stable" version = "0.1.3" @@ -1516,7 +1527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -1531,7 +1542,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -1542,9 +1553,9 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1554,10 +1565,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "rustc_version", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1581,14 +1592,14 @@ dependencies = [ [[package]] name = "diem" version = "2.0.2" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", "base64 0.13.1", "bcs 0.1.4", "chrono", - "clap 4.5.17", + "clap 4.5.20", "clap_complete", "codespan-reporting", "diem-api-types", @@ -1646,7 +1657,7 @@ dependencies = [ "regex", "reqwest", "self_update", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "shadow-rs", @@ -1654,7 +1665,7 @@ dependencies = [ "termcolor", "thiserror", "tokio", - "tokio-util 0.7.12", + "tokio-util", "toml 0.5.11", "walkdir", ] @@ -1662,7 +1673,7 @@ dependencies = [ [[package]] name = "diem-accumulator" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-crypto", @@ -1672,7 +1683,7 @@ dependencies = [ [[package]] name = "diem-aggregator" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -1690,7 +1701,7 @@ dependencies = [ [[package]] name = "diem-api" version = "0.2.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -1712,7 +1723,7 @@ dependencies = [ "fail 0.5.1", "futures", "hex", - "hyper", + "hyper 0.14.31", "itertools", "mime", "move-core-types", @@ -1722,7 +1733,7 @@ dependencies = [ "poem", "poem-openapi", "regex", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "tokio", "url", @@ -1731,7 +1742,7 @@ dependencies = [ [[package]] name = "diem-api-types" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -1751,20 +1762,20 @@ dependencies = [ "move-resource-viewer", "poem", "poem-openapi", - "serde 1.0.209", + "serde 1.0.214", "serde_json", ] [[package]] name = "diem-backup-cli" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", "bcs 0.1.4", "bytes", - "clap 4.5.17", + "clap 4.5.20", "csv", "diem-backup-service", "diem-config", @@ -1793,19 +1804,19 @@ dependencies = [ "rand 0.7.3", "regex", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tokio", "tokio-io-timeout", "tokio-stream", - "tokio-util 0.7.12", + "tokio-util", ] [[package]] name = "diem-backup-service" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -1817,9 +1828,9 @@ dependencies = [ "diem-runtimes", "diem-storage-interface", "diem-types", - "hyper", + "hyper 0.14.31", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "tokio", "warp", ] @@ -1827,16 +1838,16 @@ dependencies = [ [[package]] name = "diem-bitvec" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", ] [[package]] name = "diem-block-executor" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arc-swap", @@ -1861,11 +1872,11 @@ dependencies = [ [[package]] name = "diem-block-partitioner" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "dashmap 5.5.3", "diem-crypto", "diem-logger", @@ -1881,7 +1892,7 @@ dependencies = [ [[package]] name = "diem-bounded-executor" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "futures", "tokio", @@ -1890,7 +1901,7 @@ dependencies = [ [[package]] name = "diem-build-info" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "shadow-rs", ] @@ -1898,7 +1909,7 @@ dependencies = [ [[package]] name = "diem-cached-packages" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "diem-framework", @@ -1911,7 +1922,7 @@ dependencies = [ [[package]] name = "diem-channels" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-infallible", @@ -1923,17 +1934,17 @@ dependencies = [ [[package]] name = "diem-cli-common" version = "1.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anstyle", - "clap 4.5.17", + "clap 4.5.20", "clap_complete", ] [[package]] name = "diem-compression" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-logger", "diem-metrics-core", @@ -1945,7 +1956,7 @@ dependencies = [ [[package]] name = "diem-config" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -1965,7 +1976,7 @@ dependencies = [ "num_cpus", "poem-openapi", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_merge", "serde_yaml 0.8.26", "thiserror", @@ -1975,7 +1986,7 @@ dependencies = [ [[package]] name = "diem-consensus" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arc-swap", @@ -2026,7 +2037,7 @@ dependencies = [ "once_cell", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "serde_json", "thiserror", @@ -2037,14 +2048,14 @@ dependencies = [ [[package]] name = "diem-consensus-notifications" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-crypto", "diem-runtimes", "diem-types", "futures", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", ] @@ -2052,7 +2063,7 @@ dependencies = [ [[package]] name = "diem-consensus-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2068,26 +2079,26 @@ dependencies = [ "mirai-annotations", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "tokio", ] [[package]] name = "diem-crash-handler" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "backtrace", "diem-logger", "move-core-types", - "serde 1.0.209", + "serde 1.0.214", "toml 0.5.11", ] [[package]] name = "diem-crypto" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "ark-ec", @@ -2110,7 +2121,7 @@ dependencies = [ "rand 0.7.3", "rand_core 0.5.1", "ring 0.16.20", - "serde 1.0.209", + "serde 1.0.214", "serde-name", "serde_bytes", "sha2 0.10.8", @@ -2124,9 +2135,9 @@ dependencies = [ [[package]] name = "diem-crypto-derive" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -2134,7 +2145,7 @@ dependencies = [ [[package]] name = "diem-data-client" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-config", @@ -2153,7 +2164,7 @@ dependencies = [ "futures", "itertools", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", ] @@ -2161,7 +2172,7 @@ dependencies = [ [[package]] name = "diem-data-streaming-service" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-channels", @@ -2178,7 +2189,7 @@ dependencies = [ "enum_dispatch", "futures", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", "tokio-stream", @@ -2187,7 +2198,7 @@ dependencies = [ [[package]] name = "diem-db" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arc-swap", @@ -2195,7 +2206,7 @@ dependencies = [ "bcs 0.1.4", "byteorder", "claims", - "clap 4.5.17", + "clap 4.5.20", "dashmap 5.5.3", "diem-accumulator", "diem-config", @@ -2226,7 +2237,7 @@ dependencies = [ "proptest", "proptest-derive", "rayon", - "serde 1.0.209", + "serde 1.0.214", "static_assertions", "status-line", "thiserror", @@ -2235,7 +2246,7 @@ dependencies = [ [[package]] name = "diem-db-indexer" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2255,17 +2266,17 @@ dependencies = [ "move-core-types", "move-resource-viewer", "num-derive", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "diem-db-tool" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", - "clap 4.5.17", + "clap 4.5.20", "diem-backup-cli", "diem-backup-service", "diem-config", @@ -2285,10 +2296,10 @@ dependencies = [ [[package]] name = "diem-debugger" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "diem-crypto", "diem-gas", "diem-gas-profiling", @@ -2316,9 +2327,9 @@ dependencies = [ [[package]] name = "diem-enum-conversion-derive" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -2326,7 +2337,7 @@ dependencies = [ [[package]] name = "diem-event-notifications" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-channels", @@ -2336,14 +2347,14 @@ dependencies = [ "diem-storage-interface", "diem-types", "futures", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-executor" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arr_macro", @@ -2368,13 +2379,13 @@ dependencies = [ "num_cpus", "once_cell", "rayon", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "diem-executor-test-helpers" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-cached-packages", @@ -2398,7 +2409,7 @@ dependencies = [ [[package]] name = "diem-executor-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2412,14 +2423,14 @@ dependencies = [ "diem-types", "itertools", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-fallible" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "thiserror", ] @@ -2427,12 +2438,12 @@ dependencies = [ [[package]] name = "diem-faucet-core" version = "2.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", "captcha", - "clap 4.5.17", + "clap 4.5.20", "deadpool-redis", "diem-config", "diem-faucet-metrics-server", @@ -2451,7 +2462,7 @@ dependencies = [ "rand 0.7.3", "redis", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tokio", @@ -2461,7 +2472,7 @@ dependencies = [ [[package]] name = "diem-faucet-metrics-server" version = "2.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-logger", @@ -2469,20 +2480,20 @@ dependencies = [ "once_cell", "poem", "prometheus", - "serde 1.0.209", + "serde 1.0.214", "serde_json", ] [[package]] name = "diem-forge" version = "0.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "again", "anyhow", "async-trait", "chrono", - "clap 4.5.17", + "clap 4.5.20", "diem", "diem-cached-packages", "diem-cli-common", @@ -2505,10 +2516,11 @@ dependencies = [ "either", "futures", "hex", - "hyper", + "hyper 0.14.31", "hyper-tls", "itertools", "json-patch", + "jsonptr", "k8s-openapi", "kube", "num_cpus", @@ -2518,7 +2530,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tempfile", @@ -2531,7 +2543,7 @@ dependencies = [ [[package]] name = "diem-framework" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "ark-bls12-381", @@ -2544,7 +2556,7 @@ dependencies = [ "better_any", "blake2-rfc", "blst", - "clap 4.5.17", + "clap 4.5.20", "codespan-reporting", "curve25519-dalek", "diem-aggregator", @@ -2579,7 +2591,7 @@ dependencies = [ "rand_core 0.5.1", "rayon", "ripemd", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "serde_json", "serde_yaml 0.8.26", @@ -2596,11 +2608,11 @@ dependencies = [ [[package]] name = "diem-gas" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-framework", "diem-gas-algebra-ext", "diem-global-constants", @@ -2619,7 +2631,7 @@ dependencies = [ [[package]] name = "diem-gas-algebra-ext" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "move-core-types", ] @@ -2627,7 +2639,7 @@ dependencies = [ [[package]] name = "diem-gas-profiling" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-framework", @@ -2645,7 +2657,7 @@ dependencies = [ [[package]] name = "diem-genesis" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2664,17 +2676,17 @@ dependencies = [ "diem-vm", "diem-vm-genesis", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_yaml 0.8.26", ] [[package]] name = "diem-github-client" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-proxy", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", "ureq", @@ -2683,24 +2695,24 @@ dependencies = [ [[package]] name = "diem-global-constants" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" [[package]] name = "diem-id-generator" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" [[package]] name = "diem-indexer" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", "bcs 0.1.4", "bigdecimal", "chrono", - "clap 4.5.17", + "clap 4.5.20", "diem-api", "diem-api-types", "diem-bitvec", @@ -2722,7 +2734,7 @@ dependencies = [ "reqwest", "reqwest-middleware", "reqwest-retry", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "sha2 0.9.9", "tokio", @@ -2732,7 +2744,7 @@ dependencies = [ [[package]] name = "diem-indexer-grpc-fullnode" version = "1.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "base64 0.13.1", @@ -2754,12 +2766,12 @@ dependencies = [ "fail 0.5.1", "futures", "hex", - "hyper", + "hyper 0.14.31", "move-binary-format", "move-core-types", "move-package", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "tokio", "tokio-stream", @@ -2769,12 +2781,12 @@ dependencies = [ [[package]] name = "diem-infallible" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" [[package]] name = "diem-inspection-service" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-build-info", @@ -2785,7 +2797,7 @@ dependencies = [ "diem-network", "diem-runtimes", "futures", - "hyper", + "hyper 0.14.31", "once_cell", "prometheus", "reqwest", @@ -2797,7 +2809,7 @@ dependencies = [ [[package]] name = "diem-jellyfish-merkle" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2816,14 +2828,14 @@ dependencies = [ "proptest", "proptest-derive", "rayon", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-keygen" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-crypto", "diem-types", @@ -2833,7 +2845,7 @@ dependencies = [ [[package]] name = "diem-language-e2e-tests" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -2865,15 +2877,15 @@ dependencies = [ "proptest-derive", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "diem-log-derive" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -2881,7 +2893,7 @@ dependencies = [ [[package]] name = "diem-logger" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "backtrace", "chrono", @@ -2893,7 +2905,7 @@ dependencies = [ "hostname", "once_cell", "prometheus", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "strum", "strum_macros", @@ -2905,7 +2917,7 @@ dependencies = [ [[package]] name = "diem-mempool" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -2935,7 +2947,7 @@ dependencies = [ "once_cell", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", "tokio", @@ -2945,13 +2957,13 @@ dependencies = [ [[package]] name = "diem-mempool-notifications" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-runtimes", "diem-types", "futures", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", ] @@ -2959,7 +2971,7 @@ dependencies = [ [[package]] name = "diem-memsocket" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bytes", "diem-infallible", @@ -2970,7 +2982,7 @@ dependencies = [ [[package]] name = "diem-metrics-core" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "prometheus", @@ -2979,7 +2991,7 @@ dependencies = [ [[package]] name = "diem-move-stdlib" version = "0.1.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "hex", @@ -3002,7 +3014,7 @@ dependencies = [ [[package]] name = "diem-moving-average" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "chrono", ] @@ -3010,7 +3022,7 @@ dependencies = [ [[package]] name = "diem-mvhashmap" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -3025,7 +3037,7 @@ dependencies = [ [[package]] name = "diem-netcore" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bytes", "diem-memsocket", @@ -3033,16 +3045,16 @@ dependencies = [ "diem-types", "futures", "pin-project", - "serde 1.0.209", + "serde 1.0.214", "tokio", - "tokio-util 0.7.12", + "tokio-util", "url", ] [[package]] name = "diem-network" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -3073,19 +3085,19 @@ dependencies = [ "once_cell", "pin-project", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "serde_json", "thiserror", "tokio", "tokio-retry", - "tokio-util 0.7.12", + "tokio-util", ] [[package]] name = "diem-network-builder" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "bcs 0.1.4", @@ -3104,31 +3116,31 @@ dependencies = [ "futures", "maplit", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "tokio", ] [[package]] name = "diem-network-checker" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "diem-config", "diem-crypto", "diem-logger", "diem-network", "diem-types", "futures", - "serde 1.0.209", + "serde 1.0.214", "tokio", ] [[package]] name = "diem-network-discovery" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -3154,11 +3166,11 @@ dependencies = [ [[package]] name = "diem-node" version = "1.6.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-api", "diem-backup-service", "diem-build-info", @@ -3208,7 +3220,7 @@ dependencies = [ "maplit", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tokio", @@ -3219,7 +3231,7 @@ dependencies = [ [[package]] name = "diem-node-identity" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "claims", @@ -3231,9 +3243,9 @@ dependencies = [ [[package]] name = "diem-num-variants" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -3241,20 +3253,20 @@ dependencies = [ [[package]] name = "diem-openapi" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "percent-encoding", "poem", "poem-openapi", - "serde 1.0.209", + "serde 1.0.214", "serde_json", ] [[package]] name = "diem-package-builder" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-framework", @@ -3267,7 +3279,7 @@ dependencies = [ [[package]] name = "diem-peer-monitoring-service-client" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-channels", @@ -3284,7 +3296,7 @@ dependencies = [ "futures", "once_cell", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", "tokio", @@ -3293,7 +3305,7 @@ dependencies = [ [[package]] name = "diem-peer-monitoring-service-server" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "bytes", @@ -3312,7 +3324,7 @@ dependencies = [ "diem-types", "futures", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", ] @@ -3320,20 +3332,20 @@ dependencies = [ [[package]] name = "diem-peer-monitoring-service-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "cfg_block", "diem-config", "diem-types", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-proptest-helpers" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "crossbeam", "proptest", @@ -3343,18 +3355,18 @@ dependencies = [ [[package]] name = "diem-protos" version = "1.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "pbjson", "prost", - "serde 1.0.209", + "serde 1.0.214", "tonic", ] [[package]] name = "diem-proxy" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "ipnet", ] @@ -3362,7 +3374,7 @@ dependencies = [ [[package]] name = "diem-push-metrics" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-logger", "diem-metrics-core", @@ -3373,7 +3385,7 @@ dependencies = [ [[package]] name = "diem-rate-limiter" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-infallible", "diem-logger", @@ -3381,17 +3393,17 @@ dependencies = [ "futures", "pin-project", "tokio", - "tokio-util 0.7.12", + "tokio-util", ] [[package]] name = "diem-release-builder" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem", "diem-api-types", "diem-build-info", @@ -3411,7 +3423,7 @@ dependencies = [ "move-core-types", "move-model", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tempfile", @@ -3423,7 +3435,7 @@ dependencies = [ [[package]] name = "diem-resource-viewer" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-types", @@ -3435,7 +3447,7 @@ dependencies = [ [[package]] name = "diem-rest-client" version = "0.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -3451,7 +3463,7 @@ dependencies = [ "move-core-types", "poem-openapi", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", "tokio", @@ -3461,7 +3473,7 @@ dependencies = [ [[package]] name = "diem-retrier" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-logger", "tokio", @@ -3470,7 +3482,7 @@ dependencies = [ [[package]] name = "diem-rocksdb-options" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-config", "rocksdb", @@ -3479,11 +3491,11 @@ dependencies = [ [[package]] name = "diem-rosetta" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-cached-packages", "diem-config", "diem-crypto", @@ -3502,7 +3514,7 @@ dependencies = [ "once_cell", "percent-encoding", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tokio", @@ -3513,7 +3525,7 @@ dependencies = [ [[package]] name = "diem-runtimes" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "tokio", ] @@ -3521,7 +3533,7 @@ dependencies = [ [[package]] name = "diem-safety-rules" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-config", "diem-consensus-types", @@ -3537,7 +3549,7 @@ dependencies = [ "diem-vault-client", "once_cell", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", ] @@ -3545,7 +3557,7 @@ dependencies = [ [[package]] name = "diem-schemadb" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-infallible", @@ -3559,7 +3571,7 @@ dependencies = [ [[package]] name = "diem-scratchpad" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bitvec 0.19.6", "diem-crypto", @@ -3576,7 +3588,7 @@ dependencies = [ [[package]] name = "diem-sdk" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -3589,18 +3601,18 @@ dependencies = [ "ed25519-dalek-bip32", "move-core-types", "rand_core 0.5.1", - "serde 1.0.209", + "serde 1.0.214", "tiny-bip39", ] [[package]] name = "diem-sdk-builder" version = "0.2.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-types", "heck 0.3.3", "move-core-types", @@ -3615,19 +3627,19 @@ dependencies = [ [[package]] name = "diem-secure-net" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-logger", "diem-metrics-core", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-secure-storage" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "base64 0.13.1", @@ -3641,7 +3653,7 @@ dependencies = [ "diem-vault-client", "enum_dispatch", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", ] @@ -3649,10 +3661,10 @@ dependencies = [ [[package]] name = "diem-short-hex-str" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "mirai-annotations", - "serde 1.0.209", + "serde 1.0.214", "static_assertions", "thiserror", ] @@ -3660,7 +3672,7 @@ dependencies = [ [[package]] name = "diem-speculative-state-helper" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "crossbeam", @@ -3672,7 +3684,7 @@ dependencies = [ [[package]] name = "diem-state-sync-driver" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -3698,7 +3710,7 @@ dependencies = [ "futures", "once_cell", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", "tokio-stream", @@ -3707,13 +3719,13 @@ dependencies = [ [[package]] name = "diem-state-view" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", "diem-crypto", "diem-types", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "serde_json", ] @@ -3721,7 +3733,7 @@ dependencies = [ [[package]] name = "diem-storage-interface" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arr_macro", @@ -3741,14 +3753,14 @@ dependencies = [ "once_cell", "parking_lot 0.12.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-storage-service-client" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "async-trait", "diem-channels", @@ -3762,7 +3774,7 @@ dependencies = [ [[package]] name = "diem-storage-service-server" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "bytes", @@ -3780,7 +3792,7 @@ dependencies = [ "futures", "lru 0.7.8", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", "tokio", ] @@ -3788,7 +3800,7 @@ dependencies = [ [[package]] name = "diem-storage-service-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "diem-compression", @@ -3796,14 +3808,14 @@ dependencies = [ "diem-crypto", "diem-types", "num-traits 0.2.19", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] [[package]] name = "diem-temppath" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "hex", "rand 0.7.3", @@ -3812,7 +3824,7 @@ dependencies = [ [[package]] name = "diem-time-service" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "diem-infallible", "enum_dispatch", @@ -3825,12 +3837,12 @@ dependencies = [ [[package]] name = "diem-transaction-emitter-lib" version = "0.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "again", "anyhow", "async-trait", - "clap 4.5.17", + "clap 4.5.20", "diem", "diem-config", "diem-crypto", @@ -3848,7 +3860,7 @@ dependencies = [ "rand 0.7.3", "rand_core 0.5.1", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "tokio", "url", ] @@ -3856,12 +3868,12 @@ dependencies = [ [[package]] name = "diem-transaction-generator-lib" version = "0.0.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "again", "anyhow", "async-trait", - "clap 4.5.17", + "clap 4.5.20", "diem", "diem-config", "diem-crypto", @@ -3878,7 +3890,7 @@ dependencies = [ "rand 0.7.3", "rand_core 0.5.1", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "tokio", "url", ] @@ -3886,11 +3898,11 @@ dependencies = [ [[package]] name = "diem-transactional-test-harness" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-api-types", "diem-cached-packages", "diem-crypto", @@ -3911,14 +3923,14 @@ dependencies = [ "move-transactional-test-runner", "move-vm-runtime", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "serde_json", ] [[package]] name = "diem-types" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arr_macro", @@ -3940,7 +3952,7 @@ dependencies = [ "proptest-derive", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "serde_json", "serde_yaml 0.8.26", @@ -3951,12 +3963,12 @@ dependencies = [ [[package]] name = "diem-utils" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" [[package]] name = "diem-validator-interface" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -3977,14 +3989,14 @@ dependencies = [ [[package]] name = "diem-vault-client" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "base64 0.13.1", "chrono", "diem-crypto", "native-tls", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", "ureq", @@ -3993,7 +4005,7 @@ dependencies = [ [[package]] name = "diem-vm" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -4031,7 +4043,7 @@ dependencies = [ "ouroboros 0.15.6", "rand 0.7.3", "rayon", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "smallvec", "tracing", @@ -4040,7 +4052,7 @@ dependencies = [ [[package]] name = "diem-vm-genesis" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -4055,13 +4067,13 @@ dependencies = [ "move-vm-types", "once_cell", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "diem-vm-logging" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "arc-swap", "diem-crypto", @@ -4071,13 +4083,13 @@ dependencies = [ "diem-state-view", "diem-types", "once_cell", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "diem-vm-types" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-aggregator", @@ -4090,7 +4102,7 @@ dependencies = [ [[package]] name = "diem-vm-validator" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "diem-gas", @@ -4105,15 +4117,15 @@ dependencies = [ [[package]] name = "diem-warp-webserver" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", "diem-api-types", "diem-config", "diem-logger", - "hyper", - "serde 1.0.209", + "hyper 0.14.31", + "serde 1.0.214", "serde_json", "warp", ] @@ -4146,9 +4158,9 @@ checksum = "e7f2c3de51e2ba6bf2a648285696137aaf0f5f487bcbea93972fe8a364e131a4" dependencies = [ "diesel_table_macro_syntax", "dsl_auto_type", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4168,7 +4180,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c735641a413bc68c4923a9d6ad4bcb3ca306b794edaa7eb0b3228a99ffb25" dependencies = [ - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4256,9 +4268,9 @@ dependencies = [ "darling 0.20.10", "either", "heck 0.5.0", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4267,7 +4279,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "signature", ] @@ -4280,7 +4292,7 @@ dependencies = [ "curve25519-dalek", "ed25519", "rand 0.7.3", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "sha2 0.9.9", "zeroize", @@ -4312,9 +4324,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -4326,9 +4338,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" dependencies = [ "once_cell", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4362,7 +4374,7 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -4411,9 +4423,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fdeflate" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" dependencies = [ "simd-adler32", ] @@ -4463,12 +4475,21 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", +] + +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", ] [[package]] @@ -4515,9 +4536,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -4530,9 +4551,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -4540,15 +4561,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -4557,38 +4578,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -4647,10 +4668,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -4678,9 +4697,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git2" @@ -4718,15 +4737,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -4742,9 +4761,9 @@ dependencies = [ [[package]] name = "goldenfile" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d5c44265baec620ea19c97b4ce9f068e28f8c3d7faccc483f02968b5e3c587" +checksum = "672ff1c2f0537cf3f92065ce8aa77e2fc3f2abae2c805eb67f40ceecfbdee428" dependencies = [ "scopeguard", "similar-asserts", @@ -4763,11 +4782,11 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 2.5.0", + "http 0.2.12", + "indexmap 2.6.0", "slab", "tokio", - "tokio-util 0.7.12", + "tokio-util", "tracing", ] @@ -4780,7 +4799,7 @@ dependencies = [ "log", "pest", "pest_derive", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", ] @@ -4809,6 +4828,12 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "headers" version = "0.3.9" @@ -4817,8 +4842,23 @@ checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ "base64 0.21.7", "bytes", - "headers-core", - "http", + "headers-core 0.2.0", + "http 0.2.12", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" +dependencies = [ + "base64 0.21.7", + "bytes", + "headers-core 0.3.0", + "http 1.1.0", "httpdate", "mime", "sha1", @@ -4830,7 +4870,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.12", +] + +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http 1.1.0", ] [[package]] @@ -4881,7 +4930,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -4919,7 +4968,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.1", + "crypto-mac 0.10.0", "digest 0.9.0", ] @@ -4943,6 +4992,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -4971,6 +5029,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -4978,21 +5047,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -5011,17 +5097,17 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", "h2", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -5033,19 +5119,62 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-http-proxy" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d06dbdfbacf34d996c6fb540a71a684a7aae9056c71951163af8a8a4c07b9a4" +dependencies = [ + "bytes", + "futures-util", + "headers 0.4.0", + "http 1.1.0", + "hyper 1.5.0", + "hyper-rustls", + "hyper-util", + "pin-project-lite", + "rustls-native-certs 0.7.3", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", +] + [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ - "http", - "hyper", + "futures-util", + "http 1.1.0", + "hyper 1.5.0", + "hyper-util", "log", - "rustls 0.20.9", - "rustls-native-certs", + "rustls 0.23.16", + "rustls-native-certs 0.8.0", + "rustls-pki-types", "tokio", - "tokio-rustls 0.23.4", + "tokio-rustls 0.26.0", + "tower-service", ] [[package]] @@ -5054,12 +5183,25 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.31", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper 1.5.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -5067,17 +5209,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.31", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.5.0", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -5102,17 +5263,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.3.0" @@ -5135,15 +5285,15 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" dependencies = [ "crossbeam-deque", "globset", "log", "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "same-file", "walkdir", "winapi-util", @@ -5191,7 +5341,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -5200,7 +5350,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -5234,7 +5384,7 @@ checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df" dependencies = [ "anyhow", "proc-macro-hack", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -5245,7 +5395,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", ] @@ -5257,18 +5407,18 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", - "serde 1.0.209", + "hashbrown 0.15.0", + "serde 1.0.214", ] [[package]] @@ -5297,12 +5447,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash 0.8.11", - "clap 4.5.17", + "clap 4.5.20", "crossbeam-channel", "crossbeam-utils", "dashmap 6.1.0", "env_logger", - "indexmap 2.5.0", + "indexmap 2.6.0", "is-terminal", "itoa", "log", @@ -5349,9 +5499,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "iprange" @@ -5432,45 +5582,60 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] [[package]] name = "json-patch" -version = "0.2.7" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3fa5a61630976fc4c353c70297f2e93f1930e3ccee574d59d618ccbd5154ce" +checksum = "5b1fb8864823fad91877e6caea0baca82e49e8db50f8e5c9f9a453e27d3330fc" dependencies = [ - "serde 1.0.209", + "jsonptr", + "serde 1.0.214", "serde_json", - "treediff", + "thiserror", ] [[package]] -name = "jsonpath_lib" -version = "0.3.0" +name = "jsonpath-rust" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaa63191d68230cccb81c5aa23abd53ed64d83337cacbb25a7b8c7979523774f" +checksum = "19d8fe85bd70ff715f31ce8c739194b423d79811a19602115d611a3ec85d6200" dependencies = [ - "log", - "serde 1.0.209", + "lazy_static 1.5.0", + "once_cell", + "pest", + "pest_derive", + "regex", + "serde_json", + "thiserror", +] + +[[package]] +name = "jsonptr" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6e529149475ca0b2820835d3dce8fcc41c6b943ca608d32f35b449255e4627" +dependencies = [ + "fluent-uri", + "serde 1.0.214", "serde_json", ] [[package]] name = "k8s-openapi" -version = "0.13.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f8de9873b904e74b3533f77493731ee26742418077503683db44e1b3c54aa5c" +checksum = "9c8847402328d8301354c94d605481f25a6bdc1ed65471fd96af8eca71141b13" dependencies = [ - "base64 0.13.1", - "bytes", + "base64 0.22.1", "chrono", - "serde 1.0.209", + "serde 1.0.214", "serde-value", "serde_json", ] @@ -5486,9 +5651,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.65.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec231e9ec9e84789f9eb414d1ac40ce6c90d0517fb272a335b4233f2e272b1e" +checksum = "efffeb3df0bd4ef3e5d65044573499c0e4889b988070b08c50b25b1329289a1f" dependencies = [ "k8s-openapi", "kube-client", @@ -5497,52 +5662,55 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.65.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95dddb1fcced906d79cdae530ff39079c2d3772b2d623088fdbebe610bfa8217" +checksum = "8bf471ece8ff8d24735ce78dac4d091e9fcb8d74811aeb6b75de4d1c3f5de0f1" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", "bytes", "chrono", - "dirs-next", "either", "futures", - "http", - "http-body", - "hyper", + "home", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.0", + "hyper-http-proxy", "hyper-rustls", - "hyper-timeout", - "jsonpath_lib", + "hyper-timeout 0.5.2", + "hyper-util", + "jsonpath-rust", "k8s-openapi", "kube-core", "pem", - "pin-project", - "rustls 0.20.9", - "rustls-pemfile 0.2.1", - "serde 1.0.209", + "rustls 0.23.16", + "rustls-pemfile 2.2.0", + "secrecy", + "serde 1.0.214", "serde_json", - "serde_yaml 0.8.26", + "serde_yaml 0.9.34+deprecated", "thiserror", "tokio", - "tokio-util 0.6.10", - "tower", + "tokio-util", + "tower 0.5.1", "tower-http", "tracing", ] [[package]] name = "kube-core" -version = "0.65.0" +version = "0.96.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52b6ab05d160691083430f6f431707a4e05b64903f2ffa0095ee5efde759117" +checksum = "f42346d30bb34d1d7adc5c549b691bce7aa3a1e60254e68fab7e2d7b26fe3d77" dependencies = [ "chrono", "form_urlencoded", - "http", + "http 1.1.0", "json-patch", "k8s-openapi", - "once_cell", - "serde 1.0.209", + "serde 1.0.214", + "serde-value", "serde_json", "thiserror", ] @@ -5580,9 +5748,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libgit2-sys" @@ -5610,20 +5778,19 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libra" version = "7.0.3" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "diem", "diem-config", "diem-node", - "diem-vm", "libra-config", "libra-framework", "libra-genesis-tools", @@ -5637,6 +5804,32 @@ dependencies = [ "vergen", ] +[[package]] +name = "libra-backwards-compatibility" +version = "7.0.3" +dependencies = [ + "anyhow", + "bcs 0.1.4", + "bytes", + "diem-api-types", + "diem-backup-cli", + "diem-config", + "diem-crypto", + "diem-crypto-derive", + "diem-temppath", + "diem-types", + "hex", + "libra-types", + "move-core-types", + "once_cell", + "rand 0.7.3", + "serde 1.0.214", + "serde_bytes", + "serde_json", + "tiny-keccak", + "tokio", +] + [[package]] name = "libra-cached-packages" version = "7.0.3" @@ -5654,7 +5847,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem", "diem-config", @@ -5666,7 +5859,7 @@ dependencies = [ "libra-types", "libra-wallet", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tokio", @@ -5679,7 +5872,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem", "diem-build-info", @@ -5701,7 +5894,7 @@ dependencies = [ "base64 0.13.1", "bcs 0.1.4", "chrono", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem-config", "diem-crypto", @@ -5719,12 +5912,13 @@ dependencies = [ "diem-vm", "diem-vm-genesis", "indicatif", + "libra-backwards-compatibility", "libra-config", "libra-framework", "libra-types", "libra-wallet", "move-core-types", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "tokio", "ureq", @@ -5735,7 +5929,7 @@ name = "libra-query" version = "7.0.3" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "diem-api-types", "diem-debugger", "diem-sdk", @@ -5754,7 +5948,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-api-types", "diem-config", "diem-crypto", @@ -5810,7 +6004,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "diem-backup-cli", "diem-config", "diem-db", @@ -5821,7 +6015,7 @@ dependencies = [ "diem-temppath", "diem-types", "glob", - "libra-types", + "libra-backwards-compatibility", "num_cpus", "serde_json", "tokio", @@ -5833,7 +6027,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem-api-types", "diem-config", @@ -5862,7 +6056,7 @@ version = "7.0.3" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem", "diem-forge", @@ -5881,7 +6075,7 @@ dependencies = [ "libra-smoke-tests", "libra-types", "libra-wallet", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "smoke-test", @@ -5896,7 +6090,7 @@ dependencies = [ "anyhow", "async-trait", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "console", "diem", "diem-api-types", @@ -5915,7 +6109,7 @@ dependencies = [ "once_cell", "rand 0.7.3", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_with", "serde_yaml 0.8.26", @@ -5950,7 +6144,7 @@ dependencies = [ "anyhow", "blst", "byteorder", - "clap 4.5.17", + "clap 4.5.20", "dialoguer", "diem-config", "diem-crypto", @@ -5965,7 +6159,7 @@ dependencies = [ "pbkdf2 0.7.5", "rand 0.7.3", "rpassword", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "sha2 0.9.9", @@ -6012,7 +6206,7 @@ dependencies = [ "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", "rand 0.8.5", - "serde 1.0.209", + "serde 1.0.214", "sha2 0.9.9", "typenum", ] @@ -6123,7 +6317,7 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -6146,19 +6340,18 @@ dependencies = [ [[package]] name = "lz4" -version = "1.26.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" +checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" dependencies = [ - "libc", "lz4-sys", ] [[package]] name = "lz4-sys" -version = "1.10.0" +version = "1.11.1+lz4-1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" +checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" dependencies = [ "cc", "libc", @@ -6185,12 +6378,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.3" @@ -6209,7 +6396,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd01039851e82f8799046eabbb354056283fb265c8ec0996af940f4e85a380ff" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "toml 0.8.2", ] @@ -6220,7 +6407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffb161cc72176cb37aa47f1fc520d3ef02263d67d661f44f05d05a079e1237fd" dependencies = [ "migrations_internals", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", ] @@ -6246,16 +6433,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", - "simd-adler32", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -6263,6 +6440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -6277,6 +6455,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", +] + [[package]] name = "mirai-annotations" version = "1.12.0" @@ -6292,7 +6482,7 @@ checksum = "1fafa6961cabd9c63bcd77a45d7e3b7f3b552b70417831fb0f56db717e72407e" [[package]] name = "move-abigen" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -6303,13 +6493,13 @@ dependencies = [ "move-command-line-common", "move-core-types", "move-model", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-binary-format" version = "0.0.3" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arbitrary", @@ -6319,19 +6509,19 @@ dependencies = [ "proptest", "proptest-derive", "ref-cast", - "serde 1.0.209", + "serde 1.0.214", "variant_count", ] [[package]] name = "move-borrow-graph" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" [[package]] name = "move-bytecode-source-map" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -6340,13 +6530,13 @@ dependencies = [ "move-core-types", "move-ir-types", "move-symbol-pool", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-bytecode-utils" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "move-binary-format", @@ -6358,7 +6548,7 @@ dependencies = [ [[package]] name = "move-bytecode-verifier" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "fail 0.4.0", @@ -6372,10 +6562,10 @@ dependencies = [ [[package]] name = "move-bytecode-viewer" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "crossterm 0.26.1", "move-binary-format", "move-bytecode-source-map", @@ -6389,11 +6579,11 @@ dependencies = [ [[package]] name = "move-cli" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "codespan-reporting", "colored", "difference", @@ -6422,7 +6612,7 @@ dependencies = [ "move-vm-types", "once_cell", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_yaml 0.8.26", "tempfile", @@ -6433,7 +6623,7 @@ dependencies = [ [[package]] name = "move-command-line-common" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "difference", @@ -6442,7 +6632,7 @@ dependencies = [ "move-core-types", "num-bigint", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "sha2 0.9.9", "walkdir", ] @@ -6450,11 +6640,11 @@ dependencies = [ [[package]] name = "move-compiler" version = "0.0.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "codespan-reporting", "difference", "hex", @@ -6479,7 +6669,7 @@ dependencies = [ [[package]] name = "move-core-types" version = "0.0.4" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "arbitrary", @@ -6493,7 +6683,7 @@ dependencies = [ "proptest-derive", "rand 0.8.5", "ref-cast", - "serde 1.0.209", + "serde 1.0.214", "serde_bytes", "uint", ] @@ -6501,11 +6691,11 @@ dependencies = [ [[package]] name = "move-coverage" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "codespan", "colored", "move-binary-format", @@ -6515,16 +6705,16 @@ dependencies = [ "move-ir-types", "once_cell", "petgraph 0.5.1", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-disassembler" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "colored", "move-binary-format", "move-bytecode-source-map", @@ -6539,7 +6729,7 @@ dependencies = [ [[package]] name = "move-docgen" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "codespan", @@ -6552,13 +6742,13 @@ dependencies = [ "num", "once_cell", "regex", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-errmapgen" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -6566,17 +6756,17 @@ dependencies = [ "move-command-line-common", "move-core-types", "move-model", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-ir-compiler" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "move-binary-format", "move-bytecode-source-map", "move-bytecode-verifier", @@ -6591,7 +6781,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "codespan-reporting", @@ -6610,7 +6800,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode-syntax" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "hex", @@ -6623,7 +6813,7 @@ dependencies = [ [[package]] name = "move-ir-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "hex", @@ -6631,13 +6821,13 @@ dependencies = [ "move-core-types", "move-symbol-pool", "once_cell", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-model" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "codespan", @@ -6657,18 +6847,18 @@ dependencies = [ "num", "once_cell", "regex", - "serde 1.0.209", + "serde 1.0.214", "trace", ] [[package]] name = "move-package" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", - "clap 4.5.17", + "clap 4.5.20", "colored", "dirs-next", "itertools", @@ -6688,7 +6878,7 @@ dependencies = [ "ptree", "regex", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_yaml 0.8.26", "sha2 0.9.9", "tempfile", @@ -6700,12 +6890,12 @@ dependencies = [ [[package]] name = "move-prover" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", "atty", - "clap 4.5.17", + "clap 4.5.20", "codespan", "codespan-reporting", "futures", @@ -6727,7 +6917,7 @@ dependencies = [ "once_cell", "pretty", "rand 0.8.5", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "simplelog", "tokio", @@ -6737,7 +6927,7 @@ dependencies = [ [[package]] name = "move-prover-boogie-backend" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -6757,7 +6947,7 @@ dependencies = [ "pretty", "rand 0.8.5", "regex", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "tera", "tokio", @@ -6766,7 +6956,7 @@ dependencies = [ [[package]] name = "move-resource-viewer" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -6775,13 +6965,13 @@ dependencies = [ "move-bytecode-utils", "move-core-types", "once_cell", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-stackless-bytecode" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "codespan", "codespan-reporting", @@ -6801,13 +6991,13 @@ dependencies = [ "once_cell", "paste", "petgraph 0.5.1", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-stdlib" version = "0.1.1" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "hex", @@ -6830,16 +7020,16 @@ dependencies = [ [[package]] name = "move-symbol-pool" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "once_cell", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-table-extension" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "bcs 0.1.4", @@ -6856,10 +7046,10 @@ dependencies = [ [[package]] name = "move-transactional-test-runner" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", - "clap 4.5.17", + "clap 4.5.20", "colored", "move-binary-format", "move-bytecode-source-map", @@ -6887,11 +7077,11 @@ dependencies = [ [[package]] name = "move-unit-test" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "better_any", - "clap 4.5.17", + "clap 4.5.20", "codespan-reporting", "colored", "itertools", @@ -6917,7 +7107,7 @@ dependencies = [ [[package]] name = "move-vm-runtime" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "better_any", "fail 0.4.0", @@ -6934,7 +7124,7 @@ dependencies = [ [[package]] name = "move-vm-test-utils" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "move-binary-format", @@ -6942,19 +7132,19 @@ dependencies = [ "move-table-extension", "move-vm-types", "once_cell", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "move-vm-types" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "bcs 0.1.4", "move-binary-format", "move-core-types", "once_cell", - "serde 1.0.209", + "serde 1.0.214", "smallvec", ] @@ -6967,7 +7157,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http", + "http 0.2.12", "httparse", "log", "memchr", @@ -7099,7 +7289,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -7191,18 +7381,18 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -7212,9 +7402,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -7231,9 +7421,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7244,9 +7434,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -7297,7 +7487,7 @@ checksum = "03f2cb802b5bdfdf52f1ffa0b54ce105e4d346e91990dd571f86c91321ad49e2" dependencies = [ "Inflector", "proc-macro-error", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -7310,7 +7500,7 @@ checksum = "5f7d21ccd03305a674437ee1248f3ab5d4b1db095cf1caf49f1713ddf61956b7" dependencies = [ "Inflector", "proc-macro-error", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -7338,7 +7528,7 @@ dependencies = [ "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -7348,7 +7538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" dependencies = [ "proc-macro-crate 1.3.1", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -7396,7 +7586,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -7433,16 +7623,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "599fe9aefc2ca0df4a96179b3075faee2cacb89d4cf947a00b9a89152dfffc9d" dependencies = [ "base64 0.13.1", - "serde 1.0.209", -] - -[[package]] -name = "pbkdf2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" -dependencies = [ - "crypto-mac 0.8.0", + "serde 1.0.214", ] [[package]] @@ -7452,12 +7633,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf916dd32dd26297907890d99dc2740e33f6bd9073965af4ccff2967962f5508" dependencies = [ "base64ct", - "crypto-mac 0.10.1", + "crypto-mac 0.10.0", "hmac 0.10.1", "password-hash", "sha2 0.9.9", ] +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -7466,11 +7657,12 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pem" -version = "1.1.1" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", + "serde 1.0.214", ] [[package]] @@ -7481,9 +7673,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -7492,9 +7684,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" dependencies = [ "pest", "pest_generator", @@ -7502,22 +7694,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" dependencies = [ "once_cell", "pest", @@ -7541,7 +7733,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset 0.4.2", - "indexmap 2.5.0", + "indexmap 2.6.0", ] [[package]] @@ -7584,29 +7776,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -7616,21 +7808,21 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "png" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.4", + "miniz_oxide", ] [[package]] @@ -7643,11 +7835,11 @@ dependencies = [ "async-trait", "bytes", "chrono", - "cookie", + "cookie 0.16.2", "futures-util", - "headers", - "http", - "hyper", + "headers 0.3.9", + "http 0.2.12", + "hyper 0.14.31", "mime", "multer", "parking_lot 0.12.3", @@ -7658,7 +7850,7 @@ dependencies = [ "regex", "rfc7239", "rustls-pemfile 1.0.4", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_urlencoded", "serde_yaml 0.9.34+deprecated", @@ -7669,7 +7861,7 @@ dependencies = [ "tokio", "tokio-rustls 0.24.1", "tokio-stream", - "tokio-util 0.7.12", + "tokio-util", "tracing", ] @@ -7680,9 +7872,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ddcf4680d8d867e1e375116203846acb088483fa2070244f90589f458bbb31" dependencies = [ "proc-macro-crate 2.0.2", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7701,7 +7893,7 @@ dependencies = [ "poem-openapi-derive", "quick-xml 0.26.0", "regex", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_urlencoded", "serde_yaml 0.9.34+deprecated", @@ -7717,11 +7909,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88c3e2975c930dc72c024e75b230c3b6058fb3a746d5739b83aa8f28ab1a42d4" dependencies = [ "darling 0.14.4", - "http", + "http 0.2.12", "indexmap 1.9.3", "mime", "proc-macro-crate 1.3.1", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "regex", "syn 1.0.109", @@ -7742,9 +7934,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -7763,9 +7955,9 @@ dependencies = [ [[package]] name = "pq-sys" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a24ff9e4cf6945c988f0db7005d87747bf72864965c3529d259ad155ac41d584" +checksum = "f6cc05d7ea95200187117196eee9edd0644424911821aeb28a18ce60ea0b8793" dependencies = [ "vcpkg", ] @@ -7782,12 +7974,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ - "proc-macro2 1.0.86", - "syn 2.0.77", + "proc-macro2 1.0.89", + "syn 2.0.87", ] [[package]] @@ -7829,7 +8021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", "version_check", @@ -7841,7 +8033,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "version_check", ] @@ -7863,9 +8055,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -7891,7 +8083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ae2f6a3f14ff35c16b51ac796d1dc73c15ad6472c48836c6c467f6d52266648" dependencies = [ "reqwest", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "time", "url", @@ -7911,7 +8103,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -7946,7 +8138,7 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -7968,7 +8160,7 @@ dependencies = [ "config", "directories", "petgraph 0.6.5", - "serde 1.0.209", + "serde 1.0.214", "serde-value", "tint", ] @@ -8014,7 +8206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" dependencies = [ "memchr", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -8032,7 +8224,7 @@ version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", ] [[package]] @@ -8195,7 +8387,7 @@ dependencies = [ "ryu", "sha1_smol", "tokio", - "tokio-util 0.7.12", + "tokio-util", "url", ] @@ -8210,9 +8402,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -8243,21 +8435,21 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -8271,13 +8463,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -8288,27 +8480,27 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", - "cookie", + "cookie 0.17.0", "cookie_store", "encoding_rs", "futures-core", "futures-util", "h2", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", "hyper-tls", "ipnet", "js-sys", @@ -8319,13 +8511,15 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "serde 1.0.209", + "rustls-pemfile 1.0.4", + "serde 1.0.214", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", - "tokio-util 0.7.12", + "tokio-util", "tower-service", "url", "wasm-bindgen", @@ -8343,9 +8537,9 @@ checksum = "5a735987236a8e238bf0296c7e351b999c188ccc11477f311b82b55c93984216" dependencies = [ "anyhow", "async-trait", - "http", + "http 0.2.12", "reqwest", - "serde 1.0.209", + "serde 1.0.214", "task-local-extensions", "thiserror", ] @@ -8361,8 +8555,8 @@ dependencies = [ "chrono", "futures", "getrandom 0.2.15", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.31", "parking_lot 0.11.2", "reqwest", "reqwest-middleware", @@ -8502,9 +8696,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.36" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags 2.6.0", "errno", @@ -8533,10 +8727,39 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.8", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls" +version = "0.23.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +dependencies = [ + "log", + "once_cell", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.8", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -8550,12 +8773,29 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "0.2.1" +name = "rustls-native-certs" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ - "base64 0.13.1", + "openssl-probe", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "schannel", + "security-framework", ] [[package]] @@ -8567,6 +8807,21 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -8577,11 +8832,22 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -8612,11 +8878,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -8650,6 +8916,15 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "secrecy" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -8665,9 +8940,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -8679,7 +8954,7 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b28d58e73c427061f46c801176f54349be3c1a2818cf549e1d9bcac37eef7bca" dependencies = [ - "hyper", + "hyper 0.14.31", "indicatif", "log", "quick-xml 0.22.0", @@ -8705,9 +8980,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] @@ -8722,7 +8997,7 @@ dependencies = [ "heck 0.3.3", "include_dir 0.6.2", "maplit", - "serde 1.0.209", + "serde 1.0.214", "serde-reflection 0.3.5", "serde_bytes", "serde_yaml 0.8.26", @@ -8748,7 +9023,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12c47087018ec281d1cdab673d36aea22d816b54d498264029c05d5fa1910da6" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] @@ -8758,7 +9033,7 @@ version = "0.3.5" source = "git+https://github.com/aptos-labs/serde-reflection?rev=839aed62a20ddccf043c08961cfe74875741ccba#839aed62a20ddccf043c08961cfe74875741ccba" dependencies = [ "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] @@ -8769,7 +9044,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f05a5f801ac62a51a49d378fdb3884480041b99aced450b28990673e8ff99895" dependencies = [ "once_cell", - "serde 1.0.209", + "serde 1.0.214", "thiserror", ] @@ -8780,7 +9055,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" dependencies = [ "ordered-float", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -8789,31 +9064,31 @@ version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "memchr", "ryu", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -8822,18 +9097,18 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "606e91878516232ac3b16c12e063d4468d762f16d77e7aef14a1f2326c5f409b" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "serde_json", "thiserror", ] [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -8845,21 +9120,21 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] name = "serde_with" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.5.0", - "serde 1.0.209", + "indexmap 2.6.0", + "serde 1.0.214", "serde_derive", "serde_json", "serde_with_macros", @@ -8868,14 +9143,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling 0.20.10", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -8886,7 +9161,7 @@ checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ "indexmap 1.9.3", "ryu", - "serde 1.0.209", + "serde 1.0.214", "yaml-rust", ] @@ -8896,10 +9171,10 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "ryu", - "serde 1.0.209", + "serde 1.0.214", "unsafe-libyaml", ] @@ -9007,7 +9282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio", + "mio 0.8.11", "signal-hook", ] @@ -9044,9 +9319,9 @@ dependencies = [ [[package]] name = "similar-asserts" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" +checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" dependencies = [ "console", "similar", @@ -9113,7 +9388,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smoke-test" version = "0.1.0" -source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#fe9453ded98e8d21c63772a9d3c6bc1e5d235fe1" +source = "git+https://github.com/0LNetworkCommunity/diem.git?branch=release#e402fe6d60b1fc0c2eecc51bc606c7200a579789" dependencies = [ "anyhow", "async-trait", @@ -9245,7 +9520,7 @@ checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck 0.3.3", "proc-macro-error", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -9263,7 +9538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck 0.4.1", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "rustversion", "syn 1.0.109", @@ -9271,9 +9546,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -9292,18 +9567,18 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.77" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "unicode-ident", ] @@ -9367,9 +9642,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -9394,7 +9669,7 @@ dependencies = [ "pest_derive", "rand 0.8.5", "regex", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "slug", "unic-segment", @@ -9447,22 +9722,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "3b3c6efbfc763e64eb85c11c25320f0737cb7364c4b6336db90aa9ebe27a0bbd" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "b607164372e89797d78b8e23a6d67d5d1038c1c65efd52e1389ef8b77caba2a6" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9496,7 +9771,7 @@ dependencies = [ "num-conv", "num_threads", "powerfmt", - "serde 1.0.209", + "serde 1.0.214", "time-core", "time-macros", ] @@ -9528,17 +9803,15 @@ dependencies = [ [[package]] name = "tiny-bip39" -version = "0.8.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +checksum = "a30fd743a02bf35236f6faf99adb03089bb77e91c998dac2c2ad76bb424f668c" dependencies = [ - "anyhow", - "hmac 0.8.1", "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", + "pbkdf2 0.12.2", + "rand 0.8.5", "rustc-hash", - "sha2 0.9.9", + "sha2 0.10.8", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -9571,21 +9844,20 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.1" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777d57dcc6bb4cf084e3212e1858447222aa451f21b5e2452497d9100da65b91" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.2", "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -9600,24 +9872,25 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "tokio-metrics" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcb585a0069b53171684e22d5255984ec30d1c7304fd0a4a9a603ffd8c765cdd" +checksum = "eace09241d62c98b7eeb1107d4c5c64ca3bd7da92e8c218c153ab3a78f9be112" dependencies = [ "futures-util", "pin-project-lite", "tokio", + "tokio-stream", ] [[package]] @@ -9662,6 +9935,28 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.16", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.16" @@ -9675,9 +9970,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.18.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", @@ -9685,20 +9980,6 @@ dependencies = [ "tungstenite", ] -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.12" @@ -9719,7 +10000,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -9728,7 +10009,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "serde_spanned", "toml_datetime", "toml_edit 0.20.2", @@ -9740,7 +10021,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -9752,7 +10033,7 @@ dependencies = [ "combine", "indexmap 1.9.3", "itertools", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -9761,7 +10042,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "toml_datetime", "winnow", ] @@ -9772,8 +10053,8 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.5.0", - "serde 1.0.209", + "indexmap 2.6.0", + "serde 1.0.214", "serde_spanned", "toml_datetime", "winnow", @@ -9794,21 +10075,21 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "hyper-timeout 0.4.1", "percent-encoding", "pin-project", "prost", "prost-derive", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "tokio", "tokio-rustls 0.23.4", "tokio-stream", - "tokio-util 0.7.12", - "tower", + "tokio-util", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -9829,26 +10110,41 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.12", + "tokio-util", "tower-layer", "tower-service", "tracing", ] [[package]] -name = "tower-http" -version = "0.2.5" +name = "tower" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba3f3efabf7fb41fae8534fc20a817013dd1c12cb45441efb6c82e6556b4cd8" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", - "bytes", "futures-core", "futures-util", - "http", - "http-body", - "http-range-header", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97" +dependencies = [ + "base64 0.22.1", + "bitflags 2.6.0", + "bytes", + "http 1.1.0", + "http-body 1.0.1", + "mime", "pin-project-lite", "tower-layer", "tower-service", @@ -9873,7 +10169,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ad0c048e114d19d1140662762bfdb10682f3bc806d8be18af846600214dd9af" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", "syn 1.0.109", ] @@ -9896,9 +10192,9 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9938,7 +10234,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ - "serde 1.0.209", + "serde 1.0.214", "tracing-core", ] @@ -9952,7 +10248,7 @@ dependencies = [ "nu-ansi-term", "once_cell", "regex", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "sharded-slab", "smallvec", @@ -9971,15 +10267,6 @@ dependencies = [ "diem-transactional-test-harness", ] -[[package]] -name = "treediff" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761e8d5ad7ce14bb82b7e61ccc0ca961005a275a060b9644a2431aa11553c2ff" -dependencies = [ - "serde_json", -] - [[package]] name = "try-lock" version = "0.2.5" @@ -10001,14 +10288,14 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.18.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ - "base64 0.13.1", "byteorder", "bytes", - "http", + "data-encoding", + "http 1.1.0", "httparse", "log", "rand 0.8.5", @@ -10053,18 +10340,18 @@ dependencies = [ [[package]] name = "tzdb_data" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1889fdffac09d65c1d95c42d5202e9b21ad8c758f426e9fe09088817ea998d6" +checksum = "654c1ec546942ce0594e8d220e6b8e3899e0a0a8fe70ddd54d32a376dfefe3f8" dependencies = [ "tz-rs", ] [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uint" @@ -10145,24 +10432,21 @@ dependencies = [ [[package]] name = "unicase" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-linebreak" @@ -10172,24 +10456,24 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" @@ -10199,9 +10483,9 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" @@ -10243,7 +10527,7 @@ dependencies = [ "native-tls", "once_cell", "qstring", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "url", ] @@ -10257,7 +10541,7 @@ dependencies = [ "form_urlencoded", "idna 0.5.0", "percent-encoding", - "serde 1.0.209", + "serde 1.0.214", ] [[package]] @@ -10364,32 +10648,31 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" dependencies = [ "bytes", "futures-channel", "futures-util", - "headers", - "http", - "hyper", + "headers 0.3.9", + "http 0.2.12", + "hyper 0.14.31", "log", "mime", "mime_guess", "multer", "percent-encoding", "pin-project", - "rustls-pemfile 1.0.4", + "rustls-pemfile 2.2.0", "scoped-tls", - "serde 1.0.209", + "serde 1.0.214", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls 0.23.4", - "tokio-stream", + "tokio-rustls 0.25.0", "tokio-tungstenite", - "tokio-util 0.7.12", + "tokio-util", "tower-service", "tracing", ] @@ -10414,9 +10697,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -10425,24 +10708,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -10452,9 +10735,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote 1.0.37", "wasm-bindgen-macro-support", @@ -10462,28 +10745,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-streams" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", @@ -10509,9 +10792,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -10533,7 +10816,7 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", "wasite", "web-sys", ] @@ -10766,8 +11049,7 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "x25519-dalek" version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2392b6b94a576b4e2bf3c5b2757d63f10ada8020a2e4d08ac849ebcf6ea8e077" +source = "git+https://github.com/0LNetworkCommunity/x25519-dalek?branch=zeroize_v1#762a9501668d213daa4a1864fa1f9db22716b661" dependencies = [ "curve25519-dalek", "rand_core 0.5.1", @@ -10805,16 +11087,16 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "zeroize" -version = "1.3.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -10825,9 +11107,9 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.86", + "proc-macro2 1.0.89", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 333abf75b..a54cd7ce3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ resolver = "2" members = [ + "compatibility", "framework", "framework/cached-packages", "smoke-tests", @@ -33,6 +34,7 @@ version = "7.0.3" [workspace.dependencies] ######## Internal crate dependencies ######## # Internal crate dependencies. +libra-backwards-compatibility = { path = "compatibility" } libra-cached-packages = { path = "framework/cached-packages" } libra-config = { path = "tools/config" } libra-framework = { path = "framework" } @@ -63,6 +65,7 @@ diem-rest-client = { git = "https://github.com/0LNetworkCommunity/diem.git", bra diem-sdk = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } diem-config = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } diem-crypto = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } +diem-crypto-derive = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } diem-genesis = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } diem-global-constants = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } diem-keygen = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } @@ -131,7 +134,7 @@ criterion-cpu-time = "0.1.0" crossbeam = "0.8.1" crossbeam-channel = "0.5.4" csv = "1.2.1" -curve25519-dalek = "3" +curve25519-dalek = "3" # Latest is 4.x.x but we have to stick with 3.x.x due to api changes requiring significant application code changes. dashmap = "5.2.0" datatest-stable = "0.1.1" debug-ignore = { version = "1.0.3", features = ["serde"] } @@ -147,8 +150,8 @@ diesel_migrations = { version = "2.1.0", features = ["postgres"] } digest = "0.9.0" dir-diff = "0.3.2" dirs = "4.0.0" -ed25519-dalek = { version = "1.0.1", features = ["std", "serde"] } -ed25519-dalek-bip32 = "0.2.0" +ed25519-dalek = { version = "1", features = ["std", "serde"] } # Latest is 2.x.x but we have to stick with 1.x.x due to api changes requiring significant application code changes. +ed25519-dalek-bip32 = "0.2" # Latest is 3.x.x but we have to stick with 2.x.x due to api changes requiring significant application code changes. either = "1.6.1" enum_dispatch = "0.3.8" env_logger = "0.9.0" @@ -158,10 +161,13 @@ fail = "0.5.0" field_count = "0.1.1" flate2 = "1.0.24" fs_extra = "1.2.0" -futures = "= 0.3.24" # Previously futures v0.3.23 caused some consensus network_tests to fail. We now pin the dependency to v0.3.24. -futures-channel = "= 0.3.24" -futures-core = "0.3.25" -futures-util = "0.3.21" +# NOTE: Another group of libraries that probably should be kept in version lock-step +# 0.3.31 is just the latest release when I last changed the version here. +# In general the latest should be used, or whatever works with the selected tokio +futures = "0.3.31" +futures-channel = "0.3" +futures-core = "0.3" +futures-util = "0.3" gcp-bigquery-client = "0.13.0" get_if_addrs = "0.5.3" git2 = "0.16.1" @@ -275,18 +281,22 @@ tempfile = "3.3.0" termcolor = "1.1.2" textwrap = "0.15.0" thiserror = "1.0.37" -tiny-bip39 = "0.8.2" +tiny-bip39 = "2" tiny-keccak = { version = "2.0.2", features = ["keccak", "sha3"] } tracing = "0.1.34" tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] } trybuild = "1.0.70" -tokio = { version = "1.21.0", features = ["full"] } -tokio-io-timeout = "1.2.0" -tokio-metrics = "0.1.0" -tokio-retry = "0.3.0" -tokio-stream = "0.1.8" -tokio-test = "0.4.1" -tokio-util = { version = "0.7.2", features = ["compat", "codec"] } +# NOTE: The goal is to have the tokio dependencies (which are mostly built from the same repo) +# have latest and consistent revisions. The selected revisions should be checked to verify +# that transitive dependencies haven't regressed versions. When the tokio project publishes +# new minor versions, the specifiers below will need to be updated accordingly. +tokio = { version = "1", features = ["full"] } +tokio-io-timeout = "1" +tokio-metrics = "0.3" +tokio-retry = "0.3" +tokio-stream = "0.1" +tokio-test = "0.4" +tokio-util = { version = "0.7", features = ["compat", "codec"] } toml = "0.5.9" tonic = { version = "0.8.3", features = [ "tls-roots", @@ -306,7 +316,9 @@ walkdir = "2.3.2" warp = { version = "0.3.3", features = ["tls"] } warp-reverse-proxy = "0.5.0" which = "4.2.5" -x25519-dalek = "1.2.0" +# Latest is 2.x.x but we have to stick with 1.2.x due to api changes requiring significant application code changes. +# We're using a forked version here only to force the transitive dependency "zeroize" off of the upstream's pinned old version. +x25519-dalek = { git = "https://github.com/0LNetworkCommunity/x25519-dalek", branch = "zeroize_v1" } ######## 0L ######### colored = "2.0.0" @@ -328,7 +340,7 @@ move-compiler = { git = "https://github.com/0LNetworkCommunity/diem.git", branch move-model = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } move-vm-test-utils = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } move-vm-types = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } -move-vm-runtime = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } +move-vm-runtime = { git = "https://github.com/0LNetworkCommunity/diem.git", branch = "release" } # uses a profile similar to `cli` in Diem/Cargo.toml # optimized for performance and size diff --git a/compatibility/.DS_Store b/compatibility/.DS_Store new file mode 100644 index 000000000..5172429f2 Binary files /dev/null and b/compatibility/.DS_Store differ diff --git a/compatibility/Cargo.toml b/compatibility/Cargo.toml new file mode 100644 index 000000000..4820a038d --- /dev/null +++ b/compatibility/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "libra-backwards-compatibility" + +# Workspace inherited keys +authors = { workspace = true } +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } + + +[dependencies] +anyhow = { workspace = true } +bcs = { workspace = true } +diem-api-types = { workspace = true } +diem-backup-cli = { workspace = true } +diem-config = { workspace = true } +diem-crypto = { workspace = true } +diem-crypto-derive = { workspace = true } +diem-types = { workspace = true } +move-core-types = { workspace = true } +hex = { workspace = true } +libra-types = { workspace = true } +once_cell = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +tokio = { workspace = true } +tiny-keccak = { workspace = true } +bytes = { workspace = true } +serde_bytes = { workspace = true } +rand = { workspace = true } + +[dev-dependencies] +diem-temppath = { workspace = true } diff --git a/compatibility/fixtures/v5/state_ver_119757649.17a8/0-.chunk b/compatibility/fixtures/v5/state_ver_119757649.17a8/0-.chunk new file mode 100644 index 000000000..97a2b1ee6 Binary files /dev/null and b/compatibility/fixtures/v5/state_ver_119757649.17a8/0-.chunk differ diff --git a/compatibility/fixtures/v5/state_ver_119757649.17a8/0-17338.proof b/compatibility/fixtures/v5/state_ver_119757649.17a8/0-17338.proof new file mode 100644 index 000000000..19fc6976c Binary files /dev/null and b/compatibility/fixtures/v5/state_ver_119757649.17a8/0-17338.proof differ diff --git a/compatibility/fixtures/v5/state_ver_119757649.17a8/state.manifest b/compatibility/fixtures/v5/state_ver_119757649.17a8/state.manifest new file mode 100644 index 000000000..40c2cd220 --- /dev/null +++ b/compatibility/fixtures/v5/state_ver_119757649.17a8/state.manifest @@ -0,0 +1 @@ +{"version":119757649,"root_hash":"d2e6b6c474529cd3c3ea76cf211a528ee28bb13d7bcd8dcbef0ecf4c43bc3703","chunks":[{"first_idx":0,"last_idx":17338,"first_key":"000131122524ba9f4a13bd90a8b13c5d03ab621649c8100c6bbf7846fe8eaf0f","last_key":"fffed52c1dd93cc7aa5b79a8699df0c33eb4d65ab8d2a21bbe79f9d05ad62377","blobs":"state_ver_119757649.17a8/0-.chunk","proof":"state_ver_119757649.17a8/0-17338.proof"}],"proof":"state_ver_119757649.17a8/state.proof"} diff --git a/compatibility/fixtures/v5/state_ver_119757649.17a8/state.proof b/compatibility/fixtures/v5/state_ver_119757649.17a8/state.proof new file mode 100644 index 000000000..03363b8cc Binary files /dev/null and b/compatibility/fixtures/v5/state_ver_119757649.17a8/state.proof differ diff --git a/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-.chunk b/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-.chunk new file mode 100644 index 000000000..ed1912105 Binary files /dev/null and b/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-.chunk differ diff --git a/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-141722729.proof b/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-141722729.proof new file mode 100644 index 000000000..9067b8d9c Binary files /dev/null and b/compatibility/fixtures/v5/transaction_141722729-.891d/141722729-141722729.proof differ diff --git a/compatibility/fixtures/v5/transaction_141722729-.891d/transaction.manifest b/compatibility/fixtures/v5/transaction_141722729-.891d/transaction.manifest new file mode 100644 index 000000000..b7b67af30 --- /dev/null +++ b/compatibility/fixtures/v5/transaction_141722729-.891d/transaction.manifest @@ -0,0 +1 @@ +{"first_version":141722729,"last_version":141722729,"chunks":[{"first_version":141722729,"last_version":141722729,"transactions":"transaction_141722729-.891d/141722729-.chunk","proof":"transaction_141722729-.891d/141722729-141722729.proof"}]} \ No newline at end of file diff --git a/compatibility/src/README.md b/compatibility/src/README.md new file mode 100644 index 000000000..0184af094 --- /dev/null +++ b/compatibility/src/README.md @@ -0,0 +1,73 @@ + +# Legacy Backwards Compatibility + +# TL;DR +The encoding of the bytes in libra uses `BCS` which is a de/serialization implementation using `serde`. Libra Version Six and beyond cannot decode transaction logs or state snapshots from Libra Version Five without these tools. + +# Explain + +Version Six was a kitchen sink upgrade with a new genesis since there were upgrades throughout the stack that would have created a discontinuity in blocks anyhow. The bytes in db, logs, and backups preceding V6 had slightly different memory layouts. + +Since the Move language address format and data structure names have changed no lookup can be successful because: +1. the keys would have had different hashes, and +2. the value bytes had different encoding layouts. + +This means between V5 and V6 any query tool of the chain state (and Rust internal K-V structure) will fail to match key, or decode the value. + +# Principal PITAs + +1. Backup Manifests have changed layout. State Snapshot Manifests JSON files have changed ever so slightly, they previously did not include the `epoch` field. Reading V5 backup archive manifests would fail with V6+ tooling. + +2. `AccountStateBlob` stored bytes in records are not what they seem. Vendor gifts you this koan: "What's the sound of recursion that goes nowhere?". In the State Snapshot backup files, each chunk is represented by a tuple of `(HashedValue, AccountStateBlob)`. However, AccountStateBlob already includes a `hash` field for HashedValue. For reasons, this field was flagged to be skipped be de/serializer. In practice the bytes at rest are prepended by the hash, and not post-pended. For clarity we added a definition of `AccountStateBlobRecord`. + +3. `HashValue` is evil: The HashValue layout has not changed, but it invokes `loop garoo`, and the handcrafted deserializer of `HashedValue` uses a different intermediary representation for the byte layout. + +``` +// V5: +#[derive(::serde::Deserialize)] +#[serde(rename = "HashValue")] +struct Value<'a>(&'a [u8]); + +// V6: +struct Value<'a> { + hash: &'a [u8; HashValue::LENGTH], +} +``` + +4. `AccountAddress` makes everything fail: fixed lengths have changed, from V5 to V6 the addresses doubled in size (16 to 32 bits). No KV lookup will work because the byte-encoded key always has the Core Code Address, (0x1) which changed from being prepended with 31 zeros (for 16 bits), to 63 zeros (32 bits). So all language_storage.rs structs are changed to use `LegacyAddressV5`. + + +## Compatibility Structs and Access Vectors +Structs from V5 with their specific fields, string representations, and Account Address formats have been provided here. + +Looking up data in K-V representations of bytes is done with byte encoded `access_paths_vector`. The access path is always prepended with the AccountAddress of the core address account (which went from 16 bits to 32). Access Vector also uses the Byte encoded string name of the module, these have changes in the Move specification to being lower-cased module names, and pascal cased struct names. +``` +String representations of access path bytes as the lookup key in the K-V. +// V5: +resource_key = "0x00000000000000000000000000000001::DiemAccount::DiemAccount" + +// V6: +resource_key = "0x0000000000000000000000000000000000000000000000000000000000000001::diem_account::DiemAccount" + +``` + +This compatibility library ports the some V5 Rust code so that certain elemental types will use the correct V5 layout, e.g.: StructTag, TypeTag, HashValue, AccountAddress. + + +## Troublshooting Decoding +For any failed `bcs::from_bytes()` you will likely receive a `remaining input` error. Vendor gifts you this koan. This either means the `key` of the access_vector was not found in the Btree's bytes. Most likely it's because the V5 access_vector uses fewer bytes than the V6 tools expects (because of the account address character/byte count difference). + + +# Tests +The principal tests to run are in `state_snapshot_v5.rs`, where we try to sanity test the encoding and decoding of structs for the v5 language elements. + + +# References + +``` +$ > +$ > Loop Garoo +Goin' down to junk anew? +$ > Loop Garoo +Goin' put my hook to you +``` diff --git a/types/src/legacy_types/ancestry_legacy.rs b/compatibility/src/deprecated/ancestry_legacy.rs similarity index 100% rename from types/src/legacy_types/ancestry_legacy.rs rename to compatibility/src/deprecated/ancestry_legacy.rs diff --git a/types/src/legacy_types/autopay.rs b/compatibility/src/deprecated/autopay.rs similarity index 76% rename from types/src/legacy_types/autopay.rs rename to compatibility/src/deprecated/autopay.rs index 66b1d3444..48f50334f 100644 --- a/types/src/legacy_types/autopay.rs +++ b/compatibility/src/deprecated/autopay.rs @@ -15,47 +15,33 @@ use super::legacy_address::LegacyAddress; /// Struct that represents a AutoPay resource #[derive(Debug, Serialize, Deserialize)] pub struct AutoPayResource { - /// - pub payment: Vec, - /// - pub prev_bal: u64, + pub payment: Vec, + pub prev_bal: u64, } /// Struct that represents a view for AutoPay resource #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AutoPayView { - /// - pub payments: Vec, - /// - pub recurring_sum: u64, + pub payments: Vec, + pub recurring_sum: u64, } /// Autopay instruction #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PaymentView { - /// - pub uid: u64, - /// - pub in_type: u8, - /// - pub type_desc: String, - /// - pub payee: LegacyAddress, - /// - pub end_epoch: u64, - /// - pub prev_bal: u64, - /// - pub amt: u64, - /// - pub amount: String, - /// - pub note: Option, + pub uid: u64, + pub in_type: u8, + pub type_desc: String, + pub payee: LegacyAddress, + pub end_epoch: u64, + pub prev_bal: u64, + pub amt: u64, + pub amount: String, + pub note: Option, } impl PaymentView { - /// - pub fn is_percent_of_change(&self) -> bool { + pub fn is_percent_of_change(&self) -> bool { self.in_type == 1u8 } } @@ -63,18 +49,12 @@ impl PaymentView { /// Autopay instruction #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Payment { - /// - pub uid: u64, - /// - pub in_type: u8, - /// - pub payee: LegacyAddress, - /// - pub end_epoch: u64, - /// - pub prev_bal: u64, - /// - pub amt: u64, + pub uid: u64, + pub in_type: u8, + pub payee: LegacyAddress, + pub end_epoch: u64, + pub prev_bal: u64, + pub amt: u64, } impl Payment { @@ -105,8 +85,7 @@ impl Payment { // impl MoveResource for AutoPayResource {} impl AutoPayResource { - // /// - // pub fn struct_tag() -> StructTag { + // // pub fn struct_tag() -> StructTag { // StructTag { // address: CORE_CODE_ADDRESS, // module: AutoPayResource::module_identifier(), @@ -114,23 +93,19 @@ impl AutoPayResource { // type_params: vec![], // } // } - // /// - // pub fn access_path(account: LegacyAddress) -> AccessPath { + // // pub fn access_path(account: LegacyAddress) -> AccessPath { // let resource_key = ResourceKey::new(account, AutoPayResource::struct_tag()); // AccessPath::resource_access_path(resource_key) // } - // /// - // pub fn resource_path() -> Vec { + // // pub fn resource_path() -> Vec { // AccessPath::resource_access_vec(AutoPayResource::struct_tag()) // } - /// - pub fn try_from_bytes(bytes: &[u8]) -> Result { + pub fn try_from_bytes(bytes: &[u8]) -> Result { bcs::from_bytes(bytes).map_err(Into::into) } - // /// - // pub fn get_view(&self) -> AutoPayView { + // // pub fn get_view(&self) -> AutoPayView { // let payments = self.payment.iter().map(|each| { // PaymentView { // uid: each.uid, diff --git a/types/src/legacy_types/config.rs b/compatibility/src/deprecated/config.rs similarity index 100% rename from types/src/legacy_types/config.rs rename to compatibility/src/deprecated/config.rs diff --git a/types/src/legacy_types/fixtures.rs b/compatibility/src/deprecated/fixtures.rs similarity index 100% rename from types/src/legacy_types/fixtures.rs rename to compatibility/src/deprecated/fixtures.rs diff --git a/types/src/legacy_types/fullnode_counter.rs b/compatibility/src/deprecated/fullnode_counter.rs similarity index 86% rename from types/src/legacy_types/fullnode_counter.rs rename to compatibility/src/deprecated/fullnode_counter.rs index 75e076b93..47e787a7a 100644 --- a/types/src/legacy_types/fullnode_counter.rs +++ b/compatibility/src/deprecated/fullnode_counter.rs @@ -14,18 +14,12 @@ use serde::{Deserialize, Serialize}; /// Struct that represents a CurrencyInfo resource #[derive(Debug, Clone, Serialize, Deserialize)] pub struct FullnodeCounterResource { - /// - pub proofs_submitted_in_epoch: u64, - /// - pub proofs_paid_in_epoch: u64, - /// - pub subsidy_in_epoch: u64, - /// - pub cumulative_proofs_submitted: u64, - /// - pub cumulative_proofs_paid: u64, - /// - pub cumulative_subsidy: u64, + pub proofs_submitted_in_epoch: u64, + pub proofs_paid_in_epoch: u64, + pub subsidy_in_epoch: u64, + pub cumulative_proofs_submitted: u64, + pub cumulative_proofs_paid: u64, + pub cumulative_subsidy: u64, } impl MoveStructType for FullnodeCounterResource { diff --git a/types/src/legacy_types/gas_resource.rs b/compatibility/src/deprecated/gas_resource.rs similarity index 87% rename from types/src/legacy_types/gas_resource.rs rename to compatibility/src/deprecated/gas_resource.rs index d28517840..235c63f25 100644 --- a/types/src/legacy_types/gas_resource.rs +++ b/compatibility/src/deprecated/gas_resource.rs @@ -24,18 +24,15 @@ pub struct GasResource { } impl GasResource { - /// - pub fn new(value: u64) -> Self { + pub fn new(value: u64) -> Self { Self { value } } - /// - pub fn value(&self) -> u64 { + pub fn value(&self) -> u64 { self.value } - /// - pub fn struct_tag() -> StructTag { + pub fn struct_tag() -> StructTag { StructTag { address: CORE_CODE_ADDRESS, name: GasResource::struct_identifier(), @@ -44,8 +41,7 @@ impl GasResource { } } - /// - pub fn access_path_for() -> Vec { + pub fn access_path_for() -> Vec { AccessPath::resource_access_vec(GasResource::struct_tag()) } } diff --git a/types/src/legacy_types/genesis_proof.rs b/compatibility/src/deprecated/genesis_proof.rs similarity index 100% rename from types/src/legacy_types/genesis_proof.rs rename to compatibility/src/deprecated/genesis_proof.rs diff --git a/types/src/legacy_types/rpc_playlist.rs b/compatibility/src/deprecated/rpc_playlist.rs similarity index 100% rename from types/src/legacy_types/rpc_playlist.rs rename to compatibility/src/deprecated/rpc_playlist.rs diff --git a/types/src/legacy_types/tx_error.rs b/compatibility/src/deprecated/tx_error.rs similarity index 100% rename from types/src/legacy_types/tx_error.rs rename to compatibility/src/deprecated/tx_error.rs diff --git a/types/src/legacy_types/account.rs b/compatibility/src/deprecated/val_configs_depr.rs similarity index 100% rename from types/src/legacy_types/account.rs rename to compatibility/src/deprecated/val_configs_depr.rs diff --git a/types/src/legacy_types/validator_config.rs b/compatibility/src/deprecated/validator_config.rs similarity index 100% rename from types/src/legacy_types/validator_config.rs rename to compatibility/src/deprecated/validator_config.rs diff --git a/types/src/legacy_types/legacy_recovery_v6.rs b/compatibility/src/legacy_recovery_v6.rs similarity index 94% rename from types/src/legacy_types/legacy_recovery_v6.rs rename to compatibility/src/legacy_recovery_v6.rs index 7fb09539e..52aaa6f8f 100644 --- a/types/src/legacy_types/legacy_recovery_v6.rs +++ b/compatibility/src/legacy_recovery_v6.rs @@ -1,16 +1,18 @@ //! recovery -use crate::exports::AuthenticationKey; - -use super::ancestry_legacy::LegacyAncestryResource; -use crate::{ +use anyhow::anyhow; +use diem_types::{ + account_state::AccountState, + account_view::AccountView, + validator_config::{ValidatorConfig, ValidatorOperatorConfigResource}, +}; +use libra_types::{ core_types::legacy_currency_info::CurrencyInfoResource, - legacy_types::wallet::{ - CommunityWalletsResourceLegacy, SlowWalletListResource, SlowWalletResource, - }, + exports::AuthenticationKey, move_resource::{ + ancestry::AncestryResource, burn::{BurnCounterResource, UserBurnPreferenceResource}, - cumulative_deposits::{CumulativeDepositResource, LegacyBalanceResource}, + cumulative_deposits::{CumulativeDepositResource, LegacyBalanceResourceV6}, donor_voice::RegistryResource, donor_voice_txs::TxScheduleResource, fee_maker::{EpochFeeMakerRegistryResource, FeeMakerResource}, @@ -20,19 +22,14 @@ use crate::{ receipts::ReceiptsResource, validator_universe::ValidatorUniverseResource, vouch::MyVouchesResource, + wallet::{CommunityWalletsResource, SlowWalletListResource, SlowWalletResource}, }, }; -use anyhow::anyhow; -use diem_types::{ - account_state::AccountState, - account_view::AccountView, - validator_config::{ValidatorConfig, ValidatorOperatorConfigResource}, -}; use move_core_types::account_address::AccountAddress; use serde::{Deserialize, Serialize}; use std::{fs, path::PathBuf, str::FromStr}; -use crate::move_resource::{ +use libra_types::move_resource::{ ol_account::BurnTrackerResource, proof_of_fee::ConsensusRewardResource, }; @@ -70,7 +67,7 @@ pub struct LegacyRecoveryV6 { pub role: AccountRole, /// The balance resource of the account in the legacy system. - pub balance: Option, + pub balance: Option, /// Validator configuration information. pub val_cfg: Option, @@ -79,13 +76,13 @@ pub struct LegacyRecoveryV6 { pub val_operator_cfg: Option, /// Community wallets associated with the account. - pub comm_wallet: Option, + pub comm_wallet: Option, /// Information about the currency associated with the account. pub currency_info: Option, /// Ancestry information of the account in the legacy system. - pub ancestry: Option, + pub ancestry: Option, /// Receipts resource for the account. pub receipts: Option, @@ -204,7 +201,7 @@ pub fn get_legacy_recovery(account_state: &AccountState) -> anyhow::Result anyhow::Result()?; + account_state.get_move_resource::()?; // ancestry - legacy_recovery.ancestry = account_state.get_move_resource::()?; + legacy_recovery.ancestry = account_state.get_move_resource::()?; // receipts legacy_recovery.receipts = account_state.get_move_resource::()?; diff --git a/compatibility/src/lib.rs b/compatibility/src/lib.rs new file mode 100644 index 000000000..bcd55ce3e --- /dev/null +++ b/compatibility/src/lib.rs @@ -0,0 +1,3 @@ +pub mod legacy_recovery_v6; +pub mod sdk; +pub mod version_five; diff --git a/compatibility/src/sdk/README.md b/compatibility/src/sdk/README.md new file mode 100644 index 000000000..af36e607c --- /dev/null +++ b/compatibility/src/sdk/README.md @@ -0,0 +1,17 @@ +# Versions of Libra SDK + +The historical SDKs include: +- v5.0.0 (genesis 11/2021) +- v5.2.0 (last production v5) +- v6.9.9 (last v6) +- v7.0.3 (production as of 11/2024) + +## Why do we need these? +Transactions submitted to blockchain are done in bytecode. Decoding that bytecode into a useful object (function name, arguments, timestamp) is hard to do if you do not have the Rust serialization lib which generated the bytecode originally. + +The names of functions (and some primitives like Account Address), change between versions. + +Suppose you would like to analyze a V5 transaction. Without these files you'll have to guess the transaction type and craft an individual decoder. + +# Modifications to originals +Note that these files are code generated, and were not intended to be changed. We have however added serde De/Serialize attributes to the EntryFunctionCall, so that they can be easily be read into memory. diff --git a/compatibility/src/sdk/mod.rs b/compatibility/src/sdk/mod.rs new file mode 100644 index 000000000..4d8b5f9c0 --- /dev/null +++ b/compatibility/src/sdk/mod.rs @@ -0,0 +1,4 @@ +pub mod v5_0_0_genesis_transaction_script_builder; +pub mod v5_2_0_transaction_script_builder; +pub mod v6_libra_framework_sdk_builder; +pub mod v7_libra_framework_sdk_builder; diff --git a/compatibility/src/sdk/v5_0_0_genesis_transaction_script_builder.rs b/compatibility/src/sdk/v5_0_0_genesis_transaction_script_builder.rs new file mode 100644 index 000000000..e6b1964de --- /dev/null +++ b/compatibility/src/sdk/v5_0_0_genesis_transaction_script_builder.rs @@ -0,0 +1,9857 @@ +// 0L NOTE: copied from : https://github.com/0LNetworkCommunity/libra-legacy-v6/tree/d70716fb154339f4db71ae05edf8064013327b29/language/diem-framework/releases/artifacts/current + +// 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)] +#![allow(dead_code)] +use crate::version_five::{ + language_storage_v5::{ModuleIdV5 as ModuleId, TypeTagV5 as TypeTag}, + legacy_address_v5::LegacyAddressV5 as AccountAddress, + script_v5::{Script, ScriptFunction}, + transaction_argument_v5::TransactionArgument, + transaction_type_v5::TransactionPayload, +}; +use move_core_types::ident_str; + +use std::collections::BTreeMap as Map; + +type Bytes = Vec; + +/// Structured representation of a call into a known Move script. +/// ```ignore +/// impl ScriptCall { +/// pub fn encode(self) -> Script { .. } +/// pub fn decode(&Script) -> Option { .. } +/// } +/// ``` + +//////// 0L //////// +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, serde::Deserialize, serde::Serialize)] +// #[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))] +// #[cfg_attr(feature = "fuzzing", proptest(no_params))] +pub enum ScriptCall { + /// # Summary + /// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to + /// send, receive, and hold `Diem::Diem` 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` 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` published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances. | + /// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY` | A balance for `Currency` is already published under the sending `account`. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::create_parent_vasp_account` + /// * `Script::peer_to_peer_with_metadata` + AddCurrencyToAccount { currency: TypeTag }, + + /// # Summary + /// Stores the sending accounts ability to rotate its authentication key with a designated recovery + /// account. Both the sending and recovery accounts need to belong to the same VASP and + /// both be VASP accounts. After this transaction both the sending account and the + /// specified recovery account can rotate the sender account's authentication key. + /// + /// # Technical Description + /// Adds the `DiemAccount::KeyRotationCapability` for the sending account + /// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under + /// `recovery_address`. After this transaction has been executed successfully the account at + /// `recovery_address` and the `to_recover_account` may rotate the authentication key of + /// `to_recover_account` (the sender of this transaction). + /// + /// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key + /// rotation capability, and must be a VASP account. The account at `recovery_address` + /// must also be a VASP account belonging to the same VASP as the `to_recover_account`. + /// Additionally the account at `recovery_address` must have already initialized itself as + /// a recovery account address using the `Script::create_recovery_address` transaction script. + /// + /// The sending account's (`to_recover_account`) key rotation capability is + /// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` + /// resource stored under the account at `recovery_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction. | + /// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | + /// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | + /// + /// # Related Scripts + /// * `Script::create_recovery_address` + /// * `Script::rotate_authentication_key_with_recovery_address` + AddRecoveryRotationCapability { recovery_address: AccountAddress }, + + /// # Summary + /// Adds a validator account to the validator set, and triggers a + /// reconfiguration of the system to admit the account to the validator set for the system. This + /// transaction can only be successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script adds the account at `validator_address` to the validator set. + /// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a + /// reconfiguration. Once the reconfiguration triggered by this script's + /// execution has been performed, the account at the `validator_address` is + /// considered to be a validator in the network. + /// + /// This transaction script will fail if the `validator_address` address is already in the validator set + /// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be added to the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + AddValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # Summary + /// Burns all coins held in the preburn resource at the specified + /// preburn address and removes them from the system. The sending account must + /// be the Treasury Compliance account. + /// The account that holds the preburn resource will normally be a Designated + /// Dealer, but there are no enforced requirements that it be one. + /// + /// # Technical Description + /// This transaction permanently destroys all the coins of `Token` type + /// stored in the `Diem::Preburn` resource published under the + /// `preburn_address` account address. + /// + /// This transaction will only succeed if the sending `account` has a + /// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Token` | Type | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_EMPTY` | The `Diem::Preburn` resource is empty (has a value of 0). | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | + /// + /// # Related Scripts + /// * `Script::burn_txn_fees` + /// * `Script::cancel_burn` + /// * `Script::preburn` + Burn { + token: TypeTag, + sliding_nonce: u64, + preburn_address: AccountAddress, + }, + + /// # Summary + /// Burns the transaction fees collected in the `CoinType` currency so that the + /// Diem association may reclaim the backing coins off-chain. May only be sent + /// by the Treasury Compliance account. + /// + /// # Technical Description + /// Burns the transaction fees collected in `CoinType` so that the + /// association may reclaim the backing coins. Once this transaction has executed + /// successfully all transaction fees that will have been collected in + /// `CoinType` since the last time this script was called with that specific + /// currency. Both `balance` and `preburn` fields in the + /// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` + /// account address will have a value of 0 after the successful execution of this script. + /// + /// ## Events + /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle + /// held in the `Diem::CurrencyInfo` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | + /// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | + /// + /// # Related Scripts + /// * `Script::burn` + /// * `Script::cancel_burn` + BurnTxnFees { coin_type: TypeTag }, + + /// # Summary + /// Cancels and returns all coins held in the preburn area under + /// `preburn_address` and returns the funds to the `preburn_address`'s balance. + /// Can only be successfully sent by an account with Treasury Compliance role. + /// + /// # Technical Description + /// Cancels and returns all coins held in the `Diem::Preburn` resource under the `preburn_address` and + /// return the funds to the `preburn_address` account's `DiemAccount::Balance`. + /// The transaction must be sent by an `account` with a `Diem::BurnCapability` + /// resource published under it. The account at `preburn_address` must have a + /// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes + /// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's + /// `DiemAccount::Balance` 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` + /// resource's `burn_events` published under `0xA550C18`. + /// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s + /// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee` + /// being `preburn_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Token` | Type | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | + /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | The value held in the preburn resource was zero. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds held in the prebun area would exceed the `account`'s account limits. | + /// | `Errors::INVALID_STATE` | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed. | + /// + /// # Related Scripts + /// * `Script::burn_txn_fees` + /// * `Script::burn` + /// * `Script::preburn` + CancelBurn { + token: TypeTag, + preburn_address: AccountAddress, + }, + + /// # Summary + /// Creates a Child VASP account with its parent being the sending account of the transaction. + /// The sender of the transaction must be a Parent VASP account. + /// + /// # Technical Description + /// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of + /// `child_initial_balance` in `CoinType` and an initial authentication key of + /// `auth_key_prefix | child_address`. + /// + /// If `add_all_currencies` is true, the child address will have a zero balance in all available + /// currencies in the system. + /// + /// The new account will be a child account of the transaction sender, which must be a + /// Parent VASP account. The child account will be recorded against the limit of + /// child accounts of the creating Parent VASP account. + /// + /// ## Events + /// Successful execution with a `child_initial_balance` greater than zero will emit: + /// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address, + /// and payee field being `child_address`. This is emitted on the Parent VASP's + /// `DiemAccount::DiemAccount` `sent_events` handle. + /// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address, + /// and payee field being `child_address`. This is emitted on the new Child VASPS's + /// `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | + /// | `parent_vasp` | `&signer` | The signer reference of the sending account. Must be a Parent VASP account. | + /// | `child_address` | `address` | Address of the to-be-created Child VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | + /// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | + /// + /// # Related Scripts + /// * `Script::create_parent_vasp_account` + /// * `Script::add_currency_to_account` + /// * `Script::rotate_authentication_key` + /// * `Script::add_recovery_rotation_capability` + /// * `Script::create_recovery_address` + CreateChildVaspAccount { + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Bytes, + add_all_currencies: bool, + child_initial_balance: u64, + }, + + /// # Summary + /// Creates a Designated Dealer account with the provided information, and initializes it with + /// default mint tiers. The transaction can only be sent by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Designated Dealer role at `addr` with authentication key + /// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, + /// 0 balances for all available currencies in the system will also be added. This can only be + /// invoked by an account with the TreasuryCompliance role. + /// + /// At the time of creation the account is also initialized with default mint tiers of (500_000, + /// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the + /// account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `addr` | `address` | Address of the to-be-created Designated Dealer account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Designated Dealer. | + /// | `add_all_currencies` | `bool` | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created. | + /// + + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `addr` address is already taken. | + /// + /// # Related Scripts + /// * `Script::tiered_mint` + /// * `Script::peer_to_peer_with_metadata` + /// * `Script::rotate_dual_attestation_info` + CreateDesignatedDealer { + currency: TypeTag, + sliding_nonce: u64, + addr: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Parent VASP role at `address` with authentication key + /// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If + /// `add_all_currencies` is true, 0 balances for all available currencies in the system will + /// also be added. This can only be invoked by an TreasuryCompliance account. + /// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::add_currency_to_account` + /// * `Script::rotate_authentication_key` + /// * `Script::add_recovery_rotation_capability` + /// * `Script::create_recovery_address` + /// * `Script::rotate_dual_attestation_info` + CreateParentVaspAccount { + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Initializes the sending account as a recovery address that may be used by + /// the VASP that it belongs to. The sending account must be a VASP account. + /// Multiple recovery addresses can exist for a single VASP, but accounts in + /// each must be disjoint. + /// + /// # Technical Description + /// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then + /// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds + /// it to the resource. After the successful execution of this transaction + /// other accounts may add their key rotation to this resource so that `account` + /// may be used as a recovery account for those accounts. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | + /// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | + /// + /// # Related Scripts + /// * `Script::add_recovery_rotation_capability` + /// * `Script::rotate_authentication_key_with_recovery_address` + CreateRecoveryAddress {}, + + /// # Summary + /// Creates a Validator account. This transaction can only be sent by the Diem + /// Root account. + /// + /// # Technical Description + /// Creates an account with a Validator role at `new_account_address`, with authentication key + /// `auth_key_prefix` | `new_account_address`. It publishes a + /// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and + /// `operator_account` fields. The `human_name` field of the + /// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. + /// This script does not add the validator to the validator set or the system, + /// but only creates the account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Validator account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the validator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::add_validator_and_reconfigure` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + CreateValidatorAccount { + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + }, + + /// # Summary + /// Creates a Validator Operator account. This transaction can only be sent by the Diem + /// Root account. + /// + /// # Technical Description + /// Creates an account with a Validator Operator role at `new_account_address`, with authentication key + /// `auth_key_prefix` | `new_account_address`. It publishes a + /// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`. + /// This script does not assign the validator operator to any validator accounts but only creates the account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Validator account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the validator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + CreateValidatorOperatorAccount { + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + }, + + /// # Summary + /// Freezes the account at `address`. The sending account of this transaction + /// must be the Treasury Compliance account. The account being frozen cannot be + /// the Diem Root or Treasury Compliance account. After the successful + /// execution of this transaction no transactions may be sent from the frozen + /// account, and the frozen account may not send or receive coins. + /// + /// # Technical Description + /// Sets the `AccountFreezing::FreezingBit` to `true` and emits a + /// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the + /// Treasury Compliance account, but the account at `to_freeze_account` must + /// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the + /// Treasury Compliance address). Note that this is a per-account property + /// e.g., freezing a Parent VASP will not effect the status any of its child + /// accounts and vice versa. + /// + + /// ## Events + /// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on + /// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published + /// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `to_freeze_account` | `address` | The account address to be frozen. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC` | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`). | + /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`). | + /// + /// # Related Scripts + /// * `Script::unfreeze_account` + FreezeAccount { + sliding_nonce: u64, + to_freeze_account: AccountAddress, + }, + + /// # Summary + /// Transfers a given number of coins in a specified currency from one account to another. + /// Transfers over a specified amount defined on-chain that are between two different VASPs, or + /// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has + /// agreed to receive the coins. This transaction can be sent by any account that can hold a + /// balance, and to any account that can hold a balance. Both accounts must hold balances in the + /// currency being transacted. + /// + /// # Technical Description + /// + /// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated + /// `metadata` and an (optional) `metadata_signature` on the message + /// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`. + /// The `metadata` and `metadata_signature` parameters are only required if `amount` >= + /// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. + /// However, a transaction sender can opt in to dual attestation even when it is not required + /// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. + /// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. + /// + /// ## Events + /// Successful execution of this script emits two events: + /// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and + /// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | + /// | `payer` | `&signer` | The signer reference of the sending account that coins are being transferred from. | + /// | `payee` | `address` | The address of the account the coins are being transferred to. | + /// | `metadata` | `vector` | Optional metadata about this payment. | + /// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | + /// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::create_parent_vasp_account` + /// * `Script::add_currency_to_account` + PeerToPeerWithMetadata { + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Bytes, + metadata_signature: Bytes, + }, + + /// # Summary + /// Moves a specified number of coins in a given currency from the account's + /// balance to its preburn area after which the coins may be burned. This + /// transaction may be sent by any account that holds a balance and preburn area + /// in the specified currency. + /// + /// # Technical Description + /// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s + /// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` resource under the sender is non-zero. | + /// | `Errors::NOT_PUBLISHED` | `Roles::EROLE_ID` | The `account` did not have a role assigned to it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDESIGNATED_DEALER` | The `account` did not have the role of DesignatedDealer. | + /// + /// # Related Scripts + /// * `Script::cancel_burn` + /// * `Script::burn` + /// * `Script::burn_txn_fees` + Preburn { token: TypeTag, amount: u64 }, + + /// # Summary + /// Rotates the authentication key of the sending account to the + /// newly-specified public key and publishes a new shared authentication key + /// under the sender's account. Any account can send this transaction. + /// + /// # Technical Description + /// Rotates the authentication key of the sending account to `public_key`, + /// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource + /// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for + /// `account` under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | + /// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::rotate_shared_ed25519_public_key` + PublishSharedEd25519PublicKey { public_key: Bytes }, + + /// # Summary + /// Updates a validator's configuration. This does not reconfigure the system and will not update + /// the configuration in the validator set that is seen by other validators in the network. Can + /// only be successfully sent by a Validator Operator account that is already registered with a + /// validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` + /// so the copy of this config held in the validator set will not be updated, and the changes are + /// only "locally" under the `validator_account` account address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + RegisterValidatorConfig { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// This script removes a validator account from the validator set, and triggers a reconfiguration + /// of the system to remove the validator from the system. This transaction can only be + /// successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script removes the account at `validator_address` from the validator set. This transaction + /// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event + /// has been performed, the account at `validator_address` is no longer considered to be a + /// validator in the network. This transaction will fail if the validator at `validator_address` + /// is not in the validator set. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be removed from the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + RemoveValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # Summary + /// Rotates the transaction sender's authentication key to the supplied new authentication key. May + /// be sent by any account. + /// + /// # Technical Description + /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_nonce_admin` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKey { new_key: Bytes }, + + /// # Summary + /// Rotates the sender's authentication key to the supplied new authentication key. May be sent by + /// any account that has a sliding nonce resource published under it (usually this is Treasury + /// Compliance or Diem Root accounts). + /// + /// # Technical Description + /// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce_admin` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKeyWithNonce { sliding_nonce: u64, new_key: Bytes }, + + /// # Summary + /// Rotates the specified account's authentication key to the supplied new authentication key. May + /// only be sent by the Diem Root account as a write set transaction. + /// + /// # Technical Description + /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | + /// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKeyWithNonceAdmin { sliding_nonce: u64, new_key: Bytes }, + + /// # Summary + /// Rotates the authentication key of a specified account that is part of a recovery address to a + /// new authentication key. Only used for accounts that are part of a recovery address (see + /// `Script::add_recovery_rotation_capability` for account restrictions). + /// + /// # Technical Description + /// Rotates the authentication key of the `to_recover` account to `new_key` using the + /// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource + /// published under `recovery_address`. This transaction can be sent either by the `to_recover` + /// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published + /// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | + /// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | + /// | `new_key` | `vector` | New ed25519 public key to be used for the account at the `to_recover` address. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_nonce_admin` + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Bytes, + }, + + /// # Summary + /// Updates the url used for off-chain communication, and the public key used to verify dual + /// attestation on-chain. Transaction can be sent by any account that has dual attestation + /// information published under it. In practice the only such accounts are Designated Dealers and + /// Parent VASPs. + /// + /// # Technical Description + /// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` + /// resource published under `account`. The `new_key` must be a valid ed25519 public key. + /// + /// ## Events + /// Successful execution of this transaction emits two events: + /// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and + /// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` + /// `compliance_key_rotation_events` handle published under `account`; and + /// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for + /// off-chain communication, and the blockchain time at which the url was updated emitted on the + /// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | + /// | `new_key` | `vector` | New ed25519 public key to be used for on-chain dual attestation checking. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DualAttestation::ECREDENTIAL` | A `DualAttestation::Credential` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::create_parent_vasp_account` + /// * `Script::create_designated_dealer` + /// * `Script::rotate_dual_attestation_info` + RotateDualAttestationInfo { new_url: Bytes, new_key: Bytes }, + + /// # Summary + /// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by + /// any account that has previously published a shared ed25519 public key using + /// `Script::publish_shared_ed25519_public_key`. + /// + /// # Technical Description + /// This first rotates the public key stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it + /// rotates the authentication key using the capability stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key` + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::publish_shared_ed25519_public_key` + RotateSharedEd25519PublicKey { public_key: Bytes }, + + /// # Summary + /// Updates a validator's configuration, and triggers a reconfiguration of the system to update the + /// validator set with this new validator configuration. Can only be successfully sent by a + /// Validator Operator account that is already registered with a validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to + /// trigger a reconfiguration of the system. This reconfiguration will update the validator set + /// on-chain with the updated `ValidatorConfig::ValidatorConfig`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::register_validator_config` + SetValidatorConfigAndReconfigure { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by an account with + /// Validator role. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the sending validator account. The account at `operator_account` address must have + /// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` + /// resource published under it. The sending `account` must be a Validator and have a + /// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a + /// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + SetValidatorOperator { + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root + /// account as a write set transaction. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the validator `account`. The account at `operator_account` address must have a + /// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource + /// published under it. The account represented by the `account` signer must be a Validator and + /// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of + /// the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | + /// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_config_and_reconfigure` + SetValidatorOperatorWithNonceAdmin { + sliding_nonce: u64, + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Mints a specified number of coins in a currency to a Designated Dealer. The sending account + /// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer + /// account. + /// + /// # Technical Description + /// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at + /// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to + /// check verify the off-chain approval policy, and is based in part on the on-chain tier values + /// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to + /// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that + /// they support. The sending `tc_account` must be the Treasury Compliance account, and the + /// receiver an authorized Designated Dealer account. + /// + /// ## Events + /// Successful execution of the transaction will emit two events: + /// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the + /// `mint_event_handle` in the stored `Diem::CurrencyInfo` resource stored under + /// `0xA550C18`; and + /// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated + /// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer` + /// resource published under the `designated_dealer_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to. | + /// | `mint_amount` | `u64` | The number of coins to be minted. | + /// | `tier_index` | `u64` | The mint tier index to use for the Designated Dealer account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_MINT_AMOUNT` | `mint_amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DesignatedDealer::EDEALER` | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo` resource does not exist at `designated_dealer_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_TIER_INDEX` | The `tier_index` is out of bounds. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EMINTING_NOT_ALLOWED` | Minting is not currently allowed for `CoinType` coins. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds would exceed the `account`'s account limits. | + /// + /// # Related Scripts + /// * `Script::create_designated_dealer` + /// * `Script::peer_to_peer_with_metadata` + /// * `Script::rotate_dual_attestation_info` + TieredMint { + coin_type: TypeTag, + sliding_nonce: u64, + designated_dealer_address: AccountAddress, + mint_amount: u64, + tier_index: u64, + }, + + /// # Summary + /// Unfreezes the account at `address`. The sending account of this transaction must be the + /// Treasury Compliance account. After the successful execution of this transaction transactions + /// may be sent from the previously frozen account, and coins may be sent and received. + /// + /// # Technical Description + /// Sets the `AccountFreezing::FreezingBit` to `false` and emits a + /// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance + /// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect + /// the status any of its child accounts and vice versa. + /// + /// ## Events + /// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with + /// the `unfrozen_address` set the `to_unfreeze_account`'s address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `to_unfreeze_account` | `address` | The account address to be frozen. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// + /// # Related Scripts + /// * `Script::freeze_account` + UnfreezeAccount { + sliding_nonce: u64, + to_unfreeze_account: AccountAddress, + }, + + /// # Summary + /// Updates the Diem major version that is stored on-chain and is used by the VM. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater + /// than the current major version held on-chain. The VM reads this information and can use it to + /// preserve backwards compatibility with previous major versions of the VM. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | + UpdateDiemVersion { sliding_nonce: u64, major: u64 }, + + /// # Summary + /// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can + /// only be sent by the Treasury Compliance account. After this transaction all inter-VASP + /// payments over this limit must be checked for dual attestation. + /// + /// # Technical Description + /// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under + /// `0xA550C18`. The amount is set in micro-XDX. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_micro_xdx_limit` | `u64` | The new dual attestation limit to be used on-chain. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// + /// # Related Scripts + /// * `Script::update_exchange_rate` + /// * `Script::update_minting_ability` + UpdateDualAttestationLimit { + sliding_nonce: u64, + new_micro_xdx_limit: u64, + }, + + /// # Summary + /// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion + /// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this + /// transaction the updated exchange rate will be used for normalization of gas prices, and for + /// dual attestation checking. + /// + /// # Technical Description + /// Updates the on-chain exchange rate from the given `Currency` to micro-XDX. The exchange rate + /// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction. | + /// | `new_exchange_rate_numerator` | `u64` | The numerator for the new to micro-XDX exchange rate for `Currency`. | + /// | `new_exchange_rate_denominator` | `u64` | The denominator for the new to micro-XDX exchange rate for `Currency`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR` | `new_exchange_rate_denominator` is zero. | + /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | + /// | `Errors::LIMIT_EXCEEDED` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | + /// + /// # Related Scripts + /// * `Script::update_dual_attestation_limit` + /// * `Script::update_minting_ability` + UpdateExchangeRate { + currency: TypeTag, + sliding_nonce: u64, + new_exchange_rate_numerator: u64, + new_exchange_rate_denominator: u64, + }, + + /// # Summary + /// Script to allow or disallow minting of new coins in a specified currency. This transaction can + /// only be sent by the Treasury Compliance account. Turning minting off for a currency will have + /// no effect on coins already in circulation, and coins may still be removed from the system. + /// + /// # Technical Description + /// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo` resource + /// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if + /// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise. + /// This transaction needs to be sent by the Treasury Compliance account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | + /// | `allow_minting` | `bool` | Whether to allow minting of new coins in `Currency`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | `Currency` is not a registered currency on-chain. | + /// + /// # Related Scripts + /// * `Script::update_dual_attestation_limit` + /// * `Script::update_exchange_rate` + UpdateMintingAbility { + currency: TypeTag, + allow_minting: bool, + }, +} + +/// Structured representation of a call into a known Move script function. +/// ```ignore +/// impl ScriptFunctionCall { +/// pub fn encode(self) -> TransactionPayload { .. } +/// pub fn decode(&TransactionPayload) -> Option { .. } +/// } +/// ``` +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, serde::Deserialize, serde::Serialize)] + +pub enum ScriptFunctionCall { + /// # Summary + /// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to + /// send, receive, and hold `Diem::Diem` 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` 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` 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 + /// Add a DiemID domain to parent VASP account. The transaction can only be sent by + /// the Treasury Compliance account. + /// + /// # Technical Description + /// Adds a `DiemId::DiemIdDomain` to the `domains` field of the `DiemId::DiemIdDomains` resource published under + /// the account at `address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `address` | `address` | The `address` of the parent VASP account that will have have `domain` added to its domains. | + /// | `domain` | `vector` | The domain to be added. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_ALREADY_EXISTS` | The `domain` already exists in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | + AddDiemIdDomain { + address: AccountAddress, + domain: Bytes, + }, + + /// # Summary + /// Stores the sending accounts ability to rotate its authentication key with a designated recovery + /// account. Both the sending and recovery accounts need to belong to the same VASP and + /// both be VASP accounts. After this transaction both the sending account and the + /// specified recovery account can rotate the sender account's authentication key. + /// + /// # Technical Description + /// Adds the `DiemAccount::KeyRotationCapability` for the sending account + /// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under + /// `recovery_address`. After this transaction has been executed successfully the account at + /// `recovery_address` and the `to_recover_account` may rotate the authentication key of + /// `to_recover_account` (the sender of this transaction). + /// + /// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key + /// rotation capability, and must be a VASP account. The account at `recovery_address` + /// must also be a VASP account belonging to the same VASP as the `to_recover_account`. + /// Additionally the account at `recovery_address` must have already initialized itself as + /// a recovery account address using the `AccountAdministrationScripts::create_recovery_address` transaction script. + /// + /// The sending account's (`to_recover_account`) key rotation capability is + /// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` + /// resource stored under the account at `recovery_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `to_recover_account` | `signer` | The signer of the sending account of this transaction. | + /// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | + /// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::create_recovery_address` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address` + AddRecoveryRotationCapability { + recovery_address: AccountAddress, + }, + + /// # Summary + /// Adds a validator account to the validator set, and triggers a + /// reconfiguration of the system to admit the account to the validator set for the system. This + /// transaction can only be successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script adds the account at `validator_address` to the validator set. + /// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a + /// reconfiguration. Once the reconfiguration triggered by this script's + /// execution has been performed, the account at the `validator_address` is + /// considered to be a validator in the network. + /// + /// This transaction script will fail if the `validator_address` address is already in the validator set + /// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be added to the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemSystem::EMAX_VALIDATORS` | The validator set is already at its maximum size. The validator could not be added. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `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` + AddValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + AutopayCreateInstruction { + uid: u64, + in_type: u8, + payee: AccountAddress, + end_epoch: u64, + value: u64, + }, + + AutopayDisable {}, + + AutopayEnable {}, + + BalanceTransfer { + destination: AccountAddress, + unscaled_value: u64, + }, + + /// # Summary + /// Burns the transaction fees collected in the `CoinType` currency so that the + /// Diem association may reclaim the backing coins off-chain. May only be sent + /// by the Treasury Compliance account. + /// + /// # Technical Description + /// Burns the transaction fees collected in `CoinType` so that the + /// association may reclaim the backing coins. Once this transaction has executed + /// successfully all transaction fees that will have been collected in + /// `CoinType` since the last time this script was called with that specific + /// currency. Both `balance` and `preburn` fields in the + /// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` + /// account address will have a value of 0 after the successful execution of this script. + /// + /// # Events + /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle + /// held in the `Diem::CurrencyInfo` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | + /// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | + /// + /// # Related Scripts + /// * `TreasuryComplianceScripts::burn_with_amount` + /// * `TreasuryComplianceScripts::cancel_burn_with_amount` + BurnTxnFees { + coin_type: 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` resource published under the + /// `preburn_address` account address. + /// + /// This transaction will only succeed if the sending `account` has a + /// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` 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` published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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` resource under the `preburn_address` and + /// return the funds to the `preburn_address` account's `DiemAccount::Balance`. + /// The transaction must be sent by an `account` with a `Diem::BurnCapability` + /// resource published under it. The account at `preburn_address` must have a + /// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes + /// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's + /// `DiemAccount::Balance` 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` + /// 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` published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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, + }, + + CreateAccUser { + challenge: Bytes, + solution: Bytes, + difficulty: u64, + security: u64, + }, + + CreateAccVal { + challenge: Bytes, + solution: Bytes, + difficulty: u64, + security: u64, + ow_human_name: Bytes, + op_address: AccountAddress, + op_auth_key_prefix: Bytes, + op_consensus_pubkey: Bytes, + op_validator_network_addresses: Bytes, + op_fullnode_network_addresses: Bytes, + op_human_name: Bytes, + }, + + /// # Summary + /// Creates a Child VASP account with its parent being the sending account of the transaction. + /// The sender of the transaction must be a Parent VASP account. + /// + /// # Technical Description + /// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of + /// `child_initial_balance` in `CoinType` and an initial authentication key of + /// `auth_key_prefix | child_address`. Authentication key prefixes, and how to construct them from an ed25519 public key is described + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). + /// + /// If `add_all_currencies` is true, the child address will have a zero balance in all available + /// currencies in the system. + /// + /// The new account will be a child account of the transaction sender, which must be a + /// Parent VASP account. The child account will be recorded against the limit of + /// child accounts of the creating Parent VASP account. + /// + /// # Events + /// Successful execution will emit: + /// * A `DiemAccount::CreateAccountEvent` with the `created` field being `child_address`, + /// and the `rold_id` field being `Roles::CHILD_VASP_ROLE_ID`. This is emitted on the + /// `DiemAccount::AccountOperationsCapability` `creation_events` handle. + /// + /// Successful execution with a `child_initial_balance` greater than zero will additionaly emit: + /// * A `DiemAccount::SentPaymentEvent` with the `payee` field being `child_address`. + /// This is emitted on the Parent VASP's `DiemAccount::DiemAccount` `sent_events` handle. + /// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address. + /// This is emitted on the new Child VASPS's `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | + /// | `parent_vasp` | `signer` | The reference of the sending account. Must be a Parent VASP account. | + /// | `child_address` | `address` | Address of the to-be-created Child VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | + /// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_parent_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::add_recovery_rotation_capability` + /// * `AccountAdministrationScripts::create_recovery_address` + CreateChildVaspAccount { + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Bytes, + add_all_currencies: bool, + child_initial_balance: u64, + }, + + /// # Summary + /// Creates a Designated Dealer account with the provided information, and initializes it with + /// default mint tiers. The transaction can only be sent by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Designated Dealer role at `addr` with authentication key + /// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, + /// 0 balances for all available currencies in the system will also be added. This can only be + /// invoked by an account with the TreasuryCompliance role. + /// 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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, + }, + + /// # Summary + /// Publishes a `DiemId::DiemIdDomains` resource under a parent VASP account. + /// The sending account must be a parent VASP account. + /// + /// # Technical Description + /// Publishes a `DiemId::DiemIdDomains` resource under `account`. + /// The The `DiemId::DiemIdDomains` resource's `domains` field is a vector + /// of DiemIdDomain, and will be empty on at the end of processing this transaction. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::ALREADY_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN` | A `DiemId::DiemIdDomains` resource has already been published under `account`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending `account` was not a parent VASP account. | + CreateDiemIdDomains {}, + + /// # Summary + /// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Parent VASP role at `address` with authentication key + /// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If + /// `add_all_currencies` is true, 0 balances for all available currencies in the system will + /// also be added. This can only be invoked by an TreasuryCompliance account. + /// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. + /// 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::PARENT_VASP_ROLE_ID`. This is emitted on the + /// `DiemAccount::AccountOperationsCapability` `creation_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_child_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::add_recovery_rotation_capability` + /// * `AccountAdministrationScripts::create_recovery_address` + /// * `AccountAdministrationScripts::rotate_dual_attestation_info` + CreateParentVaspAccount { + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Initializes the sending account as a recovery address that may be used by + /// other accounts belonging to the same VASP as `account`. + /// The sending account must be a VASP account, and can be either a child or parent VASP account. + /// Multiple recovery addresses can exist for a single VASP, but accounts in + /// each must be disjoint. + /// + /// # Technical Description + /// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then + /// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds + /// it to the resource. After the successful execution of this transaction + /// other accounts may add their key rotation to this resource so that `account` + /// may be used as a recovery account for those accounts. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | + /// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | + /// + /// # Related Scripts + /// * `Script::add_recovery_rotation_capability` + /// * `Script::rotate_authentication_key_with_recovery_address` + CreateRecoveryAddress {}, + + CreateUserByCoinTx { + account: AccountAddress, + authkey_prefix: Bytes, + unscaled_value: u64, + }, + + /// # 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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, + }, + + DemoE2e { + world: u64, + }, + + /// # 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, + }, + + /// # Summary + /// Initializes the Diem consensus config that is stored on-chain. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via + /// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + InitializeDiemConsensusConfig { + sliding_nonce: u64, + }, + + Join {}, + + Leave {}, + + MinerstateCommit { + challenge: Bytes, + solution: Bytes, + difficulty: u64, + security: u64, + }, + + MinerstateCommitByOperator { + owner_address: AccountAddress, + challenge: Bytes, + solution: Bytes, + difficulty: u64, + security: u64, + }, + + MinerstateHelper {}, + + /// A validator (Alice) can delegate the authority for the operation of an upgrade to another validator (Bob). When Oracle delegation happens, effectively the consensus voting power of Alice, is added to Bob only for the effect of calculating the preference on electing a stdlib binary. Whatever binary Bob proposes, Alice will also propose without needing to be submitting transactions. + OlDelegateVote { + dest: AccountAddress, + }, + + /// First Bob must have delegation enabled, which can be done with: + OlEnableDelegation {}, + + OlOracleTx { + id: u64, + data: Bytes, + }, + + OlReconfigBulkUpdateSetup { + alice: AccountAddress, + bob: AccountAddress, + carol: AccountAddress, + sha: AccountAddress, + ram: AccountAddress, + }, + + /// Alice can remove Bob as the delegate with this function. + OlRemoveDelegation {}, + + /// # Summary + /// Transfers a given number of coins in a specified currency from one account to another. + /// Transfers over a specified amount defined on-chain that are between two different VASPs, or + /// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has + /// agreed to receive the coins. This transaction can be sent by any account that can hold a + /// balance, and to any account that can hold a balance. Both accounts must hold balances in the + /// currency being transacted. + /// + /// # Technical Description + /// + /// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated + /// `metadata` and an (optional) `metadata_signature` on the message of the form + /// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`, that + /// has been signed by the `payee`'s private key associated with the `compliance_public_key` held in + /// the `payee`'s `DualAttestation::Credential`. Both the `Signer::address_of(payer)` and `amount` fields + /// in the `metadata_signature` must be BCS-encoded bytes, and `|` denotes concatenation. + /// The `metadata` and `metadata_signature` parameters are only required if `amount` >= + /// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. + /// However, a transaction sender can opt in to dual attestation even when it is not required + /// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. + /// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. + /// + /// # Events + /// Successful execution of this script emits two events: + /// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and + /// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | + /// | `payer` | `signer` | The signer of the sending account that coins are being transferred from. | + /// | `payee` | `address` | The address of the account the coins are being transferred to. | + /// | `metadata` | `vector` | Optional metadata about this payment. | + /// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | + /// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_child_vasp_account` + /// * `AccountCreationScripts::create_parent_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + PeerToPeerWithMetadata { + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Bytes, + metadata_signature: Bytes, + }, + + /// # Summary + /// Moves a specified number of coins in a given currency from the account's + /// balance to its preburn area after which the coins may be burned. This + /// transaction may be sent by any account that holds a balance and preburn area + /// in the specified currency. + /// + /// # Technical Description + /// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s + /// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` 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 authentication key of the sending account to the newly-specified ed25519 public key and + /// publishes a new shared authentication key derived from that public key under the sender's account. + /// Any account can send this transaction. + /// + /// # Technical Description + /// Rotates the authentication key of the sending account to the + /// [authentication key derived from `public_key`](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) + /// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource + /// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for + /// `account` under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `public_key` | `vector` | A valid 32-byte Ed25519 public key for `account`'s authentication key to be rotated to and stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | + /// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::rotate_shared_ed25519_public_key` + PublishSharedEd25519PublicKey { + public_key: Bytes, + }, + + /// # Summary + /// Updates a validator's configuration. This does not reconfigure the system and will not update + /// the configuration in the validator set that is seen by other validators in the network. Can + /// only be successfully sent by a Validator Operator account that is already registered with a + /// validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` + /// so the copy of this config held in the validator set will not be updated, and the changes are + /// only "locally" under the `validator_account` account address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + RegisterValidatorConfig { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Remove a DiemID domain from parent VASP account. The transaction can only be sent by + /// the Treasury Compliance account. + /// + /// # Technical Description + /// Removes a `DiemId::DiemIdDomain` from the `domains` field of the `DiemId::DiemIdDomains` resource published under + /// account with `address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `address` | `address` | The `address` of parent VASP account that will update its domains. | + /// | `domain` | `vector` | The domain name. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_NOT_FOUND` | The `domain` does not exist in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | + RemoveDiemIdDomain { + address: AccountAddress, + domain: Bytes, + }, + + /// # Summary + /// This script removes a validator account from the validator set, and triggers a reconfiguration + /// of the system to remove the validator from the system. This transaction can only be + /// successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script removes the account at `validator_address` from the validator set. This transaction + /// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event + /// has been performed, the account at `validator_address` is no longer considered to be a + /// validator in the network. This transaction will fail if the validator at `validator_address` + /// is not in the validator set. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be removed from the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + RemoveValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # 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` | 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` | 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` | 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 + /// Rotates the authentication key of a specified account that is part of a recovery address to a + /// new authentication key. Only used for accounts that are part of a recovery address (see + /// `AccountAdministrationScripts::add_recovery_rotation_capability` for account restrictions). + /// + /// # Technical Description + /// Rotates the authentication key of the `to_recover` account to `new_key` using the + /// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource + /// published under `recovery_address`. `new_key` must be a valide authentication key as described + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). + /// This transaction can be sent either by the `to_recover` account, or by the account where the + /// `RecoveryAddress::RecoveryAddress` resource is published that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account of the transaction. | + /// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | + /// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | + /// | `new_key` | `vector` | New authentication key to be used for the account at the `to_recover` address. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin` + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Bytes, + }, + + /// # Summary + /// Updates the url used for off-chain communication, and the public key used to verify dual + /// attestation on-chain. Transaction can be sent by any account that has dual attestation + /// information published under it. In practice the only such accounts are Designated Dealers and + /// Parent VASPs. + /// + /// # Technical Description + /// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` + /// resource published under `account`. The `new_key` must be a valid ed25519 public key. + /// + /// # Events + /// Successful execution of this transaction emits two events: + /// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and + /// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` + /// `compliance_key_rotation_events` handle published under `account`; and + /// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for + /// off-chain communication, and the blockchain time at which the url was updated emitted on the + /// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account of the transaction. | + /// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | + /// | `new_key` | `vector` | 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 + /// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by + /// any account that has previously published a shared ed25519 public key using + /// `AccountAdministrationScripts::publish_shared_ed25519_public_key`. + /// + /// # Technical Description + /// `public_key` must be a valid ed25519 public key. This transaction first rotates the public key stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it + /// rotates the `account`'s authentication key to the new authentication key derived from `public_key` as defined + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) + /// using the `DiemAccount::KeyRotationCapability` stored in `account`'s `SharedEd25519PublicKey::SharedEd25519PublicKey`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::publish_shared_ed25519_public_key` + RotateSharedEd25519PublicKey { + public_key: Bytes, + }, + + /// # Summary + /// Updates the gas constants stored on chain and used by the VM for gas + /// metering. This transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the on-chain config holding the `DiemVMConfig` and emits a + /// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `global_memory_per_byte_cost` | `u64` | The new cost to read global memory per-byte to be used for gas metering. | + /// | `global_memory_per_byte_write_cost` | `u64` | The new cost to write global memory per-byte to be used for gas metering. | + /// | `min_transaction_gas_units` | `u64` | The new flat minimum amount of gas required for any transaction. | + /// | `large_transaction_cutoff` | `u64` | The new size over which an additional charge will be assessed for each additional byte. | + /// | `intrinsic_gas_per_byte` | `u64` | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`. | + /// | `maximum_number_of_gas_units` | `u64` | The new maximum number of gas units that can be set in a transaction. | + /// | `min_price_per_gas_unit` | `u64` | The new minimum gas price that can be set for a transaction. | + /// | `max_price_per_gas_unit` | `u64` | The new maximum gas price that can be set for a transaction. | + /// | `max_transaction_size_in_bytes` | `u64` | The new maximum size of a transaction that can be processed. | + /// | `gas_unit_scaling_factor` | `u64` | The new scaling factor to use when scaling between external and internal gas units. | + /// | `default_account_size` | `u64` | The new default account size to use when assessing final costs for reads and writes to global storage. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + SetGasConstants { + sliding_nonce: u64, + global_memory_per_byte_cost: u64, + global_memory_per_byte_write_cost: u64, + min_transaction_gas_units: u64, + large_transaction_cutoff: u64, + intrinsic_gas_per_byte: u64, + maximum_number_of_gas_units: u64, + min_price_per_gas_unit: u64, + max_price_per_gas_unit: u64, + max_transaction_size_in_bytes: u64, + gas_unit_scaling_factor: u64, + default_account_size: u64, + }, + + /// # Summary + /// Updates a validator's configuration, and triggers a reconfiguration of the system to update the + /// validator set with this new validator configuration. Can only be successfully sent by a + /// Validator Operator account that is already registered with a validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to + /// trigger a reconfiguration of the system. This reconfiguration will update the validator set + /// on-chain with the updated `ValidatorConfig::ValidatorConfig`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::register_validator_config` + SetValidatorConfigAndReconfigure { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by an account with + /// Validator role. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the sending validator account. The account at `operator_account` address must have + /// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` + /// resource published under it. The sending `account` must be a Validator and have a + /// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a + /// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + SetValidatorOperator { + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root + /// account as a write set transaction. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the validator `account`. The account at `operator_account` address must have a + /// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource + /// published under it. The account represented by the `account` signer must be a Validator and + /// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of + /// the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | 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. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + SetValidatorOperatorWithNonceAdmin { + sliding_nonce: u64, + operator_name: Bytes, + operator_account: AccountAddress, + }, + + SetWalletType { + type_of: u8, + }, + + /// # 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` 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` resource does not exist at `designated_dealer_address`. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` 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 + /// Updates the Diem consensus config that is stored on-chain and is used by the Consensus. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `config` | `vector` | The serialized bytes of consensus config. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + UpdateDiemConsensusConfig { + sliding_nonce: u64, + config: Bytes, + }, + + /// # Summary + /// Updates the Diem major version that is stored on-chain and is used by the VM. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater + /// than the current major version held on-chain. The VM reads this information and can use it to + /// preserve backwards compatibility with previous major versions of the VM. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | + UpdateDiemVersion { + sliding_nonce: u64, + major: u64, + }, + + /// # Summary + /// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can + /// only be sent by the Treasury Compliance account. After this transaction all inter-VASP + /// payments over this limit must be checked for dual attestation. + /// + /// # Technical Description + /// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under + /// `0xA550C18`. The amount is set in micro-XDX. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer 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. | + /// | `dm_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 `dm_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` | `dm_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `dm_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` 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, + }, + + ValAddSelf {}, +} + +impl ScriptCall { + /// Build a Diem `Script` from a structured object `ScriptCall`. + pub fn encode(self) -> Script { + use ScriptCall::*; + match self { + AddCurrencyToAccount { currency } => encode_add_currency_to_account_script(currency), + AddRecoveryRotationCapability { recovery_address } => { + encode_add_recovery_rotation_capability_script(recovery_address) + } + AddValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_add_validator_and_reconfigure_script( + sliding_nonce, + validator_name, + validator_address, + ), + Burn { + token, + sliding_nonce, + preburn_address, + } => encode_burn_script(token, sliding_nonce, preburn_address), + BurnTxnFees { coin_type } => encode_burn_txn_fees_script(coin_type), + CancelBurn { + token, + preburn_address, + } => encode_cancel_burn_script(token, preburn_address), + CreateChildVaspAccount { + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + } => encode_create_child_vasp_account_script( + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + ), + CreateDesignatedDealer { + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_designated_dealer_script( + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateParentVaspAccount { + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_parent_vasp_account_script( + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateRecoveryAddress {} => encode_create_recovery_address_script(), + CreateValidatorAccount { + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + } => encode_create_validator_account_script( + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + ), + CreateValidatorOperatorAccount { + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + } => encode_create_validator_operator_account_script( + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + ), + FreezeAccount { + sliding_nonce, + to_freeze_account, + } => encode_freeze_account_script(sliding_nonce, to_freeze_account), + PeerToPeerWithMetadata { + currency, + payee, + amount, + metadata, + metadata_signature, + } => encode_peer_to_peer_with_metadata_script( + currency, + payee, + amount, + metadata, + metadata_signature, + ), + Preburn { token, amount } => encode_preburn_script(token, amount), + PublishSharedEd25519PublicKey { public_key } => { + encode_publish_shared_ed25519_public_key_script(public_key) + } + RegisterValidatorConfig { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_register_validator_config_script( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + RemoveValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_remove_validator_and_reconfigure_script( + sliding_nonce, + validator_name, + validator_address, + ), + RotateAuthenticationKey { new_key } => encode_rotate_authentication_key_script(new_key), + RotateAuthenticationKeyWithNonce { + sliding_nonce, + new_key, + } => encode_rotate_authentication_key_with_nonce_script(sliding_nonce, new_key), + RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce, + new_key, + } => encode_rotate_authentication_key_with_nonce_admin_script(sliding_nonce, new_key), + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address, + to_recover, + new_key, + } => encode_rotate_authentication_key_with_recovery_address_script( + recovery_address, + to_recover, + new_key, + ), + RotateDualAttestationInfo { new_url, new_key } => { + encode_rotate_dual_attestation_info_script(new_url, new_key) + } + RotateSharedEd25519PublicKey { public_key } => { + encode_rotate_shared_ed25519_public_key_script(public_key) + } + SetValidatorConfigAndReconfigure { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_set_validator_config_and_reconfigure_script( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + SetValidatorOperator { + operator_name, + operator_account, + } => encode_set_validator_operator_script(operator_name, operator_account), + SetValidatorOperatorWithNonceAdmin { + sliding_nonce, + operator_name, + operator_account, + } => encode_set_validator_operator_with_nonce_admin_script( + sliding_nonce, + operator_name, + operator_account, + ), + TieredMint { + coin_type, + sliding_nonce, + designated_dealer_address, + mint_amount, + tier_index, + } => encode_tiered_mint_script( + coin_type, + sliding_nonce, + designated_dealer_address, + mint_amount, + tier_index, + ), + UnfreezeAccount { + sliding_nonce, + to_unfreeze_account, + } => encode_unfreeze_account_script(sliding_nonce, to_unfreeze_account), + UpdateDiemVersion { + sliding_nonce, + major, + } => encode_update_diem_version_script(sliding_nonce, major), + UpdateDualAttestationLimit { + sliding_nonce, + new_micro_xdx_limit, + } => encode_update_dual_attestation_limit_script(sliding_nonce, new_micro_xdx_limit), + UpdateExchangeRate { + currency, + sliding_nonce, + new_exchange_rate_numerator, + new_exchange_rate_denominator, + } => encode_update_exchange_rate_script( + currency, + sliding_nonce, + new_exchange_rate_numerator, + new_exchange_rate_denominator, + ), + UpdateMintingAbility { + currency, + allow_minting, + } => encode_update_minting_ability_script(currency, allow_minting), + } + } + + /// Try to recognize a Diem `Script` and convert it into a structured object `ScriptCall`. + pub fn decode(script: &Script) -> Option { + match TRANSACTION_SCRIPT_DECODER_MAP.get(script.code()) { + Some(decoder) => decoder(script), + None => None, + } + } + + /// Return the name of a Diem `Script` from a structured object `ScriptCall`. + pub fn name(&self) -> &'static str { + use ScriptCall::*; + match self { + AddCurrencyToAccount { .. } => "add_currency_to_account", + AddRecoveryRotationCapability { .. } => "add_recovery_rotation_capability", + AddValidatorAndReconfigure { .. } => "add_validator_and_reconfigure", + Burn { .. } => "burn", + BurnTxnFees { .. } => "burn_txn_fees", + CancelBurn { .. } => "cancel_burn", + CreateChildVaspAccount { .. } => "create_child_vasp_account", + CreateDesignatedDealer { .. } => "create_designated_dealer", + CreateParentVaspAccount { .. } => "create_parent_vasp_account", + CreateRecoveryAddress { .. } => "create_recovery_address", + CreateValidatorAccount { .. } => "create_validator_account", + CreateValidatorOperatorAccount { .. } => "create_validator_operator_account", + FreezeAccount { .. } => "freeze_account", + PeerToPeerWithMetadata { .. } => "peer_to_peer_with_metadata", + Preburn { .. } => "preburn", + PublishSharedEd25519PublicKey { .. } => "publish_shared_ed25519_public_key", + RegisterValidatorConfig { .. } => "register_validator_config", + RemoveValidatorAndReconfigure { .. } => "remove_validator_and_reconfigure", + RotateAuthenticationKey { .. } => "rotate_authentication_key", + RotateAuthenticationKeyWithNonce { .. } => "rotate_authentication_key_with_nonce", + RotateAuthenticationKeyWithNonceAdmin { .. } => { + "rotate_authentication_key_with_nonce_admin" + } + RotateAuthenticationKeyWithRecoveryAddress { .. } => { + "rotate_authentication_key_with_recovery_address" + } + RotateDualAttestationInfo { .. } => "rotate_dual_attestation_info", + RotateSharedEd25519PublicKey { .. } => "rotate_shared_ed25519_public_key", + SetValidatorConfigAndReconfigure { .. } => "set_validator_config_and_reconfigure", + SetValidatorOperator { .. } => "set_validator_operator", + SetValidatorOperatorWithNonceAdmin { .. } => "set_validator_operator_with_nonce_admin", + TieredMint { .. } => "tiered_mint", + UnfreezeAccount { .. } => "unfreeze_account", + UpdateDiemVersion { .. } => "update_diem_version", + UpdateDualAttestationLimit { .. } => "update_dual_attestation_limit", + UpdateExchangeRate { .. } => "update_exchange_rate", + UpdateMintingAbility { .. } => "update_minting_ability", + } + } +} + +impl ScriptFunctionCall { + /// Build a Diem `TransactionPayload` from a structured object `ScriptFunctionCall`. + pub fn encode(self) -> TransactionPayload { + use ScriptFunctionCall::*; + match self { + AddCurrencyToAccount { currency } => { + encode_add_currency_to_account_script_function(currency) + } + AddDiemIdDomain { address, domain } => { + encode_add_diem_id_domain_script_function(address, domain) + } + AddRecoveryRotationCapability { recovery_address } => { + encode_add_recovery_rotation_capability_script_function(recovery_address) + } + AddValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_add_validator_and_reconfigure_script_function( + sliding_nonce, + validator_name, + validator_address, + ), + AutopayCreateInstruction { + uid, + in_type, + payee, + end_epoch, + value, + } => encode_autopay_create_instruction_script_function( + uid, in_type, payee, end_epoch, value, + ), + AutopayDisable {} => encode_autopay_disable_script_function(), + AutopayEnable {} => encode_autopay_enable_script_function(), + BalanceTransfer { + destination, + unscaled_value, + } => encode_balance_transfer_script_function(destination, unscaled_value), + BurnTxnFees { coin_type } => encode_burn_txn_fees_script_function(coin_type), + 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), + CreateAccUser { + challenge, + solution, + difficulty, + security, + } => encode_create_acc_user_script_function(challenge, solution, difficulty, security), + CreateAccVal { + challenge, + solution, + difficulty, + security, + ow_human_name, + op_address, + op_auth_key_prefix, + op_consensus_pubkey, + op_validator_network_addresses, + op_fullnode_network_addresses, + op_human_name, + } => encode_create_acc_val_script_function( + challenge, + solution, + difficulty, + security, + ow_human_name, + op_address, + op_auth_key_prefix, + op_consensus_pubkey, + op_validator_network_addresses, + op_fullnode_network_addresses, + op_human_name, + ), + CreateChildVaspAccount { + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + } => encode_create_child_vasp_account_script_function( + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + ), + CreateDesignatedDealer { + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_designated_dealer_script_function( + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateDiemIdDomains {} => encode_create_diem_id_domains_script_function(), + CreateParentVaspAccount { + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_parent_vasp_account_script_function( + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateRecoveryAddress {} => encode_create_recovery_address_script_function(), + CreateUserByCoinTx { + account, + authkey_prefix, + unscaled_value, + } => encode_create_user_by_coin_tx_script_function( + account, + authkey_prefix, + unscaled_value, + ), + 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, + ), + DemoE2e { world } => encode_demo_e2e_script_function(world), + FreezeAccount { + sliding_nonce, + to_freeze_account, + } => encode_freeze_account_script_function(sliding_nonce, to_freeze_account), + InitializeDiemConsensusConfig { sliding_nonce } => { + encode_initialize_diem_consensus_config_script_function(sliding_nonce) + } + Join {} => encode_join_script_function(), + Leave {} => encode_leave_script_function(), + MinerstateCommit { + challenge, + solution, + difficulty, + security, + } => { + encode_minerstate_commit_script_function(challenge, solution, difficulty, security) + } + MinerstateCommitByOperator { + owner_address, + challenge, + solution, + difficulty, + security, + } => encode_minerstate_commit_by_operator_script_function( + owner_address, + challenge, + solution, + difficulty, + security, + ), + MinerstateHelper {} => encode_minerstate_helper_script_function(), + OlDelegateVote { dest } => encode_ol_delegate_vote_script_function(dest), + OlEnableDelegation {} => encode_ol_enable_delegation_script_function(), + OlOracleTx { id, data } => encode_ol_oracle_tx_script_function(id, data), + OlReconfigBulkUpdateSetup { + alice, + bob, + carol, + sha, + ram, + } => encode_ol_reconfig_bulk_update_setup_script_function(alice, bob, carol, sha, ram), + OlRemoveDelegation {} => encode_ol_remove_delegation_script_function(), + PeerToPeerWithMetadata { + currency, + payee, + amount, + metadata, + metadata_signature, + } => encode_peer_to_peer_with_metadata_script_function( + currency, + payee, + amount, + metadata, + metadata_signature, + ), + Preburn { token, amount } => encode_preburn_script_function(token, amount), + PublishSharedEd25519PublicKey { public_key } => { + encode_publish_shared_ed25519_public_key_script_function(public_key) + } + RegisterValidatorConfig { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_register_validator_config_script_function( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + RemoveDiemIdDomain { address, domain } => { + encode_remove_diem_id_domain_script_function(address, domain) + } + RemoveValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_remove_validator_and_reconfigure_script_function( + sliding_nonce, + validator_name, + validator_address, + ), + 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, + ), + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address, + to_recover, + new_key, + } => encode_rotate_authentication_key_with_recovery_address_script_function( + recovery_address, + to_recover, + new_key, + ), + RotateDualAttestationInfo { new_url, new_key } => { + encode_rotate_dual_attestation_info_script_function(new_url, new_key) + } + RotateSharedEd25519PublicKey { public_key } => { + encode_rotate_shared_ed25519_public_key_script_function(public_key) + } + SetGasConstants { + sliding_nonce, + global_memory_per_byte_cost, + global_memory_per_byte_write_cost, + min_transaction_gas_units, + large_transaction_cutoff, + intrinsic_gas_per_byte, + maximum_number_of_gas_units, + min_price_per_gas_unit, + max_price_per_gas_unit, + max_transaction_size_in_bytes, + gas_unit_scaling_factor, + default_account_size, + } => encode_set_gas_constants_script_function( + sliding_nonce, + global_memory_per_byte_cost, + global_memory_per_byte_write_cost, + min_transaction_gas_units, + large_transaction_cutoff, + intrinsic_gas_per_byte, + maximum_number_of_gas_units, + min_price_per_gas_unit, + max_price_per_gas_unit, + max_transaction_size_in_bytes, + gas_unit_scaling_factor, + default_account_size, + ), + SetValidatorConfigAndReconfigure { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_set_validator_config_and_reconfigure_script_function( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + SetValidatorOperator { + operator_name, + operator_account, + } => encode_set_validator_operator_script_function(operator_name, operator_account), + SetValidatorOperatorWithNonceAdmin { + sliding_nonce, + operator_name, + operator_account, + } => encode_set_validator_operator_with_nonce_admin_script_function( + sliding_nonce, + operator_name, + operator_account, + ), + SetWalletType { type_of } => encode_set_wallet_type_script_function(type_of), + 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), + UpdateDiemConsensusConfig { + sliding_nonce, + config, + } => encode_update_diem_consensus_config_script_function(sliding_nonce, config), + UpdateDiemVersion { + sliding_nonce, + major, + } => encode_update_diem_version_script_function(sliding_nonce, major), + 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), + ValAddSelf {} => encode_val_add_self_script_function(), + } + } + + /// Try to recognize a Diem `TransactionPayload` and convert it into a structured object `ScriptFunctionCall`. + pub fn decode(payload: &TransactionPayload) -> Option { + 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` 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` 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` 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 +/// Add a DiemID domain to parent VASP account. The transaction can only be sent by +/// the Treasury Compliance account. +/// +/// # Technical Description +/// Adds a `DiemId::DiemIdDomain` to the `domains` field of the `DiemId::DiemIdDomains` resource published under +/// the account at `address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `address` | `address` | The `address` of the parent VASP account that will have have `domain` added to its domains. | +/// | `domain` | `vector` | The domain to be added. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_ALREADY_EXISTS` | The `domain` already exists in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | +pub fn encode_add_diem_id_domain_script_function( + address: AccountAddress, + domain: Vec, +) -> 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!("add_diem_id_domain").to_owned(), + vec![], + vec![ + bcs::to_bytes(&address).unwrap(), + bcs::to_bytes(&domain).unwrap(), + ], + )) +} + +/// # Summary +/// Stores the sending accounts ability to rotate its authentication key with a designated recovery +/// account. Both the sending and recovery accounts need to belong to the same VASP and +/// both be VASP accounts. After this transaction both the sending account and the +/// specified recovery account can rotate the sender account's authentication key. +/// +/// # Technical Description +/// Adds the `DiemAccount::KeyRotationCapability` for the sending account +/// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under +/// `recovery_address`. After this transaction has been executed successfully the account at +/// `recovery_address` and the `to_recover_account` may rotate the authentication key of +/// `to_recover_account` (the sender of this transaction). +/// +/// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key +/// rotation capability, and must be a VASP account. The account at `recovery_address` +/// must also be a VASP account belonging to the same VASP as the `to_recover_account`. +/// Additionally the account at `recovery_address` must have already initialized itself as +/// a recovery account address using the `AccountAdministrationScripts::create_recovery_address` transaction script. +/// +/// The sending account's (`to_recover_account`) key rotation capability is +/// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` +/// resource stored under the account at `recovery_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `to_recover_account` | `signer` | The signer of the sending account of this transaction. | +/// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | +/// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::create_recovery_address` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address` +pub fn encode_add_recovery_rotation_capability_script_function( + recovery_address: 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!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("add_recovery_rotation_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&recovery_address).unwrap()], + )) +} + +/// # Summary +/// Adds a validator account to the validator set, and triggers a +/// reconfiguration of the system to admit the account to the validator set for the system. This +/// transaction can only be successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script adds the account at `validator_address` to the validator set. +/// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a +/// reconfiguration. Once the reconfiguration triggered by this script's +/// execution has been performed, the account at the `validator_address` is +/// considered to be a validator in the network. +/// +/// This transaction script will fail if the `validator_address` address is already in the validator set +/// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be added to the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemSystem::EMAX_VALIDATORS` | The validator set is already at its maximum size. The validator could not be added. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `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_add_validator_and_reconfigure_script_function( + sliding_nonce: u64, + validator_name: Vec, + validator_address: 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("add_validator_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&validator_name).unwrap(), + bcs::to_bytes(&validator_address).unwrap(), + ], + )) +} + +pub fn encode_autopay_create_instruction_script_function( + uid: u64, + in_type: u8, + payee: AccountAddress, + end_epoch: u64, + value: 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!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_create_instruction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&uid).unwrap(), + bcs::to_bytes(&in_type).unwrap(), + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&end_epoch).unwrap(), + bcs::to_bytes(&value).unwrap(), + ], + )) +} + +pub fn encode_autopay_disable_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_disable").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_autopay_enable_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_enable").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_balance_transfer_script_function( + destination: AccountAddress, + unscaled_value: 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!("TransferScripts").to_owned(), + ), + ident_str!("balance_transfer").to_owned(), + vec![], + vec![ + bcs::to_bytes(&destination).unwrap(), + bcs::to_bytes(&unscaled_value).unwrap(), + ], + )) +} + +/// # Summary +/// Burns the transaction fees collected in the `CoinType` currency so that the +/// Diem association may reclaim the backing coins off-chain. May only be sent +/// by the Treasury Compliance account. +/// +/// # Technical Description +/// Burns the transaction fees collected in `CoinType` so that the +/// association may reclaim the backing coins. Once this transaction has executed +/// successfully all transaction fees that will have been collected in +/// `CoinType` since the last time this script was called with that specific +/// currency. Both `balance` and `preburn` fields in the +/// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` +/// account address will have a value of 0 after the successful execution of this script. +/// +/// # Events +/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle +/// held in the `Diem::CurrencyInfo` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | +/// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | +/// +/// # Related Scripts +/// * `TreasuryComplianceScripts::burn_with_amount` +/// * `TreasuryComplianceScripts::cancel_burn_with_amount` +pub fn encode_burn_txn_fees_script_function(coin_type: 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!("TreasuryComplianceScripts").to_owned(), + ), + ident_str!("burn_txn_fees").to_owned(), + vec![coin_type], + 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` resource published under the +/// `preburn_address` account address. +/// +/// This transaction will only succeed if the sending `account` has a +/// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` 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` published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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` resource under the `preburn_address` and +/// return the funds to the `preburn_address` account's `DiemAccount::Balance`. +/// The transaction must be sent by an `account` with a `Diem::BurnCapability` +/// resource published under it. The account at `preburn_address` must have a +/// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes +/// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's +/// `DiemAccount::Balance` 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` +/// 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` published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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(), + ], + )) +} + +pub fn encode_create_acc_user_script_function( + challenge: Vec, + solution: Vec, + difficulty: u64, + security: 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!("AccountScripts").to_owned(), + ), + ident_str!("create_acc_user").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&difficulty).unwrap(), + bcs::to_bytes(&security).unwrap(), + ], + )) +} +#[allow(clippy::too_many_arguments)] +pub fn encode_create_acc_val_script_function( + challenge: Vec, + solution: Vec, + difficulty: u64, + security: u64, + ow_human_name: Vec, + op_address: AccountAddress, + op_auth_key_prefix: Vec, + op_consensus_pubkey: Vec, + op_validator_network_addresses: Vec, + op_fullnode_network_addresses: Vec, + op_human_name: Vec, +) -> 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!("AccountScripts").to_owned(), + ), + ident_str!("create_acc_val").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&difficulty).unwrap(), + bcs::to_bytes(&security).unwrap(), + bcs::to_bytes(&ow_human_name).unwrap(), + bcs::to_bytes(&op_address).unwrap(), + bcs::to_bytes(&op_auth_key_prefix).unwrap(), + bcs::to_bytes(&op_consensus_pubkey).unwrap(), + bcs::to_bytes(&op_validator_network_addresses).unwrap(), + bcs::to_bytes(&op_fullnode_network_addresses).unwrap(), + bcs::to_bytes(&op_human_name).unwrap(), + ], + )) +} + +/// # Summary +/// Creates a Child VASP account with its parent being the sending account of the transaction. +/// The sender of the transaction must be a Parent VASP account. +/// +/// # Technical Description +/// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of +/// `child_initial_balance` in `CoinType` and an initial authentication key of +/// `auth_key_prefix | child_address`. Authentication key prefixes, and how to construct them from an ed25519 public key is described +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). +/// +/// If `add_all_currencies` is true, the child address will have a zero balance in all available +/// currencies in the system. +/// +/// The new account will be a child account of the transaction sender, which must be a +/// Parent VASP account. The child account will be recorded against the limit of +/// child accounts of the creating Parent VASP account. +/// +/// # Events +/// Successful execution will emit: +/// * A `DiemAccount::CreateAccountEvent` with the `created` field being `child_address`, +/// and the `rold_id` field being `Roles::CHILD_VASP_ROLE_ID`. This is emitted on the +/// `DiemAccount::AccountOperationsCapability` `creation_events` handle. +/// +/// Successful execution with a `child_initial_balance` greater than zero will additionaly emit: +/// * A `DiemAccount::SentPaymentEvent` with the `payee` field being `child_address`. +/// This is emitted on the Parent VASP's `DiemAccount::DiemAccount` `sent_events` handle. +/// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address. +/// This is emitted on the new Child VASPS's `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | +/// | `parent_vasp` | `signer` | The reference of the sending account. Must be a Parent VASP account. | +/// | `child_address` | `address` | Address of the to-be-created Child VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | +/// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_parent_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::add_recovery_rotation_capability` +/// * `AccountAdministrationScripts::create_recovery_address` +pub fn encode_create_child_vasp_account_script_function( + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Vec, + add_all_currencies: bool, + child_initial_balance: 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!("AccountCreationScripts").to_owned(), + ), + ident_str!("create_child_vasp_account").to_owned(), + vec![coin_type], + vec![ + bcs::to_bytes(&child_address).unwrap(), + bcs::to_bytes(&auth_key_prefix).unwrap(), + bcs::to_bytes(&add_all_currencies).unwrap(), + bcs::to_bytes(&child_initial_balance).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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, + 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(), + ], + )) +} + +/// # Summary +/// Publishes a `DiemId::DiemIdDomains` resource under a parent VASP account. +/// The sending account must be a parent VASP account. +/// +/// # Technical Description +/// Publishes a `DiemId::DiemIdDomains` resource under `account`. +/// The The `DiemId::DiemIdDomains` resource's `domains` field is a vector +/// of DiemIdDomain, and will be empty on at the end of processing this transaction. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::ALREADY_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN` | A `DiemId::DiemIdDomains` resource has already been published under `account`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending `account` was not a parent VASP account. | +pub fn encode_create_diem_id_domains_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("create_diem_id_domains").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Parent VASP role at `address` with authentication key +/// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If +/// `add_all_currencies` is true, 0 balances for all available currencies in the system will +/// also be added. This can only be invoked by an TreasuryCompliance account. +/// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. +/// 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::PARENT_VASP_ROLE_ID`. This is emitted on the +/// `DiemAccount::AccountOperationsCapability` `creation_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_child_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::add_recovery_rotation_capability` +/// * `AccountAdministrationScripts::create_recovery_address` +/// * `AccountAdministrationScripts::rotate_dual_attestation_info` +pub fn encode_create_parent_vasp_account_script_function( + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + 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_parent_vasp_account").to_owned(), + vec![coin_type], + 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(), + bcs::to_bytes(&add_all_currencies).unwrap(), + ], + )) +} + +/// # Summary +/// Initializes the sending account as a recovery address that may be used by +/// other accounts belonging to the same VASP as `account`. +/// The sending account must be a VASP account, and can be either a child or parent VASP account. +/// Multiple recovery addresses can exist for a single VASP, but accounts in +/// each must be disjoint. +/// +/// # Technical Description +/// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then +/// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds +/// it to the resource. After the successful execution of this transaction +/// other accounts may add their key rotation to this resource so that `account` +/// may be used as a recovery account for those accounts. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | +/// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | +/// +/// # Related Scripts +/// * `Script::add_recovery_rotation_capability` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_create_recovery_address_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("create_recovery_address").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_create_user_by_coin_tx_script_function( + account: AccountAddress, + authkey_prefix: Vec, + unscaled_value: 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!("AccountScripts").to_owned(), + ), + ident_str!("create_user_by_coin_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&account).unwrap(), + bcs::to_bytes(&authkey_prefix).unwrap(), + bcs::to_bytes(&unscaled_value).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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, +) -> 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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, +) -> 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(), + ], + )) +} + +pub fn encode_demo_e2e_script_function(world: 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!("DemoScripts").to_owned(), + ), + ident_str!("demo_e2e").to_owned(), + vec![], + vec![bcs::to_bytes(&world).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(), + ], + )) +} + +/// # Summary +/// Initializes the Diem consensus config that is stored on-chain. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via +/// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +pub fn encode_initialize_diem_consensus_config_script_function( + sliding_nonce: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("initialize_diem_consensus_config").to_owned(), + vec![], + vec![bcs::to_bytes(&sliding_nonce).unwrap()], + )) +} + +pub fn encode_join_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("join").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_leave_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("leave").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_minerstate_commit_script_function( + challenge: Vec, + solution: Vec, + difficulty: u64, + security: 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!("TowerStateScripts").to_owned(), + ), + ident_str!("minerstate_commit").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&difficulty).unwrap(), + bcs::to_bytes(&security).unwrap(), + ], + )) +} + +pub fn encode_minerstate_commit_by_operator_script_function( + owner_address: AccountAddress, + challenge: Vec, + solution: Vec, + difficulty: u64, + security: 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!("TowerStateScripts").to_owned(), + ), + ident_str!("minerstate_commit_by_operator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&owner_address).unwrap(), + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&difficulty).unwrap(), + bcs::to_bytes(&security).unwrap(), + ], + )) +} + +pub fn encode_minerstate_helper_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("TowerStateScripts").to_owned(), + ), + ident_str!("minerstate_helper").to_owned(), + vec![], + vec![], + )) +} + +/// A validator (Alice) can delegate the authority for the operation of an upgrade to another validator (Bob). When Oracle delegation happens, effectively the consensus voting power of Alice, is added to Bob only for the effect of calculating the preference on electing a stdlib binary. Whatever binary Bob proposes, Alice will also propose without needing to be submitting transactions. +pub fn encode_ol_delegate_vote_script_function(dest: 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!("OracleScripts").to_owned(), + ), + ident_str!("ol_delegate_vote").to_owned(), + vec![], + vec![bcs::to_bytes(&dest).unwrap()], + )) +} + +/// First Bob must have delegation enabled, which can be done with: +pub fn encode_ol_enable_delegation_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("OracleScripts").to_owned(), + ), + ident_str!("ol_enable_delegation").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_ol_oracle_tx_script_function(id: u64, data: Vec) -> 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!("OracleScripts").to_owned(), + ), + ident_str!("ol_oracle_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&id).unwrap(), bcs::to_bytes(&data).unwrap()], + )) +} + +pub fn encode_ol_reconfig_bulk_update_setup_script_function( + alice: AccountAddress, + bob: AccountAddress, + carol: AccountAddress, + sha: AccountAddress, + ram: 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!("ValidatorScripts").to_owned(), + ), + ident_str!("ol_reconfig_bulk_update_setup").to_owned(), + vec![], + vec![ + bcs::to_bytes(&alice).unwrap(), + bcs::to_bytes(&bob).unwrap(), + bcs::to_bytes(&carol).unwrap(), + bcs::to_bytes(&sha).unwrap(), + bcs::to_bytes(&ram).unwrap(), + ], + )) +} + +/// Alice can remove Bob as the delegate with this function. +pub fn encode_ol_remove_delegation_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("OracleScripts").to_owned(), + ), + ident_str!("ol_remove_delegation").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Transfers a given number of coins in a specified currency from one account to another. +/// Transfers over a specified amount defined on-chain that are between two different VASPs, or +/// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has +/// agreed to receive the coins. This transaction can be sent by any account that can hold a +/// balance, and to any account that can hold a balance. Both accounts must hold balances in the +/// currency being transacted. +/// +/// # Technical Description +/// +/// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated +/// `metadata` and an (optional) `metadata_signature` on the message of the form +/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`, that +/// has been signed by the `payee`'s private key associated with the `compliance_public_key` held in +/// the `payee`'s `DualAttestation::Credential`. Both the `Signer::address_of(payer)` and `amount` fields +/// in the `metadata_signature` must be BCS-encoded bytes, and `|` denotes concatenation. +/// The `metadata` and `metadata_signature` parameters are only required if `amount` >= +/// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. +/// However, a transaction sender can opt in to dual attestation even when it is not required +/// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. +/// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. +/// +/// # Events +/// Successful execution of this script emits two events: +/// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and +/// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | +/// | `payer` | `signer` | The signer of the sending account that coins are being transferred from. | +/// | `payee` | `address` | The address of the account the coins are being transferred to. | +/// | `metadata` | `vector` | Optional metadata about this payment. | +/// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | +/// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_child_vasp_account` +/// * `AccountCreationScripts::create_parent_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +pub fn encode_peer_to_peer_with_metadata_script_function( + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Vec, + metadata_signature: Vec, +) -> 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!("PaymentScripts").to_owned(), + ), + ident_str!("peer_to_peer_with_metadata").to_owned(), + vec![currency], + vec![ + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&amount).unwrap(), + bcs::to_bytes(&metadata).unwrap(), + bcs::to_bytes(&metadata_signature).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` to the `Diem::Preburn` 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` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` 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 authentication key of the sending account to the newly-specified ed25519 public key and +/// publishes a new shared authentication key derived from that public key under the sender's account. +/// Any account can send this transaction. +/// +/// # Technical Description +/// Rotates the authentication key of the sending account to the +/// [authentication key derived from `public_key`](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) +/// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource +/// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for +/// `account` under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `public_key` | `vector` | A valid 32-byte Ed25519 public key for `account`'s authentication key to be rotated to and stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | +/// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::rotate_shared_ed25519_public_key` +pub fn encode_publish_shared_ed25519_public_key_script_function( + public_key: Vec, +) -> 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!("publish_shared_ed25519_public_key").to_owned(), + vec![], + vec![bcs::to_bytes(&public_key).unwrap()], + )) +} + +/// # Summary +/// Updates a validator's configuration. This does not reconfigure the system and will not update +/// the configuration in the validator set that is seen by other validators in the network. Can +/// only be successfully sent by a Validator Operator account that is already registered with a +/// validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` +/// so the copy of this config held in the validator set will not be updated, and the changes are +/// only "locally" under the `validator_account` account address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `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_register_validator_config_script_function( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("register_validator_config").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_account).unwrap(), + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&validator_network_addresses).unwrap(), + bcs::to_bytes(&fullnode_network_addresses).unwrap(), + ], + )) +} + +/// # Summary +/// Remove a DiemID domain from parent VASP account. The transaction can only be sent by +/// the Treasury Compliance account. +/// +/// # Technical Description +/// Removes a `DiemId::DiemIdDomain` from the `domains` field of the `DiemId::DiemIdDomains` resource published under +/// account with `address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `address` | `address` | The `address` of parent VASP account that will update its domains. | +/// | `domain` | `vector` | The domain name. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_NOT_FOUND` | The `domain` does not exist in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | +pub fn encode_remove_diem_id_domain_script_function( + address: AccountAddress, + domain: Vec, +) -> 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!("remove_diem_id_domain").to_owned(), + vec![], + vec![ + bcs::to_bytes(&address).unwrap(), + bcs::to_bytes(&domain).unwrap(), + ], + )) +} + +/// # Summary +/// This script removes a validator account from the validator set, and triggers a reconfiguration +/// of the system to remove the validator from the system. This transaction can only be +/// successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script removes the account at `validator_address` from the validator set. This transaction +/// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event +/// has been performed, the account at `validator_address` is no longer considered to be a +/// validator in the network. This transaction will fail if the validator at `validator_address` +/// is not in the validator set. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be removed from the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_remove_validator_and_reconfigure_script_function( + sliding_nonce: u64, + validator_name: Vec, + validator_address: 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("remove_validator_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&validator_name).unwrap(), + bcs::to_bytes(&validator_address).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` | 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) -> 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` | 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, +) -> 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` | 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, +) -> 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 +/// Rotates the authentication key of a specified account that is part of a recovery address to a +/// new authentication key. Only used for accounts that are part of a recovery address (see +/// `AccountAdministrationScripts::add_recovery_rotation_capability` for account restrictions). +/// +/// # Technical Description +/// Rotates the authentication key of the `to_recover` account to `new_key` using the +/// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource +/// published under `recovery_address`. `new_key` must be a valide authentication key as described +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). +/// This transaction can be sent either by the `to_recover` account, or by the account where the +/// `RecoveryAddress::RecoveryAddress` resource is published that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account of the transaction. | +/// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | +/// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | +/// | `new_key` | `vector` | New authentication key to be used for the account at the `to_recover` address. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin` +pub fn encode_rotate_authentication_key_with_recovery_address_script_function( + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Vec, +) -> 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_recovery_address").to_owned(), + vec![], + vec![ + bcs::to_bytes(&recovery_address).unwrap(), + bcs::to_bytes(&to_recover).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` | ASCII-encoded url to be used for off-chain communication with `account`. | +/// | `new_key` | `vector` | 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, + new_key: Vec, +) -> 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 +/// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by +/// any account that has previously published a shared ed25519 public key using +/// `AccountAdministrationScripts::publish_shared_ed25519_public_key`. +/// +/// # Technical Description +/// `public_key` must be a valid ed25519 public key. This transaction first rotates the public key stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it +/// rotates the `account`'s authentication key to the new authentication key derived from `public_key` as defined +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) +/// using the `DiemAccount::KeyRotationCapability` stored in `account`'s `SharedEd25519PublicKey::SharedEd25519PublicKey`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::publish_shared_ed25519_public_key` +pub fn encode_rotate_shared_ed25519_public_key_script_function( + public_key: Vec, +) -> 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_shared_ed25519_public_key").to_owned(), + vec![], + vec![bcs::to_bytes(&public_key).unwrap()], + )) +} + +/// # Summary +/// Updates the gas constants stored on chain and used by the VM for gas +/// metering. This transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the on-chain config holding the `DiemVMConfig` and emits a +/// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `global_memory_per_byte_cost` | `u64` | The new cost to read global memory per-byte to be used for gas metering. | +/// | `global_memory_per_byte_write_cost` | `u64` | The new cost to write global memory per-byte to be used for gas metering. | +/// | `min_transaction_gas_units` | `u64` | The new flat minimum amount of gas required for any transaction. | +/// | `large_transaction_cutoff` | `u64` | The new size over which an additional charge will be assessed for each additional byte. | +/// | `intrinsic_gas_per_byte` | `u64` | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`. | +/// | `maximum_number_of_gas_units` | `u64` | The new maximum number of gas units that can be set in a transaction. | +/// | `min_price_per_gas_unit` | `u64` | The new minimum gas price that can be set for a transaction. | +/// | `max_price_per_gas_unit` | `u64` | The new maximum gas price that can be set for a transaction. | +/// | `max_transaction_size_in_bytes` | `u64` | The new maximum size of a transaction that can be processed. | +/// | `gas_unit_scaling_factor` | `u64` | The new scaling factor to use when scaling between external and internal gas units. | +/// | `default_account_size` | `u64` | The new default account size to use when assessing final costs for reads and writes to global storage. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +#[allow(clippy::too_many_arguments)] +pub fn encode_set_gas_constants_script_function( + sliding_nonce: u64, + global_memory_per_byte_cost: u64, + global_memory_per_byte_write_cost: u64, + min_transaction_gas_units: u64, + large_transaction_cutoff: u64, + intrinsic_gas_per_byte: u64, + maximum_number_of_gas_units: u64, + min_price_per_gas_unit: u64, + max_price_per_gas_unit: u64, + max_transaction_size_in_bytes: u64, + gas_unit_scaling_factor: u64, + default_account_size: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("set_gas_constants").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&global_memory_per_byte_cost).unwrap(), + bcs::to_bytes(&global_memory_per_byte_write_cost).unwrap(), + bcs::to_bytes(&min_transaction_gas_units).unwrap(), + bcs::to_bytes(&large_transaction_cutoff).unwrap(), + bcs::to_bytes(&intrinsic_gas_per_byte).unwrap(), + bcs::to_bytes(&maximum_number_of_gas_units).unwrap(), + bcs::to_bytes(&min_price_per_gas_unit).unwrap(), + bcs::to_bytes(&max_price_per_gas_unit).unwrap(), + bcs::to_bytes(&max_transaction_size_in_bytes).unwrap(), + bcs::to_bytes(&gas_unit_scaling_factor).unwrap(), + bcs::to_bytes(&default_account_size).unwrap(), + ], + )) +} + +/// # Summary +/// Updates a validator's configuration, and triggers a reconfiguration of the system to update the +/// validator set with this new validator configuration. Can only be successfully sent by a +/// Validator Operator account that is already registered with a validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to +/// trigger a reconfiguration of the system. This reconfiguration will update the validator set +/// on-chain with the updated `ValidatorConfig::ValidatorConfig`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::register_validator_config` +pub fn encode_set_validator_config_and_reconfigure_script_function( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_config_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_account).unwrap(), + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&validator_network_addresses).unwrap(), + bcs::to_bytes(&fullnode_network_addresses).unwrap(), + ], + )) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by an account with +/// Validator role. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the sending validator account. The account at `operator_account` address must have +/// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` +/// resource published under it. The sending `account` must be a Validator and have a +/// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a +/// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_script_function( + operator_name: Vec, + operator_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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_operator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&operator_name).unwrap(), + bcs::to_bytes(&operator_account).unwrap(), + ], + )) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root +/// account as a write set transaction. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the validator `account`. The account at `operator_account` address must have a +/// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource +/// published under it. The account represented by the `account` signer must be a Validator and +/// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of +/// the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | 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. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_with_nonce_admin_script_function( + sliding_nonce: u64, + operator_name: Vec, + operator_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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_operator_with_nonce_admin").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&operator_name).unwrap(), + bcs::to_bytes(&operator_account).unwrap(), + ], + )) +} + +pub fn encode_set_wallet_type_script_function(type_of: 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!("WalletScripts").to_owned(), + ), + ident_str!("set_wallet_type").to_owned(), + vec![], + vec![bcs::to_bytes(&type_of).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` 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` resource does not exist at `designated_dealer_address`. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` 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 +/// Updates the Diem consensus config that is stored on-chain and is used by the Consensus. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `config` | `vector` | The serialized bytes of consensus config. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +pub fn encode_update_diem_consensus_config_script_function( + sliding_nonce: u64, + config: Vec, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("update_diem_consensus_config").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&config).unwrap(), + ], + )) +} + +/// # Summary +/// Updates the Diem major version that is stored on-chain and is used by the VM. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater +/// than the current major version held on-chain. The VM reads this information and can use it to +/// preserve backwards compatibility with previous major versions of the VM. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | +pub fn encode_update_diem_version_script_function( + sliding_nonce: u64, + major: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("update_diem_version").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&major).unwrap(), + ], + )) +} + +/// # Summary +/// 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. | +/// | `dm_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 `dm_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` | `dm_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `dm_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` 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()], + )) +} + +pub fn encode_val_add_self_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("val_add_self").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to +/// send, receive, and hold `Diem::Diem` 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` 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` published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances. | +/// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY` | A balance for `Currency` is already published under the sending `account`. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::create_parent_vasp_account` +/// * `Script::peer_to_peer_with_metadata` +pub fn encode_add_currency_to_account_script(currency: TypeTag) -> Script { + Script::new( + ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(), + vec![currency], + vec![], + ) +} + +/// # Summary +/// Stores the sending accounts ability to rotate its authentication key with a designated recovery +/// account. Both the sending and recovery accounts need to belong to the same VASP and +/// both be VASP accounts. After this transaction both the sending account and the +/// specified recovery account can rotate the sender account's authentication key. +/// +/// # Technical Description +/// Adds the `DiemAccount::KeyRotationCapability` for the sending account +/// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under +/// `recovery_address`. After this transaction has been executed successfully the account at +/// `recovery_address` and the `to_recover_account` may rotate the authentication key of +/// `to_recover_account` (the sender of this transaction). +/// +/// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key +/// rotation capability, and must be a VASP account. The account at `recovery_address` +/// must also be a VASP account belonging to the same VASP as the `to_recover_account`. +/// Additionally the account at `recovery_address` must have already initialized itself as +/// a recovery account address using the `Script::create_recovery_address` transaction script. +/// +/// The sending account's (`to_recover_account`) key rotation capability is +/// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` +/// resource stored under the account at `recovery_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction. | +/// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | +/// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | +/// +/// # Related Scripts +/// * `Script::create_recovery_address` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_add_recovery_rotation_capability_script(recovery_address: AccountAddress) -> Script { + Script::new( + ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(), + vec![], + vec![TransactionArgument::Address(recovery_address)], + ) +} + +/// # Summary +/// Adds a validator account to the validator set, and triggers a +/// reconfiguration of the system to admit the account to the validator set for the system. This +/// transaction can only be successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script adds the account at `validator_address` to the validator set. +/// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a +/// reconfiguration. Once the reconfiguration triggered by this script's +/// execution has been performed, the account at the `validator_address` is +/// considered to be a validator in the network. +/// +/// This transaction script will fail if the `validator_address` address is already in the validator set +/// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be added to the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_add_validator_and_reconfigure_script( + sliding_nonce: u64, + validator_name: Vec, + validator_address: AccountAddress, +) -> Script { + Script::new( + ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(validator_name), + TransactionArgument::Address(validator_address), + ], + ) +} + +/// # Summary +/// Burns all coins held in the preburn resource at the specified +/// preburn address and removes them from the system. The sending account must +/// be the Treasury Compliance account. +/// The account that holds the preburn resource will normally be a Designated +/// Dealer, but there are no enforced requirements that it be one. +/// +/// # Technical Description +/// This transaction permanently destroys all the coins of `Token` type +/// stored in the `Diem::Preburn` resource published under the +/// `preburn_address` account address. +/// +/// This transaction will only succeed if the sending `account` has a +/// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Token` | Type | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_EMPTY` | The `Diem::Preburn` resource is empty (has a value of 0). | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | +/// +/// # Related Scripts +/// * `Script::burn_txn_fees` +/// * `Script::cancel_burn` +/// * `Script::preburn` +pub fn encode_burn_script( + token: TypeTag, + sliding_nonce: u64, + preburn_address: AccountAddress, +) -> Script { + Script::new( + BURN_CODE.to_vec(), + vec![token], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(preburn_address), + ], + ) +} + +/// # Summary +/// Burns the transaction fees collected in the `CoinType` currency so that the +/// Diem association may reclaim the backing coins off-chain. May only be sent +/// by the Treasury Compliance account. +/// +/// # Technical Description +/// Burns the transaction fees collected in `CoinType` so that the +/// association may reclaim the backing coins. Once this transaction has executed +/// successfully all transaction fees that will have been collected in +/// `CoinType` since the last time this script was called with that specific +/// currency. Both `balance` and `preburn` fields in the +/// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` +/// account address will have a value of 0 after the successful execution of this script. +/// +/// ## Events +/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle +/// held in the `Diem::CurrencyInfo` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | +/// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | +/// +/// # Related Scripts +/// * `Script::burn` +/// * `Script::cancel_burn` +pub fn encode_burn_txn_fees_script(coin_type: TypeTag) -> Script { + Script::new(BURN_TXN_FEES_CODE.to_vec(), vec![coin_type], vec![]) +} + +/// # Summary +/// Cancels and returns all coins held in the preburn area under +/// `preburn_address` and returns the funds to the `preburn_address`'s balance. +/// Can only be successfully sent by an account with Treasury Compliance role. +/// +/// # Technical Description +/// Cancels and returns all coins held in the `Diem::Preburn` resource under the `preburn_address` and +/// return the funds to the `preburn_address` account's `DiemAccount::Balance`. +/// The transaction must be sent by an `account` with a `Diem::BurnCapability` +/// resource published under it. The account at `preburn_address` must have a +/// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes +/// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's +/// `DiemAccount::Balance` 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` +/// resource's `burn_events` published under `0xA550C18`. +/// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s +/// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee` +/// being `preburn_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Token` | Type | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | +/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | The value held in the preburn resource was zero. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds held in the prebun area would exceed the `account`'s account limits. | +/// | `Errors::INVALID_STATE` | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed. | +/// +/// # Related Scripts +/// * `Script::burn_txn_fees` +/// * `Script::burn` +/// * `Script::preburn` +pub fn encode_cancel_burn_script(token: TypeTag, preburn_address: AccountAddress) -> Script { + Script::new( + CANCEL_BURN_CODE.to_vec(), + vec![token], + vec![TransactionArgument::Address(preburn_address)], + ) +} + +/// # Summary +/// Creates a Child VASP account with its parent being the sending account of the transaction. +/// The sender of the transaction must be a Parent VASP account. +/// +/// # Technical Description +/// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of +/// `child_initial_balance` in `CoinType` and an initial authentication key of +/// `auth_key_prefix | child_address`. +/// +/// If `add_all_currencies` is true, the child address will have a zero balance in all available +/// currencies in the system. +/// +/// The new account will be a child account of the transaction sender, which must be a +/// Parent VASP account. The child account will be recorded against the limit of +/// child accounts of the creating Parent VASP account. +/// +/// ## Events +/// Successful execution with a `child_initial_balance` greater than zero will emit: +/// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address, +/// and payee field being `child_address`. This is emitted on the Parent VASP's +/// `DiemAccount::DiemAccount` `sent_events` handle. +/// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address, +/// and payee field being `child_address`. This is emitted on the new Child VASPS's +/// `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | +/// | `parent_vasp` | `&signer` | The signer reference of the sending account. Must be a Parent VASP account. | +/// | `child_address` | `address` | Address of the to-be-created Child VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | +/// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | +/// +/// # Related Scripts +/// * `Script::create_parent_vasp_account` +/// * `Script::add_currency_to_account` +/// * `Script::rotate_authentication_key` +/// * `Script::add_recovery_rotation_capability` +/// * `Script::create_recovery_address` +pub fn encode_create_child_vasp_account_script( + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Vec, + add_all_currencies: bool, + child_initial_balance: u64, +) -> Script { + Script::new( + CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::Address(child_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::Bool(add_all_currencies), + TransactionArgument::U64(child_initial_balance), + ], + ) +} + +/// # Summary +/// Creates a Designated Dealer account with the provided information, and initializes it with +/// default mint tiers. The transaction can only be sent by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Designated Dealer role at `addr` with authentication key +/// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, +/// 0 balances for all available currencies in the system will also be added. This can only be +/// invoked by an account with the TreasuryCompliance role. +/// +/// At the time of creation the account is also initialized with default mint tiers of (500_000, +/// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the +/// account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `addr` | `address` | Address of the to-be-created Designated Dealer account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Designated Dealer. | +/// | `add_all_currencies` | `bool` | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created. | +/// + +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `addr` address is already taken. | +/// +/// # Related Scripts +/// * `Script::tiered_mint` +/// * `Script::peer_to_peer_with_metadata` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_create_designated_dealer_script( + currency: TypeTag, + sliding_nonce: u64, + addr: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + add_all_currencies: bool, +) -> Script { + Script::new( + CREATE_DESIGNATED_DEALER_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(addr), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + TransactionArgument::Bool(add_all_currencies), + ], + ) +} + +/// # Summary +/// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Parent VASP role at `address` with authentication key +/// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If +/// `add_all_currencies` is true, 0 balances for all available currencies in the system will +/// also be added. This can only be invoked by an TreasuryCompliance account. +/// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::add_currency_to_account` +/// * `Script::rotate_authentication_key` +/// * `Script::add_recovery_rotation_capability` +/// * `Script::create_recovery_address` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_create_parent_vasp_account_script( + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + add_all_currencies: bool, +) -> Script { + Script::new( + CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + TransactionArgument::Bool(add_all_currencies), + ], + ) +} + +/// # Summary +/// Initializes the sending account as a recovery address that may be used by +/// the VASP that it belongs to. The sending account must be a VASP account. +/// Multiple recovery addresses can exist for a single VASP, but accounts in +/// each must be disjoint. +/// +/// # Technical Description +/// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then +/// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds +/// it to the resource. After the successful execution of this transaction +/// other accounts may add their key rotation to this resource so that `account` +/// may be used as a recovery account for those accounts. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | +/// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | +/// +/// # Related Scripts +/// * `Script::add_recovery_rotation_capability` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_create_recovery_address_script() -> Script { + Script::new(CREATE_RECOVERY_ADDRESS_CODE.to_vec(), vec![], vec![]) +} + +/// # Summary +/// Creates a Validator account. This transaction can only be sent by the Diem +/// Root account. +/// +/// # Technical Description +/// Creates an account with a Validator role at `new_account_address`, with authentication key +/// `auth_key_prefix` | `new_account_address`. It publishes a +/// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and +/// `operator_account` fields. The `human_name` field of the +/// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. +/// This script does not add the validator to the validator set or the system, +/// but only creates the account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Validator account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the validator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::add_validator_and_reconfigure` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_create_validator_account_script( + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, +) -> Script { + Script::new( + CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + ], + ) +} + +/// # Summary +/// Creates a Validator Operator account. This transaction can only be sent by the Diem +/// Root account. +/// +/// # Technical Description +/// Creates an account with a Validator Operator role at `new_account_address`, with authentication key +/// `auth_key_prefix` | `new_account_address`. It publishes a +/// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`. +/// This script does not assign the validator operator to any validator accounts but only creates the account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Validator account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the validator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_create_validator_operator_account_script( + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, +) -> Script { + Script::new( + CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + ], + ) +} + +/// # Summary +/// Freezes the account at `address`. The sending account of this transaction +/// must be the Treasury Compliance account. The account being frozen cannot be +/// the Diem Root or Treasury Compliance account. After the successful +/// execution of this transaction no transactions may be sent from the frozen +/// account, and the frozen account may not send or receive coins. +/// +/// # Technical Description +/// Sets the `AccountFreezing::FreezingBit` to `true` and emits a +/// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the +/// Treasury Compliance account, but the account at `to_freeze_account` must +/// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the +/// Treasury Compliance address). Note that this is a per-account property +/// e.g., freezing a Parent VASP will not effect the status any of its child +/// accounts and vice versa. +/// + +/// ## Events +/// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on +/// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published +/// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `to_freeze_account` | `address` | The account address to be frozen. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC` | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`). | +/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`). | +/// +/// # Related Scripts +/// * `Script::unfreeze_account` +pub fn encode_freeze_account_script( + sliding_nonce: u64, + to_freeze_account: AccountAddress, +) -> Script { + Script::new( + FREEZE_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(to_freeze_account), + ], + ) +} + +/// # Summary +/// Transfers a given number of coins in a specified currency from one account to another. +/// Transfers over a specified amount defined on-chain that are between two different VASPs, or +/// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has +/// agreed to receive the coins. This transaction can be sent by any account that can hold a +/// balance, and to any account that can hold a balance. Both accounts must hold balances in the +/// currency being transacted. +/// +/// # Technical Description +/// +/// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated +/// `metadata` and an (optional) `metadata_signature` on the message +/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`. +/// The `metadata` and `metadata_signature` parameters are only required if `amount` >= +/// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. +/// However, a transaction sender can opt in to dual attestation even when it is not required +/// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. +/// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. +/// +/// ## Events +/// Successful execution of this script emits two events: +/// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and +/// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | +/// | `payer` | `&signer` | The signer reference of the sending account that coins are being transferred from. | +/// | `payee` | `address` | The address of the account the coins are being transferred to. | +/// | `metadata` | `vector` | Optional metadata about this payment. | +/// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | +/// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::create_parent_vasp_account` +/// * `Script::add_currency_to_account` +pub fn encode_peer_to_peer_with_metadata_script( + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Vec, + metadata_signature: Vec, +) -> Script { + Script::new( + PEER_TO_PEER_WITH_METADATA_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::Address(payee), + TransactionArgument::U64(amount), + TransactionArgument::U8Vector(metadata), + TransactionArgument::U8Vector(metadata_signature), + ], + ) +} + +/// # Summary +/// Moves a specified number of coins in a given currency from the account's +/// balance to its preburn area after which the coins may be burned. This +/// transaction may be sent by any account that holds a balance and preburn area +/// in the specified currency. +/// +/// # Technical Description +/// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s +/// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` resource under the sender is non-zero. | +/// | `Errors::NOT_PUBLISHED` | `Roles::EROLE_ID` | The `account` did not have a role assigned to it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDESIGNATED_DEALER` | The `account` did not have the role of DesignatedDealer. | +/// +/// # Related Scripts +/// * `Script::cancel_burn` +/// * `Script::burn` +/// * `Script::burn_txn_fees` +pub fn encode_preburn_script(token: TypeTag, amount: u64) -> Script { + Script::new( + PREBURN_CODE.to_vec(), + vec![token], + vec![TransactionArgument::U64(amount)], + ) +} + +/// # Summary +/// Rotates the authentication key of the sending account to the +/// newly-specified public key and publishes a new shared authentication key +/// under the sender's account. Any account can send this transaction. +/// +/// # Technical Description +/// Rotates the authentication key of the sending account to `public_key`, +/// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource +/// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for +/// `account` under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | +/// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::rotate_shared_ed25519_public_key` +pub fn encode_publish_shared_ed25519_public_key_script(public_key: Vec) -> Script { + Script::new( + PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(public_key)], + ) +} + +/// # Summary +/// Updates a validator's configuration. This does not reconfigure the system and will not update +/// the configuration in the validator set that is seen by other validators in the network. Can +/// only be successfully sent by a Validator Operator account that is already registered with a +/// validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` +/// so the copy of this config held in the validator set will not be updated, and the changes are +/// only "locally" under the `validator_account` account address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_register_validator_config_script( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> Script { + Script::new( + REGISTER_VALIDATOR_CONFIG_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(validator_account), + TransactionArgument::U8Vector(consensus_pubkey), + TransactionArgument::U8Vector(validator_network_addresses), + TransactionArgument::U8Vector(fullnode_network_addresses), + ], + ) +} + +/// # Summary +/// This script removes a validator account from the validator set, and triggers a reconfiguration +/// of the system to remove the validator from the system. This transaction can only be +/// successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script removes the account at `validator_address` from the validator set. This transaction +/// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event +/// has been performed, the account at `validator_address` is no longer considered to be a +/// validator in the network. This transaction will fail if the validator at `validator_address` +/// is not in the validator set. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be removed from the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_remove_validator_and_reconfigure_script( + sliding_nonce: u64, + validator_name: Vec, + validator_address: AccountAddress, +) -> Script { + Script::new( + REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(validator_name), + TransactionArgument::Address(validator_address), + ], + ) +} + +/// # Summary +/// Rotates the transaction sender's authentication key to the supplied new authentication key. May +/// be sent by any account. +/// +/// # Technical Description +/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_nonce_admin` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_script(new_key: Vec) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(new_key)], + ) +} + +/// # Summary +/// Rotates the sender's authentication key to the supplied new authentication key. May be sent by +/// any account that has a sliding nonce resource published under it (usually this is Treasury +/// Compliance or Diem Root accounts). +/// +/// # Technical Description +/// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce_admin` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_with_nonce_script( + sliding_nonce: u64, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the specified account's authentication key to the supplied new authentication key. May +/// only be sent by the Diem Root account as a write set transaction. +/// +/// # Technical Description +/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | +/// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_with_nonce_admin_script( + sliding_nonce: u64, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the authentication key of a specified account that is part of a recovery address to a +/// new authentication key. Only used for accounts that are part of a recovery address (see +/// `Script::add_recovery_rotation_capability` for account restrictions). +/// +/// # Technical Description +/// Rotates the authentication key of the `to_recover` account to `new_key` using the +/// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource +/// published under `recovery_address`. This transaction can be sent either by the `to_recover` +/// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published +/// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | +/// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | +/// | `new_key` | `vector` | New ed25519 public key to be used for the account at the `to_recover` address. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_nonce_admin` +pub fn encode_rotate_authentication_key_with_recovery_address_script( + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(recovery_address), + TransactionArgument::Address(to_recover), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Updates the url used for off-chain communication, and the public key used to verify dual +/// attestation on-chain. Transaction can be sent by any account that has dual attestation +/// information published under it. In practice the only such accounts are Designated Dealers and +/// Parent VASPs. +/// +/// # Technical Description +/// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` +/// resource published under `account`. The `new_key` must be a valid ed25519 public key. +/// +/// ## Events +/// Successful execution of this transaction emits two events: +/// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and +/// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` +/// `compliance_key_rotation_events` handle published under `account`; and +/// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for +/// off-chain communication, and the blockchain time at which the url was updated emitted on the +/// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | +/// | `new_key` | `vector` | New ed25519 public key to be used for on-chain dual attestation checking. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DualAttestation::ECREDENTIAL` | A `DualAttestation::Credential` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::create_parent_vasp_account` +/// * `Script::create_designated_dealer` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_rotate_dual_attestation_info_script(new_url: Vec, new_key: Vec) -> Script { + Script::new( + ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U8Vector(new_url), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by +/// any account that has previously published a shared ed25519 public key using +/// `Script::publish_shared_ed25519_public_key`. +/// +/// # Technical Description +/// This first rotates the public key stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it +/// rotates the authentication key using the capability stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key` +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::publish_shared_ed25519_public_key` +pub fn encode_rotate_shared_ed25519_public_key_script(public_key: Vec) -> Script { + Script::new( + ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(public_key)], + ) +} + +/// # Summary +/// Updates a validator's configuration, and triggers a reconfiguration of the system to update the +/// validator set with this new validator configuration. Can only be successfully sent by a +/// Validator Operator account that is already registered with a validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to +/// trigger a reconfiguration of the system. This reconfiguration will update the validator set +/// on-chain with the updated `ValidatorConfig::ValidatorConfig`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::register_validator_config` +pub fn encode_set_validator_config_and_reconfigure_script( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> Script { + Script::new( + SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(validator_account), + TransactionArgument::U8Vector(consensus_pubkey), + TransactionArgument::U8Vector(validator_network_addresses), + TransactionArgument::U8Vector(fullnode_network_addresses), + ], + ) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by an account with +/// Validator role. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the sending validator account. The account at `operator_account` address must have +/// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` +/// resource published under it. The sending `account` must be a Validator and have a +/// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a +/// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_script( + operator_name: Vec, + operator_account: AccountAddress, +) -> Script { + Script::new( + SET_VALIDATOR_OPERATOR_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U8Vector(operator_name), + TransactionArgument::Address(operator_account), + ], + ) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root +/// account as a write set transaction. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the validator `account`. The account at `operator_account` address must have a +/// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource +/// published under it. The account represented by the `account` signer must be a Validator and +/// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of +/// the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | +/// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_with_nonce_admin_script( + sliding_nonce: u64, + operator_name: Vec, + operator_account: AccountAddress, +) -> Script { + Script::new( + SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(operator_name), + TransactionArgument::Address(operator_account), + ], + ) +} + +/// # Summary +/// Mints a specified number of coins in a currency to a Designated Dealer. The sending account +/// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer +/// account. +/// +/// # Technical Description +/// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at +/// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to +/// check verify the off-chain approval policy, and is based in part on the on-chain tier values +/// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to +/// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that +/// they support. The sending `tc_account` must be the Treasury Compliance account, and the +/// receiver an authorized Designated Dealer account. +/// +/// ## Events +/// Successful execution of the transaction will emit two events: +/// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the +/// `mint_event_handle` in the stored `Diem::CurrencyInfo` resource stored under +/// `0xA550C18`; and +/// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated +/// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer` +/// resource published under the `designated_dealer_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to. | +/// | `mint_amount` | `u64` | The number of coins to be minted. | +/// | `tier_index` | `u64` | The mint tier index to use for the Designated Dealer account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_MINT_AMOUNT` | `mint_amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DesignatedDealer::EDEALER` | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo` resource does not exist at `designated_dealer_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_TIER_INDEX` | The `tier_index` is out of bounds. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EMINTING_NOT_ALLOWED` | Minting is not currently allowed for `CoinType` coins. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds would exceed the `account`'s account limits. | +/// +/// # Related Scripts +/// * `Script::create_designated_dealer` +/// * `Script::peer_to_peer_with_metadata` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_tiered_mint_script( + coin_type: TypeTag, + sliding_nonce: u64, + designated_dealer_address: AccountAddress, + mint_amount: u64, + tier_index: u64, +) -> Script { + Script::new( + TIERED_MINT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(designated_dealer_address), + TransactionArgument::U64(mint_amount), + TransactionArgument::U64(tier_index), + ], + ) +} + +/// # Summary +/// Unfreezes the account at `address`. The sending account of this transaction must be the +/// Treasury Compliance account. After the successful execution of this transaction transactions +/// may be sent from the previously frozen account, and coins may be sent and received. +/// +/// # Technical Description +/// Sets the `AccountFreezing::FreezingBit` to `false` and emits a +/// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance +/// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect +/// the status any of its child accounts and vice versa. +/// +/// ## Events +/// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with +/// the `unfrozen_address` set the `to_unfreeze_account`'s address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `to_unfreeze_account` | `address` | The account address to be frozen. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// +/// # Related Scripts +/// * `Script::freeze_account` +pub fn encode_unfreeze_account_script( + sliding_nonce: u64, + to_unfreeze_account: AccountAddress, +) -> Script { + Script::new( + UNFREEZE_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(to_unfreeze_account), + ], + ) +} + +/// # Summary +/// Updates the Diem major version that is stored on-chain and is used by the VM. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater +/// than the current major version held on-chain. The VM reads this information and can use it to +/// preserve backwards compatibility with previous major versions of the VM. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | +pub fn encode_update_diem_version_script(sliding_nonce: u64, major: u64) -> Script { + Script::new( + UPDATE_DIEM_VERSION_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(major), + ], + ) +} + +/// # Summary +/// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can +/// only be sent by the Treasury Compliance account. After this transaction all inter-VASP +/// payments over this limit must be checked for dual attestation. +/// +/// # Technical Description +/// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under +/// `0xA550C18`. The amount is set in micro-XDX. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_micro_xdx_limit` | `u64` | The new dual attestation limit to be used on-chain. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// +/// # Related Scripts +/// * `Script::update_exchange_rate` +/// * `Script::update_minting_ability` +pub fn encode_update_dual_attestation_limit_script( + sliding_nonce: u64, + new_micro_xdx_limit: u64, +) -> Script { + Script::new( + UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(new_micro_xdx_limit), + ], + ) +} + +/// # Summary +/// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion +/// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this +/// transaction the updated exchange rate will be used for normalization of gas prices, and for +/// dual attestation checking. +/// +/// # Technical Description +/// Updates the on-chain exchange rate from the given `Currency` to micro-XDX. The exchange rate +/// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction. | +/// | `new_exchange_rate_numerator` | `u64` | The numerator for the new to micro-XDX exchange rate for `Currency`. | +/// | `new_exchange_rate_denominator` | `u64` | The denominator for the new to micro-XDX exchange rate for `Currency`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR` | `new_exchange_rate_denominator` is zero. | +/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | +/// | `Errors::LIMIT_EXCEEDED` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | +/// +/// # Related Scripts +/// * `Script::update_dual_attestation_limit` +/// * `Script::update_minting_ability` +pub fn encode_update_exchange_rate_script( + currency: TypeTag, + sliding_nonce: u64, + new_exchange_rate_numerator: u64, + new_exchange_rate_denominator: u64, +) -> Script { + Script::new( + UPDATE_EXCHANGE_RATE_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(new_exchange_rate_numerator), + TransactionArgument::U64(new_exchange_rate_denominator), + ], + ) +} + +/// # Summary +/// Script to allow or disallow minting of new coins in a specified currency. This transaction can +/// only be sent by the Treasury Compliance account. Turning minting off for a currency will have +/// no effect on coins already in circulation, and coins may still be removed from the system. +/// +/// # Technical Description +/// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo` resource +/// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if +/// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise. +/// This transaction needs to be sent by the Treasury Compliance account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | +/// | `allow_minting` | `bool` | Whether to allow minting of new coins in `Currency`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | `Currency` is not a registered currency on-chain. | +/// +/// # Related Scripts +/// * `Script::update_dual_attestation_limit` +/// * `Script::update_exchange_rate` +pub fn encode_update_minting_ability_script(currency: TypeTag, allow_minting: bool) -> Script { + Script::new( + UPDATE_MINTING_ABILITY_CODE.to_vec(), + vec![currency], + vec![TransactionArgument::Bool(allow_minting)], + ) +} + +fn decode_add_currency_to_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddCurrencyToAccount { + currency: script.ty_args().first()?.clone(), + }) + } else { + None + } +} + +fn decode_add_diem_id_domain_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddDiemIdDomain { + address: bcs::from_bytes(script.args().first()?).ok()?, + domain: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_add_recovery_rotation_capability_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddRecoveryRotationCapability { + recovery_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_add_validator_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddValidatorAndReconfigure { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + validator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_address: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_autopay_create_instruction_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AutopayCreateInstruction { + uid: bcs::from_bytes(script.args().first()?).ok()?, + in_type: bcs::from_bytes(script.args().get(1)?).ok()?, + payee: bcs::from_bytes(script.args().get(2)?).ok()?, + end_epoch: bcs::from_bytes(script.args().get(3)?).ok()?, + value: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_autopay_disable_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::AutopayDisable {}) + } else { + None + } +} + +fn decode_autopay_enable_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::AutopayEnable {}) + } else { + None + } +} + +fn decode_balance_transfer_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::BalanceTransfer { + destination: bcs::from_bytes(script.args().first()?).ok()?, + unscaled_value: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_burn_txn_fees_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::BurnTxnFees { + coin_type: script.ty_args().first()?.clone(), + }) + } else { + None + } +} + +fn decode_burn_with_amount_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::BurnWithAmount { + token: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CancelBurnWithAmount { + token: script.ty_args().first()?.clone(), + preburn_address: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_acc_user_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateAccUser { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + difficulty: bcs::from_bytes(script.args().get(2)?).ok()?, + security: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_acc_val_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateAccVal { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + difficulty: bcs::from_bytes(script.args().get(2)?).ok()?, + security: bcs::from_bytes(script.args().get(3)?).ok()?, + ow_human_name: bcs::from_bytes(script.args().get(4)?).ok()?, + op_address: bcs::from_bytes(script.args().get(5)?).ok()?, + op_auth_key_prefix: bcs::from_bytes(script.args().get(6)?).ok()?, + op_consensus_pubkey: bcs::from_bytes(script.args().get(7)?).ok()?, + op_validator_network_addresses: bcs::from_bytes(script.args().get(8)?).ok()?, + op_fullnode_network_addresses: bcs::from_bytes(script.args().get(9)?).ok()?, + op_human_name: bcs::from_bytes(script.args().get(10)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_child_vasp_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateChildVaspAccount { + coin_type: script.ty_args().first()?.clone(), + child_address: bcs::from_bytes(script.args().first()?).ok()?, + auth_key_prefix: bcs::from_bytes(script.args().get(1)?).ok()?, + add_all_currencies: bcs::from_bytes(script.args().get(2)?).ok()?, + child_initial_balance: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_designated_dealer_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateDesignatedDealer { + currency: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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_diem_id_domains_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::CreateDiemIdDomains {}) + } else { + None + } +} + +fn decode_create_parent_vasp_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateParentVaspAccount { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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()?, + add_all_currencies: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_recovery_address_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::CreateRecoveryAddress {}) + } else { + None + } +} + +fn decode_create_user_by_coin_tx_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateUserByCoinTx { + account: bcs::from_bytes(script.args().first()?).ok()?, + authkey_prefix: bcs::from_bytes(script.args().get(1)?).ok()?, + unscaled_value: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_validator_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateValidatorAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateValidatorOperatorAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).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_demo_e2e_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::DemoE2e { + world: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_freeze_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::FreezeAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + to_freeze_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_initialize_diem_consensus_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::InitializeDiemConsensusConfig { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_join_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::Join {}) + } else { + None + } +} + +fn decode_leave_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::Leave {}) + } else { + None + } +} + +fn decode_minerstate_commit_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::MinerstateCommit { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + difficulty: bcs::from_bytes(script.args().get(2)?).ok()?, + security: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_minerstate_commit_by_operator_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::MinerstateCommitByOperator { + owner_address: bcs::from_bytes(script.args().first()?).ok()?, + challenge: bcs::from_bytes(script.args().get(1)?).ok()?, + solution: bcs::from_bytes(script.args().get(2)?).ok()?, + difficulty: bcs::from_bytes(script.args().get(3)?).ok()?, + security: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_minerstate_helper_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::MinerstateHelper {}) + } else { + None + } +} + +fn decode_ol_delegate_vote_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::OlDelegateVote { + dest: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_ol_enable_delegation_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::OlEnableDelegation {}) + } else { + None + } +} + +fn decode_ol_oracle_tx_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::OlOracleTx { + id: bcs::from_bytes(script.args().first()?).ok()?, + data: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_ol_reconfig_bulk_update_setup_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::OlReconfigBulkUpdateSetup { + alice: bcs::from_bytes(script.args().first()?).ok()?, + bob: bcs::from_bytes(script.args().get(1)?).ok()?, + carol: bcs::from_bytes(script.args().get(2)?).ok()?, + sha: bcs::from_bytes(script.args().get(3)?).ok()?, + ram: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_ol_remove_delegation_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::OlRemoveDelegation {}) + } else { + None + } +} + +fn decode_peer_to_peer_with_metadata_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::PeerToPeerWithMetadata { + currency: script.ty_args().first()?.clone(), + payee: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_signature: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_preburn_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::Preburn { + token: script.ty_args().first()?.clone(), + amount: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_publish_shared_ed25519_public_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::PublishSharedEd25519PublicKey { + public_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_register_validator_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RegisterValidatorConfig { + validator_account: bcs::from_bytes(script.args().first()?).ok()?, + consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_network_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_remove_diem_id_domain_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RemoveDiemIdDomain { + address: bcs::from_bytes(script.args().first()?).ok()?, + domain: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_remove_validator_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RemoveValidatorAndReconfigure { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + validator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_address: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKey { + new_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_with_nonce_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonce { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + new_key: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_with_recovery_address_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some( + ScriptFunctionCall::RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: bcs::from_bytes(script.args().first()?).ok()?, + to_recover: bcs::from_bytes(script.args().get(1)?).ok()?, + new_key: bcs::from_bytes(script.args().get(2)?).ok()?, + }, + ) + } else { + None + } +} + +fn decode_rotate_dual_attestation_info_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateDualAttestationInfo { + new_url: bcs::from_bytes(script.args().first()?).ok()?, + new_key: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_shared_ed25519_public_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateSharedEd25519PublicKey { + public_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_set_gas_constants_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetGasConstants { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + global_memory_per_byte_cost: bcs::from_bytes(script.args().get(1)?).ok()?, + global_memory_per_byte_write_cost: bcs::from_bytes(script.args().get(2)?).ok()?, + min_transaction_gas_units: bcs::from_bytes(script.args().get(3)?).ok()?, + large_transaction_cutoff: bcs::from_bytes(script.args().get(4)?).ok()?, + intrinsic_gas_per_byte: bcs::from_bytes(script.args().get(5)?).ok()?, + maximum_number_of_gas_units: bcs::from_bytes(script.args().get(6)?).ok()?, + min_price_per_gas_unit: bcs::from_bytes(script.args().get(7)?).ok()?, + max_price_per_gas_unit: bcs::from_bytes(script.args().get(8)?).ok()?, + max_transaction_size_in_bytes: bcs::from_bytes(script.args().get(9)?).ok()?, + gas_unit_scaling_factor: bcs::from_bytes(script.args().get(10)?).ok()?, + default_account_size: bcs::from_bytes(script.args().get(11)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_config_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorConfigAndReconfigure { + validator_account: bcs::from_bytes(script.args().first()?).ok()?, + consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_network_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_operator_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorOperator { + operator_name: bcs::from_bytes(script.args().first()?).ok()?, + operator_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_operator_with_nonce_admin_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorOperatorWithNonceAdmin { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + operator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + operator_account: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_wallet_type_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetWalletType { + type_of: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_tiered_mint_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::TieredMint { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UnfreezeAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + to_unfreeze_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_diem_consensus_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDiemConsensusConfig { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + config: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_diem_version_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDiemVersion { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + major: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_dual_attestation_limit_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDualAttestationLimit { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateExchangeRate { + currency: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateMintingAbility { + currency: script.ty_args().first()?.clone(), + allow_minting: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_val_add_self_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::ValAddSelf {}) + } else { + None + } +} + +fn decode_add_currency_to_account_script(script: &Script) -> Option { + Some(ScriptCall::AddCurrencyToAccount { + currency: script.ty_args().first()?.clone(), + }) +} + +fn decode_add_recovery_rotation_capability_script(script: &Script) -> Option { + Some(ScriptCall::AddRecoveryRotationCapability { + recovery_address: decode_address_argument(script.args().first()?.clone())?, + }) +} + +fn decode_add_validator_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::AddValidatorAndReconfigure { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_address: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_burn_script(script: &Script) -> Option { + Some(ScriptCall::Burn { + token: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + preburn_address: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_burn_txn_fees_script(script: &Script) -> Option { + Some(ScriptCall::BurnTxnFees { + coin_type: script.ty_args().first()?.clone(), + }) +} + +fn decode_cancel_burn_script(script: &Script) -> Option { + Some(ScriptCall::CancelBurn { + token: script.ty_args().first()?.clone(), + preburn_address: decode_address_argument(script.args().first()?.clone())?, + }) +} + +fn decode_create_child_vasp_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateChildVaspAccount { + coin_type: script.ty_args().first()?.clone(), + child_address: decode_address_argument(script.args().first()?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(1)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(2)?.clone())?, + child_initial_balance: decode_u64_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_create_designated_dealer_script(script: &Script) -> Option { + Some(ScriptCall::CreateDesignatedDealer { + currency: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + addr: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?, + }) +} + +fn decode_create_parent_vasp_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateParentVaspAccount { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?, + }) +} + +fn decode_create_recovery_address_script(_script: &Script) -> Option { + Some(ScriptCall::CreateRecoveryAddress {}) +} + +fn decode_create_validator_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateValidatorAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_create_validator_operator_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateValidatorOperatorAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_freeze_account_script(script: &Script) -> Option { + Some(ScriptCall::FreezeAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + to_freeze_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_peer_to_peer_with_metadata_script(script: &Script) -> Option { + Some(ScriptCall::PeerToPeerWithMetadata { + currency: script.ty_args().first()?.clone(), + payee: decode_address_argument(script.args().first()?.clone())?, + amount: decode_u64_argument(script.args().get(1)?.clone())?, + metadata: decode_u8vector_argument(script.args().get(2)?.clone())?, + metadata_signature: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_preburn_script(script: &Script) -> Option { + Some(ScriptCall::Preburn { + token: script.ty_args().first()?.clone(), + amount: decode_u64_argument(script.args().first()?.clone())?, + }) +} + +fn decode_publish_shared_ed25519_public_key_script(script: &Script) -> Option { + Some(ScriptCall::PublishSharedEd25519PublicKey { + public_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_register_validator_config_script(script: &Script) -> Option { + Some(ScriptCall::RegisterValidatorConfig { + validator_account: decode_address_argument(script.args().first()?.clone())?, + consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?, + fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_remove_validator_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::RemoveValidatorAndReconfigure { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_address: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKey { + new_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_nonce_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithNonce { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_nonce_admin_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_recovery_address_script( + script: &Script, +) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: decode_address_argument(script.args().first()?.clone())?, + to_recover: decode_address_argument(script.args().get(1)?.clone())?, + new_key: decode_u8vector_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_rotate_dual_attestation_info_script(script: &Script) -> Option { + Some(ScriptCall::RotateDualAttestationInfo { + new_url: decode_u8vector_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_shared_ed25519_public_key_script(script: &Script) -> Option { + Some(ScriptCall::RotateSharedEd25519PublicKey { + public_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_set_validator_config_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorConfigAndReconfigure { + validator_account: decode_address_argument(script.args().first()?.clone())?, + consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?, + fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_set_validator_operator_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorOperator { + operator_name: decode_u8vector_argument(script.args().first()?.clone())?, + operator_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_set_validator_operator_with_nonce_admin_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorOperatorWithNonceAdmin { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + operator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + operator_account: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_tiered_mint_script(script: &Script) -> Option { + Some(ScriptCall::TieredMint { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + designated_dealer_address: decode_address_argument(script.args().get(1)?.clone())?, + mint_amount: decode_u64_argument(script.args().get(2)?.clone())?, + tier_index: decode_u64_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_unfreeze_account_script(script: &Script) -> Option { + Some(ScriptCall::UnfreezeAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + to_unfreeze_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_diem_version_script(script: &Script) -> Option { + Some(ScriptCall::UpdateDiemVersion { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + major: decode_u64_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_dual_attestation_limit_script(script: &Script) -> Option { + Some(ScriptCall::UpdateDualAttestationLimit { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_micro_xdx_limit: decode_u64_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_exchange_rate_script(script: &Script) -> Option { + Some(ScriptCall::UpdateExchangeRate { + currency: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_exchange_rate_numerator: decode_u64_argument(script.args().get(1)?.clone())?, + new_exchange_rate_denominator: decode_u64_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_update_minting_ability_script(script: &Script) -> Option { + Some(ScriptCall::UpdateMintingAbility { + currency: script.ty_args().first()?.clone(), + allow_minting: decode_bool_argument(script.args().first()?.clone())?, + }) +} + +type TransactionScriptDecoderMap = std::collections::HashMap< + Vec, + Box Option + std::marker::Sync + std::marker::Send>, +>; + +static TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy = + once_cell::sync::Lazy::new(|| { + let mut map: TransactionScriptDecoderMap = std::collections::HashMap::new(); + map.insert( + ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(), + Box::new(decode_add_currency_to_account_script), + ); + map.insert( + ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(), + Box::new(decode_add_recovery_rotation_capability_script), + ); + map.insert( + ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_add_validator_and_reconfigure_script), + ); + map.insert(BURN_CODE.to_vec(), Box::new(decode_burn_script)); + map.insert( + BURN_TXN_FEES_CODE.to_vec(), + Box::new(decode_burn_txn_fees_script), + ); + map.insert( + CANCEL_BURN_CODE.to_vec(), + Box::new(decode_cancel_burn_script), + ); + map.insert( + CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_child_vasp_account_script), + ); + map.insert( + CREATE_DESIGNATED_DEALER_CODE.to_vec(), + Box::new(decode_create_designated_dealer_script), + ); + map.insert( + CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_parent_vasp_account_script), + ); + map.insert( + CREATE_RECOVERY_ADDRESS_CODE.to_vec(), + Box::new(decode_create_recovery_address_script), + ); + map.insert( + CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_validator_account_script), + ); + map.insert( + CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_validator_operator_account_script), + ); + map.insert( + FREEZE_ACCOUNT_CODE.to_vec(), + Box::new(decode_freeze_account_script), + ); + map.insert( + PEER_TO_PEER_WITH_METADATA_CODE.to_vec(), + Box::new(decode_peer_to_peer_with_metadata_script), + ); + map.insert(PREBURN_CODE.to_vec(), Box::new(decode_preburn_script)); + map.insert( + PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + Box::new(decode_publish_shared_ed25519_public_key_script), + ); + map.insert( + REGISTER_VALIDATOR_CONFIG_CODE.to_vec(), + Box::new(decode_register_validator_config_script), + ); + map.insert( + REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_remove_validator_and_reconfigure_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_nonce_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_nonce_admin_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_recovery_address_script), + ); + map.insert( + ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(), + Box::new(decode_rotate_dual_attestation_info_script), + ); + map.insert( + ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + Box::new(decode_rotate_shared_ed25519_public_key_script), + ); + map.insert( + SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_set_validator_config_and_reconfigure_script), + ); + map.insert( + SET_VALIDATOR_OPERATOR_CODE.to_vec(), + Box::new(decode_set_validator_operator_script), + ); + map.insert( + SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(), + Box::new(decode_set_validator_operator_with_nonce_admin_script), + ); + map.insert( + TIERED_MINT_CODE.to_vec(), + Box::new(decode_tiered_mint_script), + ); + map.insert( + UNFREEZE_ACCOUNT_CODE.to_vec(), + Box::new(decode_unfreeze_account_script), + ); + map.insert( + UPDATE_DIEM_VERSION_CODE.to_vec(), + Box::new(decode_update_diem_version_script), + ); + map.insert( + UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(), + Box::new(decode_update_dual_attestation_limit_script), + ); + map.insert( + UPDATE_EXCHANGE_RATE_CODE.to_vec(), + Box::new(decode_update_exchange_rate_script), + ); + map.insert( + UPDATE_MINTING_ABILITY_CODE.to_vec(), + Box::new(decode_update_minting_ability_script), + ); + map + }); + +type ScriptFunctionDecoderMap = std::collections::HashMap< + String, + Box< + dyn Fn(&TransactionPayload) -> Option + + std::marker::Sync + + std::marker::Send, + >, +>; + +static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = + 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( + "TreasuryComplianceScriptsadd_diem_id_domain".to_string(), + Box::new(decode_add_diem_id_domain_script_function), + ); + map.insert( + "AccountAdministrationScriptsadd_recovery_rotation_capability".to_string(), + Box::new(decode_add_recovery_rotation_capability_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsadd_validator_and_reconfigure".to_string(), + Box::new(decode_add_validator_and_reconfigure_script_function), + ); + map.insert( + "AutoPayScriptsautopay_create_instruction".to_string(), + Box::new(decode_autopay_create_instruction_script_function), + ); + map.insert( + "AutoPayScriptsautopay_disable".to_string(), + Box::new(decode_autopay_disable_script_function), + ); + map.insert( + "AutoPayScriptsautopay_enable".to_string(), + Box::new(decode_autopay_enable_script_function), + ); + map.insert( + "TransferScriptsbalance_transfer".to_string(), + Box::new(decode_balance_transfer_script_function), + ); + map.insert( + "TreasuryComplianceScriptsburn_txn_fees".to_string(), + Box::new(decode_burn_txn_fees_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( + "AccountScriptscreate_acc_user".to_string(), + Box::new(decode_create_acc_user_script_function), + ); + map.insert( + "AccountScriptscreate_acc_val".to_string(), + Box::new(decode_create_acc_val_script_function), + ); + map.insert( + "AccountCreationScriptscreate_child_vasp_account".to_string(), + Box::new(decode_create_child_vasp_account_script_function), + ); + map.insert( + "AccountCreationScriptscreate_designated_dealer".to_string(), + Box::new(decode_create_designated_dealer_script_function), + ); + map.insert( + "AccountAdministrationScriptscreate_diem_id_domains".to_string(), + Box::new(decode_create_diem_id_domains_script_function), + ); + map.insert( + "AccountCreationScriptscreate_parent_vasp_account".to_string(), + Box::new(decode_create_parent_vasp_account_script_function), + ); + map.insert( + "AccountAdministrationScriptscreate_recovery_address".to_string(), + Box::new(decode_create_recovery_address_script_function), + ); + map.insert( + "AccountScriptscreate_user_by_coin_tx".to_string(), + Box::new(decode_create_user_by_coin_tx_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( + "DemoScriptsdemo_e2e".to_string(), + Box::new(decode_demo_e2e_script_function), + ); + map.insert( + "TreasuryComplianceScriptsfreeze_account".to_string(), + Box::new(decode_freeze_account_script_function), + ); + map.insert( + "SystemAdministrationScriptsinitialize_diem_consensus_config".to_string(), + Box::new(decode_initialize_diem_consensus_config_script_function), + ); + map.insert( + "ValidatorScriptsjoin".to_string(), + Box::new(decode_join_script_function), + ); + map.insert( + "ValidatorScriptsleave".to_string(), + Box::new(decode_leave_script_function), + ); + map.insert( + "TowerStateScriptsminerstate_commit".to_string(), + Box::new(decode_minerstate_commit_script_function), + ); + map.insert( + "TowerStateScriptsminerstate_commit_by_operator".to_string(), + Box::new(decode_minerstate_commit_by_operator_script_function), + ); + map.insert( + "TowerStateScriptsminerstate_helper".to_string(), + Box::new(decode_minerstate_helper_script_function), + ); + map.insert( + "OracleScriptsol_delegate_vote".to_string(), + Box::new(decode_ol_delegate_vote_script_function), + ); + map.insert( + "OracleScriptsol_enable_delegation".to_string(), + Box::new(decode_ol_enable_delegation_script_function), + ); + map.insert( + "OracleScriptsol_oracle_tx".to_string(), + Box::new(decode_ol_oracle_tx_script_function), + ); + map.insert( + "ValidatorScriptsol_reconfig_bulk_update_setup".to_string(), + Box::new(decode_ol_reconfig_bulk_update_setup_script_function), + ); + map.insert( + "OracleScriptsol_remove_delegation".to_string(), + Box::new(decode_ol_remove_delegation_script_function), + ); + map.insert( + "PaymentScriptspeer_to_peer_with_metadata".to_string(), + Box::new(decode_peer_to_peer_with_metadata_script_function), + ); + map.insert( + "TreasuryComplianceScriptspreburn".to_string(), + Box::new(decode_preburn_script_function), + ); + map.insert( + "AccountAdministrationScriptspublish_shared_ed25519_public_key".to_string(), + Box::new(decode_publish_shared_ed25519_public_key_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsregister_validator_config".to_string(), + Box::new(decode_register_validator_config_script_function), + ); + map.insert( + "TreasuryComplianceScriptsremove_diem_id_domain".to_string(), + Box::new(decode_remove_diem_id_domain_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsremove_validator_and_reconfigure".to_string(), + Box::new(decode_remove_validator_and_reconfigure_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_authentication_key_with_recovery_address" + .to_string(), + Box::new(decode_rotate_authentication_key_with_recovery_address_script_function), + ); + map.insert( + "AccountAdministrationScriptsrotate_dual_attestation_info".to_string(), + Box::new(decode_rotate_dual_attestation_info_script_function), + ); + map.insert( + "AccountAdministrationScriptsrotate_shared_ed25519_public_key".to_string(), + Box::new(decode_rotate_shared_ed25519_public_key_script_function), + ); + map.insert( + "SystemAdministrationScriptsset_gas_constants".to_string(), + Box::new(decode_set_gas_constants_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_config_and_reconfigure".to_string(), + Box::new(decode_set_validator_config_and_reconfigure_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_operator".to_string(), + Box::new(decode_set_validator_operator_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_operator_with_nonce_admin".to_string(), + Box::new(decode_set_validator_operator_with_nonce_admin_script_function), + ); + map.insert( + "WalletScriptsset_wallet_type".to_string(), + Box::new(decode_set_wallet_type_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( + "SystemAdministrationScriptsupdate_diem_consensus_config".to_string(), + Box::new(decode_update_diem_consensus_config_script_function), + ); + map.insert( + "SystemAdministrationScriptsupdate_diem_version".to_string(), + Box::new(decode_update_diem_version_script_function), + ); + map.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.insert( + "ValidatorScriptsval_add_self".to_string(), + Box::new(decode_val_add_self_script_function), + ); + map + }); + +fn decode_bool_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::Bool(value) => Some(value), + _ => None, + } +} + +fn decode_u8_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::U8(value) => Some(value), + _ => None, + } +} + +fn decode_u64_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::U64(value) => Some(value), + _ => None, + } +} + +fn decode_address_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::Address(value) => Some(value), + _ => None, + } +} + +fn decode_u8vector_argument(arg: TransactionArgument) -> Option> { + match arg { + TransactionArgument::U8Vector(value) => Some(value), + _ => None, + } +} + +const ADD_CURRENCY_TO_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, + 110, 116, 12, 97, 100, 100, 95, 99, 117, 114, 114, 101, 110, 99, 121, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2, +]; + +const ADD_RECOVERY_ROTATION_CAPABILITY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 15, 7, 33, 106, 8, 139, 1, + 16, 0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 8, 0, 5, 0, 2, + 6, 12, 5, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118, + 101, 114, 121, 65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, + 111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, + 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 23, 97, 100, 100, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 3, + 5, 11, 0, 17, 0, 10, 1, 17, 1, 2, +]; + +const ADD_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 91, 8, 136, 1, 16, 0, 0, + 0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12, + 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, + 111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, + 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, + 95, 110, 97, 109, 101, 13, 97, 100, 100, 95, 118, 97, 108, 105, 100, 97, 116, 111, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10, 3, 17, 1, 11, + 2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10, 3, 17, 2, 2, +]; + +const BURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 17, 7, 34, 45, 8, 79, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 2, 6, 12, 5, 3, 6, 12, 3, 5, + 1, 9, 0, 4, 68, 105, 101, 109, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, + 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, + 116, 4, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 7, 10, + 0, 10, 1, 17, 0, 11, 0, 10, 2, 56, 0, 2, +]; + +const BURN_TXN_FEES_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 14, 84, 114, 97, 110, 115, 97, 99, 116, 105, + 111, 110, 70, 101, 101, 9, 98, 117, 114, 110, 95, 102, 101, 101, 115, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2, +]; + +const CANCEL_BURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 24, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 5, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, + 117, 110, 116, 11, 99, 97, 110, 99, 101, 108, 95, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2, +]; + +const CREATE_CHILD_VASP_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 8, 1, 0, 2, 2, 2, 4, 3, 6, 22, 4, 28, 4, 5, 32, 35, 7, 67, 122, + 8, 189, 1, 16, 6, 205, 1, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 1, 1, 0, 3, 2, 3, 0, 0, 4, 4, 1, 1, + 1, 0, 5, 3, 1, 0, 0, 6, 2, 6, 4, 6, 12, 5, 10, 2, 1, 0, 1, 6, 12, 1, 8, 0, 5, 6, 8, 0, 5, 3, + 10, 2, 10, 2, 5, 6, 12, 5, 10, 2, 1, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, + 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105, 116, + 121, 25, 99, 114, 101, 97, 116, 101, 95, 99, 104, 105, 108, 100, 95, 118, 97, 115, 112, 95, 97, + 99, 99, 111, 117, 110, 116, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100, + 114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95, 102, 114, + 111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, + 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 10, 2, 1, 0, 1, 1, 5, 3, 25, 10, 0, 10, 1, 11, 2, 10, 3, 56, 0, 10, 4, 6, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 3, 10, 5, 22, 11, 0, 17, 1, 12, 5, 14, 5, 10, 1, 10, 4, 7, 0, 7, 0, 56, 1, 11, 5, 17, 3, + 5, 24, 11, 0, 1, 2, +]; + +const CREATE_DESIGNATED_DEALER_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 72, 8, 116, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2, + 1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, + 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, + 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97, + 116, 101, 95, 100, 101, 115, 105, 103, 110, 97, 116, 101, 100, 95, 100, 101, 97, 108, 101, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0, 11, 0, 10, + 2, 11, 3, 11, 4, 10, 5, 56, 0, 2, +]; + +const CREATE_PARENT_VASP_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 74, 8, 118, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2, + 1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, + 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, + 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 26, 99, 114, 101, 97, + 116, 101, 95, 112, 97, 114, 101, 110, 116, 95, 118, 97, 115, 112, 95, 97, 99, 99, 111, 117, + 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0, + 11, 0, 10, 2, 11, 3, 11, 4, 10, 5, 56, 0, 2, +]; + +const CREATE_RECOVERY_ADDRESS_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 12, 7, 30, 90, 8, 120, 16, + 0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 12, 8, 0, 0, 11, + 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118, 101, 114, 121, + 65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, + 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, + 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, + 121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 3, 5, 10, 0, 11, 0, 17, 0, 17, 1, 2, +]; + +const CREATE_VALIDATOR_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 72, 8, 108, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10, + 2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, + 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, + 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105, + 100, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11, 0, 10, 2, 11, 3, 11, 4, 17, 1, 2, +]; + +const CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 81, 8, 117, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10, + 2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, + 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, + 95, 111, 114, 95, 97, 98, 111, 114, 116, 33, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105, + 100, 97, 116, 111, 114, 95, 111, 112, 101, 114, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117, + 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11, + 0, 10, 2, 11, 3, 11, 4, 17, 1, 2, +]; + +const FREEZE_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 66, 8, 94, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99, + 111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110, + 103, 78, 111, 110, 99, 101, 14, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111, 117, 110, + 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, + 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10, 1, 17, 1, + 11, 0, 10, 2, 17, 0, 2, +]; + +const PEER_TO_PEER_WITH_METADATA_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 29, 7, 53, 96, 8, + 149, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12, + 1, 8, 0, 5, 6, 8, 0, 5, 3, 10, 2, 10, 2, 0, 5, 6, 12, 5, 3, 10, 2, 10, 2, 1, 9, 0, 11, 68, 105, + 101, 109, 65, 99, 99, 111, 117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, + 104, 100, 114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95, + 102, 114, 111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, + 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 4, 1, 12, 11, 0, 17, 0, 12, 5, 14, 5, 10, 1, 10, 2, 11, 3, 11, 4, 56, 0, 11, + 5, 17, 2, 2, +]; + +const PREBURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 21, 7, 45, 95, 8, + 140, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12, + 1, 8, 0, 3, 6, 12, 6, 8, 0, 3, 0, 2, 6, 12, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, + 117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105, + 116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, + 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 7, 112, 114, 101, 98, 117, 114, 110, 27, 114, + 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, 99, 97, 112, 97, + 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 4, 1, 10, + 10, 0, 17, 0, 12, 2, 11, 0, 14, 2, 10, 1, 56, 0, 11, 2, 17, 2, 2, +]; + +const PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 31, 8, 44, 16, 0, 0, 0, 1, + 0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80, + 117, 98, 108, 105, 99, 75, 101, 121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2, +]; + +const REGISTER_VALIDATOR_CONFIG_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 11, 7, 18, 27, 8, 45, 16, 0, 0, 0, 1, + 0, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, + 111, 110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 7, 11, 0, 10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 2, +]; + +const REMOVE_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 94, 8, 139, 1, 16, 0, 0, + 0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12, + 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, + 111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, + 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, + 95, 110, 97, 109, 101, 16, 114, 101, 109, 111, 118, 101, 95, 118, 97, 108, 105, 100, 97, 116, + 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10, + 3, 17, 1, 11, 2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10, + 3, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 2, 2, 4, 3, 6, 15, 5, 21, 18, 7, 39, 124, 8, 163, 1, + 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 1, 2, 0, 0, 4, 3, 2, 0, 1, 6, 12, 1, 8, 0, 0, 2, 6, + 8, 0, 10, 2, 2, 6, 12, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 21, 75, + 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121, + 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, + 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115, 116, 111, 114, 101, + 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105, + 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 4, 1, 9, 11, 0, 17, 0, 12, 2, 14, 2, 11, 1, 17, 2, 11, 2, 17, 1, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 23, 7, 51, 159, 1, 8, 210, + 1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2, + 6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 3, 6, 12, 3, 10, 2, 11, 68, 105, 101, 109, + 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, + 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, + 114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116, + 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115, + 116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, + 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 10, 0, 10, 1, 17, 0, 11, 0, 17, 1, 12, 3, 14, 3, 11, 2, 17, + 3, 11, 3, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 25, 7, 53, 159, 1, 8, 212, + 1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2, + 6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 4, 6, 12, 6, 12, 3, 10, 2, 11, 68, 105, 101, + 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, + 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, + 111, 114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, + 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, + 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, + 115, 116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, + 97, 112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, + 104, 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 11, 0, 10, 2, 17, 0, 11, 1, 17, 1, 12, 4, 14, 4, 11, 3, + 17, 3, 11, 4, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 8, 7, 15, 42, 8, 57, 16, 0, 0, 0, 1, + 0, 1, 0, 4, 6, 12, 5, 5, 10, 2, 0, 15, 82, 101, 99, 111, 118, 101, 114, 121, 65, 100, 100, 114, + 101, 115, 115, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105, 99, + 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 6, 11, 0, 10, 1, 10, 2, 11, 3, 17, 0, 2, +]; + +const ROTATE_DUAL_ATTESTATION_INFO_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 10, 5, 12, 13, 7, 25, 61, 8, 86, 16, 0, 0, 0, + 1, 0, 1, 0, 0, 2, 0, 1, 0, 2, 6, 12, 10, 2, 0, 3, 6, 12, 10, 2, 10, 2, 15, 68, 117, 97, 108, + 65, 116, 116, 101, 115, 116, 97, 116, 105, 111, 110, 15, 114, 111, 116, 97, 116, 101, 95, 98, + 97, 115, 101, 95, 117, 114, 108, 28, 114, 111, 116, 97, 116, 101, 95, 99, 111, 109, 112, 108, + 105, 97, 110, 99, 101, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 11, 1, 17, 0, 11, 0, 11, 2, 17, 1, 2, +]; + +const ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 34, 8, 47, 16, 0, 0, 0, 1, + 0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80, + 117, 98, 108, 105, 99, 75, 101, 121, 10, 114, 111, 116, 97, 116, 101, 95, 107, 101, 121, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2, +]; + +const SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 15, 7, 29, 68, 8, 97, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 2, 6, 12, 5, 10, 68, 105, + 101, 109, 83, 121, 115, 116, 101, 109, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, + 110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 29, 117, 112, 100, 97, + 116, 101, 95, 99, 111, 110, 102, 105, 103, 95, 97, 110, 100, 95, 114, 101, 99, 111, 110, 102, + 105, 103, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 10, 10, 0, + 10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 11, 0, 10, 1, 17, 1, 2, +]; + +const SET_VALIDATOR_OPERATOR_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 19, 7, 33, 68, 8, 101, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 3, 0, 1, 5, 1, 10, 2, 2, 6, 12, 5, 0, 3, 6, 12, 10, 2, 5, 2, 1, 3, + 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23, 86, 97, 108, + 105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, + 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101, 12, 115, 101, 116, 95, + 111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 5, + 15, 10, 2, 17, 0, 11, 1, 33, 12, 3, 11, 3, 3, 11, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, + 0, 10, 2, 17, 1, 2, +]; + +const SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 26, 7, 47, 103, 8, 150, 1, 16, 0, 0, + 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 4, 2, 3, 0, 1, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 5, 6, 12, 6, 12, 3, 10, 2, 5, 2, 1, 3, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, + 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23, + 86, 97, 108, 105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110, + 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101, + 12, 115, 101, 116, 95, 111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 5, 6, 18, 11, 0, 10, 2, 17, 0, 10, 4, 17, 1, 11, 3, 33, 12, 5, 11, 5, 3, 14, + 11, 1, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 1, 10, 4, 17, 2, 2, +]; + +const TIERED_MINT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 21, 7, 38, 59, 8, 97, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 4, 6, 12, 5, 3, 3, 5, 6, 12, + 3, 5, 3, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, + 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, + 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 11, 116, 105, 101, 114, 101, 100, 95, 109, + 105, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 9, 10, 0, 10, 1, 17, + 0, 11, 0, 10, 2, 10, 3, 10, 4, 56, 0, 2, +]; + +const UNFREEZE_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 68, 8, 96, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99, + 111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110, + 103, 78, 111, 110, 99, 101, 16, 117, 110, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111, + 117, 110, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10, + 1, 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_DIEM_VERSION_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 51, 8, 75, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 11, 68, 105, 101, 109, 86, + 101, 114, 115, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 3, + 115, 101, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10, + 1, 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_DUAL_ATTESTATION_LIMIT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 71, 8, 95, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 15, 68, 117, 97, 108, 65, 116, + 116, 101, 115, 116, 97, 116, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, + 99, 101, 19, 115, 101, 116, 95, 109, 105, 99, 114, 111, 100, 105, 101, 109, 95, 108, 105, 109, + 105, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, + 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10, 1, + 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_EXCHANGE_RATE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 6, 2, 6, 4, 3, 10, 16, 4, 26, 2, 5, 28, 25, 7, 53, 99, + 8, 152, 1, 16, 0, 0, 0, 1, 0, 2, 1, 1, 2, 0, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 3, 1, 1, 2, + 6, 2, 3, 3, 1, 8, 0, 2, 6, 12, 3, 0, 2, 6, 12, 8, 0, 4, 6, 12, 3, 3, 3, 1, 9, 0, 4, 68, 105, + 101, 109, 12, 70, 105, 120, 101, 100, 80, 111, 105, 110, 116, 51, 50, 12, 83, 108, 105, 100, + 105, 110, 103, 78, 111, 110, 99, 101, 20, 99, 114, 101, 97, 116, 101, 95, 102, 114, 111, 109, + 95, 114, 97, 116, 105, 111, 110, 97, 108, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, + 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 117, 112, 100, 97, 116, 101, 95, 120, + 100, 120, 95, 101, 120, 99, 104, 97, 110, 103, 101, 95, 114, 97, 116, 101, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 1, 11, 10, 0, 10, 1, 17, 1, 10, 2, 10, 3, 17, 0, 12, 4, 11, + 0, 11, 4, 56, 0, 2, +]; + +const UPDATE_MINTING_ABILITY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 28, 8, 46, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 1, 0, 1, 9, 0, 4, 68, 105, 101, 109, 22, 117, 112, 100, + 97, 116, 101, 95, 109, 105, 110, 116, 105, 110, 103, 95, 97, 98, 105, 108, 105, 116, 121, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2, +]; diff --git a/compatibility/src/sdk/v5_2_0_transaction_script_builder.rs b/compatibility/src/sdk/v5_2_0_transaction_script_builder.rs new file mode 100644 index 000000000..7acc45ab6 --- /dev/null +++ b/compatibility/src/sdk/v5_2_0_transaction_script_builder.rs @@ -0,0 +1,9622 @@ +// 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)] +#![allow(dead_code)] +use crate::version_five::{ + language_storage_v5::{ModuleIdV5 as ModuleId, TypeTagV5 as TypeTag}, + legacy_address_v5::LegacyAddressV5 as AccountAddress, + script_v5::{Script, ScriptFunction}, + transaction_argument_v5::TransactionArgument, + transaction_type_v5::TransactionPayload, +}; + +// TODO: are these unchanged? +// use diem_types::{Script, ScriptFunction,}; +use move_core_types::ident_str; +use std::collections::BTreeMap as Map; + +type Bytes = Vec; + +/// Structured representation of a call into a known Move script. +/// ```ignore +/// impl ScriptCall { +/// pub fn encode(self) -> Script { .. } +/// pub fn decode(&Script) -> Option { .. } +/// } +/// ``` + +//////// 0L //////// +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, serde::Deserialize, serde::Serialize)] + +// #[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))] +// #[cfg_attr(feature = "fuzzing", proptest(no_params))] +pub enum ScriptCall { + /// # Summary + /// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to + /// send, receive, and hold `Diem::Diem` 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` 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` published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances. | + /// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY` | A balance for `Currency` is already published under the sending `account`. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::create_parent_vasp_account` + /// * `Script::peer_to_peer_with_metadata` + AddCurrencyToAccount { currency: TypeTag }, + + /// # Summary + /// Stores the sending accounts ability to rotate its authentication key with a designated recovery + /// account. Both the sending and recovery accounts need to belong to the same VASP and + /// both be VASP accounts. After this transaction both the sending account and the + /// specified recovery account can rotate the sender account's authentication key. + /// + /// # Technical Description + /// Adds the `DiemAccount::KeyRotationCapability` for the sending account + /// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under + /// `recovery_address`. After this transaction has been executed successfully the account at + /// `recovery_address` and the `to_recover_account` may rotate the authentication key of + /// `to_recover_account` (the sender of this transaction). + /// + /// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key + /// rotation capability, and must be a VASP account. The account at `recovery_address` + /// must also be a VASP account belonging to the same VASP as the `to_recover_account`. + /// Additionally the account at `recovery_address` must have already initialized itself as + /// a recovery account address using the `Script::create_recovery_address` transaction script. + /// + /// The sending account's (`to_recover_account`) key rotation capability is + /// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` + /// resource stored under the account at `recovery_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction. | + /// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | + /// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | + /// + /// # Related Scripts + /// * `Script::create_recovery_address` + /// * `Script::rotate_authentication_key_with_recovery_address` + AddRecoveryRotationCapability { recovery_address: AccountAddress }, + + /// # Summary + /// Adds a validator account to the validator set, and triggers a + /// reconfiguration of the system to admit the account to the validator set for the system. This + /// transaction can only be successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script adds the account at `validator_address` to the validator set. + /// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a + /// reconfiguration. Once the reconfiguration triggered by this script's + /// execution has been performed, the account at the `validator_address` is + /// considered to be a validator in the network. + /// + /// This transaction script will fail if the `validator_address` address is already in the validator set + /// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be added to the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + AddValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # Summary + /// Burns all coins held in the preburn resource at the specified + /// preburn address and removes them from the system. The sending account must + /// be the Treasury Compliance account. + /// The account that holds the preburn resource will normally be a Designated + /// Dealer, but there are no enforced requirements that it be one. + /// + /// # Technical Description + /// This transaction permanently destroys all the coins of `Token` type + /// stored in the `Diem::Preburn` resource published under the + /// `preburn_address` account address. + /// + /// This transaction will only succeed if the sending `account` has a + /// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Token` | Type | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_EMPTY` | The `Diem::Preburn` resource is empty (has a value of 0). | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | + /// + /// # Related Scripts + /// * `Script::burn_txn_fees` + /// * `Script::cancel_burn` + /// * `Script::preburn` + Burn { + token: TypeTag, + sliding_nonce: u64, + preburn_address: AccountAddress, + }, + + /// # Summary + /// Burns the transaction fees collected in the `CoinType` currency so that the + /// Diem association may reclaim the backing coins off-chain. May only be sent + /// by the Treasury Compliance account. + /// + /// # Technical Description + /// Burns the transaction fees collected in `CoinType` so that the + /// association may reclaim the backing coins. Once this transaction has executed + /// successfully all transaction fees that will have been collected in + /// `CoinType` since the last time this script was called with that specific + /// currency. Both `balance` and `preburn` fields in the + /// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` + /// account address will have a value of 0 after the successful execution of this script. + /// + /// ## Events + /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle + /// held in the `Diem::CurrencyInfo` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | + /// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | + /// + /// # Related Scripts + /// * `Script::burn` + /// * `Script::cancel_burn` + BurnTxnFees { coin_type: TypeTag }, + + /// # Summary + /// Cancels and returns all coins held in the preburn area under + /// `preburn_address` and returns the funds to the `preburn_address`'s balance. + /// Can only be successfully sent by an account with Treasury Compliance role. + /// + /// # Technical Description + /// Cancels and returns all coins held in the `Diem::Preburn` resource under the `preburn_address` and + /// return the funds to the `preburn_address` account's `DiemAccount::Balance`. + /// The transaction must be sent by an `account` with a `Diem::BurnCapability` + /// resource published under it. The account at `preburn_address` must have a + /// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes + /// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's + /// `DiemAccount::Balance` 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` + /// resource's `burn_events` published under `0xA550C18`. + /// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s + /// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee` + /// being `preburn_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Token` | Type | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | + /// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | The value held in the preburn resource was zero. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds held in the prebun area would exceed the `account`'s account limits. | + /// | `Errors::INVALID_STATE` | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed. | + /// + /// # Related Scripts + /// * `Script::burn_txn_fees` + /// * `Script::burn` + /// * `Script::preburn` + CancelBurn { + token: TypeTag, + preburn_address: AccountAddress, + }, + + /// # Summary + /// Creates a Child VASP account with its parent being the sending account of the transaction. + /// The sender of the transaction must be a Parent VASP account. + /// + /// # Technical Description + /// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of + /// `child_initial_balance` in `CoinType` and an initial authentication key of + /// `auth_key_prefix | child_address`. + /// + /// If `add_all_currencies` is true, the child address will have a zero balance in all available + /// currencies in the system. + /// + /// The new account will be a child account of the transaction sender, which must be a + /// Parent VASP account. The child account will be recorded against the limit of + /// child accounts of the creating Parent VASP account. + /// + /// ## Events + /// Successful execution with a `child_initial_balance` greater than zero will emit: + /// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address, + /// and payee field being `child_address`. This is emitted on the Parent VASP's + /// `DiemAccount::DiemAccount` `sent_events` handle. + /// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address, + /// and payee field being `child_address`. This is emitted on the new Child VASPS's + /// `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | + /// | `parent_vasp` | `&signer` | The signer reference of the sending account. Must be a Parent VASP account. | + /// | `child_address` | `address` | Address of the to-be-created Child VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | + /// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | + /// + /// # Related Scripts + /// * `Script::create_parent_vasp_account` + /// * `Script::add_currency_to_account` + /// * `Script::rotate_authentication_key` + /// * `Script::add_recovery_rotation_capability` + /// * `Script::create_recovery_address` + CreateChildVaspAccount { + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Bytes, + add_all_currencies: bool, + child_initial_balance: u64, + }, + + /// # Summary + /// Creates a Designated Dealer account with the provided information, and initializes it with + /// default mint tiers. The transaction can only be sent by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Designated Dealer role at `addr` with authentication key + /// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, + /// 0 balances for all available currencies in the system will also be added. This can only be + /// invoked by an account with the TreasuryCompliance role. + /// + /// At the time of creation the account is also initialized with default mint tiers of (500_000, + /// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the + /// account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `addr` | `address` | Address of the to-be-created Designated Dealer account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Designated Dealer. | + /// | `add_all_currencies` | `bool` | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created. | + /// + + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `addr` address is already taken. | + /// + /// # Related Scripts + /// * `Script::tiered_mint` + /// * `Script::peer_to_peer_with_metadata` + /// * `Script::rotate_dual_attestation_info` + CreateDesignatedDealer { + currency: TypeTag, + sliding_nonce: u64, + addr: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Parent VASP role at `address` with authentication key + /// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If + /// `add_all_currencies` is true, 0 balances for all available currencies in the system will + /// also be added. This can only be invoked by an TreasuryCompliance account. + /// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::add_currency_to_account` + /// * `Script::rotate_authentication_key` + /// * `Script::add_recovery_rotation_capability` + /// * `Script::create_recovery_address` + /// * `Script::rotate_dual_attestation_info` + CreateParentVaspAccount { + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Initializes the sending account as a recovery address that may be used by + /// the VASP that it belongs to. The sending account must be a VASP account. + /// Multiple recovery addresses can exist for a single VASP, but accounts in + /// each must be disjoint. + /// + /// # Technical Description + /// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then + /// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds + /// it to the resource. After the successful execution of this transaction + /// other accounts may add their key rotation to this resource so that `account` + /// may be used as a recovery account for those accounts. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | + /// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | + /// + /// # Related Scripts + /// * `Script::add_recovery_rotation_capability` + /// * `Script::rotate_authentication_key_with_recovery_address` + CreateRecoveryAddress {}, + + /// # Summary + /// Creates a Validator account. This transaction can only be sent by the Diem + /// Root account. + /// + /// # Technical Description + /// Creates an account with a Validator role at `new_account_address`, with authentication key + /// `auth_key_prefix` | `new_account_address`. It publishes a + /// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and + /// `operator_account` fields. The `human_name` field of the + /// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. + /// This script does not add the validator to the validator set or the system, + /// but only creates the account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Validator account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the validator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::add_validator_and_reconfigure` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + CreateValidatorAccount { + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + }, + + /// # Summary + /// Creates a Validator Operator account. This transaction can only be sent by the Diem + /// Root account. + /// + /// # Technical Description + /// Creates an account with a Validator Operator role at `new_account_address`, with authentication key + /// `auth_key_prefix` | `new_account_address`. It publishes a + /// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`. + /// This script does not assign the validator operator to any validator accounts but only creates the account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Validator account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the validator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + CreateValidatorOperatorAccount { + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + }, + + /// # Summary + /// Freezes the account at `address`. The sending account of this transaction + /// must be the Treasury Compliance account. The account being frozen cannot be + /// the Diem Root or Treasury Compliance account. After the successful + /// execution of this transaction no transactions may be sent from the frozen + /// account, and the frozen account may not send or receive coins. + /// + /// # Technical Description + /// Sets the `AccountFreezing::FreezingBit` to `true` and emits a + /// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the + /// Treasury Compliance account, but the account at `to_freeze_account` must + /// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the + /// Treasury Compliance address). Note that this is a per-account property + /// e.g., freezing a Parent VASP will not effect the status any of its child + /// accounts and vice versa. + /// + + /// ## Events + /// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on + /// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published + /// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `to_freeze_account` | `address` | The account address to be frozen. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC` | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`). | + /// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`). | + /// + /// # Related Scripts + /// * `Script::unfreeze_account` + FreezeAccount { + sliding_nonce: u64, + to_freeze_account: AccountAddress, + }, + + /// # Summary + /// Transfers a given number of coins in a specified currency from one account to another. + /// Transfers over a specified amount defined on-chain that are between two different VASPs, or + /// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has + /// agreed to receive the coins. This transaction can be sent by any account that can hold a + /// balance, and to any account that can hold a balance. Both accounts must hold balances in the + /// currency being transacted. + /// + /// # Technical Description + /// + /// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated + /// `metadata` and an (optional) `metadata_signature` on the message + /// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`. + /// The `metadata` and `metadata_signature` parameters are only required if `amount` >= + /// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. + /// However, a transaction sender can opt in to dual attestation even when it is not required + /// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. + /// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. + /// + /// ## Events + /// Successful execution of this script emits two events: + /// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and + /// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | + /// | `payer` | `&signer` | The signer reference of the sending account that coins are being transferred from. | + /// | `payee` | `address` | The address of the account the coins are being transferred to. | + /// | `metadata` | `vector` | Optional metadata about this payment. | + /// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | + /// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | + /// + /// # Related Scripts + /// * `Script::create_child_vasp_account` + /// * `Script::create_parent_vasp_account` + /// * `Script::add_currency_to_account` + PeerToPeerWithMetadata { + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Bytes, + metadata_signature: Bytes, + }, + + /// # Summary + /// Moves a specified number of coins in a given currency from the account's + /// balance to its preburn area after which the coins may be burned. This + /// transaction may be sent by any account that holds a balance and preburn area + /// in the specified currency. + /// + /// # Technical Description + /// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s + /// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` resource under the sender is non-zero. | + /// | `Errors::NOT_PUBLISHED` | `Roles::EROLE_ID` | The `account` did not have a role assigned to it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDESIGNATED_DEALER` | The `account` did not have the role of DesignatedDealer. | + /// + /// # Related Scripts + /// * `Script::cancel_burn` + /// * `Script::burn` + /// * `Script::burn_txn_fees` + Preburn { token: TypeTag, amount: u64 }, + + /// # Summary + /// Rotates the authentication key of the sending account to the + /// newly-specified public key and publishes a new shared authentication key + /// under the sender's account. Any account can send this transaction. + /// + /// # Technical Description + /// Rotates the authentication key of the sending account to `public_key`, + /// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource + /// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for + /// `account` under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | + /// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::rotate_shared_ed25519_public_key` + PublishSharedEd25519PublicKey { public_key: Bytes }, + + /// # Summary + /// Updates a validator's configuration. This does not reconfigure the system and will not update + /// the configuration in the validator set that is seen by other validators in the network. Can + /// only be successfully sent by a Validator Operator account that is already registered with a + /// validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` + /// so the copy of this config held in the validator set will not be updated, and the changes are + /// only "locally" under the `validator_account` account address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + RegisterValidatorConfig { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// This script removes a validator account from the validator set, and triggers a reconfiguration + /// of the system to remove the validator from the system. This transaction can only be + /// successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script removes the account at `validator_address` from the validator set. This transaction + /// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event + /// has been performed, the account at `validator_address` is no longer considered to be a + /// validator in the network. This transaction will fail if the validator at `validator_address` + /// is not in the validator set. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be removed from the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + RemoveValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # Summary + /// Rotates the transaction sender's authentication key to the supplied new authentication key. May + /// be sent by any account. + /// + /// # Technical Description + /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_nonce_admin` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKey { new_key: Bytes }, + + /// # Summary + /// Rotates the sender's authentication key to the supplied new authentication key. May be sent by + /// any account that has a sliding nonce resource published under it (usually this is Treasury + /// Compliance or Diem Root accounts). + /// + /// # Technical Description + /// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce_admin` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKeyWithNonce { sliding_nonce: u64, new_key: Bytes }, + + /// # Summary + /// Rotates the specified account's authentication key to the supplied new authentication key. May + /// only be sent by the Diem Root account as a write set transaction. + /// + /// # Technical Description + /// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. + /// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated + /// its `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | + /// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | + /// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_recovery_address` + RotateAuthenticationKeyWithNonceAdmin { sliding_nonce: u64, new_key: Bytes }, + + /// # Summary + /// Rotates the authentication key of a specified account that is part of a recovery address to a + /// new authentication key. Only used for accounts that are part of a recovery address (see + /// `Script::add_recovery_rotation_capability` for account restrictions). + /// + /// # Technical Description + /// Rotates the authentication key of the `to_recover` account to `new_key` using the + /// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource + /// published under `recovery_address`. This transaction can be sent either by the `to_recover` + /// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published + /// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | + /// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | + /// | `new_key` | `vector` | New ed25519 public key to be used for the account at the `to_recover` address. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `Script::rotate_authentication_key` + /// * `Script::rotate_authentication_key_with_nonce` + /// * `Script::rotate_authentication_key_with_nonce_admin` + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Bytes, + }, + + /// # Summary + /// Updates the url used for off-chain communication, and the public key used to verify dual + /// attestation on-chain. Transaction can be sent by any account that has dual attestation + /// information published under it. In practice the only such accounts are Designated Dealers and + /// Parent VASPs. + /// + /// # Technical Description + /// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` + /// resource published under `account`. The `new_key` must be a valid ed25519 public key. + /// + /// ## Events + /// Successful execution of this transaction emits two events: + /// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and + /// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` + /// `compliance_key_rotation_events` handle published under `account`; and + /// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for + /// off-chain communication, and the blockchain time at which the url was updated emitted on the + /// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account of the transaction. | + /// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | + /// | `new_key` | `vector` | New ed25519 public key to be used for on-chain dual attestation checking. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DualAttestation::ECREDENTIAL` | A `DualAttestation::Credential` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::create_parent_vasp_account` + /// * `Script::create_designated_dealer` + /// * `Script::rotate_dual_attestation_info` + RotateDualAttestationInfo { new_url: Bytes, new_key: Bytes }, + + /// # Summary + /// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by + /// any account that has previously published a shared ed25519 public key using + /// `Script::publish_shared_ed25519_public_key`. + /// + /// # Technical Description + /// This first rotates the public key stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it + /// rotates the authentication key using the capability stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key` + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `Script::publish_shared_ed25519_public_key` + RotateSharedEd25519PublicKey { public_key: Bytes }, + + /// # Summary + /// Updates a validator's configuration, and triggers a reconfiguration of the system to update the + /// validator set with this new validator configuration. Can only be successfully sent by a + /// Validator Operator account that is already registered with a validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to + /// trigger a reconfiguration of the system. This reconfiguration will update the validator set + /// on-chain with the updated `ValidatorConfig::ValidatorConfig`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::register_validator_config` + SetValidatorConfigAndReconfigure { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by an account with + /// Validator role. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the sending validator account. The account at `operator_account` address must have + /// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` + /// resource published under it. The sending `account` must be a Validator and have a + /// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a + /// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | The signer reference of the sending account of the transaction. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator_with_nonce_admin` + /// * `Script::set_validator_config_and_reconfigure` + SetValidatorOperator { + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root + /// account as a write set transaction. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the validator `account`. The account at `operator_account` address must have a + /// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource + /// published under it. The account represented by the `account` signer must be a Validator and + /// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of + /// the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | + /// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `Script::create_validator_account` + /// * `Script::create_validator_operator_account` + /// * `Script::register_validator_config` + /// * `Script::remove_validator_and_reconfigure` + /// * `Script::add_validator_and_reconfigure` + /// * `Script::set_validator_operator` + /// * `Script::set_validator_config_and_reconfigure` + SetValidatorOperatorWithNonceAdmin { + sliding_nonce: u64, + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Mints a specified number of coins in a currency to a Designated Dealer. The sending account + /// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer + /// account. + /// + /// # Technical Description + /// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at + /// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to + /// check verify the off-chain approval policy, and is based in part on the on-chain tier values + /// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to + /// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that + /// they support. The sending `tc_account` must be the Treasury Compliance account, and the + /// receiver an authorized Designated Dealer account. + /// + /// ## Events + /// Successful execution of the transaction will emit two events: + /// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the + /// `mint_event_handle` in the stored `Diem::CurrencyInfo` resource stored under + /// `0xA550C18`; and + /// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated + /// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer` + /// resource published under the `designated_dealer_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to. | + /// | `mint_amount` | `u64` | The number of coins to be minted. | + /// | `tier_index` | `u64` | The mint tier index to use for the Designated Dealer account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_MINT_AMOUNT` | `mint_amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DesignatedDealer::EDEALER` | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo` resource does not exist at `designated_dealer_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_TIER_INDEX` | The `tier_index` is out of bounds. | + /// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EMINTING_NOT_ALLOWED` | Minting is not currently allowed for `CoinType` coins. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds would exceed the `account`'s account limits. | + /// + /// # Related Scripts + /// * `Script::create_designated_dealer` + /// * `Script::peer_to_peer_with_metadata` + /// * `Script::rotate_dual_attestation_info` + TieredMint { + coin_type: TypeTag, + sliding_nonce: u64, + designated_dealer_address: AccountAddress, + mint_amount: u64, + tier_index: u64, + }, + + /// # Summary + /// Unfreezes the account at `address`. The sending account of this transaction must be the + /// Treasury Compliance account. After the successful execution of this transaction transactions + /// may be sent from the previously frozen account, and coins may be sent and received. + /// + /// # Technical Description + /// Sets the `AccountFreezing::FreezingBit` to `false` and emits a + /// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance + /// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect + /// the status any of its child accounts and vice versa. + /// + /// ## Events + /// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with + /// the `unfrozen_address` set the `to_unfreeze_account`'s address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `to_unfreeze_account` | `address` | The account address to be frozen. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// + /// # Related Scripts + /// * `Script::freeze_account` + UnfreezeAccount { + sliding_nonce: u64, + to_unfreeze_account: AccountAddress, + }, + + /// # Summary + /// Updates the Diem major version that is stored on-chain and is used by the VM. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater + /// than the current major version held on-chain. The VM reads this information and can use it to + /// preserve backwards compatibility with previous major versions of the VM. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | + UpdateDiemVersion { sliding_nonce: u64, major: u64 }, + + /// # Summary + /// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can + /// only be sent by the Treasury Compliance account. After this transaction all inter-VASP + /// payments over this limit must be checked for dual attestation. + /// + /// # Technical Description + /// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under + /// `0xA550C18`. The amount is set in micro-XDX. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_micro_xdx_limit` | `u64` | The new dual attestation limit to be used on-chain. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// + /// # Related Scripts + /// * `Script::update_exchange_rate` + /// * `Script::update_minting_ability` + UpdateDualAttestationLimit { + sliding_nonce: u64, + new_micro_xdx_limit: u64, + }, + + /// # Summary + /// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion + /// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this + /// transaction the updated exchange rate will be used for normalization of gas prices, and for + /// dual attestation checking. + /// + /// # Technical Description + /// Updates the on-chain exchange rate from the given `Currency` to micro-XDX. The exchange rate + /// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. | + /// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction. | + /// | `new_exchange_rate_numerator` | `u64` | The numerator for the new to micro-XDX exchange rate for `Currency`. | + /// | `new_exchange_rate_denominator` | `u64` | The denominator for the new to micro-XDX exchange rate for `Currency`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR` | `new_exchange_rate_denominator` is zero. | + /// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | + /// | `Errors::LIMIT_EXCEEDED` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | + /// + /// # Related Scripts + /// * `Script::update_dual_attestation_limit` + /// * `Script::update_minting_ability` + UpdateExchangeRate { + currency: TypeTag, + sliding_nonce: u64, + new_exchange_rate_numerator: u64, + new_exchange_rate_denominator: u64, + }, + + /// # Summary + /// Script to allow or disallow minting of new coins in a specified currency. This transaction can + /// only be sent by the Treasury Compliance account. Turning minting off for a currency will have + /// no effect on coins already in circulation, and coins may still be removed from the system. + /// + /// # Technical Description + /// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo` resource + /// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if + /// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise. + /// This transaction needs to be sent by the Treasury Compliance account. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. | + /// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | + /// | `allow_minting` | `bool` | Whether to allow minting of new coins in `Currency`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | `Currency` is not a registered currency on-chain. | + /// + /// # Related Scripts + /// * `Script::update_dual_attestation_limit` + /// * `Script::update_exchange_rate` + UpdateMintingAbility { + currency: TypeTag, + allow_minting: bool, + }, +} + +/// Structured representation of a call into a known Move script function. +/// ```ignore +/// impl ScriptFunctionCall { +/// pub fn encode(self) -> TransactionPayload { .. } +/// pub fn decode(&TransactionPayload) -> Option { .. } +/// } +/// ``` +#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, serde::Deserialize, serde::Serialize)] +// #[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` 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` 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` 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 + /// Add a DiemID domain to parent VASP account. The transaction can only be sent by + /// the Treasury Compliance account. + /// + /// # Technical Description + /// Adds a `DiemId::DiemIdDomain` to the `domains` field of the `DiemId::DiemIdDomains` resource published under + /// the account at `address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `address` | `address` | The `address` of the parent VASP account that will have have `domain` added to its domains. | + /// | `domain` | `vector` | The domain to be added. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_ALREADY_EXISTS` | The `domain` already exists in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | + AddDiemIdDomain { + address: AccountAddress, + domain: Bytes, + }, + + /// # Summary + /// Stores the sending accounts ability to rotate its authentication key with a designated recovery + /// account. Both the sending and recovery accounts need to belong to the same VASP and + /// both be VASP accounts. After this transaction both the sending account and the + /// specified recovery account can rotate the sender account's authentication key. + /// + /// # Technical Description + /// Adds the `DiemAccount::KeyRotationCapability` for the sending account + /// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under + /// `recovery_address`. After this transaction has been executed successfully the account at + /// `recovery_address` and the `to_recover_account` may rotate the authentication key of + /// `to_recover_account` (the sender of this transaction). + /// + /// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key + /// rotation capability, and must be a VASP account. The account at `recovery_address` + /// must also be a VASP account belonging to the same VASP as the `to_recover_account`. + /// Additionally the account at `recovery_address` must have already initialized itself as + /// a recovery account address using the `AccountAdministrationScripts::create_recovery_address` transaction script. + /// + /// The sending account's (`to_recover_account`) key rotation capability is + /// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` + /// resource stored under the account at `recovery_address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `to_recover_account` | `signer` | The signer of the sending account of this transaction. | + /// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | + /// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::create_recovery_address` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address` + AddRecoveryRotationCapability { + recovery_address: AccountAddress, + }, + + /// # Summary + /// Adds a validator account to the validator set, and triggers a + /// reconfiguration of the system to admit the account to the validator set for the system. This + /// transaction can only be successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script adds the account at `validator_address` to the validator set. + /// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a + /// reconfiguration. Once the reconfiguration triggered by this script's + /// execution has been performed, the account at the `validator_address` is + /// considered to be a validator in the network. + /// + /// This transaction script will fail if the `validator_address` address is already in the validator set + /// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be added to the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemSystem::EMAX_VALIDATORS` | The validator set is already at its maximum size. The validator could not be added. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `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` + AddValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + AutopayCreateInstruction { + uid: u64, + in_type: u8, + payee: AccountAddress, + end_epoch: u64, + value: u64, + }, + + AutopayDisable {}, + + AutopayEnable {}, + + /// # Summary + /// Burns the transaction fees collected in the `CoinType` currency so that the + /// Diem association may reclaim the backing coins off-chain. May only be sent + /// by the Treasury Compliance account. + /// + /// # Technical Description + /// Burns the transaction fees collected in `CoinType` so that the + /// association may reclaim the backing coins. Once this transaction has executed + /// successfully all transaction fees that will have been collected in + /// `CoinType` since the last time this script was called with that specific + /// currency. Both `balance` and `preburn` fields in the + /// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` + /// account address will have a value of 0 after the successful execution of this script. + /// + /// # Events + /// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle + /// held in the `Diem::CurrencyInfo` resource's `burn_events` published under + /// `0xA550C18`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | + /// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | + /// + /// # Related Scripts + /// * `TreasuryComplianceScripts::burn_with_amount` + /// * `TreasuryComplianceScripts::cancel_burn_with_amount` + BurnTxnFees { + coin_type: 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` resource published under the + /// `preburn_address` account address. + /// + /// This transaction will only succeed if the sending `account` has a + /// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` 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` published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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` resource under the `preburn_address` and + /// return the funds to the `preburn_address` account's `DiemAccount::Balance`. + /// The transaction must be sent by an `account` with a `Diem::BurnCapability` + /// resource published under it. The account at `preburn_address` must have a + /// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes + /// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's + /// `DiemAccount::Balance` 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` + /// 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` published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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, + }, + + CreateAccUser { + challenge: Bytes, + solution: Bytes, + }, + + CreateAccVal { + challenge: Bytes, + solution: Bytes, + ow_human_name: Bytes, + op_address: AccountAddress, + op_auth_key_prefix: Bytes, + op_consensus_pubkey: Bytes, + op_validator_network_addresses: Bytes, + op_fullnode_network_addresses: Bytes, + op_human_name: Bytes, + }, + + /// # Summary + /// Creates a Child VASP account with its parent being the sending account of the transaction. + /// The sender of the transaction must be a Parent VASP account. + /// + /// # Technical Description + /// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of + /// `child_initial_balance` in `CoinType` and an initial authentication key of + /// `auth_key_prefix | child_address`. Authentication key prefixes, and how to construct them from an ed25519 public key is described + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). + /// + /// If `add_all_currencies` is true, the child address will have a zero balance in all available + /// currencies in the system. + /// + /// The new account will be a child account of the transaction sender, which must be a + /// Parent VASP account. The child account will be recorded against the limit of + /// child accounts of the creating Parent VASP account. + /// + /// # Events + /// Successful execution will emit: + /// * A `DiemAccount::CreateAccountEvent` with the `created` field being `child_address`, + /// and the `rold_id` field being `Roles::CHILD_VASP_ROLE_ID`. This is emitted on the + /// `DiemAccount::AccountOperationsCapability` `creation_events` handle. + /// + /// Successful execution with a `child_initial_balance` greater than zero will additionaly emit: + /// * A `DiemAccount::SentPaymentEvent` with the `payee` field being `child_address`. + /// This is emitted on the Parent VASP's `DiemAccount::DiemAccount` `sent_events` handle. + /// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address. + /// This is emitted on the new Child VASPS's `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | + /// | `parent_vasp` | `signer` | The reference of the sending account. Must be a Parent VASP account. | + /// | `child_address` | `address` | Address of the to-be-created Child VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | + /// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_parent_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::add_recovery_rotation_capability` + /// * `AccountAdministrationScripts::create_recovery_address` + CreateChildVaspAccount { + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Bytes, + add_all_currencies: bool, + child_initial_balance: u64, + }, + + /// # Summary + /// Creates a Designated Dealer account with the provided information, and initializes it with + /// default mint tiers. The transaction can only be sent by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Designated Dealer role at `addr` with authentication key + /// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, + /// 0 balances for all available currencies in the system will also be added. This can only be + /// invoked by an account with the TreasuryCompliance role. + /// 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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, + }, + + /// # Summary + /// Publishes a `DiemId::DiemIdDomains` resource under a parent VASP account. + /// The sending account must be a parent VASP account. + /// + /// # Technical Description + /// Publishes a `DiemId::DiemIdDomains` resource under `account`. + /// The The `DiemId::DiemIdDomains` resource's `domains` field is a vector + /// of DiemIdDomain, and will be empty on at the end of processing this transaction. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::ALREADY_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN` | A `DiemId::DiemIdDomains` resource has already been published under `account`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending `account` was not a parent VASP account. | + CreateDiemIdDomains {}, + + /// # Summary + /// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. + /// + /// # Technical Description + /// Creates an account with the Parent VASP role at `address` with authentication key + /// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If + /// `add_all_currencies` is true, 0 balances for all available currencies in the system will + /// also be added. This can only be invoked by an TreasuryCompliance account. + /// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. + /// 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::PARENT_VASP_ROLE_ID`. This is emitted on the + /// `DiemAccount::AccountOperationsCapability` `creation_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | + /// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | + /// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | + /// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_child_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::add_recovery_rotation_capability` + /// * `AccountAdministrationScripts::create_recovery_address` + /// * `AccountAdministrationScripts::rotate_dual_attestation_info` + CreateParentVaspAccount { + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Bytes, + human_name: Bytes, + add_all_currencies: bool, + }, + + /// # Summary + /// Initializes the sending account as a recovery address that may be used by + /// other accounts belonging to the same VASP as `account`. + /// The sending account must be a VASP account, and can be either a child or parent VASP account. + /// Multiple recovery addresses can exist for a single VASP, but accounts in + /// each must be disjoint. + /// + /// # Technical Description + /// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then + /// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds + /// it to the resource. After the successful execution of this transaction + /// other accounts may add their key rotation to this resource so that `account` + /// may be used as a recovery account for those accounts. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | + /// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | + /// + /// # Related Scripts + /// * `Script::add_recovery_rotation_capability` + /// * `Script::rotate_authentication_key_with_recovery_address` + CreateRecoveryAddress {}, + + /// # Summary + /// Creates a Validator account. This transaction can only be sent by the Diem + /// Root account. + /// + /// # Technical Description + /// Creates an account with a Validator role at `new_account_address`, with authentication key + /// `auth_key_prefix` | `new_account_address`. It publishes a + /// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and + /// `operator_account` fields. The `human_name` field of the + /// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. + /// This script does not add the validator to the validator set or the system, + /// but only creates the account. + /// 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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` | The authentication key prefix that will be used initially for the newly created account. | + /// | `human_name` | `vector` | 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, + }, + + DemoE2e { + world: u64, + }, + + /// # 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, + }, + + /// # Summary + /// Initializes the Diem consensus config that is stored on-chain. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via + /// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + InitializeDiemConsensusConfig { + sliding_nonce: u64, + }, + + Join {}, + + Leave {}, + + MinerstateCommit { + challenge: Bytes, + solution: Bytes, + }, + + MinerstateCommitByOperator { + owner_address: AccountAddress, + challenge: Bytes, + solution: Bytes, + }, + + MinerstateHelper {}, + + OlOracleTx { + id: u64, + data: Bytes, + }, + + OlReconfigBulkUpdateSetup { + alice: AccountAddress, + bob: AccountAddress, + carol: AccountAddress, + sha: AccountAddress, + ram: AccountAddress, + }, + + /// # Summary + /// Transfers a given number of coins in a specified currency from one account to another. + /// Transfers over a specified amount defined on-chain that are between two different VASPs, or + /// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has + /// agreed to receive the coins. This transaction can be sent by any account that can hold a + /// balance, and to any account that can hold a balance. Both accounts must hold balances in the + /// currency being transacted. + /// + /// # Technical Description + /// + /// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated + /// `metadata` and an (optional) `metadata_signature` on the message of the form + /// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`, that + /// has been signed by the `payee`'s private key associated with the `compliance_public_key` held in + /// the `payee`'s `DualAttestation::Credential`. Both the `Signer::address_of(payer)` and `amount` fields + /// in the `metadata_signature` must be BCS-encoded bytes, and `|` denotes concatenation. + /// The `metadata` and `metadata_signature` parameters are only required if `amount` >= + /// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. + /// However, a transaction sender can opt in to dual attestation even when it is not required + /// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. + /// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. + /// + /// # Events + /// Successful execution of this script emits two events: + /// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and + /// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | + /// | `payer` | `signer` | The signer of the sending account that coins are being transferred from. | + /// | `payee` | `address` | The address of the account the coins are being transferred to. | + /// | `metadata` | `vector` | Optional metadata about this payment. | + /// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | + /// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | + /// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | + /// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | + /// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_child_vasp_account` + /// * `AccountCreationScripts::create_parent_vasp_account` + /// * `AccountAdministrationScripts::add_currency_to_account` + PeerToPeerWithMetadata { + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Bytes, + metadata_signature: Bytes, + }, + + /// # Summary + /// Moves a specified number of coins in a given currency from the account's + /// balance to its preburn area after which the coins may be burned. This + /// transaction may be sent by any account that holds a balance and preburn area + /// in the specified currency. + /// + /// # Technical Description + /// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s + /// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | + /// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` 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 authentication key of the sending account to the newly-specified ed25519 public key and + /// publishes a new shared authentication key derived from that public key under the sender's account. + /// Any account can send this transaction. + /// + /// # Technical Description + /// Rotates the authentication key of the sending account to the + /// [authentication key derived from `public_key`](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) + /// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource + /// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for + /// `account` under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `public_key` | `vector` | A valid 32-byte Ed25519 public key for `account`'s authentication key to be rotated to and stored. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | + /// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::rotate_shared_ed25519_public_key` + PublishSharedEd25519PublicKey { + public_key: Bytes, + }, + + /// # Summary + /// Updates a validator's configuration. This does not reconfigure the system and will not update + /// the configuration in the validator set that is seen by other validators in the network. Can + /// only be successfully sent by a Validator Operator account that is already registered with a + /// validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` + /// so the copy of this config held in the validator set will not be updated, and the changes are + /// only "locally" under the `validator_account` account address. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + RegisterValidatorConfig { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Remove a DiemID domain from parent VASP account. The transaction can only be sent by + /// the Treasury Compliance account. + /// + /// # Technical Description + /// Removes a `DiemId::DiemIdDomain` from the `domains` field of the `DiemId::DiemIdDomains` resource published under + /// account with `address`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | + /// | `address` | `address` | The `address` of parent VASP account that will update its domains. | + /// | `domain` | `vector` | The domain name. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | + /// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_NOT_FOUND` | The `domain` does not exist in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | + RemoveDiemIdDomain { + address: AccountAddress, + domain: Bytes, + }, + + /// # Summary + /// This script removes a validator account from the validator set, and triggers a reconfiguration + /// of the system to remove the validator from the system. This transaction can only be + /// successfully called by the Diem Root account. + /// + /// # Technical Description + /// This script removes the account at `validator_address` from the validator set. This transaction + /// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event + /// has been performed, the account at `validator_address` is no longer considered to be a + /// validator in the network. This transaction will fail if the validator at `validator_address` + /// is not in the validator set. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | + /// | `validator_address` | `address` | The validator account address to be removed from the validator set. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | + /// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + RemoveValidatorAndReconfigure { + sliding_nonce: u64, + validator_name: Bytes, + validator_address: AccountAddress, + }, + + /// # 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` | 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` | 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` | 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 + /// Rotates the authentication key of a specified account that is part of a recovery address to a + /// new authentication key. Only used for accounts that are part of a recovery address (see + /// `AccountAdministrationScripts::add_recovery_rotation_capability` for account restrictions). + /// + /// # Technical Description + /// Rotates the authentication key of the `to_recover` account to `new_key` using the + /// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource + /// published under `recovery_address`. `new_key` must be a valide authentication key as described + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). + /// This transaction can be sent either by the `to_recover` account, or by the account where the + /// `RecoveryAddress::RecoveryAddress` resource is published that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account of the transaction. | + /// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | + /// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | + /// | `new_key` | `vector` | New authentication key to be used for the account at the `to_recover` address. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | + /// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | + /// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::rotate_authentication_key` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce` + /// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin` + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Bytes, + }, + + /// # Summary + /// Updates the url used for off-chain communication, and the public key used to verify dual + /// attestation on-chain. Transaction can be sent by any account that has dual attestation + /// information published under it. In practice the only such accounts are Designated Dealers and + /// Parent VASPs. + /// + /// # Technical Description + /// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` + /// resource published under `account`. The `new_key` must be a valid ed25519 public key. + /// + /// # Events + /// Successful execution of this transaction emits two events: + /// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and + /// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` + /// `compliance_key_rotation_events` handle published under `account`; and + /// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for + /// off-chain communication, and the blockchain time at which the url was updated emitted on the + /// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account of the transaction. | + /// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | + /// | `new_key` | `vector` | 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 + /// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by + /// any account that has previously published a shared ed25519 public key using + /// `AccountAdministrationScripts::publish_shared_ed25519_public_key`. + /// + /// # Technical Description + /// `public_key` must be a valid ed25519 public key. This transaction first rotates the public key stored in `account`'s + /// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it + /// rotates the `account`'s authentication key to the new authentication key derived from `public_key` as defined + /// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) + /// using the `DiemAccount::KeyRotationCapability` stored in `account`'s `SharedEd25519PublicKey::SharedEd25519PublicKey`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `public_key` | `vector` | 32-byte Ed25519 public key. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | + /// + /// # Related Scripts + /// * `AccountAdministrationScripts::publish_shared_ed25519_public_key` + RotateSharedEd25519PublicKey { + public_key: Bytes, + }, + + /// # Summary + /// Updates the gas constants stored on chain and used by the VM for gas + /// metering. This transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the on-chain config holding the `DiemVMConfig` and emits a + /// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `global_memory_per_byte_cost` | `u64` | The new cost to read global memory per-byte to be used for gas metering. | + /// | `global_memory_per_byte_write_cost` | `u64` | The new cost to write global memory per-byte to be used for gas metering. | + /// | `min_transaction_gas_units` | `u64` | The new flat minimum amount of gas required for any transaction. | + /// | `large_transaction_cutoff` | `u64` | The new size over which an additional charge will be assessed for each additional byte. | + /// | `intrinsic_gas_per_byte` | `u64` | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`. | + /// | `maximum_number_of_gas_units` | `u64` | The new maximum number of gas units that can be set in a transaction. | + /// | `min_price_per_gas_unit` | `u64` | The new minimum gas price that can be set for a transaction. | + /// | `max_price_per_gas_unit` | `u64` | The new maximum gas price that can be set for a transaction. | + /// | `max_transaction_size_in_bytes` | `u64` | The new maximum size of a transaction that can be processed. | + /// | `gas_unit_scaling_factor` | `u64` | The new scaling factor to use when scaling between external and internal gas units. | + /// | `default_account_size` | `u64` | The new default account size to use when assessing final costs for reads and writes to global storage. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + SetGasConstants { + sliding_nonce: u64, + global_memory_per_byte_cost: u64, + global_memory_per_byte_write_cost: u64, + min_transaction_gas_units: u64, + large_transaction_cutoff: u64, + intrinsic_gas_per_byte: u64, + maximum_number_of_gas_units: u64, + min_price_per_gas_unit: u64, + max_price_per_gas_unit: u64, + max_transaction_size_in_bytes: u64, + gas_unit_scaling_factor: u64, + default_account_size: u64, + }, + + /// # Summary + /// Updates a validator's configuration, and triggers a reconfiguration of the system to update the + /// validator set with this new validator configuration. Can only be successfully sent by a + /// Validator Operator account that is already registered with a validator. + /// + /// # Technical Description + /// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` + /// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to + /// trigger a reconfiguration of the system. This reconfiguration will update the validator set + /// on-chain with the updated `ValidatorConfig::ValidatorConfig`. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | + /// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | + /// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | + /// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::register_validator_config` + SetValidatorConfigAndReconfigure { + validator_account: AccountAddress, + consensus_pubkey: Bytes, + validator_network_addresses: Bytes, + fullnode_network_addresses: Bytes, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by an account with + /// Validator role. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the sending validator account. The account at `operator_account` address must have + /// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` + /// resource published under it. The sending `account` must be a Validator and have a + /// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a + /// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | The signer of the sending account of the transaction. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + SetValidatorOperator { + operator_name: Bytes, + operator_account: AccountAddress, + }, + + /// # Summary + /// Sets the validator operator for a validator in the validator's configuration resource "locally" + /// and does not reconfigure the system. Changes from this transaction will not picked up by the + /// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root + /// account as a write set transaction. + /// + /// # Technical Description + /// Sets the account at `operator_account` address and with the specified `human_name` as an + /// operator for the validator `account`. The account at `operator_account` address must have a + /// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource + /// published under it. The account represented by the `account` signer must be a Validator and + /// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of + /// the system is initiated by this script. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `dr_account` | `signer` | 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. | + /// | `operator_name` | `vector` | Validator operator's human name. | + /// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | + /// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | + /// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | + /// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | + /// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | + /// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | + /// + /// # Related Scripts + /// * `AccountCreationScripts::create_validator_account` + /// * `AccountCreationScripts::create_validator_operator_account` + /// * `ValidatorAdministrationScripts::register_validator_config` + /// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` + /// * `ValidatorAdministrationScripts::set_validator_operator` + /// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` + SetValidatorOperatorWithNonceAdmin { + sliding_nonce: u64, + operator_name: Bytes, + operator_account: AccountAddress, + }, + + SetWalletType { + type_of: u8, + }, + + /// # 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` 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` resource does not exist at `designated_dealer_address`. | + /// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` 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 + /// Updates the Diem consensus config that is stored on-chain and is used by the Consensus. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `config` | `vector` | The serialized bytes of consensus config. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + UpdateDiemConsensusConfig { + sliding_nonce: u64, + config: Bytes, + }, + + /// # Summary + /// Updates the Diem major version that is stored on-chain and is used by the VM. This + /// transaction can only be sent from the Diem Root account. + /// + /// # Technical Description + /// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger + /// a reconfiguration of the system. The `major` version that is passed in must be strictly greater + /// than the current major version held on-chain. The VM reads this information and can use it to + /// preserve backwards compatibility with previous major versions of the VM. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | + /// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | + /// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | + /// + /// # Common Abort Conditions + /// | Error Category | Error Reason | Description | + /// | ---------------- | -------------- | ------------- | + /// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | + /// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | + /// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | + /// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | + UpdateDiemVersion { + sliding_nonce: u64, + major: u64, + }, + + /// # Summary + /// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can + /// only be sent by the Treasury Compliance account. After this transaction all inter-VASP + /// payments over this limit must be checked for dual attestation. + /// + /// # Technical Description + /// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under + /// `0xA550C18`. The amount is set in micro-XDX. + /// + /// # Parameters + /// | Name | Type | Description | + /// | ------ | ------ | ------------- | + /// | `tc_account` | `signer` | The signer 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. | + /// | `dm_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 `dm_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` | `dm_account` is not the Treasury Compliance account. | + /// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `dm_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` 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, + }, + + ValAddSelf {}, +} + +impl ScriptCall { + /// Build a Diem `Script` from a structured object `ScriptCall`. + pub fn encode(self) -> Script { + use ScriptCall::*; + match self { + AddCurrencyToAccount { currency } => encode_add_currency_to_account_script(currency), + AddRecoveryRotationCapability { recovery_address } => { + encode_add_recovery_rotation_capability_script(recovery_address) + } + AddValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_add_validator_and_reconfigure_script( + sliding_nonce, + validator_name, + validator_address, + ), + Burn { + token, + sliding_nonce, + preburn_address, + } => encode_burn_script(token, sliding_nonce, preburn_address), + BurnTxnFees { coin_type } => encode_burn_txn_fees_script(coin_type), + CancelBurn { + token, + preburn_address, + } => encode_cancel_burn_script(token, preburn_address), + CreateChildVaspAccount { + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + } => encode_create_child_vasp_account_script( + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + ), + CreateDesignatedDealer { + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_designated_dealer_script( + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateParentVaspAccount { + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_parent_vasp_account_script( + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateRecoveryAddress {} => encode_create_recovery_address_script(), + CreateValidatorAccount { + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + } => encode_create_validator_account_script( + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + ), + CreateValidatorOperatorAccount { + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + } => encode_create_validator_operator_account_script( + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + ), + FreezeAccount { + sliding_nonce, + to_freeze_account, + } => encode_freeze_account_script(sliding_nonce, to_freeze_account), + PeerToPeerWithMetadata { + currency, + payee, + amount, + metadata, + metadata_signature, + } => encode_peer_to_peer_with_metadata_script( + currency, + payee, + amount, + metadata, + metadata_signature, + ), + Preburn { token, amount } => encode_preburn_script(token, amount), + PublishSharedEd25519PublicKey { public_key } => { + encode_publish_shared_ed25519_public_key_script(public_key) + } + RegisterValidatorConfig { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_register_validator_config_script( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + RemoveValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_remove_validator_and_reconfigure_script( + sliding_nonce, + validator_name, + validator_address, + ), + RotateAuthenticationKey { new_key } => encode_rotate_authentication_key_script(new_key), + RotateAuthenticationKeyWithNonce { + sliding_nonce, + new_key, + } => encode_rotate_authentication_key_with_nonce_script(sliding_nonce, new_key), + RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce, + new_key, + } => encode_rotate_authentication_key_with_nonce_admin_script(sliding_nonce, new_key), + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address, + to_recover, + new_key, + } => encode_rotate_authentication_key_with_recovery_address_script( + recovery_address, + to_recover, + new_key, + ), + RotateDualAttestationInfo { new_url, new_key } => { + encode_rotate_dual_attestation_info_script(new_url, new_key) + } + RotateSharedEd25519PublicKey { public_key } => { + encode_rotate_shared_ed25519_public_key_script(public_key) + } + SetValidatorConfigAndReconfigure { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_set_validator_config_and_reconfigure_script( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + SetValidatorOperator { + operator_name, + operator_account, + } => encode_set_validator_operator_script(operator_name, operator_account), + SetValidatorOperatorWithNonceAdmin { + sliding_nonce, + operator_name, + operator_account, + } => encode_set_validator_operator_with_nonce_admin_script( + sliding_nonce, + operator_name, + operator_account, + ), + TieredMint { + coin_type, + sliding_nonce, + designated_dealer_address, + mint_amount, + tier_index, + } => encode_tiered_mint_script( + coin_type, + sliding_nonce, + designated_dealer_address, + mint_amount, + tier_index, + ), + UnfreezeAccount { + sliding_nonce, + to_unfreeze_account, + } => encode_unfreeze_account_script(sliding_nonce, to_unfreeze_account), + UpdateDiemVersion { + sliding_nonce, + major, + } => encode_update_diem_version_script(sliding_nonce, major), + UpdateDualAttestationLimit { + sliding_nonce, + new_micro_xdx_limit, + } => encode_update_dual_attestation_limit_script(sliding_nonce, new_micro_xdx_limit), + UpdateExchangeRate { + currency, + sliding_nonce, + new_exchange_rate_numerator, + new_exchange_rate_denominator, + } => encode_update_exchange_rate_script( + currency, + sliding_nonce, + new_exchange_rate_numerator, + new_exchange_rate_denominator, + ), + UpdateMintingAbility { + currency, + allow_minting, + } => encode_update_minting_ability_script(currency, allow_minting), + } + } + + /// Try to recognize a Diem `Script` and convert it into a structured object `ScriptCall`. + pub fn decode(script: &Script) -> Option { + match TRANSACTION_SCRIPT_DECODER_MAP.get(script.code()) { + Some(decoder) => decoder(script), + None => None, + } + } + + /// Return the name of a Diem `Script` from a structured object `ScriptCall`. + pub fn name(&self) -> &'static str { + use ScriptCall::*; + match self { + AddCurrencyToAccount { .. } => "add_currency_to_account", + AddRecoveryRotationCapability { .. } => "add_recovery_rotation_capability", + AddValidatorAndReconfigure { .. } => "add_validator_and_reconfigure", + Burn { .. } => "burn", + BurnTxnFees { .. } => "burn_txn_fees", + CancelBurn { .. } => "cancel_burn", + CreateChildVaspAccount { .. } => "create_child_vasp_account", + CreateDesignatedDealer { .. } => "create_designated_dealer", + CreateParentVaspAccount { .. } => "create_parent_vasp_account", + CreateRecoveryAddress { .. } => "create_recovery_address", + CreateValidatorAccount { .. } => "create_validator_account", + CreateValidatorOperatorAccount { .. } => "create_validator_operator_account", + FreezeAccount { .. } => "freeze_account", + PeerToPeerWithMetadata { .. } => "peer_to_peer_with_metadata", + Preburn { .. } => "preburn", + PublishSharedEd25519PublicKey { .. } => "publish_shared_ed25519_public_key", + RegisterValidatorConfig { .. } => "register_validator_config", + RemoveValidatorAndReconfigure { .. } => "remove_validator_and_reconfigure", + RotateAuthenticationKey { .. } => "rotate_authentication_key", + RotateAuthenticationKeyWithNonce { .. } => "rotate_authentication_key_with_nonce", + RotateAuthenticationKeyWithNonceAdmin { .. } => { + "rotate_authentication_key_with_nonce_admin" + } + RotateAuthenticationKeyWithRecoveryAddress { .. } => { + "rotate_authentication_key_with_recovery_address" + } + RotateDualAttestationInfo { .. } => "rotate_dual_attestation_info", + RotateSharedEd25519PublicKey { .. } => "rotate_shared_ed25519_public_key", + SetValidatorConfigAndReconfigure { .. } => "set_validator_config_and_reconfigure", + SetValidatorOperator { .. } => "set_validator_operator", + SetValidatorOperatorWithNonceAdmin { .. } => "set_validator_operator_with_nonce_admin", + TieredMint { .. } => "tiered_mint", + UnfreezeAccount { .. } => "unfreeze_account", + UpdateDiemVersion { .. } => "update_diem_version", + UpdateDualAttestationLimit { .. } => "update_dual_attestation_limit", + UpdateExchangeRate { .. } => "update_exchange_rate", + UpdateMintingAbility { .. } => "update_minting_ability", + } + } +} + +impl ScriptFunctionCall { + /// Build a Diem `TransactionPayload` from a structured object `ScriptFunctionCall`. + pub fn encode(self) -> TransactionPayload { + use ScriptFunctionCall::*; + match self { + AddCurrencyToAccount { currency } => { + encode_add_currency_to_account_script_function(currency) + } + AddDiemIdDomain { address, domain } => { + encode_add_diem_id_domain_script_function(address, domain) + } + AddRecoveryRotationCapability { recovery_address } => { + encode_add_recovery_rotation_capability_script_function(recovery_address) + } + AddValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_add_validator_and_reconfigure_script_function( + sliding_nonce, + validator_name, + validator_address, + ), + AutopayCreateInstruction { + uid, + in_type, + payee, + end_epoch, + value, + } => encode_autopay_create_instruction_script_function( + uid, in_type, payee, end_epoch, value, + ), + AutopayDisable {} => encode_autopay_disable_script_function(), + AutopayEnable {} => encode_autopay_enable_script_function(), + BurnTxnFees { coin_type } => encode_burn_txn_fees_script_function(coin_type), + 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), + CreateAccUser { + challenge, + solution, + } => encode_create_acc_user_script_function(challenge, solution), + CreateAccVal { + challenge, + solution, + ow_human_name, + op_address, + op_auth_key_prefix, + op_consensus_pubkey, + op_validator_network_addresses, + op_fullnode_network_addresses, + op_human_name, + } => encode_create_acc_val_script_function( + challenge, + solution, + ow_human_name, + op_address, + op_auth_key_prefix, + op_consensus_pubkey, + op_validator_network_addresses, + op_fullnode_network_addresses, + op_human_name, + ), + CreateChildVaspAccount { + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + } => encode_create_child_vasp_account_script_function( + coin_type, + child_address, + auth_key_prefix, + add_all_currencies, + child_initial_balance, + ), + CreateDesignatedDealer { + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_designated_dealer_script_function( + currency, + sliding_nonce, + addr, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateDiemIdDomains {} => encode_create_diem_id_domains_script_function(), + CreateParentVaspAccount { + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + } => encode_create_parent_vasp_account_script_function( + coin_type, + sliding_nonce, + new_account_address, + auth_key_prefix, + human_name, + add_all_currencies, + ), + CreateRecoveryAddress {} => encode_create_recovery_address_script_function(), + 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, + ), + DemoE2e { world } => encode_demo_e2e_script_function(world), + FreezeAccount { + sliding_nonce, + to_freeze_account, + } => encode_freeze_account_script_function(sliding_nonce, to_freeze_account), + InitializeDiemConsensusConfig { sliding_nonce } => { + encode_initialize_diem_consensus_config_script_function(sliding_nonce) + } + Join {} => encode_join_script_function(), + Leave {} => encode_leave_script_function(), + MinerstateCommit { + challenge, + solution, + } => encode_minerstate_commit_script_function(challenge, solution), + MinerstateCommitByOperator { + owner_address, + challenge, + solution, + } => encode_minerstate_commit_by_operator_script_function( + owner_address, + challenge, + solution, + ), + MinerstateHelper {} => encode_minerstate_helper_script_function(), + OlOracleTx { id, data } => encode_ol_oracle_tx_script_function(id, data), + OlReconfigBulkUpdateSetup { + alice, + bob, + carol, + sha, + ram, + } => encode_ol_reconfig_bulk_update_setup_script_function(alice, bob, carol, sha, ram), + PeerToPeerWithMetadata { + currency, + payee, + amount, + metadata, + metadata_signature, + } => encode_peer_to_peer_with_metadata_script_function( + currency, + payee, + amount, + metadata, + metadata_signature, + ), + Preburn { token, amount } => encode_preburn_script_function(token, amount), + PublishSharedEd25519PublicKey { public_key } => { + encode_publish_shared_ed25519_public_key_script_function(public_key) + } + RegisterValidatorConfig { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_register_validator_config_script_function( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + RemoveDiemIdDomain { address, domain } => { + encode_remove_diem_id_domain_script_function(address, domain) + } + RemoveValidatorAndReconfigure { + sliding_nonce, + validator_name, + validator_address, + } => encode_remove_validator_and_reconfigure_script_function( + sliding_nonce, + validator_name, + validator_address, + ), + 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, + ), + RotateAuthenticationKeyWithRecoveryAddress { + recovery_address, + to_recover, + new_key, + } => encode_rotate_authentication_key_with_recovery_address_script_function( + recovery_address, + to_recover, + new_key, + ), + RotateDualAttestationInfo { new_url, new_key } => { + encode_rotate_dual_attestation_info_script_function(new_url, new_key) + } + RotateSharedEd25519PublicKey { public_key } => { + encode_rotate_shared_ed25519_public_key_script_function(public_key) + } + SetGasConstants { + sliding_nonce, + global_memory_per_byte_cost, + global_memory_per_byte_write_cost, + min_transaction_gas_units, + large_transaction_cutoff, + intrinsic_gas_per_byte, + maximum_number_of_gas_units, + min_price_per_gas_unit, + max_price_per_gas_unit, + max_transaction_size_in_bytes, + gas_unit_scaling_factor, + default_account_size, + } => encode_set_gas_constants_script_function( + sliding_nonce, + global_memory_per_byte_cost, + global_memory_per_byte_write_cost, + min_transaction_gas_units, + large_transaction_cutoff, + intrinsic_gas_per_byte, + maximum_number_of_gas_units, + min_price_per_gas_unit, + max_price_per_gas_unit, + max_transaction_size_in_bytes, + gas_unit_scaling_factor, + default_account_size, + ), + SetValidatorConfigAndReconfigure { + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + } => encode_set_validator_config_and_reconfigure_script_function( + validator_account, + consensus_pubkey, + validator_network_addresses, + fullnode_network_addresses, + ), + SetValidatorOperator { + operator_name, + operator_account, + } => encode_set_validator_operator_script_function(operator_name, operator_account), + SetValidatorOperatorWithNonceAdmin { + sliding_nonce, + operator_name, + operator_account, + } => encode_set_validator_operator_with_nonce_admin_script_function( + sliding_nonce, + operator_name, + operator_account, + ), + SetWalletType { type_of } => encode_set_wallet_type_script_function(type_of), + 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), + UpdateDiemConsensusConfig { + sliding_nonce, + config, + } => encode_update_diem_consensus_config_script_function(sliding_nonce, config), + UpdateDiemVersion { + sliding_nonce, + major, + } => encode_update_diem_version_script_function(sliding_nonce, major), + 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), + ValAddSelf {} => encode_val_add_self_script_function(), + } + } + + /// Try to recognize a Diem `TransactionPayload` and convert it into a structured object `ScriptFunctionCall`. + pub fn decode(payload: &TransactionPayload) -> Option { + 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` 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` 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` 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 +/// Add a DiemID domain to parent VASP account. The transaction can only be sent by +/// the Treasury Compliance account. +/// +/// # Technical Description +/// Adds a `DiemId::DiemIdDomain` to the `domains` field of the `DiemId::DiemIdDomains` resource published under +/// the account at `address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `address` | `address` | The `address` of the parent VASP account that will have have `domain` added to its domains. | +/// | `domain` | `vector` | The domain to be added. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_ALREADY_EXISTS` | The `domain` already exists in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | +pub fn encode_add_diem_id_domain_script_function( + address: AccountAddress, + domain: Vec, +) -> 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!("add_diem_id_domain").to_owned(), + vec![], + vec![ + bcs::to_bytes(&address).unwrap(), + bcs::to_bytes(&domain).unwrap(), + ], + )) +} + +/// # Summary +/// Stores the sending accounts ability to rotate its authentication key with a designated recovery +/// account. Both the sending and recovery accounts need to belong to the same VASP and +/// both be VASP accounts. After this transaction both the sending account and the +/// specified recovery account can rotate the sender account's authentication key. +/// +/// # Technical Description +/// Adds the `DiemAccount::KeyRotationCapability` for the sending account +/// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under +/// `recovery_address`. After this transaction has been executed successfully the account at +/// `recovery_address` and the `to_recover_account` may rotate the authentication key of +/// `to_recover_account` (the sender of this transaction). +/// +/// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key +/// rotation capability, and must be a VASP account. The account at `recovery_address` +/// must also be a VASP account belonging to the same VASP as the `to_recover_account`. +/// Additionally the account at `recovery_address` must have already initialized itself as +/// a recovery account address using the `AccountAdministrationScripts::create_recovery_address` transaction script. +/// +/// The sending account's (`to_recover_account`) key rotation capability is +/// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` +/// resource stored under the account at `recovery_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `to_recover_account` | `signer` | The signer of the sending account of this transaction. | +/// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | +/// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::create_recovery_address` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_recovery_address` +pub fn encode_add_recovery_rotation_capability_script_function( + recovery_address: 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!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("add_recovery_rotation_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&recovery_address).unwrap()], + )) +} + +/// # Summary +/// Adds a validator account to the validator set, and triggers a +/// reconfiguration of the system to admit the account to the validator set for the system. This +/// transaction can only be successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script adds the account at `validator_address` to the validator set. +/// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a +/// reconfiguration. Once the reconfiguration triggered by this script's +/// execution has been performed, the account at the `validator_address` is +/// considered to be a validator in the network. +/// +/// This transaction script will fail if the `validator_address` address is already in the validator set +/// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be added to the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemSystem::EMAX_VALIDATORS` | The validator set is already at its maximum size. The validator could not be added. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `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_add_validator_and_reconfigure_script_function( + sliding_nonce: u64, + validator_name: Vec, + validator_address: 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("add_validator_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&validator_name).unwrap(), + bcs::to_bytes(&validator_address).unwrap(), + ], + )) +} + +pub fn encode_autopay_create_instruction_script_function( + uid: u64, + in_type: u8, + payee: AccountAddress, + end_epoch: u64, + value: 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!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_create_instruction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&uid).unwrap(), + bcs::to_bytes(&in_type).unwrap(), + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&end_epoch).unwrap(), + bcs::to_bytes(&value).unwrap(), + ], + )) +} + +pub fn encode_autopay_disable_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_disable").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_autopay_enable_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AutoPayScripts").to_owned(), + ), + ident_str!("autopay_enable").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Burns the transaction fees collected in the `CoinType` currency so that the +/// Diem association may reclaim the backing coins off-chain. May only be sent +/// by the Treasury Compliance account. +/// +/// # Technical Description +/// Burns the transaction fees collected in `CoinType` so that the +/// association may reclaim the backing coins. Once this transaction has executed +/// successfully all transaction fees that will have been collected in +/// `CoinType` since the last time this script was called with that specific +/// currency. Both `balance` and `preburn` fields in the +/// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` +/// account address will have a value of 0 after the successful execution of this script. +/// +/// # Events +/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle +/// held in the `Diem::CurrencyInfo` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | +/// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | +/// +/// # Related Scripts +/// * `TreasuryComplianceScripts::burn_with_amount` +/// * `TreasuryComplianceScripts::cancel_burn_with_amount` +pub fn encode_burn_txn_fees_script_function(coin_type: 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!("TreasuryComplianceScripts").to_owned(), + ), + ident_str!("burn_txn_fees").to_owned(), + vec![coin_type], + 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` resource published under the +/// `preburn_address` account address. +/// +/// This transaction will only succeed if the sending `account` has a +/// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` 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` published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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` resource under the `preburn_address` and +/// return the funds to the `preburn_address` account's `DiemAccount::Balance`. +/// The transaction must be sent by an `account` with a `Diem::BurnCapability` +/// resource published under it. The account at `preburn_address` must have a +/// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes +/// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's +/// `DiemAccount::Balance` 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` +/// 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` published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_NOT_FOUND` | The `Diem::PreburnQueue` 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` 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(), + ], + )) +} + +pub fn encode_create_acc_user_script_function( + challenge: Vec, + solution: Vec, +) -> 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!("AccountScripts").to_owned(), + ), + ident_str!("create_acc_user").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + ], + )) +} + +#[allow(clippy::too_many_arguments)] +pub fn encode_create_acc_val_script_function( + challenge: Vec, + solution: Vec, + ow_human_name: Vec, + op_address: AccountAddress, + op_auth_key_prefix: Vec, + op_consensus_pubkey: Vec, + op_validator_network_addresses: Vec, + op_fullnode_network_addresses: Vec, + op_human_name: Vec, +) -> 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!("AccountScripts").to_owned(), + ), + ident_str!("create_acc_val").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&ow_human_name).unwrap(), + bcs::to_bytes(&op_address).unwrap(), + bcs::to_bytes(&op_auth_key_prefix).unwrap(), + bcs::to_bytes(&op_consensus_pubkey).unwrap(), + bcs::to_bytes(&op_validator_network_addresses).unwrap(), + bcs::to_bytes(&op_fullnode_network_addresses).unwrap(), + bcs::to_bytes(&op_human_name).unwrap(), + ], + )) +} + +/// # Summary +/// Creates a Child VASP account with its parent being the sending account of the transaction. +/// The sender of the transaction must be a Parent VASP account. +/// +/// # Technical Description +/// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of +/// `child_initial_balance` in `CoinType` and an initial authentication key of +/// `auth_key_prefix | child_address`. Authentication key prefixes, and how to construct them from an ed25519 public key is described +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). +/// +/// If `add_all_currencies` is true, the child address will have a zero balance in all available +/// currencies in the system. +/// +/// The new account will be a child account of the transaction sender, which must be a +/// Parent VASP account. The child account will be recorded against the limit of +/// child accounts of the creating Parent VASP account. +/// +/// # Events +/// Successful execution will emit: +/// * A `DiemAccount::CreateAccountEvent` with the `created` field being `child_address`, +/// and the `rold_id` field being `Roles::CHILD_VASP_ROLE_ID`. This is emitted on the +/// `DiemAccount::AccountOperationsCapability` `creation_events` handle. +/// +/// Successful execution with a `child_initial_balance` greater than zero will additionaly emit: +/// * A `DiemAccount::SentPaymentEvent` with the `payee` field being `child_address`. +/// This is emitted on the Parent VASP's `DiemAccount::DiemAccount` `sent_events` handle. +/// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address. +/// This is emitted on the new Child VASPS's `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | +/// | `parent_vasp` | `signer` | The reference of the sending account. Must be a Parent VASP account. | +/// | `child_address` | `address` | Address of the to-be-created Child VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | +/// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_parent_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::add_recovery_rotation_capability` +/// * `AccountAdministrationScripts::create_recovery_address` +pub fn encode_create_child_vasp_account_script_function( + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Vec, + add_all_currencies: bool, + child_initial_balance: 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!("AccountCreationScripts").to_owned(), + ), + ident_str!("create_child_vasp_account").to_owned(), + vec![coin_type], + vec![ + bcs::to_bytes(&child_address).unwrap(), + bcs::to_bytes(&auth_key_prefix).unwrap(), + bcs::to_bytes(&add_all_currencies).unwrap(), + bcs::to_bytes(&child_initial_balance).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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, + 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(), + ], + )) +} + +/// # Summary +/// Publishes a `DiemId::DiemIdDomains` resource under a parent VASP account. +/// The sending account must be a parent VASP account. +/// +/// # Technical Description +/// Publishes a `DiemId::DiemIdDomains` resource under `account`. +/// The The `DiemId::DiemIdDomains` resource's `domains` field is a vector +/// of DiemIdDomain, and will be empty on at the end of processing this transaction. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::ALREADY_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN` | A `DiemId::DiemIdDomains` resource has already been published under `account`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending `account` was not a parent VASP account. | +pub fn encode_create_diem_id_domains_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("create_diem_id_domains").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Parent VASP role at `address` with authentication key +/// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If +/// `add_all_currencies` is true, 0 balances for all available currencies in the system will +/// also be added. This can only be invoked by an TreasuryCompliance account. +/// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. +/// 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::PARENT_VASP_ROLE_ID`. This is emitted on the +/// `DiemAccount::AccountOperationsCapability` `creation_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_child_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::add_recovery_rotation_capability` +/// * `AccountAdministrationScripts::create_recovery_address` +/// * `AccountAdministrationScripts::rotate_dual_attestation_info` +pub fn encode_create_parent_vasp_account_script_function( + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + 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_parent_vasp_account").to_owned(), + vec![coin_type], + 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(), + bcs::to_bytes(&add_all_currencies).unwrap(), + ], + )) +} + +/// # Summary +/// Initializes the sending account as a recovery address that may be used by +/// other accounts belonging to the same VASP as `account`. +/// The sending account must be a VASP account, and can be either a child or parent VASP account. +/// Multiple recovery addresses can exist for a single VASP, but accounts in +/// each must be disjoint. +/// +/// # Technical Description +/// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then +/// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds +/// it to the resource. After the successful execution of this transaction +/// other accounts may add their key rotation to this resource so that `account` +/// may be used as a recovery account for those accounts. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | +/// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | +/// +/// # Related Scripts +/// * `Script::add_recovery_rotation_capability` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_create_recovery_address_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("AccountAdministrationScripts").to_owned(), + ), + ident_str!("create_recovery_address").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Creates a Validator account. This transaction can only be sent by the Diem +/// Root account. +/// +/// # Technical Description +/// Creates an account with a Validator role at `new_account_address`, with authentication key +/// `auth_key_prefix` | `new_account_address`. It publishes a +/// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and +/// `operator_account` fields. The `human_name` field of the +/// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. +/// This script does not add the validator to the validator set or the system, +/// but only creates the account. +/// 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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, +) -> 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` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | 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, + human_name: Vec, +) -> 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(), + ], + )) +} + +pub fn encode_demo_e2e_script_function(world: 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!("DemoScripts").to_owned(), + ), + ident_str!("demo_e2e").to_owned(), + vec![], + vec![bcs::to_bytes(&world).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(), + ], + )) +} + +/// # Summary +/// Initializes the Diem consensus config that is stored on-chain. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Initializes the `DiemConsensusConfig` on-chain config to empty and allows future updates from DiemRoot via +/// `update_diem_consensus_config`. This doesn't emit a `DiemConfig::NewEpochEvent`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +pub fn encode_initialize_diem_consensus_config_script_function( + sliding_nonce: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("initialize_diem_consensus_config").to_owned(), + vec![], + vec![bcs::to_bytes(&sliding_nonce).unwrap()], + )) +} + +pub fn encode_join_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("join").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_leave_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("leave").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_minerstate_commit_script_function( + challenge: Vec, + solution: Vec, +) -> 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!("MinerStateScripts").to_owned(), + ), + ident_str!("minerstate_commit").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + ], + )) +} + +pub fn encode_minerstate_commit_by_operator_script_function( + owner_address: AccountAddress, + challenge: Vec, + solution: Vec, +) -> 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!("MinerStateScripts").to_owned(), + ), + ident_str!("minerstate_commit_by_operator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&owner_address).unwrap(), + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + ], + )) +} + +pub fn encode_minerstate_helper_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("MinerStateScripts").to_owned(), + ), + ident_str!("minerstate_helper").to_owned(), + vec![], + vec![], + )) +} + +pub fn encode_ol_oracle_tx_script_function(id: u64, data: Vec) -> 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!("OracleScripts").to_owned(), + ), + ident_str!("ol_oracle_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&id).unwrap(), bcs::to_bytes(&data).unwrap()], + )) +} + +pub fn encode_ol_reconfig_bulk_update_setup_script_function( + alice: AccountAddress, + bob: AccountAddress, + carol: AccountAddress, + sha: AccountAddress, + ram: 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!("ValidatorScripts").to_owned(), + ), + ident_str!("ol_reconfig_bulk_update_setup").to_owned(), + vec![], + vec![ + bcs::to_bytes(&alice).unwrap(), + bcs::to_bytes(&bob).unwrap(), + bcs::to_bytes(&carol).unwrap(), + bcs::to_bytes(&sha).unwrap(), + bcs::to_bytes(&ram).unwrap(), + ], + )) +} + +/// # Summary +/// Transfers a given number of coins in a specified currency from one account to another. +/// Transfers over a specified amount defined on-chain that are between two different VASPs, or +/// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has +/// agreed to receive the coins. This transaction can be sent by any account that can hold a +/// balance, and to any account that can hold a balance. Both accounts must hold balances in the +/// currency being transacted. +/// +/// # Technical Description +/// +/// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated +/// `metadata` and an (optional) `metadata_signature` on the message of the form +/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`, that +/// has been signed by the `payee`'s private key associated with the `compliance_public_key` held in +/// the `payee`'s `DualAttestation::Credential`. Both the `Signer::address_of(payer)` and `amount` fields +/// in the `metadata_signature` must be BCS-encoded bytes, and `|` denotes concatenation. +/// The `metadata` and `metadata_signature` parameters are only required if `amount` >= +/// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. +/// However, a transaction sender can opt in to dual attestation even when it is not required +/// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. +/// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. +/// +/// # Events +/// Successful execution of this script emits two events: +/// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and +/// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | +/// | `payer` | `signer` | The signer of the sending account that coins are being transferred from. | +/// | `payee` | `address` | The address of the account the coins are being transferred to. | +/// | `metadata` | `vector` | Optional metadata about this payment. | +/// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | +/// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_child_vasp_account` +/// * `AccountCreationScripts::create_parent_vasp_account` +/// * `AccountAdministrationScripts::add_currency_to_account` +pub fn encode_peer_to_peer_with_metadata_script_function( + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Vec, + metadata_signature: Vec, +) -> 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!("PaymentScripts").to_owned(), + ), + ident_str!("peer_to_peer_with_metadata").to_owned(), + vec![currency], + vec![ + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&amount).unwrap(), + bcs::to_bytes(&metadata).unwrap(), + bcs::to_bytes(&metadata_signature).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` to the `Diem::Preburn` 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` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` 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 authentication key of the sending account to the newly-specified ed25519 public key and +/// publishes a new shared authentication key derived from that public key under the sender's account. +/// Any account can send this transaction. +/// +/// # Technical Description +/// Rotates the authentication key of the sending account to the +/// [authentication key derived from `public_key`](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) +/// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource +/// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for +/// `account` under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `public_key` | `vector` | A valid 32-byte Ed25519 public key for `account`'s authentication key to be rotated to and stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | +/// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::rotate_shared_ed25519_public_key` +pub fn encode_publish_shared_ed25519_public_key_script_function( + public_key: Vec, +) -> 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!("publish_shared_ed25519_public_key").to_owned(), + vec![], + vec![bcs::to_bytes(&public_key).unwrap()], + )) +} + +/// # Summary +/// Updates a validator's configuration. This does not reconfigure the system and will not update +/// the configuration in the validator set that is seen by other validators in the network. Can +/// only be successfully sent by a Validator Operator account that is already registered with a +/// validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` +/// so the copy of this config held in the validator set will not be updated, and the changes are +/// only "locally" under the `validator_account` account address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `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_register_validator_config_script_function( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("register_validator_config").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_account).unwrap(), + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&validator_network_addresses).unwrap(), + bcs::to_bytes(&fullnode_network_addresses).unwrap(), + ], + )) +} + +/// # Summary +/// Remove a DiemID domain from parent VASP account. The transaction can only be sent by +/// the Treasury Compliance account. +/// +/// # Technical Description +/// Removes a `DiemId::DiemIdDomain` from the `domains` field of the `DiemId::DiemIdDomains` resource published under +/// account with `address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `signer` | The signer of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `address` | `address` | The `address` of parent VASP account that will update its domains. | +/// | `domain` | `vector` | The domain name. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAIN_MANAGER` | The `DiemId::DiemIdDomainManager` resource is not yet published under the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `DiemId::EDIEM_ID_DOMAINS_NOT_PUBLISHED` | `address` does not have a `DiemId::DiemIdDomains` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EINVALID_DIEM_ID_DOMAIN` | The `domain` is greater in length than `DiemId::DOMAIN_LENGTH`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemId::EDOMAIN_NOT_FOUND` | The `domain` does not exist in the list of `DiemId::DiemIdDomain`s in the `DiemId::DiemIdDomains` resource published under `address`. | +pub fn encode_remove_diem_id_domain_script_function( + address: AccountAddress, + domain: Vec, +) -> 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!("remove_diem_id_domain").to_owned(), + vec![], + vec![ + bcs::to_bytes(&address).unwrap(), + bcs::to_bytes(&domain).unwrap(), + ], + )) +} + +/// # Summary +/// This script removes a validator account from the validator set, and triggers a reconfiguration +/// of the system to remove the validator from the system. This transaction can only be +/// successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script removes the account at `validator_address` from the validator set. This transaction +/// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event +/// has been performed, the account at `validator_address` is no longer considered to be a +/// validator in the network. This transaction will fail if the validator at `validator_address` +/// is not in the validator set. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | The signer of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be removed from the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_remove_validator_and_reconfigure_script_function( + sliding_nonce: u64, + validator_name: Vec, + validator_address: 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("remove_validator_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&validator_name).unwrap(), + bcs::to_bytes(&validator_address).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` | 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) -> 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` | 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, +) -> 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` | 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, +) -> 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 +/// Rotates the authentication key of a specified account that is part of a recovery address to a +/// new authentication key. Only used for accounts that are part of a recovery address (see +/// `AccountAdministrationScripts::add_recovery_rotation_capability` for account restrictions). +/// +/// # Technical Description +/// Rotates the authentication key of the `to_recover` account to `new_key` using the +/// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource +/// published under `recovery_address`. `new_key` must be a valide authentication key as described +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys). +/// This transaction can be sent either by the `to_recover` account, or by the account where the +/// `RecoveryAddress::RecoveryAddress` resource is published that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account of the transaction. | +/// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | +/// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | +/// | `new_key` | `vector` | New authentication key to be used for the account at the `to_recover` address. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::rotate_authentication_key` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce` +/// * `AccountAdministrationScripts::rotate_authentication_key_with_nonce_admin` +pub fn encode_rotate_authentication_key_with_recovery_address_script_function( + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Vec, +) -> 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_recovery_address").to_owned(), + vec![], + vec![ + bcs::to_bytes(&recovery_address).unwrap(), + bcs::to_bytes(&to_recover).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` | ASCII-encoded url to be used for off-chain communication with `account`. | +/// | `new_key` | `vector` | 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, + new_key: Vec, +) -> 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 +/// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by +/// any account that has previously published a shared ed25519 public key using +/// `AccountAdministrationScripts::publish_shared_ed25519_public_key`. +/// +/// # Technical Description +/// `public_key` must be a valid ed25519 public key. This transaction first rotates the public key stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it +/// rotates the `account`'s authentication key to the new authentication key derived from `public_key` as defined +/// [here](https://developers.diem.com/docs/core/accounts/#addresses-authentication-keys-and-cryptographic-keys) +/// using the `DiemAccount::KeyRotationCapability` stored in `account`'s `SharedEd25519PublicKey::SharedEd25519PublicKey`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `AccountAdministrationScripts::publish_shared_ed25519_public_key` +pub fn encode_rotate_shared_ed25519_public_key_script_function( + public_key: Vec, +) -> 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_shared_ed25519_public_key").to_owned(), + vec![], + vec![bcs::to_bytes(&public_key).unwrap()], + )) +} + +/// # Summary +/// Updates the gas constants stored on chain and used by the VM for gas +/// metering. This transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the on-chain config holding the `DiemVMConfig` and emits a +/// `DiemConfig::NewEpochEvent` to trigger a reconfiguration of the system. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `global_memory_per_byte_cost` | `u64` | The new cost to read global memory per-byte to be used for gas metering. | +/// | `global_memory_per_byte_write_cost` | `u64` | The new cost to write global memory per-byte to be used for gas metering. | +/// | `min_transaction_gas_units` | `u64` | The new flat minimum amount of gas required for any transaction. | +/// | `large_transaction_cutoff` | `u64` | The new size over which an additional charge will be assessed for each additional byte. | +/// | `intrinsic_gas_per_byte` | `u64` | The new number of units of gas that to be charged per-byte over the new `large_transaction_cutoff`. | +/// | `maximum_number_of_gas_units` | `u64` | The new maximum number of gas units that can be set in a transaction. | +/// | `min_price_per_gas_unit` | `u64` | The new minimum gas price that can be set for a transaction. | +/// | `max_price_per_gas_unit` | `u64` | The new maximum gas price that can be set for a transaction. | +/// | `max_transaction_size_in_bytes` | `u64` | The new maximum size of a transaction that can be processed. | +/// | `gas_unit_scaling_factor` | `u64` | The new scaling factor to use when scaling between external and internal gas units. | +/// | `default_account_size` | `u64` | The new default account size to use when assessing final costs for reads and writes to global storage. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemVMConfig::EGAS_CONSTANT_INCONSISTENCY` | The provided gas constants are inconsistent. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. +/// | + +#[allow(clippy::too_many_arguments)] +pub fn encode_set_gas_constants_script_function( + sliding_nonce: u64, + global_memory_per_byte_cost: u64, + global_memory_per_byte_write_cost: u64, + min_transaction_gas_units: u64, + large_transaction_cutoff: u64, + intrinsic_gas_per_byte: u64, + maximum_number_of_gas_units: u64, + min_price_per_gas_unit: u64, + max_price_per_gas_unit: u64, + max_transaction_size_in_bytes: u64, + gas_unit_scaling_factor: u64, + default_account_size: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("set_gas_constants").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&global_memory_per_byte_cost).unwrap(), + bcs::to_bytes(&global_memory_per_byte_write_cost).unwrap(), + bcs::to_bytes(&min_transaction_gas_units).unwrap(), + bcs::to_bytes(&large_transaction_cutoff).unwrap(), + bcs::to_bytes(&intrinsic_gas_per_byte).unwrap(), + bcs::to_bytes(&maximum_number_of_gas_units).unwrap(), + bcs::to_bytes(&min_price_per_gas_unit).unwrap(), + bcs::to_bytes(&max_price_per_gas_unit).unwrap(), + bcs::to_bytes(&max_transaction_size_in_bytes).unwrap(), + bcs::to_bytes(&gas_unit_scaling_factor).unwrap(), + bcs::to_bytes(&default_account_size).unwrap(), + ], + )) +} + +/// # Summary +/// Updates a validator's configuration, and triggers a reconfiguration of the system to update the +/// validator set with this new validator configuration. Can only be successfully sent by a +/// Validator Operator account that is already registered with a validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to +/// trigger a reconfiguration of the system. This reconfiguration will update the validator set +/// on-chain with the updated `ValidatorConfig::ValidatorConfig`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `signer` | Signer of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::register_validator_config` +pub fn encode_set_validator_config_and_reconfigure_script_function( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> 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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_config_and_reconfigure").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_account).unwrap(), + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&validator_network_addresses).unwrap(), + bcs::to_bytes(&fullnode_network_addresses).unwrap(), + ], + )) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by an account with +/// Validator role. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the sending validator account. The account at `operator_account` address must have +/// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` +/// resource published under it. The sending `account` must be a Validator and have a +/// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a +/// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | The signer of the sending account of the transaction. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator_with_nonce_admin` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_script_function( + operator_name: Vec, + operator_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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_operator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&operator_name).unwrap(), + bcs::to_bytes(&operator_account).unwrap(), + ], + )) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root +/// account as a write set transaction. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the validator `account`. The account at `operator_account` address must have a +/// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource +/// published under it. The account represented by the `account` signer must be a Validator and +/// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of +/// the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `signer` | 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. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `AccountCreationScripts::create_validator_account` +/// * `AccountCreationScripts::create_validator_operator_account` +/// * `ValidatorAdministrationScripts::register_validator_config` +/// * `ValidatorAdministrationScripts::remove_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::add_validator_and_reconfigure` +/// * `ValidatorAdministrationScripts::set_validator_operator` +/// * `ValidatorAdministrationScripts::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_with_nonce_admin_script_function( + sliding_nonce: u64, + operator_name: Vec, + operator_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!("ValidatorAdministrationScripts").to_owned(), + ), + ident_str!("set_validator_operator_with_nonce_admin").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&operator_name).unwrap(), + bcs::to_bytes(&operator_account).unwrap(), + ], + )) +} + +pub fn encode_set_wallet_type_script_function(type_of: 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!("WalletScripts").to_owned(), + ), + ident_str!("set_wallet_type").to_owned(), + vec![], + vec![bcs::to_bytes(&type_of).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` 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` resource does not exist at `designated_dealer_address`. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` 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 +/// Updates the Diem consensus config that is stored on-chain and is used by the Consensus. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemConsensusConfig` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `config` | `vector` | The serialized bytes of consensus config. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +pub fn encode_update_diem_consensus_config_script_function( + sliding_nonce: u64, + config: Vec, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("update_diem_consensus_config").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&config).unwrap(), + ], + )) +} + +/// # Summary +/// Updates the Diem major version that is stored on-chain and is used by the VM. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater +/// than the current major version held on-chain. The VM reads this information and can use it to +/// preserve backwards compatibility with previous major versions of the VM. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `signer` | Signer of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | +pub fn encode_update_diem_version_script_function( + sliding_nonce: u64, + major: u64, +) -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("SystemAdministrationScripts").to_owned(), + ), + ident_str!("update_diem_version").to_owned(), + vec![], + vec![ + bcs::to_bytes(&sliding_nonce).unwrap(), + bcs::to_bytes(&major).unwrap(), + ], + )) +} + +/// # Summary +/// 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. | +/// | `dm_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 `dm_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` | `dm_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `dm_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` 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()], + )) +} + +pub fn encode_val_add_self_script_function() -> TransactionPayload { + TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new( + AccountAddress::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), + ident_str!("ValidatorScripts").to_owned(), + ), + ident_str!("val_add_self").to_owned(), + vec![], + vec![], + )) +} + +/// # Summary +/// Adds a zero `Currency` balance to the sending `account`. This will enable `account` to +/// send, receive, and hold `Diem::Diem` 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` 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` published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being added to the sending account of the transaction. `Currency` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EROLE_CANT_STORE_BALANCE` | The sending `account`'s role does not permit balances. | +/// | `Errors::ALREADY_PUBLISHED` | `DiemAccount::EADD_EXISTING_CURRENCY` | A balance for `Currency` is already published under the sending `account`. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::create_parent_vasp_account` +/// * `Script::peer_to_peer_with_metadata` +pub fn encode_add_currency_to_account_script(currency: TypeTag) -> Script { + Script::new( + ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(), + vec![currency], + vec![], + ) +} + +/// # Summary +/// Stores the sending accounts ability to rotate its authentication key with a designated recovery +/// account. Both the sending and recovery accounts need to belong to the same VASP and +/// both be VASP accounts. After this transaction both the sending account and the +/// specified recovery account can rotate the sender account's authentication key. +/// +/// # Technical Description +/// Adds the `DiemAccount::KeyRotationCapability` for the sending account +/// (`to_recover_account`) to the `RecoveryAddress::RecoveryAddress` resource under +/// `recovery_address`. After this transaction has been executed successfully the account at +/// `recovery_address` and the `to_recover_account` may rotate the authentication key of +/// `to_recover_account` (the sender of this transaction). +/// +/// The sending account of this transaction (`to_recover_account`) must not have previously given away its unique key +/// rotation capability, and must be a VASP account. The account at `recovery_address` +/// must also be a VASP account belonging to the same VASP as the `to_recover_account`. +/// Additionally the account at `recovery_address` must have already initialized itself as +/// a recovery account address using the `Script::create_recovery_address` transaction script. +/// +/// The sending account's (`to_recover_account`) key rotation capability is +/// removed in this transaction and stored in the `RecoveryAddress::RecoveryAddress` +/// resource stored under the account at `recovery_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `to_recover_account` | `&signer` | The signer reference of the sending account of this transaction. | +/// | `recovery_address` | `address` | The account address where the `to_recover_account`'s `DiemAccount::KeyRotationCapability` will be stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `to_recover_account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION` | `to_recover_account` and `recovery_address` do not belong to the same VASP. | +/// | `Errors::LIMIT_EXCEEDED` | ` RecoveryAddress::EMAX_KEYS_REGISTERED` | `RecoveryAddress::MAX_REGISTERED_KEYS` have already been registered with this `recovery_address`. | +/// +/// # Related Scripts +/// * `Script::create_recovery_address` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_add_recovery_rotation_capability_script(recovery_address: AccountAddress) -> Script { + Script::new( + ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(), + vec![], + vec![TransactionArgument::Address(recovery_address)], + ) +} + +/// # Summary +/// Adds a validator account to the validator set, and triggers a +/// reconfiguration of the system to admit the account to the validator set for the system. This +/// transaction can only be successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script adds the account at `validator_address` to the validator set. +/// This transaction emits a `DiemConfig::NewEpochEvent` event and triggers a +/// reconfiguration. Once the reconfiguration triggered by this script's +/// execution has been performed, the account at the `validator_address` is +/// considered to be a validator in the network. +/// +/// This transaction script will fail if the `validator_address` address is already in the validator set +/// or does not have a `ValidatorConfig::ValidatorConfig` resource already published under it. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be added to the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EINVALID_PROSPECTIVE_VALIDATOR` | The validator to be added does not have a `ValidatorConfig::ValidatorConfig` resource published under it, or its `config` field is empty. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::EALREADY_A_VALIDATOR` | The `validator_address` account is already a registered validator. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_add_validator_and_reconfigure_script( + sliding_nonce: u64, + validator_name: Vec, + validator_address: AccountAddress, +) -> Script { + Script::new( + ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(validator_name), + TransactionArgument::Address(validator_address), + ], + ) +} + +/// # Summary +/// Burns all coins held in the preburn resource at the specified +/// preburn address and removes them from the system. The sending account must +/// be the Treasury Compliance account. +/// The account that holds the preburn resource will normally be a Designated +/// Dealer, but there are no enforced requirements that it be one. +/// +/// # Technical Description +/// This transaction permanently destroys all the coins of `Token` type +/// stored in the `Diem::Preburn` resource published under the +/// `preburn_address` account address. +/// +/// This transaction will only succeed if the sending `account` has a +/// `Diem::BurnCapability`, and a `Diem::Preburn` 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` 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` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Token` | Type | The Move type for the `Token` currency being burned. `Token` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_EMPTY` | The `Diem::Preburn` resource is empty (has a value of 0). | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | +/// +/// # Related Scripts +/// * `Script::burn_txn_fees` +/// * `Script::cancel_burn` +/// * `Script::preburn` +pub fn encode_burn_script( + token: TypeTag, + sliding_nonce: u64, + preburn_address: AccountAddress, +) -> Script { + Script::new( + BURN_CODE.to_vec(), + vec![token], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(preburn_address), + ], + ) +} + +/// # Summary +/// Burns the transaction fees collected in the `CoinType` currency so that the +/// Diem association may reclaim the backing coins off-chain. May only be sent +/// by the Treasury Compliance account. +/// +/// # Technical Description +/// Burns the transaction fees collected in `CoinType` so that the +/// association may reclaim the backing coins. Once this transaction has executed +/// successfully all transaction fees that will have been collected in +/// `CoinType` since the last time this script was called with that specific +/// currency. Both `balance` and `preburn` fields in the +/// `TransactionFee::TransactionFee` resource published under the `0xB1E55ED` +/// account address will have a value of 0 after the successful execution of this script. +/// +/// ## Events +/// The successful execution of this transaction will emit a `Diem::BurnEvent` on the event handle +/// held in the `Diem::CurrencyInfo` resource's `burn_events` published under +/// `0xA550C18`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being added to the sending account of the transaction. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `TransactionFee::ETRANSACTION_FEE` | `CoinType` is not an accepted transaction fee currency. | +/// | `Errors::INVALID_ARGUMENT` | `Diem::ECOIN` | The collected fees in `CoinType` are zero. | +/// +/// # Related Scripts +/// * `Script::burn` +/// * `Script::cancel_burn` +pub fn encode_burn_txn_fees_script(coin_type: TypeTag) -> Script { + Script::new(BURN_TXN_FEES_CODE.to_vec(), vec![coin_type], vec![]) +} + +/// # Summary +/// Cancels and returns all coins held in the preburn area under +/// `preburn_address` and returns the funds to the `preburn_address`'s balance. +/// Can only be successfully sent by an account with Treasury Compliance role. +/// +/// # Technical Description +/// Cancels and returns all coins held in the `Diem::Preburn` resource under the `preburn_address` and +/// return the funds to the `preburn_address` account's `DiemAccount::Balance`. +/// The transaction must be sent by an `account` with a `Diem::BurnCapability` +/// resource published under it. The account at `preburn_address` must have a +/// `Diem::Preburn` resource published under it, and its value must be nonzero. The transaction removes +/// the entire balance held in the `Diem::Preburn` resource, and returns it back to the account's +/// `DiemAccount::Balance` 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` +/// resource's `burn_events` published under `0xA550C18`. +/// * A `DiemAccount::ReceivedPaymentEvent` on the `preburn_address`'s +/// `DiemAccount::DiemAccount` `received_events` event handle with both the `payer` and `payee` +/// being `preburn_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Token` | Type | The Move type for the `Token` currenty that burning is being cancelled for. `Token` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | The signer reference of the sending account of this transaction, must have a burn capability for `Token` published under it. | +/// | `preburn_address` | `address` | The address where the coins to-be-burned are currently held. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EBURN_CAPABILITY` | The sending `account` does not have a `Diem::BurnCapability` published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::EPREBURN` | The account at `preburn_address` does not have a `Diem::Preburn` resource published under it. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The specified `Token` is not a registered currency on-chain. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | The value held in the preburn resource was zero. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | The account at `preburn_address` doesn't have a balance resource for `Token`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds held in the prebun area would exceed the `account`'s account limits. | +/// | `Errors::INVALID_STATE` | `DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET` | The `account` does not have a compliance key set on it but dual attestion checking was performed. | +/// +/// # Related Scripts +/// * `Script::burn_txn_fees` +/// * `Script::burn` +/// * `Script::preburn` +pub fn encode_cancel_burn_script(token: TypeTag, preburn_address: AccountAddress) -> Script { + Script::new( + CANCEL_BURN_CODE.to_vec(), + vec![token], + vec![TransactionArgument::Address(preburn_address)], + ) +} + +/// # Summary +/// Creates a Child VASP account with its parent being the sending account of the transaction. +/// The sender of the transaction must be a Parent VASP account. +/// +/// # Technical Description +/// Creates a `ChildVASP` account for the sender `parent_vasp` at `child_address` with a balance of +/// `child_initial_balance` in `CoinType` and an initial authentication key of +/// `auth_key_prefix | child_address`. +/// +/// If `add_all_currencies` is true, the child address will have a zero balance in all available +/// currencies in the system. +/// +/// The new account will be a child account of the transaction sender, which must be a +/// Parent VASP account. The child account will be recorded against the limit of +/// child accounts of the creating Parent VASP account. +/// +/// ## Events +/// Successful execution with a `child_initial_balance` greater than zero will emit: +/// * A `DiemAccount::SentPaymentEvent` with the `payer` field being the Parent VASP's address, +/// and payee field being `child_address`. This is emitted on the Parent VASP's +/// `DiemAccount::DiemAccount` `sent_events` handle. +/// * A `DiemAccount::ReceivedPaymentEvent` with the `payer` field being the Parent VASP's address, +/// and payee field being `child_address`. This is emitted on the new Child VASPS's +/// `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` that the child account should be created with. `CoinType` must be an already-registered currency on-chain. | +/// | `parent_vasp` | `&signer` | The signer reference of the sending account. Must be a Parent VASP account. | +/// | `child_address` | `address` | Address of the to-be-created Child VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// | `child_initial_balance` | `u64` | The initial balance in `CoinType` to give the child account when it's created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | The `auth_key_prefix` was not of length 32. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EPARENT_VASP` | The sending account wasn't a Parent VASP account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `child_address` address is already taken. | +/// | `Errors::LIMIT_EXCEEDED` | `VASP::ETOO_MANY_CHILDREN` | The sending account has reached the maximum number of allowed child accounts. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED` | The withdrawal capability for the sending account has already been extracted. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | The sending account doesn't have a balance in `CoinType`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | The sending account doesn't have at least `child_initial_balance` of `CoinType` balance. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECANNOT_CREATE_AT_VM_RESERVED` | The `child_address` is the reserved address 0x0. | +/// +/// # Related Scripts +/// * `Script::create_parent_vasp_account` +/// * `Script::add_currency_to_account` +/// * `Script::rotate_authentication_key` +/// * `Script::add_recovery_rotation_capability` +/// * `Script::create_recovery_address` +pub fn encode_create_child_vasp_account_script( + coin_type: TypeTag, + child_address: AccountAddress, + auth_key_prefix: Vec, + add_all_currencies: bool, + child_initial_balance: u64, +) -> Script { + Script::new( + CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::Address(child_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::Bool(add_all_currencies), + TransactionArgument::U64(child_initial_balance), + ], + ) +} + +/// # Summary +/// Creates a Designated Dealer account with the provided information, and initializes it with +/// default mint tiers. The transaction can only be sent by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Designated Dealer role at `addr` with authentication key +/// `auth_key_prefix` | `addr` and a 0 balance of type `Currency`. If `add_all_currencies` is true, +/// 0 balances for all available currencies in the system will also be added. This can only be +/// invoked by an account with the TreasuryCompliance role. +/// +/// At the time of creation the account is also initialized with default mint tiers of (500_000, +/// 5000_000, 50_000_000, 500_000_000), and preburn areas for each currency that is added to the +/// account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` that the Designated Dealer should be initialized with. `Currency` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `addr` | `address` | Address of the to-be-created Designated Dealer account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Designated Dealer. | +/// | `add_all_currencies` | `bool` | Whether to publish preburn, balance, and tier info resources for all known (SCS) currencies or just `Currency` when the account is created. | +/// + +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `Currency` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `addr` address is already taken. | +/// +/// # Related Scripts +/// * `Script::tiered_mint` +/// * `Script::peer_to_peer_with_metadata` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_create_designated_dealer_script( + currency: TypeTag, + sliding_nonce: u64, + addr: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + add_all_currencies: bool, +) -> Script { + Script::new( + CREATE_DESIGNATED_DEALER_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(addr), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + TransactionArgument::Bool(add_all_currencies), + ], + ) +} + +/// # Summary +/// Creates a Parent VASP account with the specified human name. Must be called by the Treasury Compliance account. +/// +/// # Technical Description +/// Creates an account with the Parent VASP role at `address` with authentication key +/// `auth_key_prefix` | `new_account_address` and a 0 balance of type `CoinType`. If +/// `add_all_currencies` is true, 0 balances for all available currencies in the system will +/// also be added. This can only be invoked by an TreasuryCompliance account. +/// `sliding_nonce` is a unique nonce for operation, see `SlidingNonce` for details. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` currency that the Parent VASP account should be initialized with. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Parent VASP account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the Parent VASP. | +/// | `add_all_currencies` | `bool` | Whether to publish balance resources for all known currencies when the account is created. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | The `CoinType` is not a registered currency on-chain. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::add_currency_to_account` +/// * `Script::rotate_authentication_key` +/// * `Script::add_recovery_rotation_capability` +/// * `Script::create_recovery_address` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_create_parent_vasp_account_script( + coin_type: TypeTag, + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, + add_all_currencies: bool, +) -> Script { + Script::new( + CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + TransactionArgument::Bool(add_all_currencies), + ], + ) +} + +/// # Summary +/// Initializes the sending account as a recovery address that may be used by +/// the VASP that it belongs to. The sending account must be a VASP account. +/// Multiple recovery addresses can exist for a single VASP, but accounts in +/// each must be disjoint. +/// +/// # Technical Description +/// Publishes a `RecoveryAddress::RecoveryAddress` resource under `account`. It then +/// extracts the `DiemAccount::KeyRotationCapability` for `account` and adds +/// it to the resource. After the successful execution of this transaction +/// other accounts may add their key rotation to this resource so that `account` +/// may be used as a recovery account for those accounts. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer of the sending account of the transaction. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ENOT_A_VASP` | `account` is not a VASP account. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE` | A key rotation recovery cycle would be created by adding `account`'s key rotation capability. | +/// | `Errors::ALREADY_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | A `RecoveryAddress::RecoveryAddress` resource has already been published under `account`. | +/// +/// # Related Scripts +/// * `Script::add_recovery_rotation_capability` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_create_recovery_address_script() -> Script { + Script::new(CREATE_RECOVERY_ADDRESS_CODE.to_vec(), vec![], vec![]) +} + +/// # Summary +/// Creates a Validator account. This transaction can only be sent by the Diem +/// Root account. +/// +/// # Technical Description +/// Creates an account with a Validator role at `new_account_address`, with authentication key +/// `auth_key_prefix` | `new_account_address`. It publishes a +/// `ValidatorConfig::ValidatorConfig` resource with empty `config`, and +/// `operator_account` fields. The `human_name` field of the +/// `ValidatorConfig::ValidatorConfig` is set to the passed in `human_name`. +/// This script does not add the validator to the validator set or the system, +/// but only creates the account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Validator account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the validator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::add_validator_and_reconfigure` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_create_validator_account_script( + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, +) -> Script { + Script::new( + CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + ], + ) +} + +/// # Summary +/// Creates a Validator Operator account. This transaction can only be sent by the Diem +/// Root account. +/// +/// # Technical Description +/// Creates an account with a Validator Operator role at `new_account_address`, with authentication key +/// `auth_key_prefix` | `new_account_address`. It publishes a +/// `ValidatorOperatorConfig::ValidatorOperatorConfig` resource with the specified `human_name`. +/// This script does not assign the validator operator to any validator accounts but only creates the account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_account_address` | `address` | Address of the to-be-created Validator account. | +/// | `auth_key_prefix` | `vector` | The authentication key prefix that will be used initially for the newly created account. | +/// | `human_name` | `vector` | ASCII-encoded human name for the validator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::ALREADY_PUBLISHED` | `Roles::EROLE_ID` | The `new_account_address` address is already taken. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_create_validator_operator_account_script( + sliding_nonce: u64, + new_account_address: AccountAddress, + auth_key_prefix: Vec, + human_name: Vec, +) -> Script { + Script::new( + CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(new_account_address), + TransactionArgument::U8Vector(auth_key_prefix), + TransactionArgument::U8Vector(human_name), + ], + ) +} + +/// # Summary +/// Freezes the account at `address`. The sending account of this transaction +/// must be the Treasury Compliance account. The account being frozen cannot be +/// the Diem Root or Treasury Compliance account. After the successful +/// execution of this transaction no transactions may be sent from the frozen +/// account, and the frozen account may not send or receive coins. +/// +/// # Technical Description +/// Sets the `AccountFreezing::FreezingBit` to `true` and emits a +/// `AccountFreezing::FreezeAccountEvent`. The transaction sender must be the +/// Treasury Compliance account, but the account at `to_freeze_account` must +/// not be either `0xA550C18` (the Diem Root address), or `0xB1E55ED` (the +/// Treasury Compliance address). Note that this is a per-account property +/// e.g., freezing a Parent VASP will not effect the status any of its child +/// accounts and vice versa. +/// + +/// ## Events +/// Successful execution of this transaction will emit a `AccountFreezing::FreezeAccountEvent` on +/// the `freeze_event_handle` held in the `AccountFreezing::FreezeEventsHolder` resource published +/// under `0xA550C18` with the `frozen_address` being the `to_freeze_account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `to_freeze_account` | `address` | The account address to be frozen. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_TC` | `to_freeze_account` was the Treasury Compliance account (`0xB1E55ED`). | +/// | `Errors::INVALID_ARGUMENT` | `AccountFreezing::ECANNOT_FREEZE_DIEM_ROOT` | `to_freeze_account` was the Diem Root account (`0xA550C18`). | +/// +/// # Related Scripts +/// * `Script::unfreeze_account` +pub fn encode_freeze_account_script( + sliding_nonce: u64, + to_freeze_account: AccountAddress, +) -> Script { + Script::new( + FREEZE_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(to_freeze_account), + ], + ) +} + +/// # Summary +/// Transfers a given number of coins in a specified currency from one account to another. +/// Transfers over a specified amount defined on-chain that are between two different VASPs, or +/// other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has +/// agreed to receive the coins. This transaction can be sent by any account that can hold a +/// balance, and to any account that can hold a balance. Both accounts must hold balances in the +/// currency being transacted. +/// +/// # Technical Description +/// +/// Transfers `amount` coins of type `Currency` from `payer` to `payee` with (optional) associated +/// `metadata` and an (optional) `metadata_signature` on the message +/// `metadata` | `Signer::address_of(payer)` | `amount` | `DualAttestation::DOMAIN_SEPARATOR`. +/// The `metadata` and `metadata_signature` parameters are only required if `amount` >= +/// `DualAttestation::get_cur_microdiem_limit` XDX and `payer` and `payee` are distinct VASPs. +/// However, a transaction sender can opt in to dual attestation even when it is not required +/// (e.g., a DesignatedDealer -> VASP payment) by providing a non-empty `metadata_signature`. +/// Standardized `metadata` BCS format can be found in `diem_types::transaction::metadata::Metadata`. +/// +/// ## Events +/// Successful execution of this script emits two events: +/// * A `DiemAccount::SentPaymentEvent` on `payer`'s `DiemAccount::DiemAccount` `sent_events` handle; and +/// * A `DiemAccount::ReceivedPaymentEvent` on `payee`'s `DiemAccount::DiemAccount` `received_events` handle. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` being sent in this transaction. `Currency` must be an already-registered currency on-chain. | +/// | `payer` | `&signer` | The signer reference of the sending account that coins are being transferred from. | +/// | `payee` | `address` | The address of the account the coins are being transferred to. | +/// | `metadata` | `vector` | Optional metadata about this payment. | +/// | `metadata_signature` | `vector` | Optional signature over `metadata` and payment information. See | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY` | `payer` doesn't hold a balance in `Currency`. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EINSUFFICIENT_BALANCE` | `amount` is greater than `payer`'s balance in `Currency`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::ECOIN_DEPOSIT_IS_ZERO` | `amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DiemAccount::EPAYEE_DOES_NOT_EXIST` | No account exists at the `payee` address. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE` | An account exists at `payee`, but it does not accept payments in `Currency`. | +/// | `Errors::INVALID_STATE` | `AccountFreezing::EACCOUNT_FROZEN` | The `payee` account is frozen. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EMALFORMED_METADATA_SIGNATURE` | `metadata_signature` is not 64 bytes. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_METADATA_SIGNATURE` | `metadata_signature` does not verify on the against the `payee'`s `DualAttestation::Credential` `compliance_public_key` public key. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS` | `payer` has exceeded its daily withdrawal limits for the backing coins of XDX. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | `payee` has exceeded its daily deposit limits for XDX. | +/// +/// # Related Scripts +/// * `Script::create_child_vasp_account` +/// * `Script::create_parent_vasp_account` +/// * `Script::add_currency_to_account` +pub fn encode_peer_to_peer_with_metadata_script( + currency: TypeTag, + payee: AccountAddress, + amount: u64, + metadata: Vec, + metadata_signature: Vec, +) -> Script { + Script::new( + PEER_TO_PEER_WITH_METADATA_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::Address(payee), + TransactionArgument::U64(amount), + TransactionArgument::U8Vector(metadata), + TransactionArgument::U8Vector(metadata_signature), + ], + ) +} + +/// # Summary +/// Moves a specified number of coins in a given currency from the account's +/// balance to its preburn area after which the coins may be burned. This +/// transaction may be sent by any account that holds a balance and preburn area +/// in the specified currency. +/// +/// # Technical Description +/// Moves the specified `amount` of coins in `Token` currency from the sending `account`'s +/// `DiemAccount::Balance` to the `Diem::Preburn` 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` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EPREBURN_OCCUPIED` | The `value` field in the `Diem::Preburn` resource under the sender is non-zero. | +/// | `Errors::NOT_PUBLISHED` | `Roles::EROLE_ID` | The `account` did not have a role assigned to it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDESIGNATED_DEALER` | The `account` did not have the role of DesignatedDealer. | +/// +/// # Related Scripts +/// * `Script::cancel_burn` +/// * `Script::burn` +/// * `Script::burn_txn_fees` +pub fn encode_preburn_script(token: TypeTag, amount: u64) -> Script { + Script::new( + PREBURN_CODE.to_vec(), + vec![token], + vec![TransactionArgument::U64(amount)], + ) +} + +/// # Summary +/// Rotates the authentication key of the sending account to the +/// newly-specified public key and publishes a new shared authentication key +/// under the sender's account. Any account can send this transaction. +/// +/// # Technical Description +/// Rotates the authentication key of the sending account to `public_key`, +/// and publishes a `SharedEd25519PublicKey::SharedEd25519PublicKey` resource +/// containing the 32-byte ed25519 `public_key` and the `DiemAccount::KeyRotationCapability` for +/// `account` under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key for `account`' authentication key to be rotated to and stored. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability` resource. | +/// | `Errors::ALREADY_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | The `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is already published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::rotate_shared_ed25519_public_key` +pub fn encode_publish_shared_ed25519_public_key_script(public_key: Vec) -> Script { + Script::new( + PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(public_key)], + ) +} + +/// # Summary +/// Updates a validator's configuration. This does not reconfigure the system and will not update +/// the configuration in the validator set that is seen by other validators in the network. Can +/// only be successfully sent by a Validator Operator account that is already registered with a +/// validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It does not emit a `DiemConfig::NewEpochEvent` +/// so the copy of this config held in the validator set will not be updated, and the changes are +/// only "locally" under the `validator_account` account address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_register_validator_config_script( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> Script { + Script::new( + REGISTER_VALIDATOR_CONFIG_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(validator_account), + TransactionArgument::U8Vector(consensus_pubkey), + TransactionArgument::U8Vector(validator_network_addresses), + TransactionArgument::U8Vector(fullnode_network_addresses), + ], + ) +} + +/// # Summary +/// This script removes a validator account from the validator set, and triggers a reconfiguration +/// of the system to remove the validator from the system. This transaction can only be +/// successfully called by the Diem Root account. +/// +/// # Technical Description +/// This script removes the account at `validator_address` from the validator set. This transaction +/// emits a `DiemConfig::NewEpochEvent` event. Once the reconfiguration triggered by this event +/// has been performed, the account at `validator_address` is no longer considered to be a +/// validator in the network. This transaction will fail if the validator at `validator_address` +/// is not in the validator set. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Diem Root signer. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `validator_name` | `vector` | ASCII-encoded human name for the validator. Must match the human name in the `ValidatorConfig::ValidatorConfig` for the validator. | +/// | `validator_address` | `address` | The validator account address to be removed from the validator set. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | 0 | 0 | The provided `validator_name` does not match the already-recorded human name for the validator. | +/// | `Errors::INVALID_ARGUMENT` | `DiemSystem::ENOT_AN_ACTIVE_VALIDATOR` | The validator to be removed is not in the validator set. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EDIEM_ROOT` | The sending account is not the Diem Root account. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_remove_validator_and_reconfigure_script( + sliding_nonce: u64, + validator_name: Vec, + validator_address: AccountAddress, +) -> Script { + Script::new( + REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(validator_name), + TransactionArgument::Address(validator_address), + ], + ) +} + +/// # Summary +/// Rotates the transaction sender's authentication key to the supplied new authentication key. May +/// be sent by any account. +/// +/// # Technical Description +/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_nonce_admin` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_script(new_key: Vec) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(new_key)], + ) +} + +/// # Summary +/// Rotates the sender's authentication key to the supplied new authentication key. May be sent by +/// any account that has a sliding nonce resource published under it (usually this is Treasury +/// Compliance or Diem Root accounts). +/// +/// # Technical Description +/// Rotates the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce_admin` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_with_nonce_script( + sliding_nonce: u64, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the specified account's authentication key to the supplied new authentication key. May +/// only be sent by the Diem Root account as a write set transaction. +/// +/// # Technical Description +/// Rotate the `account`'s `DiemAccount::DiemAccount` `authentication_key` field to `new_key`. +/// `new_key` must be a valid ed25519 public key, and `account` must not have previously delegated +/// its `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | +/// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | +/// | `new_key` | `vector` | New ed25519 public key to be used for `account`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::INVALID_STATE` | `DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED` | `account` has already delegated/extracted its `DiemAccount::KeyRotationCapability`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_recovery_address` +pub fn encode_rotate_authentication_key_with_nonce_admin_script( + sliding_nonce: u64, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the authentication key of a specified account that is part of a recovery address to a +/// new authentication key. Only used for accounts that are part of a recovery address (see +/// `Script::add_recovery_rotation_capability` for account restrictions). +/// +/// # Technical Description +/// Rotates the authentication key of the `to_recover` account to `new_key` using the +/// `DiemAccount::KeyRotationCapability` stored in the `RecoveryAddress::RecoveryAddress` resource +/// published under `recovery_address`. This transaction can be sent either by the `to_recover` +/// account, or by the account where the `RecoveryAddress::RecoveryAddress` resource is published +/// that contains `to_recover`'s `DiemAccount::KeyRotationCapability`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `recovery_address` | `address` | Address where `RecoveryAddress::RecoveryAddress` that holds `to_recover`'s `DiemAccount::KeyRotationCapability` is published. | +/// | `to_recover` | `address` | The address of the account whose authentication key will be updated. | +/// | `new_key` | `vector` | New ed25519 public key to be used for the account at the `to_recover` address. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `RecoveryAddress::ERECOVERY_ADDRESS` | `recovery_address` does not have a `RecoveryAddress::RecoveryAddress` resource published under it. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::ECANNOT_ROTATE_KEY` | The address of `account` is not `recovery_address` or `to_recover`. | +/// | `Errors::INVALID_ARGUMENT` | `RecoveryAddress::EACCOUNT_NOT_RECOVERABLE` | `to_recover`'s `DiemAccount::KeyRotationCapability` is not in the `RecoveryAddress::RecoveryAddress` resource published under `recovery_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DiemAccount::EMALFORMED_AUTHENTICATION_KEY` | `new_key` was an invalid length. | +/// +/// # Related Scripts +/// * `Script::rotate_authentication_key` +/// * `Script::rotate_authentication_key_with_nonce` +/// * `Script::rotate_authentication_key_with_nonce_admin` +pub fn encode_rotate_authentication_key_with_recovery_address_script( + recovery_address: AccountAddress, + to_recover: AccountAddress, + new_key: Vec, +) -> Script { + Script::new( + ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(recovery_address), + TransactionArgument::Address(to_recover), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Updates the url used for off-chain communication, and the public key used to verify dual +/// attestation on-chain. Transaction can be sent by any account that has dual attestation +/// information published under it. In practice the only such accounts are Designated Dealers and +/// Parent VASPs. +/// +/// # Technical Description +/// Updates the `base_url` and `compliance_public_key` fields of the `DualAttestation::Credential` +/// resource published under `account`. The `new_key` must be a valid ed25519 public key. +/// +/// ## Events +/// Successful execution of this transaction emits two events: +/// * A `DualAttestation::ComplianceKeyRotationEvent` containing the new compliance public key, and +/// the blockchain time at which the key was updated emitted on the `DualAttestation::Credential` +/// `compliance_key_rotation_events` handle published under `account`; and +/// * A `DualAttestation::BaseUrlRotationEvent` containing the new base url to be used for +/// off-chain communication, and the blockchain time at which the url was updated emitted on the +/// `DualAttestation::Credential` `base_url_rotation_events` handle published under `account`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account of the transaction. | +/// | `new_url` | `vector` | ASCII-encoded url to be used for off-chain communication with `account`. | +/// | `new_key` | `vector` | New ed25519 public key to be used for on-chain dual attestation checking. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `DualAttestation::ECREDENTIAL` | A `DualAttestation::Credential` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `DualAttestation::EINVALID_PUBLIC_KEY` | `new_key` is not a valid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::create_parent_vasp_account` +/// * `Script::create_designated_dealer` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_rotate_dual_attestation_info_script(new_url: Vec, new_key: Vec) -> Script { + Script::new( + ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U8Vector(new_url), + TransactionArgument::U8Vector(new_key), + ], + ) +} + +/// # Summary +/// Rotates the authentication key in a `SharedEd25519PublicKey`. This transaction can be sent by +/// any account that has previously published a shared ed25519 public key using +/// `Script::publish_shared_ed25519_public_key`. +/// +/// # Technical Description +/// This first rotates the public key stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` resource to `public_key`, after which it +/// rotates the authentication key using the capability stored in `account`'s +/// `SharedEd25519PublicKey::SharedEd25519PublicKey` to a new value derived from `public_key` +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `public_key` | `vector` | 32-byte Ed25519 public key. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SharedEd25519PublicKey::ESHARED_KEY` | A `SharedEd25519PublicKey::SharedEd25519PublicKey` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY` | `public_key` is an invalid ed25519 public key. | +/// +/// # Related Scripts +/// * `Script::publish_shared_ed25519_public_key` +pub fn encode_rotate_shared_ed25519_public_key_script(public_key: Vec) -> Script { + Script::new( + ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + vec![], + vec![TransactionArgument::U8Vector(public_key)], + ) +} + +/// # Summary +/// Updates a validator's configuration, and triggers a reconfiguration of the system to update the +/// validator set with this new validator configuration. Can only be successfully sent by a +/// Validator Operator account that is already registered with a validator. +/// +/// # Technical Description +/// This updates the fields with corresponding names held in the `ValidatorConfig::ValidatorConfig` +/// config resource held under `validator_account`. It then emits a `DiemConfig::NewEpochEvent` to +/// trigger a reconfiguration of the system. This reconfiguration will update the validator set +/// on-chain with the updated `ValidatorConfig::ValidatorConfig`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `validator_operator_account` | `&signer` | Signer reference of the sending account. Must be the registered validator operator for the validator at `validator_address`. | +/// | `validator_account` | `address` | The address of the validator's `ValidatorConfig::ValidatorConfig` resource being updated. | +/// | `consensus_pubkey` | `vector` | New Ed25519 public key to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `validator_network_addresses` | `vector` | New set of `validator_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// | `fullnode_network_addresses` | `vector` | New set of `fullnode_network_addresses` to be used in the updated `ValidatorConfig::ValidatorConfig`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | `validator_address` does not have a `ValidatorConfig::ValidatorConfig` resource published under it. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR_OPERATOR` | `validator_operator_account` does not have a Validator Operator role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_TRANSACTION_SENDER` | `validator_operator_account` is not the registered operator for the validator at `validator_address`. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::EINVALID_CONSENSUS_KEY` | `consensus_pubkey` is not a valid ed25519 public key. | +/// | `Errors::INVALID_STATE` | `DiemConfig::EINVALID_BLOCK_TIME` | An invalid time value was encountered in reconfiguration. Unlikely to occur. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::register_validator_config` +pub fn encode_set_validator_config_and_reconfigure_script( + validator_account: AccountAddress, + consensus_pubkey: Vec, + validator_network_addresses: Vec, + fullnode_network_addresses: Vec, +) -> Script { + Script::new( + SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::Address(validator_account), + TransactionArgument::U8Vector(consensus_pubkey), + TransactionArgument::U8Vector(validator_network_addresses), + TransactionArgument::U8Vector(fullnode_network_addresses), + ], + ) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by an account with +/// Validator role. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the sending validator account. The account at `operator_account` address must have +/// a Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` +/// resource published under it. The sending `account` must be a Validator and have a +/// `ValidatorConfig::ValidatorConfig` resource published under it. This script does not emit a +/// `DiemConfig::NewEpochEvent` and no reconfiguration of the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | The signer reference of the sending account of the transaction. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator_with_nonce_admin` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_script( + operator_name: Vec, + operator_account: AccountAddress, +) -> Script { + Script::new( + SET_VALIDATOR_OPERATOR_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U8Vector(operator_name), + TransactionArgument::Address(operator_account), + ], + ) +} + +/// # Summary +/// Sets the validator operator for a validator in the validator's configuration resource "locally" +/// and does not reconfigure the system. Changes from this transaction will not picked up by the +/// system until a reconfiguration of the system is triggered. May only be sent by the Diem Root +/// account as a write set transaction. +/// +/// # Technical Description +/// Sets the account at `operator_account` address and with the specified `human_name` as an +/// operator for the validator `account`. The account at `operator_account` address must have a +/// Validator Operator role and have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource +/// published under it. The account represented by the `account` signer must be a Validator and +/// have a `ValidatorConfig::ValidatorConfig` resource published under it. No reconfiguration of +/// the system is initiated by this script. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `dr_account` | `&signer` | The signer reference of the sending account of the write set transaction. May only be the Diem Root signer. | +/// | `account` | `&signer` | Signer reference of account specified in the `execute_as` field of the write set transaction. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction for Diem Root. | +/// | `operator_name` | `vector` | Validator operator's human name. | +/// | `operator_account` | `address` | Address of the validator operator account to be added as the `account` validator's operator. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `dr_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` in `dr_account` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` in `dr_account` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` in` dr_account` has been previously recorded. | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | The sending account is not the Diem Root account or Treasury Compliance account | +/// | `Errors::NOT_PUBLISHED` | `ValidatorOperatorConfig::EVALIDATOR_OPERATOR_CONFIG` | The `ValidatorOperatorConfig::ValidatorOperatorConfig` resource is not published under `operator_account`. | +/// | 0 | 0 | The `human_name` field of the `ValidatorOperatorConfig::ValidatorOperatorConfig` resource under `operator_account` does not match the provided `human_name`. | +/// | `Errors::REQUIRES_ROLE` | `Roles::EVALIDATOR` | `account` does not have a Validator account role. | +/// | `Errors::INVALID_ARGUMENT` | `ValidatorConfig::ENOT_A_VALIDATOR_OPERATOR` | The account at `operator_account` does not have a `ValidatorOperatorConfig::ValidatorOperatorConfig` resource. | +/// | `Errors::NOT_PUBLISHED` | `ValidatorConfig::EVALIDATOR_CONFIG` | A `ValidatorConfig::ValidatorConfig` is not published under `account`. | +/// +/// # Related Scripts +/// * `Script::create_validator_account` +/// * `Script::create_validator_operator_account` +/// * `Script::register_validator_config` +/// * `Script::remove_validator_and_reconfigure` +/// * `Script::add_validator_and_reconfigure` +/// * `Script::set_validator_operator` +/// * `Script::set_validator_config_and_reconfigure` +pub fn encode_set_validator_operator_with_nonce_admin_script( + sliding_nonce: u64, + operator_name: Vec, + operator_account: AccountAddress, +) -> Script { + Script::new( + SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U8Vector(operator_name), + TransactionArgument::Address(operator_account), + ], + ) +} + +/// # Summary +/// Mints a specified number of coins in a currency to a Designated Dealer. The sending account +/// must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer +/// account. +/// +/// # Technical Description +/// Mints `mint_amount` of coins in the `CoinType` currency to Designated Dealer account at +/// `designated_dealer_address`. The `tier_index` parameter specifies which tier should be used to +/// check verify the off-chain approval policy, and is based in part on the on-chain tier values +/// for the specific Designated Dealer, and the number of `CoinType` coins that have been minted to +/// the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that +/// they support. The sending `tc_account` must be the Treasury Compliance account, and the +/// receiver an authorized Designated Dealer account. +/// +/// ## Events +/// Successful execution of the transaction will emit two events: +/// * A `Diem::MintEvent` with the amount and currency code minted is emitted on the +/// `mint_event_handle` in the stored `Diem::CurrencyInfo` resource stored under +/// `0xA550C18`; and +/// * A `DesignatedDealer::ReceivedMintEvent` with the amount, currency code, and Designated +/// Dealer's address is emitted on the `mint_event_handle` in the stored `DesignatedDealer::Dealer` +/// resource published under the `designated_dealer_address`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `CoinType` | Type | The Move type for the `CoinType` being minted. `CoinType` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `designated_dealer_address` | `address` | The address of the Designated Dealer account being minted to. | +/// | `mint_amount` | `u64` | The number of coins to be minted. | +/// | `tier_index` | `u64` | The mint tier index to use for the Designated Dealer account. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_MINT_AMOUNT` | `mint_amount` is zero. | +/// | `Errors::NOT_PUBLISHED` | `DesignatedDealer::EDEALER` | `DesignatedDealer::Dealer` or `DesignatedDealer::TierInfo` resource does not exist at `designated_dealer_address`. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_TIER_INDEX` | The `tier_index` is out of bounds. | +/// | `Errors::INVALID_ARGUMENT` | `DesignatedDealer::EINVALID_AMOUNT_FOR_TIER` | `mint_amount` exceeds the maximum allowed amount for `tier_index`. | +/// | `Errors::REQUIRES_CAPABILITY` | `Diem::EMINT_CAPABILITY` | `tc_account` does not have a `Diem::MintCapability` resource published under it. | +/// | `Errors::INVALID_STATE` | `Diem::EMINTING_NOT_ALLOWED` | Minting is not currently allowed for `CoinType` coins. | +/// | `Errors::LIMIT_EXCEEDED` | `DiemAccount::EDEPOSIT_EXCEEDS_LIMITS` | The depositing of the funds would exceed the `account`'s account limits. | +/// +/// # Related Scripts +/// * `Script::create_designated_dealer` +/// * `Script::peer_to_peer_with_metadata` +/// * `Script::rotate_dual_attestation_info` +pub fn encode_tiered_mint_script( + coin_type: TypeTag, + sliding_nonce: u64, + designated_dealer_address: AccountAddress, + mint_amount: u64, + tier_index: u64, +) -> Script { + Script::new( + TIERED_MINT_CODE.to_vec(), + vec![coin_type], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(designated_dealer_address), + TransactionArgument::U64(mint_amount), + TransactionArgument::U64(tier_index), + ], + ) +} + +/// # Summary +/// Unfreezes the account at `address`. The sending account of this transaction must be the +/// Treasury Compliance account. After the successful execution of this transaction transactions +/// may be sent from the previously frozen account, and coins may be sent and received. +/// +/// # Technical Description +/// Sets the `AccountFreezing::FreezingBit` to `false` and emits a +/// `AccountFreezing::UnFreezeAccountEvent`. The transaction sender must be the Treasury Compliance +/// account. Note that this is a per-account property so unfreezing a Parent VASP will not effect +/// the status any of its child accounts and vice versa. +/// +/// ## Events +/// Successful execution of this script will emit a `AccountFreezing::UnFreezeAccountEvent` with +/// the `unfrozen_address` set the `to_unfreeze_account`'s address. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `to_unfreeze_account` | `address` | The account address to be frozen. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | The sending account is not the Treasury Compliance account. | +/// +/// # Related Scripts +/// * `Script::freeze_account` +pub fn encode_unfreeze_account_script( + sliding_nonce: u64, + to_unfreeze_account: AccountAddress, +) -> Script { + Script::new( + UNFREEZE_ACCOUNT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::Address(to_unfreeze_account), + ], + ) +} + +/// # Summary +/// Updates the Diem major version that is stored on-chain and is used by the VM. This +/// transaction can only be sent from the Diem Root account. +/// +/// # Technical Description +/// Updates the `DiemVersion` on-chain config and emits a `DiemConfig::NewEpochEvent` to trigger +/// a reconfiguration of the system. The `major` version that is passed in must be strictly greater +/// than the current major version held on-chain. The VM reads this information and can use it to +/// preserve backwards compatibility with previous major versions of the VM. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `major` | `u64` | The `major` version of the VM to be used from this transaction on. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::EDIEM_ROOT` | `account` is not the Diem Root account. | +/// | `Errors::INVALID_ARGUMENT` | `DiemVersion::EINVALID_MAJOR_VERSION_NUMBER` | `major` is less-than or equal to the current major version stored on-chain. | +pub fn encode_update_diem_version_script(sliding_nonce: u64, major: u64) -> Script { + Script::new( + UPDATE_DIEM_VERSION_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(major), + ], + ) +} + +/// # Summary +/// Update the dual attestation limit on-chain. Defined in terms of micro-XDX. The transaction can +/// only be sent by the Treasury Compliance account. After this transaction all inter-VASP +/// payments over this limit must be checked for dual attestation. +/// +/// # Technical Description +/// Updates the `micro_xdx_limit` field of the `DualAttestation::Limit` resource published under +/// `0xA550C18`. The amount is set in micro-XDX. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for this transaction. | +/// | `new_micro_xdx_limit` | `u64` | The new dual attestation limit to be used on-chain. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// +/// # Related Scripts +/// * `Script::update_exchange_rate` +/// * `Script::update_minting_ability` +pub fn encode_update_dual_attestation_limit_script( + sliding_nonce: u64, + new_micro_xdx_limit: u64, +) -> Script { + Script::new( + UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(), + vec![], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(new_micro_xdx_limit), + ], + ) +} + +/// # Summary +/// Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion +/// to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this +/// transaction the updated exchange rate will be used for normalization of gas prices, and for +/// dual attestation checking. +/// +/// # Technical Description +/// Updates the on-chain exchange rate from the given `Currency` to micro-XDX. The exchange rate +/// is given by `new_exchange_rate_numerator/new_exchange_rate_denominator`. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` whose exchange rate is being updated. `Currency` must be an already-registered currency on-chain. | +/// | `tc_account` | `&signer` | The signer reference of the sending account of this transaction. Must be the Treasury Compliance account. | +/// | `sliding_nonce` | `u64` | The `sliding_nonce` (see: `SlidingNonce`) to be used for the transaction. | +/// | `new_exchange_rate_numerator` | `u64` | The numerator for the new to micro-XDX exchange rate for `Currency`. | +/// | `new_exchange_rate_denominator` | `u64` | The denominator for the new to micro-XDX exchange rate for `Currency`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::NOT_PUBLISHED` | `SlidingNonce::ESLIDING_NONCE` | A `SlidingNonce` resource is not published under `tc_account`. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_OLD` | The `sliding_nonce` is too old and it's impossible to determine if it's duplicated or not. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_TOO_NEW` | The `sliding_nonce` is too far in the future. | +/// | `Errors::INVALID_ARGUMENT` | `SlidingNonce::ENONCE_ALREADY_RECORDED` | The `sliding_nonce` has been previously recorded. | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::REQUIRES_ROLE` | `Roles::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::EDENOMINATOR` | `new_exchange_rate_denominator` is zero. | +/// | `Errors::INVALID_ARGUMENT` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | +/// | `Errors::LIMIT_EXCEEDED` | `FixedPoint32::ERATIO_OUT_OF_RANGE` | The quotient is unrepresentable as a `FixedPoint32`. | +/// +/// # Related Scripts +/// * `Script::update_dual_attestation_limit` +/// * `Script::update_minting_ability` +pub fn encode_update_exchange_rate_script( + currency: TypeTag, + sliding_nonce: u64, + new_exchange_rate_numerator: u64, + new_exchange_rate_denominator: u64, +) -> Script { + Script::new( + UPDATE_EXCHANGE_RATE_CODE.to_vec(), + vec![currency], + vec![ + TransactionArgument::U64(sliding_nonce), + TransactionArgument::U64(new_exchange_rate_numerator), + TransactionArgument::U64(new_exchange_rate_denominator), + ], + ) +} + +/// # Summary +/// Script to allow or disallow minting of new coins in a specified currency. This transaction can +/// only be sent by the Treasury Compliance account. Turning minting off for a currency will have +/// no effect on coins already in circulation, and coins may still be removed from the system. +/// +/// # Technical Description +/// This transaction sets the `can_mint` field of the `Diem::CurrencyInfo` resource +/// published under `0xA550C18` to the value of `allow_minting`. Minting of coins if allowed if +/// this field is set to `true` and minting of new coins in `Currency` is disallowed otherwise. +/// This transaction needs to be sent by the Treasury Compliance account. +/// +/// # Parameters +/// | Name | Type | Description | +/// | ------ | ------ | ------------- | +/// | `Currency` | Type | The Move type for the `Currency` whose minting ability is being updated. `Currency` must be an already-registered currency on-chain. | +/// | `account` | `&signer` | Signer reference of the sending account. Must be the Diem Root account. | +/// | `allow_minting` | `bool` | Whether to allow minting of new coins in `Currency`. | +/// +/// # Common Abort Conditions +/// | Error Category | Error Reason | Description | +/// | ---------------- | -------------- | ------------- | +/// | `Errors::REQUIRES_ADDRESS` | `CoreAddresses::ETREASURY_COMPLIANCE` | `tc_account` is not the Treasury Compliance account. | +/// | `Errors::NOT_PUBLISHED` | `Diem::ECURRENCY_INFO` | `Currency` is not a registered currency on-chain. | +/// +/// # Related Scripts +/// * `Script::update_dual_attestation_limit` +/// * `Script::update_exchange_rate` +pub fn encode_update_minting_ability_script(currency: TypeTag, allow_minting: bool) -> Script { + Script::new( + UPDATE_MINTING_ABILITY_CODE.to_vec(), + vec![currency], + vec![TransactionArgument::Bool(allow_minting)], + ) +} + +fn decode_add_currency_to_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddCurrencyToAccount { + currency: script.ty_args().first()?.clone(), + }) + } else { + None + } +} + +fn decode_add_diem_id_domain_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddDiemIdDomain { + address: bcs::from_bytes(script.args().first()?).ok()?, + domain: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_add_recovery_rotation_capability_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddRecoveryRotationCapability { + recovery_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_add_validator_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AddValidatorAndReconfigure { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + validator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_address: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_autopay_create_instruction_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::AutopayCreateInstruction { + uid: bcs::from_bytes(script.args().first()?).ok()?, + in_type: bcs::from_bytes(script.args().get(1)?).ok()?, + payee: bcs::from_bytes(script.args().get(2)?).ok()?, + end_epoch: bcs::from_bytes(script.args().get(3)?).ok()?, + value: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_autopay_disable_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::AutopayDisable {}) + } else { + None + } +} + +fn decode_autopay_enable_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::AutopayEnable {}) + } else { + None + } +} + +fn decode_burn_txn_fees_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::BurnTxnFees { + coin_type: script.ty_args().first()?.clone(), + }) + } else { + None + } +} + +fn decode_burn_with_amount_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::BurnWithAmount { + token: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CancelBurnWithAmount { + token: script.ty_args().first()?.clone(), + preburn_address: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_acc_user_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateAccUser { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_acc_val_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateAccVal { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + ow_human_name: bcs::from_bytes(script.args().get(2)?).ok()?, + op_address: bcs::from_bytes(script.args().get(3)?).ok()?, + op_auth_key_prefix: bcs::from_bytes(script.args().get(4)?).ok()?, + op_consensus_pubkey: bcs::from_bytes(script.args().get(5)?).ok()?, + op_validator_network_addresses: bcs::from_bytes(script.args().get(6)?).ok()?, + op_fullnode_network_addresses: bcs::from_bytes(script.args().get(7)?).ok()?, + op_human_name: bcs::from_bytes(script.args().get(8)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_child_vasp_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateChildVaspAccount { + coin_type: script.ty_args().first()?.clone(), + child_address: bcs::from_bytes(script.args().first()?).ok()?, + auth_key_prefix: bcs::from_bytes(script.args().get(1)?).ok()?, + add_all_currencies: bcs::from_bytes(script.args().get(2)?).ok()?, + child_initial_balance: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_designated_dealer_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateDesignatedDealer { + currency: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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_diem_id_domains_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::CreateDiemIdDomains {}) + } else { + None + } +} + +fn decode_create_parent_vasp_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateParentVaspAccount { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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()?, + add_all_currencies: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_create_recovery_address_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::CreateRecoveryAddress {}) + } else { + None + } +} + +fn decode_create_validator_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateValidatorAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::CreateValidatorOperatorAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).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_demo_e2e_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::DemoE2e { + world: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_freeze_account_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::FreezeAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + to_freeze_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_initialize_diem_consensus_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::InitializeDiemConsensusConfig { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_join_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::Join {}) + } else { + None + } +} + +fn decode_leave_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::Leave {}) + } else { + None + } +} + +fn decode_minerstate_commit_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::MinerstateCommit { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_minerstate_commit_by_operator_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::MinerstateCommitByOperator { + owner_address: bcs::from_bytes(script.args().first()?).ok()?, + challenge: bcs::from_bytes(script.args().get(1)?).ok()?, + solution: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_minerstate_helper_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::MinerstateHelper {}) + } else { + None + } +} + +fn decode_ol_oracle_tx_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::OlOracleTx { + id: bcs::from_bytes(script.args().first()?).ok()?, + data: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_ol_reconfig_bulk_update_setup_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::OlReconfigBulkUpdateSetup { + alice: bcs::from_bytes(script.args().first()?).ok()?, + bob: bcs::from_bytes(script.args().get(1)?).ok()?, + carol: bcs::from_bytes(script.args().get(2)?).ok()?, + sha: bcs::from_bytes(script.args().get(3)?).ok()?, + ram: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } +} + +fn decode_peer_to_peer_with_metadata_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::PeerToPeerWithMetadata { + currency: script.ty_args().first()?.clone(), + payee: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_signature: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_preburn_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::Preburn { + token: script.ty_args().first()?.clone(), + amount: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_publish_shared_ed25519_public_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::PublishSharedEd25519PublicKey { + public_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_register_validator_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RegisterValidatorConfig { + validator_account: bcs::from_bytes(script.args().first()?).ok()?, + consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_network_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_remove_diem_id_domain_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RemoveDiemIdDomain { + address: bcs::from_bytes(script.args().first()?).ok()?, + domain: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_remove_validator_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RemoveValidatorAndReconfigure { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + validator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_address: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKey { + new_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_with_nonce_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonce { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + new_key: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_authentication_key_with_recovery_address_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some( + ScriptFunctionCall::RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: bcs::from_bytes(script.args().first()?).ok()?, + to_recover: bcs::from_bytes(script.args().get(1)?).ok()?, + new_key: bcs::from_bytes(script.args().get(2)?).ok()?, + }, + ) + } else { + None + } +} + +fn decode_rotate_dual_attestation_info_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateDualAttestationInfo { + new_url: bcs::from_bytes(script.args().first()?).ok()?, + new_key: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_rotate_shared_ed25519_public_key_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::RotateSharedEd25519PublicKey { + public_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_set_gas_constants_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetGasConstants { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + global_memory_per_byte_cost: bcs::from_bytes(script.args().get(1)?).ok()?, + global_memory_per_byte_write_cost: bcs::from_bytes(script.args().get(2)?).ok()?, + min_transaction_gas_units: bcs::from_bytes(script.args().get(3)?).ok()?, + large_transaction_cutoff: bcs::from_bytes(script.args().get(4)?).ok()?, + intrinsic_gas_per_byte: bcs::from_bytes(script.args().get(5)?).ok()?, + maximum_number_of_gas_units: bcs::from_bytes(script.args().get(6)?).ok()?, + min_price_per_gas_unit: bcs::from_bytes(script.args().get(7)?).ok()?, + max_price_per_gas_unit: bcs::from_bytes(script.args().get(8)?).ok()?, + max_transaction_size_in_bytes: bcs::from_bytes(script.args().get(9)?).ok()?, + gas_unit_scaling_factor: bcs::from_bytes(script.args().get(10)?).ok()?, + default_account_size: bcs::from_bytes(script.args().get(11)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_config_and_reconfigure_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorConfigAndReconfigure { + validator_account: bcs::from_bytes(script.args().first()?).ok()?, + consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + validator_network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_network_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_operator_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorOperator { + operator_name: bcs::from_bytes(script.args().first()?).ok()?, + operator_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_validator_operator_with_nonce_admin_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetValidatorOperatorWithNonceAdmin { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + operator_name: bcs::from_bytes(script.args().get(1)?).ok()?, + operator_account: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } +} + +fn decode_set_wallet_type_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::SetWalletType { + type_of: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_tiered_mint_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::TieredMint { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UnfreezeAccount { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + to_unfreeze_account: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_diem_consensus_config_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDiemConsensusConfig { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + config: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_diem_version_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDiemVersion { + sliding_nonce: bcs::from_bytes(script.args().first()?).ok()?, + major: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } +} + +fn decode_update_dual_attestation_limit_script_function( + payload: &TransactionPayload, +) -> Option { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateDualAttestationLimit { + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateExchangeRate { + currency: script.ty_args().first()?.clone(), + sliding_nonce: bcs::from_bytes(script.args().first()?).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 { + if let TransactionPayload::ScriptFunction(script) = payload { + Some(ScriptFunctionCall::UpdateMintingAbility { + currency: script.ty_args().first()?.clone(), + allow_minting: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } +} + +fn decode_val_add_self_script_function(payload: &TransactionPayload) -> Option { + if let TransactionPayload::ScriptFunction(_script) = payload { + Some(ScriptFunctionCall::ValAddSelf {}) + } else { + None + } +} + +fn decode_add_currency_to_account_script(script: &Script) -> Option { + Some(ScriptCall::AddCurrencyToAccount { + currency: script.ty_args().first()?.clone(), + }) +} + +fn decode_add_recovery_rotation_capability_script(script: &Script) -> Option { + Some(ScriptCall::AddRecoveryRotationCapability { + recovery_address: decode_address_argument(script.args().first()?.clone())?, + }) +} + +fn decode_add_validator_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::AddValidatorAndReconfigure { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_address: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_burn_script(script: &Script) -> Option { + Some(ScriptCall::Burn { + token: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + preburn_address: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_burn_txn_fees_script(script: &Script) -> Option { + Some(ScriptCall::BurnTxnFees { + coin_type: script.ty_args().first()?.clone(), + }) +} + +fn decode_cancel_burn_script(script: &Script) -> Option { + Some(ScriptCall::CancelBurn { + token: script.ty_args().first()?.clone(), + preburn_address: decode_address_argument(script.args().first()?.clone())?, + }) +} + +fn decode_create_child_vasp_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateChildVaspAccount { + coin_type: script.ty_args().first()?.clone(), + child_address: decode_address_argument(script.args().first()?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(1)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(2)?.clone())?, + child_initial_balance: decode_u64_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_create_designated_dealer_script(script: &Script) -> Option { + Some(ScriptCall::CreateDesignatedDealer { + currency: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + addr: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?, + }) +} + +fn decode_create_parent_vasp_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateParentVaspAccount { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + add_all_currencies: decode_bool_argument(script.args().get(4)?.clone())?, + }) +} + +fn decode_create_recovery_address_script(_script: &Script) -> Option { + Some(ScriptCall::CreateRecoveryAddress {}) +} + +fn decode_create_validator_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateValidatorAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_create_validator_operator_account_script(script: &Script) -> Option { + Some(ScriptCall::CreateValidatorOperatorAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_account_address: decode_address_argument(script.args().get(1)?.clone())?, + auth_key_prefix: decode_u8vector_argument(script.args().get(2)?.clone())?, + human_name: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_freeze_account_script(script: &Script) -> Option { + Some(ScriptCall::FreezeAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + to_freeze_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_peer_to_peer_with_metadata_script(script: &Script) -> Option { + Some(ScriptCall::PeerToPeerWithMetadata { + currency: script.ty_args().first()?.clone(), + payee: decode_address_argument(script.args().first()?.clone())?, + amount: decode_u64_argument(script.args().get(1)?.clone())?, + metadata: decode_u8vector_argument(script.args().get(2)?.clone())?, + metadata_signature: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_preburn_script(script: &Script) -> Option { + Some(ScriptCall::Preburn { + token: script.ty_args().first()?.clone(), + amount: decode_u64_argument(script.args().first()?.clone())?, + }) +} + +fn decode_publish_shared_ed25519_public_key_script(script: &Script) -> Option { + Some(ScriptCall::PublishSharedEd25519PublicKey { + public_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_register_validator_config_script(script: &Script) -> Option { + Some(ScriptCall::RegisterValidatorConfig { + validator_account: decode_address_argument(script.args().first()?.clone())?, + consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?, + fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_remove_validator_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::RemoveValidatorAndReconfigure { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + validator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_address: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKey { + new_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_nonce_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithNonce { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_nonce_admin_script(script: &Script) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithNonceAdmin { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_authentication_key_with_recovery_address_script( + script: &Script, +) -> Option { + Some(ScriptCall::RotateAuthenticationKeyWithRecoveryAddress { + recovery_address: decode_address_argument(script.args().first()?.clone())?, + to_recover: decode_address_argument(script.args().get(1)?.clone())?, + new_key: decode_u8vector_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_rotate_dual_attestation_info_script(script: &Script) -> Option { + Some(ScriptCall::RotateDualAttestationInfo { + new_url: decode_u8vector_argument(script.args().first()?.clone())?, + new_key: decode_u8vector_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_rotate_shared_ed25519_public_key_script(script: &Script) -> Option { + Some(ScriptCall::RotateSharedEd25519PublicKey { + public_key: decode_u8vector_argument(script.args().first()?.clone())?, + }) +} + +fn decode_set_validator_config_and_reconfigure_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorConfigAndReconfigure { + validator_account: decode_address_argument(script.args().first()?.clone())?, + consensus_pubkey: decode_u8vector_argument(script.args().get(1)?.clone())?, + validator_network_addresses: decode_u8vector_argument(script.args().get(2)?.clone())?, + fullnode_network_addresses: decode_u8vector_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_set_validator_operator_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorOperator { + operator_name: decode_u8vector_argument(script.args().first()?.clone())?, + operator_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_set_validator_operator_with_nonce_admin_script(script: &Script) -> Option { + Some(ScriptCall::SetValidatorOperatorWithNonceAdmin { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + operator_name: decode_u8vector_argument(script.args().get(1)?.clone())?, + operator_account: decode_address_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_tiered_mint_script(script: &Script) -> Option { + Some(ScriptCall::TieredMint { + coin_type: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + designated_dealer_address: decode_address_argument(script.args().get(1)?.clone())?, + mint_amount: decode_u64_argument(script.args().get(2)?.clone())?, + tier_index: decode_u64_argument(script.args().get(3)?.clone())?, + }) +} + +fn decode_unfreeze_account_script(script: &Script) -> Option { + Some(ScriptCall::UnfreezeAccount { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + to_unfreeze_account: decode_address_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_diem_version_script(script: &Script) -> Option { + Some(ScriptCall::UpdateDiemVersion { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + major: decode_u64_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_dual_attestation_limit_script(script: &Script) -> Option { + Some(ScriptCall::UpdateDualAttestationLimit { + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_micro_xdx_limit: decode_u64_argument(script.args().get(1)?.clone())?, + }) +} + +fn decode_update_exchange_rate_script(script: &Script) -> Option { + Some(ScriptCall::UpdateExchangeRate { + currency: script.ty_args().first()?.clone(), + sliding_nonce: decode_u64_argument(script.args().first()?.clone())?, + new_exchange_rate_numerator: decode_u64_argument(script.args().get(1)?.clone())?, + new_exchange_rate_denominator: decode_u64_argument(script.args().get(2)?.clone())?, + }) +} + +fn decode_update_minting_ability_script(script: &Script) -> Option { + Some(ScriptCall::UpdateMintingAbility { + currency: script.ty_args().first()?.clone(), + allow_minting: decode_bool_argument(script.args().first()?.clone())?, + }) +} + +type TransactionScriptDecoderMap = std::collections::HashMap< + Vec, + Box Option + std::marker::Sync + std::marker::Send>, +>; + +static TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy = + once_cell::sync::Lazy::new(|| { + let mut map: TransactionScriptDecoderMap = std::collections::HashMap::new(); + map.insert( + ADD_CURRENCY_TO_ACCOUNT_CODE.to_vec(), + Box::new(decode_add_currency_to_account_script), + ); + map.insert( + ADD_RECOVERY_ROTATION_CAPABILITY_CODE.to_vec(), + Box::new(decode_add_recovery_rotation_capability_script), + ); + map.insert( + ADD_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_add_validator_and_reconfigure_script), + ); + map.insert(BURN_CODE.to_vec(), Box::new(decode_burn_script)); + map.insert( + BURN_TXN_FEES_CODE.to_vec(), + Box::new(decode_burn_txn_fees_script), + ); + map.insert( + CANCEL_BURN_CODE.to_vec(), + Box::new(decode_cancel_burn_script), + ); + map.insert( + CREATE_CHILD_VASP_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_child_vasp_account_script), + ); + map.insert( + CREATE_DESIGNATED_DEALER_CODE.to_vec(), + Box::new(decode_create_designated_dealer_script), + ); + map.insert( + CREATE_PARENT_VASP_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_parent_vasp_account_script), + ); + map.insert( + CREATE_RECOVERY_ADDRESS_CODE.to_vec(), + Box::new(decode_create_recovery_address_script), + ); + map.insert( + CREATE_VALIDATOR_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_validator_account_script), + ); + map.insert( + CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE.to_vec(), + Box::new(decode_create_validator_operator_account_script), + ); + map.insert( + FREEZE_ACCOUNT_CODE.to_vec(), + Box::new(decode_freeze_account_script), + ); + map.insert( + PEER_TO_PEER_WITH_METADATA_CODE.to_vec(), + Box::new(decode_peer_to_peer_with_metadata_script), + ); + map.insert(PREBURN_CODE.to_vec(), Box::new(decode_preburn_script)); + map.insert( + PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + Box::new(decode_publish_shared_ed25519_public_key_script), + ); + map.insert( + REGISTER_VALIDATOR_CONFIG_CODE.to_vec(), + Box::new(decode_register_validator_config_script), + ); + map.insert( + REMOVE_VALIDATOR_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_remove_validator_and_reconfigure_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_nonce_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_nonce_admin_script), + ); + map.insert( + ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE.to_vec(), + Box::new(decode_rotate_authentication_key_with_recovery_address_script), + ); + map.insert( + ROTATE_DUAL_ATTESTATION_INFO_CODE.to_vec(), + Box::new(decode_rotate_dual_attestation_info_script), + ); + map.insert( + ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE.to_vec(), + Box::new(decode_rotate_shared_ed25519_public_key_script), + ); + map.insert( + SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE.to_vec(), + Box::new(decode_set_validator_config_and_reconfigure_script), + ); + map.insert( + SET_VALIDATOR_OPERATOR_CODE.to_vec(), + Box::new(decode_set_validator_operator_script), + ); + map.insert( + SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE.to_vec(), + Box::new(decode_set_validator_operator_with_nonce_admin_script), + ); + map.insert( + TIERED_MINT_CODE.to_vec(), + Box::new(decode_tiered_mint_script), + ); + map.insert( + UNFREEZE_ACCOUNT_CODE.to_vec(), + Box::new(decode_unfreeze_account_script), + ); + map.insert( + UPDATE_DIEM_VERSION_CODE.to_vec(), + Box::new(decode_update_diem_version_script), + ); + map.insert( + UPDATE_DUAL_ATTESTATION_LIMIT_CODE.to_vec(), + Box::new(decode_update_dual_attestation_limit_script), + ); + map.insert( + UPDATE_EXCHANGE_RATE_CODE.to_vec(), + Box::new(decode_update_exchange_rate_script), + ); + map.insert( + UPDATE_MINTING_ABILITY_CODE.to_vec(), + Box::new(decode_update_minting_ability_script), + ); + map + }); + +type ScriptFunctionDecoderMap = std::collections::HashMap< + String, + Box< + dyn Fn(&TransactionPayload) -> Option + + std::marker::Sync + + std::marker::Send, + >, +>; + +static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = + 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( + "TreasuryComplianceScriptsadd_diem_id_domain".to_string(), + Box::new(decode_add_diem_id_domain_script_function), + ); + map.insert( + "AccountAdministrationScriptsadd_recovery_rotation_capability".to_string(), + Box::new(decode_add_recovery_rotation_capability_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsadd_validator_and_reconfigure".to_string(), + Box::new(decode_add_validator_and_reconfigure_script_function), + ); + map.insert( + "AutoPayScriptsautopay_create_instruction".to_string(), + Box::new(decode_autopay_create_instruction_script_function), + ); + map.insert( + "AutoPayScriptsautopay_disable".to_string(), + Box::new(decode_autopay_disable_script_function), + ); + map.insert( + "AutoPayScriptsautopay_enable".to_string(), + Box::new(decode_autopay_enable_script_function), + ); + map.insert( + "TreasuryComplianceScriptsburn_txn_fees".to_string(), + Box::new(decode_burn_txn_fees_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( + "AccountScriptscreate_acc_user".to_string(), + Box::new(decode_create_acc_user_script_function), + ); + map.insert( + "AccountScriptscreate_acc_val".to_string(), + Box::new(decode_create_acc_val_script_function), + ); + map.insert( + "AccountCreationScriptscreate_child_vasp_account".to_string(), + Box::new(decode_create_child_vasp_account_script_function), + ); + map.insert( + "AccountCreationScriptscreate_designated_dealer".to_string(), + Box::new(decode_create_designated_dealer_script_function), + ); + map.insert( + "AccountAdministrationScriptscreate_diem_id_domains".to_string(), + Box::new(decode_create_diem_id_domains_script_function), + ); + map.insert( + "AccountCreationScriptscreate_parent_vasp_account".to_string(), + Box::new(decode_create_parent_vasp_account_script_function), + ); + map.insert( + "AccountAdministrationScriptscreate_recovery_address".to_string(), + Box::new(decode_create_recovery_address_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( + "DemoScriptsdemo_e2e".to_string(), + Box::new(decode_demo_e2e_script_function), + ); + map.insert( + "TreasuryComplianceScriptsfreeze_account".to_string(), + Box::new(decode_freeze_account_script_function), + ); + map.insert( + "SystemAdministrationScriptsinitialize_diem_consensus_config".to_string(), + Box::new(decode_initialize_diem_consensus_config_script_function), + ); + map.insert( + "ValidatorScriptsjoin".to_string(), + Box::new(decode_join_script_function), + ); + map.insert( + "ValidatorScriptsleave".to_string(), + Box::new(decode_leave_script_function), + ); + map.insert( + "MinerStateScriptsminerstate_commit".to_string(), + Box::new(decode_minerstate_commit_script_function), + ); + map.insert( + "MinerStateScriptsminerstate_commit_by_operator".to_string(), + Box::new(decode_minerstate_commit_by_operator_script_function), + ); + map.insert( + "MinerStateScriptsminerstate_helper".to_string(), + Box::new(decode_minerstate_helper_script_function), + ); + map.insert( + "OracleScriptsol_oracle_tx".to_string(), + Box::new(decode_ol_oracle_tx_script_function), + ); + map.insert( + "ValidatorScriptsol_reconfig_bulk_update_setup".to_string(), + Box::new(decode_ol_reconfig_bulk_update_setup_script_function), + ); + map.insert( + "PaymentScriptspeer_to_peer_with_metadata".to_string(), + Box::new(decode_peer_to_peer_with_metadata_script_function), + ); + map.insert( + "TreasuryComplianceScriptspreburn".to_string(), + Box::new(decode_preburn_script_function), + ); + map.insert( + "AccountAdministrationScriptspublish_shared_ed25519_public_key".to_string(), + Box::new(decode_publish_shared_ed25519_public_key_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsregister_validator_config".to_string(), + Box::new(decode_register_validator_config_script_function), + ); + map.insert( + "TreasuryComplianceScriptsremove_diem_id_domain".to_string(), + Box::new(decode_remove_diem_id_domain_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsremove_validator_and_reconfigure".to_string(), + Box::new(decode_remove_validator_and_reconfigure_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_authentication_key_with_recovery_address" + .to_string(), + Box::new(decode_rotate_authentication_key_with_recovery_address_script_function), + ); + map.insert( + "AccountAdministrationScriptsrotate_dual_attestation_info".to_string(), + Box::new(decode_rotate_dual_attestation_info_script_function), + ); + map.insert( + "AccountAdministrationScriptsrotate_shared_ed25519_public_key".to_string(), + Box::new(decode_rotate_shared_ed25519_public_key_script_function), + ); + map.insert( + "SystemAdministrationScriptsset_gas_constants".to_string(), + Box::new(decode_set_gas_constants_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_config_and_reconfigure".to_string(), + Box::new(decode_set_validator_config_and_reconfigure_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_operator".to_string(), + Box::new(decode_set_validator_operator_script_function), + ); + map.insert( + "ValidatorAdministrationScriptsset_validator_operator_with_nonce_admin".to_string(), + Box::new(decode_set_validator_operator_with_nonce_admin_script_function), + ); + map.insert( + "WalletScriptsset_wallet_type".to_string(), + Box::new(decode_set_wallet_type_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( + "SystemAdministrationScriptsupdate_diem_consensus_config".to_string(), + Box::new(decode_update_diem_consensus_config_script_function), + ); + map.insert( + "SystemAdministrationScriptsupdate_diem_version".to_string(), + Box::new(decode_update_diem_version_script_function), + ); + map.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.insert( + "ValidatorScriptsval_add_self".to_string(), + Box::new(decode_val_add_self_script_function), + ); + map + }); + +fn decode_bool_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::Bool(value) => Some(value), + _ => None, + } +} + +fn decode_u8_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::U8(value) => Some(value), + _ => None, + } +} + +fn decode_u64_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::U64(value) => Some(value), + _ => None, + } +} + +fn decode_address_argument(arg: TransactionArgument) -> Option { + match arg { + TransactionArgument::Address(value) => Some(value), + _ => None, + } +} + +fn decode_u8vector_argument(arg: TransactionArgument) -> Option> { + match arg { + TransactionArgument::U8Vector(value) => Some(value), + _ => None, + } +} + +const ADD_CURRENCY_TO_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, + 110, 116, 12, 97, 100, 100, 95, 99, 117, 114, 114, 101, 110, 99, 121, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2, +]; + +const ADD_RECOVERY_ROTATION_CAPABILITY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 15, 7, 33, 106, 8, 139, 1, + 16, 0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 8, 0, 5, 0, 2, + 6, 12, 5, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118, + 101, 114, 121, 65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, + 111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, + 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 23, 97, 100, 100, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 3, + 5, 11, 0, 17, 0, 10, 1, 17, 1, 2, +]; + +const ADD_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 91, 8, 136, 1, 16, 0, 0, + 0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12, + 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, + 111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, + 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, + 95, 110, 97, 109, 101, 13, 97, 100, 100, 95, 118, 97, 108, 105, 100, 97, 116, 111, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10, 3, 17, 1, 11, + 2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10, 3, 17, 2, 2, +]; + +const BURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 17, 7, 34, 45, 8, 79, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 2, 6, 12, 5, 3, 6, 12, 3, 5, + 1, 9, 0, 4, 68, 105, 101, 109, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, + 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, + 116, 4, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 7, 10, + 0, 10, 1, 17, 0, 11, 0, 10, 2, 56, 0, 2, +]; + +const BURN_TXN_FEES_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 7, 7, 17, 25, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 1, 6, 12, 0, 1, 9, 0, 14, 84, 114, 97, 110, 115, 97, 99, 116, 105, + 111, 110, 70, 101, 101, 9, 98, 117, 114, 110, 95, 102, 101, 101, 115, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 3, 11, 0, 56, 0, 2, +]; + +const CANCEL_BURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 24, 8, 42, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 5, 0, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, + 117, 110, 116, 11, 99, 97, 110, 99, 101, 108, 95, 98, 117, 114, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2, +]; + +const CREATE_CHILD_VASP_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 8, 1, 0, 2, 2, 2, 4, 3, 6, 22, 4, 28, 4, 5, 32, 35, 7, 67, 122, + 8, 189, 1, 16, 6, 205, 1, 4, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 1, 1, 0, 3, 2, 3, 0, 0, 4, 4, 1, 1, + 1, 0, 5, 3, 1, 0, 0, 6, 2, 6, 4, 6, 12, 5, 10, 2, 1, 0, 1, 6, 12, 1, 8, 0, 5, 6, 8, 0, 5, 3, + 10, 2, 10, 2, 5, 6, 12, 5, 10, 2, 1, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, + 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105, 116, + 121, 25, 99, 114, 101, 97, 116, 101, 95, 99, 104, 105, 108, 100, 95, 118, 97, 115, 112, 95, 97, + 99, 99, 111, 117, 110, 116, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100, + 114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95, 102, 114, + 111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, + 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 10, 2, 1, 0, 1, 1, 5, 3, 25, 10, 0, 10, 1, 11, 2, 10, 3, 56, 0, 10, 4, 6, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 3, 10, 5, 22, 11, 0, 17, 1, 12, 5, 14, 5, 10, 1, 10, 4, 7, 0, 7, 0, 56, 1, 11, 5, 17, 3, + 5, 24, 11, 0, 1, 2, +]; + +const CREATE_DESIGNATED_DEALER_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 72, 8, 116, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2, + 1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, + 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, + 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97, + 116, 101, 95, 100, 101, 115, 105, 103, 110, 97, 116, 101, 100, 95, 100, 101, 97, 108, 101, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0, 11, 0, 10, + 2, 11, 3, 11, 4, 10, 5, 56, 0, 2, +]; + +const CREATE_PARENT_VASP_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 27, 7, 44, 74, 8, 118, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 5, 6, 12, 5, 10, 2, 10, 2, + 1, 6, 6, 12, 3, 5, 10, 2, 10, 2, 1, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, + 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, + 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 26, 99, 114, 101, 97, + 116, 101, 95, 112, 97, 114, 101, 110, 116, 95, 118, 97, 115, 112, 95, 97, 99, 99, 111, 117, + 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 10, 10, 0, 10, 1, 17, 0, + 11, 0, 10, 2, 11, 3, 11, 4, 10, 5, 56, 0, 2, +]; + +const CREATE_RECOVERY_ADDRESS_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 10, 5, 18, 12, 7, 30, 90, 8, 120, 16, + 0, 0, 0, 1, 0, 2, 1, 0, 0, 3, 0, 1, 0, 1, 4, 2, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 12, 8, 0, 0, 11, + 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 15, 82, 101, 99, 111, 118, 101, 114, 121, + 65, 100, 100, 114, 101, 115, 115, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, + 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, + 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, + 121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 3, 5, 10, 0, 11, 0, 17, 0, 17, 1, 2, +]; + +const CREATE_VALIDATOR_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 72, 8, 108, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10, + 2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, + 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, + 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105, + 100, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11, 0, 10, 2, 11, 3, 11, 4, 17, 1, 2, +]; + +const CREATE_VALIDATOR_OPERATOR_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 22, 7, 36, 81, 8, 117, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 2, 6, 12, 3, 0, 4, 6, 12, 5, 10, 2, 10, 2, 5, 6, 12, 3, 5, 10, + 2, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, + 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, + 95, 111, 114, 95, 97, 98, 111, 114, 116, 33, 99, 114, 101, 97, 116, 101, 95, 118, 97, 108, 105, + 100, 97, 116, 111, 114, 95, 111, 112, 101, 114, 97, 116, 111, 114, 95, 97, 99, 99, 111, 117, + 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 9, 10, 0, 10, 1, 17, 0, 11, + 0, 10, 2, 11, 3, 11, 4, 17, 1, 2, +]; + +const FREEZE_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 66, 8, 94, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99, + 111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110, + 103, 78, 111, 110, 99, 101, 14, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111, 117, 110, + 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, + 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10, 1, 17, 1, + 11, 0, 10, 2, 17, 0, 2, +]; + +const PEER_TO_PEER_WITH_METADATA_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 29, 7, 53, 96, 8, + 149, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12, + 1, 8, 0, 5, 6, 8, 0, 5, 3, 10, 2, 10, 2, 0, 5, 6, 12, 5, 3, 10, 2, 10, 2, 1, 9, 0, 11, 68, 105, + 101, 109, 65, 99, 99, 111, 117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, + 104, 100, 114, 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 8, 112, 97, 121, 95, + 102, 114, 111, 109, 27, 114, 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, + 97, 119, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 4, 1, 12, 11, 0, 17, 0, 12, 5, 14, 5, 10, 1, 10, 2, 11, 3, 11, 4, 56, 0, 11, + 5, 17, 2, 2, +]; + +const PREBURN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 2, 2, 2, 4, 3, 6, 16, 4, 22, 2, 5, 24, 21, 7, 45, 95, 8, + 140, 1, 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 2, 3, 1, 1, 0, 4, 1, 3, 0, 1, 5, 1, 6, 12, + 1, 8, 0, 3, 6, 12, 6, 8, 0, 3, 0, 2, 6, 12, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, + 117, 110, 116, 18, 87, 105, 116, 104, 100, 114, 97, 119, 67, 97, 112, 97, 98, 105, 108, 105, + 116, 121, 27, 101, 120, 116, 114, 97, 99, 116, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, + 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 7, 112, 114, 101, 98, 117, 114, 110, 27, 114, + 101, 115, 116, 111, 114, 101, 95, 119, 105, 116, 104, 100, 114, 97, 119, 95, 99, 97, 112, 97, + 98, 105, 108, 105, 116, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 4, 1, 10, + 10, 0, 17, 0, 12, 2, 11, 0, 14, 2, 10, 1, 56, 0, 11, 2, 17, 2, 2, +]; + +const PUBLISH_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 31, 8, 44, 16, 0, 0, 0, 1, + 0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80, + 117, 98, 108, 105, 99, 75, 101, 121, 7, 112, 117, 98, 108, 105, 115, 104, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2, +]; + +const REGISTER_VALIDATOR_CONFIG_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 11, 7, 18, 27, 8, 45, 16, 0, 0, 0, 1, + 0, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, + 111, 110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 7, 11, 0, 10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 2, +]; + +const REMOVE_VALIDATOR_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 24, 7, 45, 94, 8, 139, 1, 16, 0, 0, + 0, 1, 0, 2, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 4, 6, 12, 3, 10, 2, 5, 2, 1, 3, 10, 68, 105, 101, 109, 83, 121, 115, 116, 101, 109, 12, + 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, + 111, 114, 67, 111, 110, 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, + 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, + 95, 110, 97, 109, 101, 16, 114, 101, 109, 111, 118, 101, 95, 118, 97, 108, 105, 100, 97, 116, + 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 6, 18, 10, 0, 10, 1, 17, 0, 10, + 3, 17, 1, 11, 2, 33, 12, 4, 11, 4, 3, 14, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 0, 10, + 3, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 2, 2, 4, 3, 6, 15, 5, 21, 18, 7, 39, 124, 8, 163, 1, + 16, 0, 0, 0, 1, 1, 0, 0, 2, 0, 1, 0, 0, 3, 1, 2, 0, 0, 4, 3, 2, 0, 1, 6, 12, 1, 8, 0, 0, 2, 6, + 8, 0, 10, 2, 2, 6, 12, 10, 2, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 21, 75, + 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105, 108, 105, 116, 121, + 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, + 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115, 116, 111, 114, 101, + 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105, + 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 4, 1, 9, 11, 0, 17, 0, 12, 2, 14, 2, 11, 1, 17, 2, 11, 2, 17, 1, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 23, 7, 51, 159, 1, 8, 210, + 1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2, + 6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 3, 6, 12, 3, 10, 2, 11, 68, 105, 101, 109, + 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, + 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, 111, + 114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, 105, + 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, 116, + 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, 115, + 116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, 97, + 112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, + 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 10, 0, 10, 1, 17, 0, 11, 0, 17, 1, 12, 3, 14, 3, 11, 2, 17, + 3, 11, 3, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_NONCE_ADMIN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 2, 4, 4, 3, 8, 20, 5, 28, 25, 7, 53, 159, 1, 8, 212, + 1, 16, 0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 0, 1, 0, 0, 4, 2, 3, 0, 0, 5, 3, 1, 0, 0, 6, 4, 1, 0, 2, + 6, 12, 3, 0, 1, 6, 12, 1, 8, 0, 2, 6, 8, 0, 10, 2, 4, 6, 12, 6, 12, 3, 10, 2, 11, 68, 105, 101, + 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, + 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, 98, + 111, 114, 116, 21, 75, 101, 121, 82, 111, 116, 97, 116, 105, 111, 110, 67, 97, 112, 97, 98, + 105, 108, 105, 116, 121, 31, 101, 120, 116, 114, 97, 99, 116, 95, 107, 101, 121, 95, 114, 111, + 116, 97, 116, 105, 111, 110, 95, 99, 97, 112, 97, 98, 105, 108, 105, 116, 121, 31, 114, 101, + 115, 116, 111, 114, 101, 95, 107, 101, 121, 95, 114, 111, 116, 97, 116, 105, 111, 110, 95, 99, + 97, 112, 97, 98, 105, 108, 105, 116, 121, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, + 104, 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 3, 12, 11, 0, 10, 2, 17, 0, 11, 1, 17, 1, 12, 4, 14, 4, 11, 3, + 17, 3, 11, 4, 17, 2, 2, +]; + +const ROTATE_AUTHENTICATION_KEY_WITH_RECOVERY_ADDRESS_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 8, 7, 15, 42, 8, 57, 16, 0, 0, 0, 1, + 0, 1, 0, 4, 6, 12, 5, 5, 10, 2, 0, 15, 82, 101, 99, 111, 118, 101, 114, 121, 65, 100, 100, 114, + 101, 115, 115, 25, 114, 111, 116, 97, 116, 101, 95, 97, 117, 116, 104, 101, 110, 116, 105, 99, + 97, 116, 105, 111, 110, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 6, 11, 0, 10, 1, 10, 2, 11, 3, 17, 0, 2, +]; + +const ROTATE_DUAL_ATTESTATION_INFO_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 10, 5, 12, 13, 7, 25, 61, 8, 86, 16, 0, 0, 0, + 1, 0, 1, 0, 0, 2, 0, 1, 0, 2, 6, 12, 10, 2, 0, 3, 6, 12, 10, 2, 10, 2, 15, 68, 117, 97, 108, + 65, 116, 116, 101, 115, 116, 97, 116, 105, 111, 110, 15, 114, 111, 116, 97, 116, 101, 95, 98, + 97, 115, 101, 95, 117, 114, 108, 28, 114, 111, 116, 97, 116, 101, 95, 99, 111, 109, 112, 108, + 105, 97, 110, 99, 101, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 11, 1, 17, 0, 11, 0, 11, 2, 17, 1, 2, +]; + +const ROTATE_SHARED_ED25519_PUBLIC_KEY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 2, 3, 2, 5, 5, 7, 6, 7, 13, 34, 8, 47, 16, 0, 0, 0, 1, + 0, 1, 0, 2, 6, 12, 10, 2, 0, 22, 83, 104, 97, 114, 101, 100, 69, 100, 50, 53, 53, 49, 57, 80, + 117, 98, 108, 105, 99, 75, 101, 121, 10, 114, 111, 116, 97, 116, 101, 95, 107, 101, 121, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 4, 11, 0, 11, 1, 17, 0, 2, +]; + +const SET_VALIDATOR_CONFIG_AND_RECONFIGURE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 15, 7, 29, 68, 8, 97, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 0, 5, 6, 12, 5, 10, 2, 10, 2, 10, 2, 0, 2, 6, 12, 5, 10, 68, 105, + 101, 109, 83, 121, 115, 116, 101, 109, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, + 110, 102, 105, 103, 10, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103, 29, 117, 112, 100, 97, + 116, 101, 95, 99, 111, 110, 102, 105, 103, 95, 97, 110, 100, 95, 114, 101, 99, 111, 110, 102, + 105, 103, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 10, 10, 0, + 10, 1, 11, 2, 11, 3, 11, 4, 17, 0, 11, 0, 10, 1, 17, 1, 2, +]; + +const SET_VALIDATOR_OPERATOR_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 19, 7, 33, 68, 8, 101, 16, 0, 0, 0, + 1, 1, 2, 0, 1, 0, 0, 3, 2, 3, 0, 1, 5, 1, 10, 2, 2, 6, 12, 5, 0, 3, 6, 12, 10, 2, 5, 2, 1, 3, + 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23, 86, 97, 108, + 105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, + 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101, 12, 115, 101, 116, 95, + 111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 5, + 15, 10, 2, 17, 0, 11, 1, 33, 12, 3, 11, 3, 3, 11, 11, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, + 0, 10, 2, 17, 1, 2, +]; + +const SET_VALIDATOR_OPERATOR_WITH_NONCE_ADMIN_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 6, 3, 6, 15, 5, 21, 26, 7, 47, 103, 8, 150, 1, 16, 0, 0, + 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 4, 2, 3, 0, 1, 5, 4, 1, 0, 2, 6, 12, 3, 0, 1, 5, 1, 10, 2, 2, 6, + 12, 5, 5, 6, 12, 6, 12, 3, 10, 2, 5, 2, 1, 3, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, + 110, 99, 101, 15, 86, 97, 108, 105, 100, 97, 116, 111, 114, 67, 111, 110, 102, 105, 103, 23, + 86, 97, 108, 105, 100, 97, 116, 111, 114, 79, 112, 101, 114, 97, 116, 111, 114, 67, 111, 110, + 102, 105, 103, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 14, 103, 101, 116, 95, 104, 117, 109, 97, 110, 95, 110, 97, 109, 101, + 12, 115, 101, 116, 95, 111, 112, 101, 114, 97, 116, 111, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 5, 6, 18, 11, 0, 10, 2, 17, 0, 10, 4, 17, 1, 11, 3, 33, 12, 5, 11, 5, 3, 14, + 11, 1, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 39, 11, 1, 10, 4, 17, 2, 2, +]; + +const TIERED_MINT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 4, 3, 4, 11, 4, 15, 2, 5, 17, 21, 7, 38, 59, 8, 97, 16, + 0, 0, 0, 1, 1, 2, 0, 1, 0, 0, 3, 2, 1, 1, 1, 1, 4, 2, 6, 12, 3, 0, 4, 6, 12, 5, 3, 3, 5, 6, 12, + 3, 5, 3, 3, 1, 9, 0, 11, 68, 105, 101, 109, 65, 99, 99, 111, 117, 110, 116, 12, 83, 108, 105, + 100, 105, 110, 103, 78, 111, 110, 99, 101, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, + 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 11, 116, 105, 101, 114, 101, 100, 95, 109, + 105, 110, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 1, 9, 10, 0, 10, 1, 17, + 0, 11, 0, 10, 2, 10, 3, 10, 4, 56, 0, 2, +]; + +const UNFREEZE_ACCOUNT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 14, 7, 28, 68, 8, 96, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 2, 1, 0, 2, 6, 12, 5, 0, 2, 6, 12, 3, 3, 6, 12, 3, 5, 15, 65, 99, 99, + 111, 117, 110, 116, 70, 114, 101, 101, 122, 105, 110, 103, 12, 83, 108, 105, 100, 105, 110, + 103, 78, 111, 110, 99, 101, 16, 117, 110, 102, 114, 101, 101, 122, 101, 95, 97, 99, 99, 111, + 117, 110, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 1, 7, 10, 0, 10, + 1, 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_DIEM_VERSION_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 51, 8, 75, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 11, 68, 105, 101, 109, 86, + 101, 114, 115, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, 99, 101, 3, + 115, 101, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, + 97, 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10, + 1, 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_DUAL_ATTESTATION_LIMIT_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 5, 1, 0, 4, 3, 4, 10, 5, 14, 10, 7, 24, 71, 8, 95, 16, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 6, 12, 3, 0, 3, 6, 12, 3, 3, 15, 68, 117, 97, 108, 65, 116, + 116, 101, 115, 116, 97, 116, 105, 111, 110, 12, 83, 108, 105, 100, 105, 110, 103, 78, 111, 110, + 99, 101, 19, 115, 101, 116, 95, 109, 105, 99, 114, 111, 100, 105, 101, 109, 95, 108, 105, 109, + 105, 116, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, 99, 101, 95, 111, 114, 95, 97, + 98, 111, 114, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 7, 10, 0, 10, 1, + 17, 1, 11, 0, 10, 2, 17, 0, 2, +]; + +const UPDATE_EXCHANGE_RATE_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 7, 1, 0, 6, 2, 6, 4, 3, 10, 16, 4, 26, 2, 5, 28, 25, 7, 53, 99, + 8, 152, 1, 16, 0, 0, 0, 1, 0, 2, 1, 1, 2, 0, 1, 3, 0, 1, 0, 2, 4, 2, 3, 0, 0, 5, 4, 3, 1, 1, 2, + 6, 2, 3, 3, 1, 8, 0, 2, 6, 12, 3, 0, 2, 6, 12, 8, 0, 4, 6, 12, 3, 3, 3, 1, 9, 0, 4, 68, 105, + 101, 109, 12, 70, 105, 120, 101, 100, 80, 111, 105, 110, 116, 51, 50, 12, 83, 108, 105, 100, + 105, 110, 103, 78, 111, 110, 99, 101, 20, 99, 114, 101, 97, 116, 101, 95, 102, 114, 111, 109, + 95, 114, 97, 116, 105, 111, 110, 97, 108, 21, 114, 101, 99, 111, 114, 100, 95, 110, 111, 110, + 99, 101, 95, 111, 114, 95, 97, 98, 111, 114, 116, 24, 117, 112, 100, 97, 116, 101, 95, 120, + 100, 120, 95, 101, 120, 99, 104, 97, 110, 103, 101, 95, 114, 97, 116, 101, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 1, 11, 10, 0, 10, 1, 17, 1, 10, 2, 10, 3, 17, 0, 12, 4, 11, + 0, 11, 4, 56, 0, 2, +]; + +const UPDATE_MINTING_ABILITY_CODE: &[u8] = &[ + 161, 28, 235, 11, 1, 0, 0, 0, 6, 1, 0, 2, 3, 2, 6, 4, 8, 2, 5, 10, 8, 7, 18, 28, 8, 46, 16, 0, + 0, 0, 1, 0, 1, 1, 1, 0, 2, 2, 6, 12, 1, 0, 1, 9, 0, 4, 68, 105, 101, 109, 22, 117, 112, 100, + 97, 116, 101, 95, 109, 105, 110, 116, 105, 110, 103, 95, 97, 98, 105, 108, 105, 116, 121, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 4, 11, 0, 10, 1, 56, 0, 2, +]; diff --git a/compatibility/src/sdk/v6_libra_framework_sdk_builder.rs b/compatibility/src/sdk/v6_libra_framework_sdk_builder.rs new file mode 100644 index 000000000..9b56ca52e --- /dev/null +++ b/compatibility/src/sdk/v6_libra_framework_sdk_builder.rs @@ -0,0 +1,3692 @@ +/////// OL //////// +// NOTE: these files are copied from the original version which were at +// the time deployed to production. +// They are originally automatically generated code. +// A minor modification is adding serde de/serializers to the EntryFunctionCall enum. +//////// end //////// + +// Copyright © Diem Foundation +// SPDX-License-Identifier: Apache-2.0 + +// This file was generated. Do not modify! +// +// To update this code, run: `cargo run --release -p 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 `diem-sdk-builder`. + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] +use diem_types::{ + account_address::AccountAddress, + transaction::{EntryFunction, TransactionPayload}, +}; +use move_core_types::{ + ident_str, + language_storage::{ModuleId, TypeTag}, +}; + +type Bytes = Vec; + +/// Structured representation of a call into a known Move entry function. +/// ```ignore +/// impl EntryFunctionCall { +/// pub fn encode(self) -> TransactionPayload { .. } +/// pub fn decode(&TransactionPayload) -> Option { .. } +/// } +/// ``` +/// + +//////// OL /////// +// NOTE: the serde de/serializers were added manually for use in +// explorer and data warehouse +//////// end //////// +#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)] +// #[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))] +// #[cfg_attr(feature = "fuzzing", proptest(no_params))] +pub enum EntryFunctionCall { + /// Offers rotation capability on behalf of `account` to the account at address `recipient_address`. + /// An account can delegate its rotation capability to only one other address at one time. If the account + /// has an existing rotation capability offer, calling this function will update the rotation capability offer with + /// the new `recipient_address`. + /// Here, `rotation_capability_sig_bytes` signature indicates that this key rotation is authorized by the account owner, + /// and prevents the classic "time-of-check time-of-use" attack. + /// For example, users usually rely on what the wallet displays to them as the transaction's outcome. Consider a contract that with 50% probability + /// (based on the current timestamp in Move), rotates somebody's key. The wallet might be unlucky and get an outcome where nothing is rotated, + /// incorrectly telling the user nothing bad will happen. But when the transaction actually gets executed, the attacker gets lucky and + /// the execution path triggers the account key rotation. + /// We prevent such attacks by asking for this extra signature authorizing the key rotation. + /// + /// @param rotation_capability_sig_bytes is the signature by the account owner's key on `RotationCapabilityOfferProofChallengeV2`. + /// @param account_scheme is the scheme of the account (ed25519 or multi_ed25519). + /// @param account_public_key_bytes is the public key of the account owner. + /// @param recipient_address is the address of the recipient of the rotation capability - note that if there's an existing rotation capability + /// offer, calling this function will replace the previous `recipient_address` upon successful verification. + AccountOfferRotationCapability { + rotation_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, + }, + + /// Offers signer capability on behalf of `account` to the account at address `recipient_address`. + /// An account can delegate its signer capability to only one other address at one time. + /// `signer_capability_key_bytes` is the `SignerCapabilityOfferProofChallengeV2` signed by the account owner's key + /// `account_scheme` is the scheme of the account (ed25519 or multi_ed25519). + /// `account_public_key_bytes` is the public key of the account owner. + /// `recipient_address` is the address of the recipient of the signer capability - note that if there's an existing + /// `recipient_address` in the account owner's `SignerCapabilityOffer`, this will replace the + /// previous `recipient_address` upon successful verification (the previous recipient will no longer have access + /// to the account owner's signer capability). + AccountOfferSignerCapability { + signer_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, + }, + + /// Revoke any rotation capability offer in the specified account. + AccountRevokeAnyRotationCapability {}, + + /// Revoke any signer capability offer in the specified account. + AccountRevokeAnySignerCapability {}, + + /// Revoke the rotation capability offer given to `to_be_revoked_recipient_address` from `account` + AccountRevokeRotationCapability { + to_be_revoked_address: AccountAddress, + }, + + /// Revoke the account owner's signer capability offer for `to_be_revoked_address` (i.e., the address that + /// has a signer capability offer from `account` but will be revoked in this function). + AccountRevokeSignerCapability { + to_be_revoked_address: AccountAddress, + }, + + /// Generic authentication key rotation function that allows the user to rotate their authentication key from any scheme to any scheme. + /// To authorize the rotation, we need two signatures: + /// - the first signature `cap_rotate_key` refers to the signature by the account owner's current key on a valid `RotationProofChallenge`, + /// demonstrating that the user intends to and has the capability to rotate the authentication key of this account; + /// - the second signature `cap_update_table` refers to the signature by the new key (that the account owner wants to rotate to) on a + /// valid `RotationProofChallenge`, demonstrating that the user owns the new private key, and has the authority to update the + /// `OriginatingAddress` map with the new address mapping ``. + /// To verify these two signatures, we need their corresponding public key and public key scheme: we use `from_scheme` and `from_public_key_bytes` + /// to verify `cap_rotate_key`, and `to_scheme` and `to_public_key_bytes` to verify `cap_update_table`. + /// A scheme of 0 refers to an Ed25519 key and a scheme of 1 refers to Multi-Ed25519 keys. + /// `originating address` refers to an account's original/first address. + /// + /// Here is an example attack if we don't ask for the second signature `cap_update_table`: + /// Alice has rotated her account `addr_a` to `new_addr_a`. As a result, the following entry is created, to help Alice when recovering her wallet: + /// `OriginatingAddress[new_addr_a]` -> `addr_a` + /// Alice has had bad day: her laptop blew up and she needs to reset her account on a new one. + /// (Fortunately, she still has her secret key `new_sk_a` associated with her new address `new_addr_a`, so she can do this.) + /// + /// But Bob likes to mess with Alice. + /// Bob creates an account `addr_b` and maliciously rotates it to Alice's new address `new_addr_a`. Since we are no longer checking a PoK, + /// Bob can easily do this. + /// + /// Now, the table will be updated to make Alice's new address point to Bob's address: `OriginatingAddress[new_addr_a]` -> `addr_b`. + /// When Alice recovers her account, her wallet will display the attacker's address (Bob's) `addr_b` as her address. + /// Now Alice will give `addr_b` to everyone to pay her, but the money will go to Bob. + /// + /// Because we ask for a valid `cap_update_table`, this kind of attack is not possible. Bob would not have the secret key of Alice's address + /// to rotate his address to Alice's address in the first place. + AccountRotateAuthenticationKey { + from_scheme: u8, + from_public_key_bytes: Vec, + to_scheme: u8, + to_public_key_bytes: Vec, + cap_rotate_key: Vec, + cap_update_table: Vec, + }, + + AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address: AccountAddress, + new_scheme: u8, + new_public_key_bytes: Vec, + cap_update_table: Vec, + }, + + /// User opts into burns being sent to community (recycle burn). + /// default is false (burn is final). + BurnSetSendCommunity { + community: bool, + }, + + /// Same as `publish_package` but as an entry function which can be called as a transaction. Because + /// of current restrictions for txn parameters, the metadata needs to be passed in serialized form. + CodePublishPackageTxn { + metadata_serialized: Vec, + code: Vec>, + }, + + /// Transfers `amount` of coins `CoinType` from `from` to `to`. + CoinTransfer { + coin_type: TypeTag, + to: AccountAddress, + amount: u64, + }, + + /// Add or remove a signer to/from the multisig, and check if they may be related in the ancestry tree + CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address: AccountAddress, + new_signer: AccountAddress, + is_add_operation: bool, + n_of_m: u64, + vote_duration_epochs: u64, + }, + + /// convenience function to check if the account can be caged + /// after all the structs are in place + CommunityWalletInitFinalizeAndCage { + initial_authorities: Vec, + num_signers: u64, + }, + + CommunityWalletInitInitCommunity { + check_addresses: Vec, + check_threshold: u64, + }, + + DiemGovernanceAddApprovedScriptHashScript { + proposal_id: u64, + }, + + DiemGovernanceAssertCanResolve { + proposal_id: u64, + }, + + /// Create a single-step proposal with the backing `stake_pool`. + /// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, + /// only the exact script with matching hash can be successfully executed. + DiemGovernanceCreateProposal { + stake_pool: AccountAddress, + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + }, + + /// Create a single-step or multi-step proposal with the backing `stake_pool`. + /// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, + /// only the exact script with matching hash can be successfully executed. + DiemGovernanceCreateProposalV2 { + stake_pool: AccountAddress, + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, + }, + + /// Create a single-step or multi-step proposal with the backing `stake_pool`. + /// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, + /// only the exact script with matching hash can be successfully executed. + DiemGovernanceOlCreateProposalV2 { + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, + }, + + /// Vote on proposal with `proposal_id` and voting power from `stake_pool`. + DiemGovernanceOlVote { + proposal_id: u64, + should_pass: bool, + }, + + DiemGovernanceSmokeTriggerEpoch {}, + + /// Any end user can triger epoch/boundary and reconfiguration + /// as long as the VM set the BoundaryBit to true. + /// We do this because we don't want the VM calling complex + /// logic itself. Any abort would cause a halt. + /// On the other hand, a user can call the function once the VM + /// decides the epoch can change. Any error will just cause the + /// user's transaction to abort, but the chain will continue. + /// Whatever fix is needed can be done online with on-chain governance. + DiemGovernanceTriggerEpoch {}, + + /// Vote on proposal with `proposal_id` and voting power from `stake_pool`. + DiemGovernanceVote { + proposal_id: u64, + should_pass: bool, + }, + + DonorVoiceTxsProposeLiquidateTx { + multisig_address: AccountAddress, + }, + + DonorVoiceTxsProposePaymentTx { + multisig_address: AccountAddress, + payee: AccountAddress, + value: u64, + description: Vec, + }, + + DonorVoiceTxsProposeVetoTx { + multisig_address: AccountAddress, + id: u64, + }, + + DonorVoiceTxsVoteLiquidationTx { + multisig_address: AccountAddress, + }, + + /// Entry functiont to vote the veto. + DonorVoiceTxsVoteVetoTx { + multisig_address: AccountAddress, + id: u64, + }, + + EpochBoundarySmokeTriggerEpoch {}, + + /// Only a Voucher of the validator can flip the unjail bit. + /// This is a way to make sure the validator is ready to rejoin. + JailUnjailByVoucher { + addr: AccountAddress, + }, + + /// Only callable in tests and testnets where the core resources account exists. + /// Claim the delegated mint capability and destroy the delegated token. + LibraCoinClaimMintCapability {}, + + /// Only callable in tests and testnets where the core resources account exists. + /// Create delegated token for the address so the account could claim MintCapability later. + LibraCoinDelegateMintCapability { + to: AccountAddress, + }, + + /// Root account can mint to an address. Only used for genesis and tests. + /// The "root" account in smoke tests has some privileges. + LibraCoinMintToImpl { + dst_addr: AccountAddress, + amount: u64, + }, + + /// finalize the account and put in a cage. Will abort if governance has not + MultiActionFinalizeAndCage { + initial_authorities: Vec, + num_signers: u64, + }, + + /// Similar to add_owners, but only allow adding one owner. + MultisigAccountAddOwner { + new_owner: AccountAddress, + }, + + /// Add new owners to the multisig account. This can only be invoked by the multisig account itself, through the + /// proposal flow. + /// + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the owners list. + MultisigAccountAddOwners { + new_owners: Vec, + }, + + /// Approve a multisig transaction. + MultisigAccountApproveTransaction { + multisig_account: AccountAddress, + sequence_number: u64, + }, + + /// Creates a new multisig account and add the signer as a single owner. + MultisigAccountCreate { + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Create a multisig transaction, which will have one approval initially (from the creator). + /// + /// @param target_function The target function to call such as 0x123::module_to_call::function_to_call. + /// @param args Vector of BCS-encoded argument values to invoke the target function with. + MultisigAccountCreateTransaction { + multisig_account: AccountAddress, + payload: Vec, + }, + + /// Create a multisig transaction with a transaction hash instead of the full payload. + /// This means the payload will be stored off chain for gas saving. Later, during execution, the executor will need + /// to provide the full payload, which will be validated against the hash stored on-chain. + /// + /// @param function_hash The sha-256 hash of the function to invoke, e.g. 0x123::module_to_call::function_to_call. + /// @param args_hash The sha-256 hash of the function arguments - a concatenated vector of the bcs-encoded + /// function arguments. + MultisigAccountCreateTransactionWithHash { + multisig_account: AccountAddress, + payload_hash: Vec, + }, + + /// Creates a new multisig account on top of an existing account. + /// + /// This offers a migration path for an existing account with a multi-ed25519 auth key (native multisig account). + /// In order to ensure a malicious module cannot obtain backdoor control over an existing account, a signed message + /// with a valid signature from the account's auth key is required. + MultisigAccountCreateWithExistingAccount { + multisig_address: AccountAddress, + owners: Vec, + num_signatures_required: u64, + account_scheme: u8, + account_public_key: Vec, + create_multisig_account_signed_message: Vec, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Creates a new multisig account with the specified additional owner list and signatures required. + /// + /// @param additional_owners The owner account who calls this function cannot be in the additional_owners and there + /// cannot be any duplicate owners in the list. + /// @param num_signatures_required The number of signatures required to execute a transaction. Must be at least 1 and + /// at most the total number of owners. + MultisigAccountCreateWithOwners { + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Remove the next transaction if it has sufficient owner rejections. + MultisigAccountExecuteRejectedTransaction { + multisig_account: AccountAddress, + }, + + /// keeps the origin account as the ADDRESS + /// rotates the key to ZERO + MultisigAccountMigrateWithOwners { + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Reject a multisig transaction. + MultisigAccountRejectTransaction { + multisig_account: AccountAddress, + sequence_number: u64, + }, + + /// Similar to remove_owners, but only allow removing one owner. + MultisigAccountRemoveOwner { + owner_to_remove: AccountAddress, + }, + + /// Remove owners from the multisig account. This can only be invoked by the multisig account itself, through the + /// proposal flow. + /// + /// This function skips any owners who are not in the multisig account's list of owners. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the owners list. + MultisigAccountRemoveOwners { + owners_to_remove: Vec, + }, + + /// Allow the multisig account to update its own metadata. Note that this overrides the entire existing metadata. + /// If any attributes are not specified in the metadata, they will be removed! + /// + /// This can only be invoked by the multisig account itself, through the proposal flow. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the number of signatures required. + MultisigAccountUpdateMetadata { + keys: Vec>, + values: Vec>, + }, + + /// Update the number of signatures required to execute transaction in the specified multisig account. + /// + /// This can only be invoked by the multisig account itself, through the proposal flow. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the number of signatures required. + MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required: u64, + }, + + /// Generic function that can be used to either approve or reject a multisig transaction + MultisigAccountVoteTransanction { + multisig_account: AccountAddress, + sequence_number: u64, + approved: bool, + }, + + /// Entry function that can be used to transfer, if allow_ungated_transfer is set true. + ObjectTransferCall { + object: AccountAddress, + to: AccountAddress, + }, + + /// Helper for tests to create acounts + /// Belt and suspenders + OlAccountCreateAccount { + auth_key: AccountAddress, + }, + + /// Set whether `account` can receive direct transfers of coins that they have not explicitly registered to receive. + OlAccountSetAllowDirectCoinTransfers { + allow: bool, + }, + + /// Convenient function to transfer GAS to a recipient account that might not exist. + /// This would create the recipient account first, which also registers it to receive GAS, before transferring. + OlAccountTransfer { + to: AccountAddress, + amount: u64, + }, + + OracleInitProvider {}, + + ProofOfFeeInitBidding {}, + + /// retract bid + ProofOfFeePofRetractBid {}, + + /// update the bid for the sender + ProofOfFeePofUpdateBid { + bid: u64, + epoch_expiry: u64, + }, + + /// This fucntion initiates governance for the multisig. It is called by the sponsor address, and is only callable once. + /// init_gov fails gracefully if the governance is already initialized. + /// init_type will throw errors if the type is already initialized. + SafeInitPaymentMultisig {}, + + SlowWalletSmokeTestVmUnlock { + user_addr: AccountAddress, + unlocked: u64, + transferred: u64, + }, + + /// Users can change their account to slow, by calling the entry function + /// Warning: this is permanent for the account. There's no way to + /// reverse a "slow wallet". + SlowWalletUserSetSlow {}, + + /// Initialize the validator account and give ownership to the signing account + /// except it leaves the ValidatorConfig to be set by another entity. + /// Note: this triggers setting the operator and owner, set it to the account's address + /// to set later. + StakeInitializeStakeOwner { + initial_stake_amount: u64, + operator: AccountAddress, + _voter: AccountAddress, + }, + + /// Initialize the validator account and give ownership to the signing account. + StakeInitializeValidator { + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, + }, + + /// Rotate the consensus key of the validator, it'll take effect in next epoch. + StakeRotateConsensusKey { + validator_address: AccountAddress, + new_consensus_pubkey: Vec, + proof_of_possession: Vec, + }, + + /// Allows an owner to change the operator of the stake pool. + StakeSetOperator { + new_operator: AccountAddress, + }, + + /// Update the network and full node addresses of the validator. This only takes effect in the next epoch. + StakeUpdateNetworkAndFullnodeAddresses { + validator_address: AccountAddress, + new_network_addresses: Vec, + new_fullnode_addresses: Vec, + }, + + /// The entry point to commit miner state. + TowerStateMinerstateCommit { + challenge: Vec, + solution: Vec, + difficulty: u64, + security: u64, + }, + + /// This is the entrypoint for a validator joining the network. + /// Separates the logic of registration from validator election etc. (in stake.move). + /// This prevents dependency cycling issues, since stake.move is a large module. + ValidatorUniverseRegisterValidator { + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, + }, + + /// Updates the major version to a larger version. + /// This can be called by on chain governance. + VersionSetVersion { + major: u64, + }, + + /// you may want to add people who are related to you + /// there are no known use cases for this at the moment. + VouchInsistVouchFor { + wanna_be_my_friend: AccountAddress, + }, + + VouchRevoke { + its_not_me_its_you: AccountAddress, + }, + + /// will only succesfully vouch if the two are not related by ancestry + /// prevents spending a vouch that would not be counted. + /// to add a vouch and ignore this check use insist_vouch + VouchVouchFor { + wanna_be_my_friend: AccountAddress, + }, +} + +impl EntryFunctionCall { + /// Build an Diem `TransactionPayload` from a structured object `EntryFunctionCall`. + pub fn encode(self) -> TransactionPayload { + use EntryFunctionCall::*; + match self { + AccountOfferRotationCapability { + rotation_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + } => account_offer_rotation_capability( + rotation_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + ), + AccountOfferSignerCapability { + signer_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + } => account_offer_signer_capability( + signer_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + ), + AccountRevokeAnyRotationCapability {} => account_revoke_any_rotation_capability(), + AccountRevokeAnySignerCapability {} => account_revoke_any_signer_capability(), + AccountRevokeRotationCapability { + to_be_revoked_address, + } => account_revoke_rotation_capability(to_be_revoked_address), + AccountRevokeSignerCapability { + to_be_revoked_address, + } => account_revoke_signer_capability(to_be_revoked_address), + AccountRotateAuthenticationKey { + from_scheme, + from_public_key_bytes, + to_scheme, + to_public_key_bytes, + cap_rotate_key, + cap_update_table, + } => account_rotate_authentication_key( + from_scheme, + from_public_key_bytes, + to_scheme, + to_public_key_bytes, + cap_rotate_key, + cap_update_table, + ), + AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address, + new_scheme, + new_public_key_bytes, + cap_update_table, + } => account_rotate_authentication_key_with_rotation_capability( + rotation_cap_offerer_address, + new_scheme, + new_public_key_bytes, + cap_update_table, + ), + BurnSetSendCommunity { community } => burn_set_send_community(community), + CodePublishPackageTxn { + metadata_serialized, + code, + } => code_publish_package_txn(metadata_serialized, code), + CoinTransfer { + coin_type, + to, + amount, + } => coin_transfer(coin_type, to, amount), + CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address, + new_signer, + is_add_operation, + n_of_m, + vote_duration_epochs, + } => community_wallet_init_change_signer_community_multisig( + multisig_address, + new_signer, + is_add_operation, + n_of_m, + vote_duration_epochs, + ), + CommunityWalletInitFinalizeAndCage { + initial_authorities, + num_signers, + } => community_wallet_init_finalize_and_cage(initial_authorities, num_signers), + CommunityWalletInitInitCommunity { + check_addresses, + check_threshold, + } => community_wallet_init_init_community(check_addresses, check_threshold), + DiemGovernanceAddApprovedScriptHashScript { proposal_id } => { + diem_governance_add_approved_script_hash_script(proposal_id) + } + DiemGovernanceAssertCanResolve { proposal_id } => { + diem_governance_assert_can_resolve(proposal_id) + } + DiemGovernanceCreateProposal { + stake_pool, + execution_hash, + metadata_location, + metadata_hash, + } => diem_governance_create_proposal( + stake_pool, + execution_hash, + metadata_location, + metadata_hash, + ), + DiemGovernanceCreateProposalV2 { + stake_pool, + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + } => diem_governance_create_proposal_v2( + stake_pool, + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + ), + DiemGovernanceOlCreateProposalV2 { + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + } => diem_governance_ol_create_proposal_v2( + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + ), + DiemGovernanceOlVote { + proposal_id, + should_pass, + } => diem_governance_ol_vote(proposal_id, should_pass), + DiemGovernanceSmokeTriggerEpoch {} => diem_governance_smoke_trigger_epoch(), + DiemGovernanceTriggerEpoch {} => diem_governance_trigger_epoch(), + DiemGovernanceVote { + proposal_id, + should_pass, + } => diem_governance_vote(proposal_id, should_pass), + DonorVoiceTxsProposeLiquidateTx { multisig_address } => { + donor_voice_txs_propose_liquidate_tx(multisig_address) + } + DonorVoiceTxsProposePaymentTx { + multisig_address, + payee, + value, + description, + } => donor_voice_txs_propose_payment_tx(multisig_address, payee, value, description), + DonorVoiceTxsProposeVetoTx { + multisig_address, + id, + } => donor_voice_txs_propose_veto_tx(multisig_address, id), + DonorVoiceTxsVoteLiquidationTx { multisig_address } => { + donor_voice_txs_vote_liquidation_tx(multisig_address) + } + DonorVoiceTxsVoteVetoTx { + multisig_address, + id, + } => donor_voice_txs_vote_veto_tx(multisig_address, id), + EpochBoundarySmokeTriggerEpoch {} => epoch_boundary_smoke_trigger_epoch(), + JailUnjailByVoucher { addr } => jail_unjail_by_voucher(addr), + LibraCoinClaimMintCapability {} => libra_coin_claim_mint_capability(), + LibraCoinDelegateMintCapability { to } => libra_coin_delegate_mint_capability(to), + LibraCoinMintToImpl { dst_addr, amount } => libra_coin_mint_to_impl(dst_addr, amount), + MultiActionFinalizeAndCage { + initial_authorities, + num_signers, + } => multi_action_finalize_and_cage(initial_authorities, num_signers), + MultisigAccountAddOwner { new_owner } => multisig_account_add_owner(new_owner), + MultisigAccountAddOwners { new_owners } => multisig_account_add_owners(new_owners), + MultisigAccountApproveTransaction { + multisig_account, + sequence_number, + } => multisig_account_approve_transaction(multisig_account, sequence_number), + MultisigAccountCreate { + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_create(num_signatures_required, metadata_keys, metadata_values), + MultisigAccountCreateTransaction { + multisig_account, + payload, + } => multisig_account_create_transaction(multisig_account, payload), + MultisigAccountCreateTransactionWithHash { + multisig_account, + payload_hash, + } => multisig_account_create_transaction_with_hash(multisig_account, payload_hash), + MultisigAccountCreateWithExistingAccount { + multisig_address, + owners, + num_signatures_required, + account_scheme, + account_public_key, + create_multisig_account_signed_message, + metadata_keys, + metadata_values, + } => multisig_account_create_with_existing_account( + multisig_address, + owners, + num_signatures_required, + account_scheme, + account_public_key, + create_multisig_account_signed_message, + metadata_keys, + metadata_values, + ), + MultisigAccountCreateWithOwners { + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_create_with_owners( + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + ), + MultisigAccountExecuteRejectedTransaction { multisig_account } => { + multisig_account_execute_rejected_transaction(multisig_account) + } + MultisigAccountMigrateWithOwners { + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_migrate_with_owners( + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + ), + MultisigAccountRejectTransaction { + multisig_account, + sequence_number, + } => multisig_account_reject_transaction(multisig_account, sequence_number), + MultisigAccountRemoveOwner { owner_to_remove } => { + multisig_account_remove_owner(owner_to_remove) + } + MultisigAccountRemoveOwners { owners_to_remove } => { + multisig_account_remove_owners(owners_to_remove) + } + MultisigAccountUpdateMetadata { keys, values } => { + multisig_account_update_metadata(keys, values) + } + MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required, + } => multisig_account_update_signatures_required(new_num_signatures_required), + MultisigAccountVoteTransanction { + multisig_account, + sequence_number, + approved, + } => multisig_account_vote_transanction(multisig_account, sequence_number, approved), + ObjectTransferCall { object, to } => object_transfer_call(object, to), + OlAccountCreateAccount { auth_key } => ol_account_create_account(auth_key), + OlAccountSetAllowDirectCoinTransfers { allow } => { + ol_account_set_allow_direct_coin_transfers(allow) + } + OlAccountTransfer { to, amount } => ol_account_transfer(to, amount), + OracleInitProvider {} => oracle_init_provider(), + ProofOfFeeInitBidding {} => proof_of_fee_init_bidding(), + ProofOfFeePofRetractBid {} => proof_of_fee_pof_retract_bid(), + ProofOfFeePofUpdateBid { bid, epoch_expiry } => { + proof_of_fee_pof_update_bid(bid, epoch_expiry) + } + SafeInitPaymentMultisig {} => safe_init_payment_multisig(), + SlowWalletSmokeTestVmUnlock { + user_addr, + unlocked, + transferred, + } => slow_wallet_smoke_test_vm_unlock(user_addr, unlocked, transferred), + SlowWalletUserSetSlow {} => slow_wallet_user_set_slow(), + StakeInitializeStakeOwner { + initial_stake_amount, + operator, + _voter, + } => stake_initialize_stake_owner(initial_stake_amount, operator, _voter), + StakeInitializeValidator { + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + } => stake_initialize_validator( + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + ), + StakeRotateConsensusKey { + validator_address, + new_consensus_pubkey, + proof_of_possession, + } => stake_rotate_consensus_key( + validator_address, + new_consensus_pubkey, + proof_of_possession, + ), + StakeSetOperator { new_operator } => stake_set_operator(new_operator), + StakeUpdateNetworkAndFullnodeAddresses { + validator_address, + new_network_addresses, + new_fullnode_addresses, + } => stake_update_network_and_fullnode_addresses( + validator_address, + new_network_addresses, + new_fullnode_addresses, + ), + TowerStateMinerstateCommit { + challenge, + solution, + difficulty, + security, + } => tower_state_minerstate_commit(challenge, solution, difficulty, security), + ValidatorUniverseRegisterValidator { + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + } => validator_universe_register_validator( + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + ), + VersionSetVersion { major } => version_set_version(major), + VouchInsistVouchFor { wanna_be_my_friend } => { + vouch_insist_vouch_for(wanna_be_my_friend) + } + VouchRevoke { its_not_me_its_you } => vouch_revoke(its_not_me_its_you), + VouchVouchFor { wanna_be_my_friend } => vouch_vouch_for(wanna_be_my_friend), + } + } + + /// Try to recognize an Diem `TransactionPayload` and convert it into a structured object `EntryFunctionCall`. + pub fn decode(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + match SCRIPT_FUNCTION_DECODER_MAP.get(&format!( + "{}_{}", + script.module().name(), + script.function() + )) { + Some(decoder) => decoder(payload), + None => None, + } + } else { + None + } + } +} + +/// Offers rotation capability on behalf of `account` to the account at address `recipient_address`. +/// An account can delegate its rotation capability to only one other address at one time. If the account +/// has an existing rotation capability offer, calling this function will update the rotation capability offer with +/// the new `recipient_address`. +/// Here, `rotation_capability_sig_bytes` signature indicates that this key rotation is authorized by the account owner, +/// and prevents the classic "time-of-check time-of-use" attack. +/// For example, users usually rely on what the wallet displays to them as the transaction's outcome. Consider a contract that with 50% probability +/// (based on the current timestamp in Move), rotates somebody's key. The wallet might be unlucky and get an outcome where nothing is rotated, +/// incorrectly telling the user nothing bad will happen. But when the transaction actually gets executed, the attacker gets lucky and +/// the execution path triggers the account key rotation. +/// We prevent such attacks by asking for this extra signature authorizing the key rotation. +/// +/// @param rotation_capability_sig_bytes is the signature by the account owner's key on `RotationCapabilityOfferProofChallengeV2`. +/// @param account_scheme is the scheme of the account (ed25519 or multi_ed25519). +/// @param account_public_key_bytes is the public key of the account owner. +/// @param recipient_address is the address of the recipient of the rotation capability - note that if there's an existing rotation capability +/// offer, calling this function will replace the previous `recipient_address` upon successful verification. +pub fn account_offer_rotation_capability( + rotation_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("offer_rotation_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&rotation_capability_sig_bytes).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key_bytes).unwrap(), + bcs::to_bytes(&recipient_address).unwrap(), + ], + )) +} + +/// Offers signer capability on behalf of `account` to the account at address `recipient_address`. +/// An account can delegate its signer capability to only one other address at one time. +/// `signer_capability_key_bytes` is the `SignerCapabilityOfferProofChallengeV2` signed by the account owner's key +/// `account_scheme` is the scheme of the account (ed25519 or multi_ed25519). +/// `account_public_key_bytes` is the public key of the account owner. +/// `recipient_address` is the address of the recipient of the signer capability - note that if there's an existing +/// `recipient_address` in the account owner's `SignerCapabilityOffer`, this will replace the +/// previous `recipient_address` upon successful verification (the previous recipient will no longer have access +/// to the account owner's signer capability). +pub fn account_offer_signer_capability( + signer_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("offer_signer_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&signer_capability_sig_bytes).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key_bytes).unwrap(), + bcs::to_bytes(&recipient_address).unwrap(), + ], + )) +} + +/// Revoke any rotation capability offer in the specified account. +pub fn account_revoke_any_rotation_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_any_rotation_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Revoke any signer capability offer in the specified account. +pub fn account_revoke_any_signer_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_any_signer_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Revoke the rotation capability offer given to `to_be_revoked_recipient_address` from `account` +pub fn account_revoke_rotation_capability( + to_be_revoked_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_rotation_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to_be_revoked_address).unwrap()], + )) +} + +/// Revoke the account owner's signer capability offer for `to_be_revoked_address` (i.e., the address that +/// has a signer capability offer from `account` but will be revoked in this function). +pub fn account_revoke_signer_capability( + to_be_revoked_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_signer_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to_be_revoked_address).unwrap()], + )) +} + +/// Generic authentication key rotation function that allows the user to rotate their authentication key from any scheme to any scheme. +/// To authorize the rotation, we need two signatures: +/// - the first signature `cap_rotate_key` refers to the signature by the account owner's current key on a valid `RotationProofChallenge`, +/// demonstrating that the user intends to and has the capability to rotate the authentication key of this account; +/// - the second signature `cap_update_table` refers to the signature by the new key (that the account owner wants to rotate to) on a +/// valid `RotationProofChallenge`, demonstrating that the user owns the new private key, and has the authority to update the +/// `OriginatingAddress` map with the new address mapping ``. +/// To verify these two signatures, we need their corresponding public key and public key scheme: we use `from_scheme` and `from_public_key_bytes` +/// to verify `cap_rotate_key`, and `to_scheme` and `to_public_key_bytes` to verify `cap_update_table`. +/// A scheme of 0 refers to an Ed25519 key and a scheme of 1 refers to Multi-Ed25519 keys. +/// `originating address` refers to an account's original/first address. +/// +/// Here is an example attack if we don't ask for the second signature `cap_update_table`: +/// Alice has rotated her account `addr_a` to `new_addr_a`. As a result, the following entry is created, to help Alice when recovering her wallet: +/// `OriginatingAddress[new_addr_a]` -> `addr_a` +/// Alice has had bad day: her laptop blew up and she needs to reset her account on a new one. +/// (Fortunately, she still has her secret key `new_sk_a` associated with her new address `new_addr_a`, so she can do this.) +/// +/// But Bob likes to mess with Alice. +/// Bob creates an account `addr_b` and maliciously rotates it to Alice's new address `new_addr_a`. Since we are no longer checking a PoK, +/// Bob can easily do this. +/// +/// Now, the table will be updated to make Alice's new address point to Bob's address: `OriginatingAddress[new_addr_a]` -> `addr_b`. +/// When Alice recovers her account, her wallet will display the attacker's address (Bob's) `addr_b` as her address. +/// Now Alice will give `addr_b` to everyone to pay her, but the money will go to Bob. +/// +/// Because we ask for a valid `cap_update_table`, this kind of attack is not possible. Bob would not have the secret key of Alice's address +/// to rotate his address to Alice's address in the first place. +pub fn account_rotate_authentication_key( + from_scheme: u8, + from_public_key_bytes: Vec, + to_scheme: u8, + to_public_key_bytes: Vec, + cap_rotate_key: Vec, + cap_update_table: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("rotate_authentication_key").to_owned(), + vec![], + vec![ + bcs::to_bytes(&from_scheme).unwrap(), + bcs::to_bytes(&from_public_key_bytes).unwrap(), + bcs::to_bytes(&to_scheme).unwrap(), + bcs::to_bytes(&to_public_key_bytes).unwrap(), + bcs::to_bytes(&cap_rotate_key).unwrap(), + bcs::to_bytes(&cap_update_table).unwrap(), + ], + )) +} + +pub fn account_rotate_authentication_key_with_rotation_capability( + rotation_cap_offerer_address: AccountAddress, + new_scheme: u8, + new_public_key_bytes: Vec, + cap_update_table: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("rotate_authentication_key_with_rotation_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&rotation_cap_offerer_address).unwrap(), + bcs::to_bytes(&new_scheme).unwrap(), + bcs::to_bytes(&new_public_key_bytes).unwrap(), + bcs::to_bytes(&cap_update_table).unwrap(), + ], + )) +} + +/// User opts into burns being sent to community (recycle burn). +/// default is false (burn is final). +pub fn burn_set_send_community(community: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("burn").to_owned(), + ), + ident_str!("set_send_community").to_owned(), + vec![], + vec![bcs::to_bytes(&community).unwrap()], + )) +} + +/// Same as `publish_package` but as an entry function which can be called as a transaction. Because +/// of current restrictions for txn parameters, the metadata needs to be passed in serialized form. +pub fn code_publish_package_txn( + metadata_serialized: Vec, + code: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("code").to_owned(), + ), + ident_str!("publish_package_txn").to_owned(), + vec![], + vec![ + bcs::to_bytes(&metadata_serialized).unwrap(), + bcs::to_bytes(&code).unwrap(), + ], + )) +} + +/// Transfers `amount` of coins `CoinType` from `from` to `to`. +pub fn coin_transfer(coin_type: TypeTag, to: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("coin").to_owned(), + ), + ident_str!("transfer").to_owned(), + vec![coin_type], + vec![bcs::to_bytes(&to).unwrap(), bcs::to_bytes(&amount).unwrap()], + )) +} + +/// Add or remove a signer to/from the multisig, and check if they may be related in the ancestry tree +pub fn community_wallet_init_change_signer_community_multisig( + multisig_address: AccountAddress, + new_signer: AccountAddress, + is_add_operation: bool, + n_of_m: u64, + vote_duration_epochs: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("change_signer_community_multisig").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&new_signer).unwrap(), + bcs::to_bytes(&is_add_operation).unwrap(), + bcs::to_bytes(&n_of_m).unwrap(), + bcs::to_bytes(&vote_duration_epochs).unwrap(), + ], + )) +} + +/// convenience function to check if the account can be caged +/// after all the structs are in place +pub fn community_wallet_init_finalize_and_cage( + initial_authorities: Vec, + num_signers: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("finalize_and_cage").to_owned(), + vec![], + vec![ + bcs::to_bytes(&initial_authorities).unwrap(), + bcs::to_bytes(&num_signers).unwrap(), + ], + )) +} + +pub fn community_wallet_init_init_community( + check_addresses: Vec, + check_threshold: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("init_community").to_owned(), + vec![], + vec![ + bcs::to_bytes(&check_addresses).unwrap(), + bcs::to_bytes(&check_threshold).unwrap(), + ], + )) +} + +pub fn diem_governance_add_approved_script_hash_script(proposal_id: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("add_approved_script_hash_script").to_owned(), + vec![], + vec![bcs::to_bytes(&proposal_id).unwrap()], + )) +} + +pub fn diem_governance_assert_can_resolve(proposal_id: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("assert_can_resolve").to_owned(), + vec![], + vec![bcs::to_bytes(&proposal_id).unwrap()], + )) +} + +/// Create a single-step proposal with the backing `stake_pool`. +/// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, +/// only the exact script with matching hash can be successfully executed. +pub fn diem_governance_create_proposal( + stake_pool: AccountAddress, + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("create_proposal").to_owned(), + vec![], + vec![ + bcs::to_bytes(&stake_pool).unwrap(), + bcs::to_bytes(&execution_hash).unwrap(), + bcs::to_bytes(&metadata_location).unwrap(), + bcs::to_bytes(&metadata_hash).unwrap(), + ], + )) +} + +/// Create a single-step or multi-step proposal with the backing `stake_pool`. +/// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, +/// only the exact script with matching hash can be successfully executed. +pub fn diem_governance_create_proposal_v2( + stake_pool: AccountAddress, + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("create_proposal_v2").to_owned(), + vec![], + vec![ + bcs::to_bytes(&stake_pool).unwrap(), + bcs::to_bytes(&execution_hash).unwrap(), + bcs::to_bytes(&metadata_location).unwrap(), + bcs::to_bytes(&metadata_hash).unwrap(), + bcs::to_bytes(&is_multi_step_proposal).unwrap(), + ], + )) +} + +/// Create a single-step or multi-step proposal with the backing `stake_pool`. +/// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, +/// only the exact script with matching hash can be successfully executed. +pub fn diem_governance_ol_create_proposal_v2( + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("ol_create_proposal_v2").to_owned(), + vec![], + vec![ + bcs::to_bytes(&execution_hash).unwrap(), + bcs::to_bytes(&metadata_location).unwrap(), + bcs::to_bytes(&metadata_hash).unwrap(), + bcs::to_bytes(&is_multi_step_proposal).unwrap(), + ], + )) +} + +/// Vote on proposal with `proposal_id` and voting power from `stake_pool`. +pub fn diem_governance_ol_vote(proposal_id: u64, should_pass: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("ol_vote").to_owned(), + vec![], + vec![ + bcs::to_bytes(&proposal_id).unwrap(), + bcs::to_bytes(&should_pass).unwrap(), + ], + )) +} + +pub fn diem_governance_smoke_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("smoke_trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Any end user can triger epoch/boundary and reconfiguration +/// as long as the VM set the BoundaryBit to true. +/// We do this because we don't want the VM calling complex +/// logic itself. Any abort would cause a halt. +/// On the other hand, a user can call the function once the VM +/// decides the epoch can change. Any error will just cause the +/// user's transaction to abort, but the chain will continue. +/// Whatever fix is needed can be done online with on-chain governance. +pub fn diem_governance_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Vote on proposal with `proposal_id` and voting power from `stake_pool`. +pub fn diem_governance_vote(proposal_id: u64, should_pass: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("vote").to_owned(), + vec![], + vec![ + bcs::to_bytes(&proposal_id).unwrap(), + bcs::to_bytes(&should_pass).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_propose_liquidate_tx( + multisig_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_liquidate_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +pub fn donor_voice_txs_propose_payment_tx( + multisig_address: AccountAddress, + payee: AccountAddress, + value: u64, + description: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_payment_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&value).unwrap(), + bcs::to_bytes(&description).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_propose_veto_tx( + multisig_address: AccountAddress, + id: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_veto_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&id).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_vote_liquidation_tx(multisig_address: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("vote_liquidation_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +/// Entry functiont to vote the veto. +pub fn donor_voice_txs_vote_veto_tx( + multisig_address: AccountAddress, + id: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("vote_veto_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&id).unwrap(), + ], + )) +} + +pub fn epoch_boundary_smoke_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("epoch_boundary").to_owned(), + ), + ident_str!("smoke_trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Only a Voucher of the validator can flip the unjail bit. +/// This is a way to make sure the validator is ready to rejoin. +pub fn jail_unjail_by_voucher(addr: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("jail").to_owned(), + ), + ident_str!("unjail_by_voucher").to_owned(), + vec![], + vec![bcs::to_bytes(&addr).unwrap()], + )) +} + +/// Only callable in tests and testnets where the core resources account exists. +/// Claim the delegated mint capability and destroy the delegated token. +pub fn libra_coin_claim_mint_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("claim_mint_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Only callable in tests and testnets where the core resources account exists. +/// Create delegated token for the address so the account could claim MintCapability later. +pub fn libra_coin_delegate_mint_capability(to: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("delegate_mint_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to).unwrap()], + )) +} + +/// Root account can mint to an address. Only used for genesis and tests. +/// The "root" account in smoke tests has some privileges. +pub fn libra_coin_mint_to_impl(dst_addr: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("mint_to_impl").to_owned(), + vec![], + vec![ + bcs::to_bytes(&dst_addr).unwrap(), + bcs::to_bytes(&amount).unwrap(), + ], + )) +} + +/// finalize the account and put in a cage. Will abort if governance has not +pub fn multi_action_finalize_and_cage( + initial_authorities: Vec, + num_signers: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multi_action").to_owned(), + ), + ident_str!("finalize_and_cage").to_owned(), + vec![], + vec![ + bcs::to_bytes(&initial_authorities).unwrap(), + bcs::to_bytes(&num_signers).unwrap(), + ], + )) +} + +/// Similar to add_owners, but only allow adding one owner. +pub fn multisig_account_add_owner(new_owner: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("add_owner").to_owned(), + vec![], + vec![bcs::to_bytes(&new_owner).unwrap()], + )) +} + +/// Add new owners to the multisig account. This can only be invoked by the multisig account itself, through the +/// proposal flow. +/// +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the owners list. +pub fn multisig_account_add_owners(new_owners: Vec) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("add_owners").to_owned(), + vec![], + vec![bcs::to_bytes(&new_owners).unwrap()], + )) +} + +/// Approve a multisig transaction. +pub fn multisig_account_approve_transaction( + multisig_account: AccountAddress, + sequence_number: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("approve_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + ], + )) +} + +/// Creates a new multisig account and add the signer as a single owner. +pub fn multisig_account_create( + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create").to_owned(), + vec![], + vec![ + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Create a multisig transaction, which will have one approval initially (from the creator). +/// +/// @param target_function The target function to call such as 0x123::module_to_call::function_to_call. +/// @param args Vector of BCS-encoded argument values to invoke the target function with. +pub fn multisig_account_create_transaction( + multisig_account: AccountAddress, + payload: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&payload).unwrap(), + ], + )) +} + +/// Create a multisig transaction with a transaction hash instead of the full payload. +/// This means the payload will be stored off chain for gas saving. Later, during execution, the executor will need +/// to provide the full payload, which will be validated against the hash stored on-chain. +/// +/// @param function_hash The sha-256 hash of the function to invoke, e.g. 0x123::module_to_call::function_to_call. +/// @param args_hash The sha-256 hash of the function arguments - a concatenated vector of the bcs-encoded +/// function arguments. +pub fn multisig_account_create_transaction_with_hash( + multisig_account: AccountAddress, + payload_hash: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_transaction_with_hash").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&payload_hash).unwrap(), + ], + )) +} + +/// Creates a new multisig account on top of an existing account. +/// +/// This offers a migration path for an existing account with a multi-ed25519 auth key (native multisig account). +/// In order to ensure a malicious module cannot obtain backdoor control over an existing account, a signed message +/// with a valid signature from the account's auth key is required. +pub fn multisig_account_create_with_existing_account( + multisig_address: AccountAddress, + owners: Vec, + num_signatures_required: u64, + account_scheme: u8, + account_public_key: Vec, + create_multisig_account_signed_message: Vec, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_with_existing_account").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key).unwrap(), + bcs::to_bytes(&create_multisig_account_signed_message).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Creates a new multisig account with the specified additional owner list and signatures required. +/// +/// @param additional_owners The owner account who calls this function cannot be in the additional_owners and there +/// cannot be any duplicate owners in the list. +/// @param num_signatures_required The number of signatures required to execute a transaction. Must be at least 1 and +/// at most the total number of owners. +pub fn multisig_account_create_with_owners( + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_with_owners").to_owned(), + vec![], + vec![ + bcs::to_bytes(&additional_owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Remove the next transaction if it has sufficient owner rejections. +pub fn multisig_account_execute_rejected_transaction( + multisig_account: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("execute_rejected_transaction").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_account).unwrap()], + )) +} + +/// keeps the origin account as the ADDRESS +/// rotates the key to ZERO +pub fn multisig_account_migrate_with_owners( + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("migrate_with_owners").to_owned(), + vec![], + vec![ + bcs::to_bytes(&additional_owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Reject a multisig transaction. +pub fn multisig_account_reject_transaction( + multisig_account: AccountAddress, + sequence_number: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("reject_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + ], + )) +} + +/// Similar to remove_owners, but only allow removing one owner. +pub fn multisig_account_remove_owner(owner_to_remove: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("remove_owner").to_owned(), + vec![], + vec![bcs::to_bytes(&owner_to_remove).unwrap()], + )) +} + +/// Remove owners from the multisig account. This can only be invoked by the multisig account itself, through the +/// proposal flow. +/// +/// This function skips any owners who are not in the multisig account's list of owners. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the owners list. +pub fn multisig_account_remove_owners(owners_to_remove: Vec) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("remove_owners").to_owned(), + vec![], + vec![bcs::to_bytes(&owners_to_remove).unwrap()], + )) +} + +/// Allow the multisig account to update its own metadata. Note that this overrides the entire existing metadata. +/// If any attributes are not specified in the metadata, they will be removed! +/// +/// This can only be invoked by the multisig account itself, through the proposal flow. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the number of signatures required. +pub fn multisig_account_update_metadata( + keys: Vec>, + values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("update_metadata").to_owned(), + vec![], + vec![ + bcs::to_bytes(&keys).unwrap(), + bcs::to_bytes(&values).unwrap(), + ], + )) +} + +/// Update the number of signatures required to execute transaction in the specified multisig account. +/// +/// This can only be invoked by the multisig account itself, through the proposal flow. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the number of signatures required. +pub fn multisig_account_update_signatures_required( + new_num_signatures_required: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("update_signatures_required").to_owned(), + vec![], + vec![bcs::to_bytes(&new_num_signatures_required).unwrap()], + )) +} + +/// Generic function that can be used to either approve or reject a multisig transaction +pub fn multisig_account_vote_transanction( + multisig_account: AccountAddress, + sequence_number: u64, + approved: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("vote_transanction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + bcs::to_bytes(&approved).unwrap(), + ], + )) +} + +/// Entry function that can be used to transfer, if allow_ungated_transfer is set true. +pub fn object_transfer_call(object: AccountAddress, to: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("object").to_owned(), + ), + ident_str!("transfer_call").to_owned(), + vec![], + vec![bcs::to_bytes(&object).unwrap(), bcs::to_bytes(&to).unwrap()], + )) +} + +/// Helper for tests to create acounts +/// Belt and suspenders +pub fn ol_account_create_account(auth_key: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("create_account").to_owned(), + vec![], + vec![bcs::to_bytes(&auth_key).unwrap()], + )) +} + +/// Set whether `account` can receive direct transfers of coins that they have not explicitly registered to receive. +pub fn ol_account_set_allow_direct_coin_transfers(allow: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("set_allow_direct_coin_transfers").to_owned(), + vec![], + vec![bcs::to_bytes(&allow).unwrap()], + )) +} + +/// Convenient function to transfer GAS to a recipient account that might not exist. +/// This would create the recipient account first, which also registers it to receive GAS, before transferring. +pub fn ol_account_transfer(to: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("transfer").to_owned(), + vec![], + vec![bcs::to_bytes(&to).unwrap(), bcs::to_bytes(&amount).unwrap()], + )) +} + +pub fn oracle_init_provider() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("oracle").to_owned(), + ), + ident_str!("init_provider").to_owned(), + vec![], + vec![], + )) +} + +pub fn proof_of_fee_init_bidding() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("init_bidding").to_owned(), + vec![], + vec![], + )) +} + +/// retract bid +pub fn proof_of_fee_pof_retract_bid() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("pof_retract_bid").to_owned(), + vec![], + vec![], + )) +} + +/// update the bid for the sender +pub fn proof_of_fee_pof_update_bid(bid: u64, epoch_expiry: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("pof_update_bid").to_owned(), + vec![], + vec![ + bcs::to_bytes(&bid).unwrap(), + bcs::to_bytes(&epoch_expiry).unwrap(), + ], + )) +} + +/// This fucntion initiates governance for the multisig. It is called by the sponsor address, and is only callable once. +/// init_gov fails gracefully if the governance is already initialized. +/// init_type will throw errors if the type is already initialized. +pub fn safe_init_payment_multisig() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("safe").to_owned(), + ), + ident_str!("init_payment_multisig").to_owned(), + vec![], + vec![], + )) +} + +pub fn slow_wallet_smoke_test_vm_unlock( + user_addr: AccountAddress, + unlocked: u64, + transferred: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("slow_wallet").to_owned(), + ), + ident_str!("smoke_test_vm_unlock").to_owned(), + vec![], + vec![ + bcs::to_bytes(&user_addr).unwrap(), + bcs::to_bytes(&unlocked).unwrap(), + bcs::to_bytes(&transferred).unwrap(), + ], + )) +} + +/// Users can change their account to slow, by calling the entry function +/// Warning: this is permanent for the account. There's no way to +/// reverse a "slow wallet". +pub fn slow_wallet_user_set_slow() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("slow_wallet").to_owned(), + ), + ident_str!("user_set_slow").to_owned(), + vec![], + vec![], + )) +} + +/// Initialize the validator account and give ownership to the signing account +/// except it leaves the ValidatorConfig to be set by another entity. +/// Note: this triggers setting the operator and owner, set it to the account's address +/// to set later. +pub fn stake_initialize_stake_owner( + initial_stake_amount: u64, + operator: AccountAddress, + _voter: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("initialize_stake_owner").to_owned(), + vec![], + vec![ + bcs::to_bytes(&initial_stake_amount).unwrap(), + bcs::to_bytes(&operator).unwrap(), + bcs::to_bytes(&_voter).unwrap(), + ], + )) +} + +/// Initialize the validator account and give ownership to the signing account. +pub fn stake_initialize_validator( + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("initialize_validator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + bcs::to_bytes(&network_addresses).unwrap(), + bcs::to_bytes(&fullnode_addresses).unwrap(), + ], + )) +} + +/// Rotate the consensus key of the validator, it'll take effect in next epoch. +pub fn stake_rotate_consensus_key( + validator_address: AccountAddress, + new_consensus_pubkey: Vec, + proof_of_possession: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("rotate_consensus_key").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_address).unwrap(), + bcs::to_bytes(&new_consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + ], + )) +} + +/// Allows an owner to change the operator of the stake pool. +pub fn stake_set_operator(new_operator: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("set_operator").to_owned(), + vec![], + vec![bcs::to_bytes(&new_operator).unwrap()], + )) +} + +/// Update the network and full node addresses of the validator. This only takes effect in the next epoch. +pub fn stake_update_network_and_fullnode_addresses( + validator_address: AccountAddress, + new_network_addresses: Vec, + new_fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("update_network_and_fullnode_addresses").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_address).unwrap(), + bcs::to_bytes(&new_network_addresses).unwrap(), + bcs::to_bytes(&new_fullnode_addresses).unwrap(), + ], + )) +} + +/// The entry point to commit miner state. +pub fn tower_state_minerstate_commit( + challenge: Vec, + solution: Vec, + difficulty: u64, + security: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("tower_state").to_owned(), + ), + ident_str!("minerstate_commit").to_owned(), + vec![], + vec![ + bcs::to_bytes(&challenge).unwrap(), + bcs::to_bytes(&solution).unwrap(), + bcs::to_bytes(&difficulty).unwrap(), + bcs::to_bytes(&security).unwrap(), + ], + )) +} + +/// This is the entrypoint for a validator joining the network. +/// Separates the logic of registration from validator election etc. (in stake.move). +/// This prevents dependency cycling issues, since stake.move is a large module. +pub fn validator_universe_register_validator( + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("validator_universe").to_owned(), + ), + ident_str!("register_validator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + bcs::to_bytes(&network_addresses).unwrap(), + bcs::to_bytes(&fullnode_addresses).unwrap(), + ], + )) +} + +/// Updates the major version to a larger version. +/// This can be called by on chain governance. +pub fn version_set_version(major: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("version").to_owned(), + ), + ident_str!("set_version").to_owned(), + vec![], + vec![bcs::to_bytes(&major).unwrap()], + )) +} + +/// you may want to add people who are related to you +/// there are no known use cases for this at the moment. +pub fn vouch_insist_vouch_for(wanna_be_my_friend: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("insist_vouch_for").to_owned(), + vec![], + vec![bcs::to_bytes(&wanna_be_my_friend).unwrap()], + )) +} + +pub fn vouch_revoke(its_not_me_its_you: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("revoke").to_owned(), + vec![], + vec![bcs::to_bytes(&its_not_me_its_you).unwrap()], + )) +} + +/// will only succesfully vouch if the two are not related by ancestry +/// prevents spending a vouch that would not be counted. +/// to add a vouch and ignore this check use insist_vouch +pub fn vouch_vouch_for(wanna_be_my_friend: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("vouch_for").to_owned(), + vec![], + vec![bcs::to_bytes(&wanna_be_my_friend).unwrap()], + )) +} +mod decoder { + use super::*; + pub fn account_offer_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountOfferRotationCapability { + rotation_capability_sig_bytes: bcs::from_bytes(script.args().first()?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + account_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + recipient_address: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn account_offer_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountOfferSignerCapability { + signer_capability_sig_bytes: bcs::from_bytes(script.args().first()?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + account_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + recipient_address: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn account_revoke_any_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::AccountRevokeAnyRotationCapability {}) + } else { + None + } + } + + pub fn account_revoke_any_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::AccountRevokeAnySignerCapability {}) + } else { + None + } + } + + pub fn account_revoke_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRevokeRotationCapability { + to_be_revoked_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn account_revoke_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRevokeSignerCapability { + to_be_revoked_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn account_rotate_authentication_key( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRotateAuthenticationKey { + from_scheme: bcs::from_bytes(script.args().first()?).ok()?, + from_public_key_bytes: bcs::from_bytes(script.args().get(1)?).ok()?, + to_scheme: bcs::from_bytes(script.args().get(2)?).ok()?, + to_public_key_bytes: bcs::from_bytes(script.args().get(3)?).ok()?, + cap_rotate_key: bcs::from_bytes(script.args().get(4)?).ok()?, + cap_update_table: bcs::from_bytes(script.args().get(5)?).ok()?, + }) + } else { + None + } + } + + pub fn account_rotate_authentication_key_with_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address: bcs::from_bytes(script.args().first()?).ok()?, + new_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + new_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + cap_update_table: bcs::from_bytes(script.args().get(3)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn burn_set_send_community(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::BurnSetSendCommunity { + community: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn code_publish_package_txn(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CodePublishPackageTxn { + metadata_serialized: bcs::from_bytes(script.args().first()?).ok()?, + code: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn coin_transfer(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CoinTransfer { + coin_type: script.ty_args().first()?.clone(), + to: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn community_wallet_init_change_signer_community_multisig( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + new_signer: bcs::from_bytes(script.args().get(1)?).ok()?, + is_add_operation: bcs::from_bytes(script.args().get(2)?).ok()?, + n_of_m: bcs::from_bytes(script.args().get(3)?).ok()?, + vote_duration_epochs: bcs::from_bytes(script.args().get(4)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn community_wallet_init_finalize_and_cage( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CommunityWalletInitFinalizeAndCage { + initial_authorities: bcs::from_bytes(script.args().first()?).ok()?, + num_signers: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn community_wallet_init_init_community( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CommunityWalletInitInitCommunity { + check_addresses: bcs::from_bytes(script.args().first()?).ok()?, + check_threshold: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_add_approved_script_hash_script( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::DiemGovernanceAddApprovedScriptHashScript { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + }, + ) + } else { + None + } + } + + pub fn diem_governance_assert_can_resolve( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceAssertCanResolve { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_create_proposal( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceCreateProposal { + stake_pool: bcs::from_bytes(script.args().first()?).ok()?, + execution_hash: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_location: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_hash: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_create_proposal_v2( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceCreateProposalV2 { + stake_pool: bcs::from_bytes(script.args().first()?).ok()?, + execution_hash: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_location: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_hash: bcs::from_bytes(script.args().get(3)?).ok()?, + is_multi_step_proposal: bcs::from_bytes(script.args().get(4)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_ol_create_proposal_v2( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceOlCreateProposalV2 { + execution_hash: bcs::from_bytes(script.args().first()?).ok()?, + metadata_location: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_hash: bcs::from_bytes(script.args().get(2)?).ok()?, + is_multi_step_proposal: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_ol_vote(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceOlVote { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + should_pass: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_smoke_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::DiemGovernanceSmokeTriggerEpoch {}) + } else { + None + } + } + + pub fn diem_governance_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::DiemGovernanceTriggerEpoch {}) + } else { + None + } + } + + pub fn diem_governance_vote(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceVote { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + should_pass: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_liquidate_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposeLiquidateTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_payment_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposePaymentTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + payee: bcs::from_bytes(script.args().get(1)?).ok()?, + value: bcs::from_bytes(script.args().get(2)?).ok()?, + description: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_veto_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposeVetoTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + id: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_vote_liquidation_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsVoteLiquidationTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_vote_veto_tx(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsVoteVetoTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + id: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn epoch_boundary_smoke_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::EpochBoundarySmokeTriggerEpoch {}) + } else { + None + } + } + + pub fn jail_unjail_by_voucher(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::JailUnjailByVoucher { + addr: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn libra_coin_claim_mint_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::LibraCoinClaimMintCapability {}) + } else { + None + } + } + + pub fn libra_coin_delegate_mint_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::LibraCoinDelegateMintCapability { + to: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn libra_coin_mint_to_impl(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::LibraCoinMintToImpl { + dst_addr: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multi_action_finalize_and_cage( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultiActionFinalizeAndCage { + initial_authorities: bcs::from_bytes(script.args().first()?).ok()?, + num_signers: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_add_owner(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountAddOwner { + new_owner: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_add_owners(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountAddOwners { + new_owners: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_approve_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountApproveTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreate { + num_signatures_required: bcs::from_bytes(script.args().first()?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreateTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + payload: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create_transaction_with_hash( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountCreateTransactionWithHash { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + payload_hash: bcs::from_bytes(script.args().get(1)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_create_with_existing_account( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountCreateWithExistingAccount { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + owners: bcs::from_bytes(script.args().get(1)?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(2)?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(3)?).ok()?, + account_public_key: bcs::from_bytes(script.args().get(4)?).ok()?, + create_multisig_account_signed_message: bcs::from_bytes(script.args().get(5)?) + .ok()?, + metadata_keys: bcs::from_bytes(script.args().get(6)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(7)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_create_with_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreateWithOwners { + additional_owners: bcs::from_bytes(script.args().first()?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_execute_rejected_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountExecuteRejectedTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_migrate_with_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountMigrateWithOwners { + additional_owners: bcs::from_bytes(script.args().first()?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_reject_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRejectTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_remove_owner( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRemoveOwner { + owner_to_remove: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_remove_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRemoveOwners { + owners_to_remove: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_update_metadata( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountUpdateMetadata { + keys: bcs::from_bytes(script.args().first()?).ok()?, + values: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_update_signatures_required( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_vote_transanction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountVoteTransanction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + approved: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn object_transfer_call(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ObjectTransferCall { + object: bcs::from_bytes(script.args().first()?).ok()?, + to: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_create_account(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountCreateAccount { + auth_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_set_allow_direct_coin_transfers( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountSetAllowDirectCoinTransfers { + allow: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_transfer(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountTransfer { + to: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn oracle_init_provider(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::OracleInitProvider {}) + } else { + None + } + } + + pub fn proof_of_fee_init_bidding(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::ProofOfFeeInitBidding {}) + } else { + None + } + } + + pub fn proof_of_fee_pof_retract_bid(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::ProofOfFeePofRetractBid {}) + } else { + None + } + } + + pub fn proof_of_fee_pof_update_bid(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ProofOfFeePofUpdateBid { + bid: bcs::from_bytes(script.args().first()?).ok()?, + epoch_expiry: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn safe_init_payment_multisig(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::SafeInitPaymentMultisig {}) + } else { + None + } + } + + pub fn slow_wallet_smoke_test_vm_unlock( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::SlowWalletSmokeTestVmUnlock { + user_addr: bcs::from_bytes(script.args().first()?).ok()?, + unlocked: bcs::from_bytes(script.args().get(1)?).ok()?, + transferred: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn slow_wallet_user_set_slow(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::SlowWalletUserSetSlow {}) + } else { + None + } + } + + pub fn stake_initialize_stake_owner(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeInitializeStakeOwner { + initial_stake_amount: bcs::from_bytes(script.args().first()?).ok()?, + operator: bcs::from_bytes(script.args().get(1)?).ok()?, + _voter: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn stake_initialize_validator(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeInitializeValidator { + consensus_pubkey: bcs::from_bytes(script.args().first()?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(1)?).ok()?, + network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn stake_rotate_consensus_key(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeRotateConsensusKey { + validator_address: bcs::from_bytes(script.args().first()?).ok()?, + new_consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn stake_set_operator(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeSetOperator { + new_operator: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn stake_update_network_and_fullnode_addresses( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeUpdateNetworkAndFullnodeAddresses { + validator_address: bcs::from_bytes(script.args().first()?).ok()?, + new_network_addresses: bcs::from_bytes(script.args().get(1)?).ok()?, + new_fullnode_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn tower_state_minerstate_commit( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::TowerStateMinerstateCommit { + challenge: bcs::from_bytes(script.args().first()?).ok()?, + solution: bcs::from_bytes(script.args().get(1)?).ok()?, + difficulty: bcs::from_bytes(script.args().get(2)?).ok()?, + security: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn validator_universe_register_validator( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ValidatorUniverseRegisterValidator { + consensus_pubkey: bcs::from_bytes(script.args().first()?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(1)?).ok()?, + network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn version_set_version(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VersionSetVersion { + major: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_insist_vouch_for(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchInsistVouchFor { + wanna_be_my_friend: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_revoke(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchRevoke { + its_not_me_its_you: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_vouch_for(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchVouchFor { + wanna_be_my_friend: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } +} + +type EntryFunctionDecoderMap = std::collections::HashMap< + String, + Box< + dyn Fn(&TransactionPayload) -> Option + + std::marker::Sync + + std::marker::Send, + >, +>; + +static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = + once_cell::sync::Lazy::new(|| { + let mut map: EntryFunctionDecoderMap = std::collections::HashMap::new(); + map.insert( + "account_offer_rotation_capability".to_string(), + Box::new(decoder::account_offer_rotation_capability), + ); + map.insert( + "account_offer_signer_capability".to_string(), + Box::new(decoder::account_offer_signer_capability), + ); + map.insert( + "account_revoke_any_rotation_capability".to_string(), + Box::new(decoder::account_revoke_any_rotation_capability), + ); + map.insert( + "account_revoke_any_signer_capability".to_string(), + Box::new(decoder::account_revoke_any_signer_capability), + ); + map.insert( + "account_revoke_rotation_capability".to_string(), + Box::new(decoder::account_revoke_rotation_capability), + ); + map.insert( + "account_revoke_signer_capability".to_string(), + Box::new(decoder::account_revoke_signer_capability), + ); + map.insert( + "account_rotate_authentication_key".to_string(), + Box::new(decoder::account_rotate_authentication_key), + ); + map.insert( + "account_rotate_authentication_key_with_rotation_capability".to_string(), + Box::new(decoder::account_rotate_authentication_key_with_rotation_capability), + ); + map.insert( + "burn_set_send_community".to_string(), + Box::new(decoder::burn_set_send_community), + ); + map.insert( + "code_publish_package_txn".to_string(), + Box::new(decoder::code_publish_package_txn), + ); + map.insert( + "coin_transfer".to_string(), + Box::new(decoder::coin_transfer), + ); + map.insert( + "community_wallet_init_change_signer_community_multisig".to_string(), + Box::new(decoder::community_wallet_init_change_signer_community_multisig), + ); + map.insert( + "community_wallet_init_finalize_and_cage".to_string(), + Box::new(decoder::community_wallet_init_finalize_and_cage), + ); + map.insert( + "community_wallet_init_init_community".to_string(), + Box::new(decoder::community_wallet_init_init_community), + ); + map.insert( + "diem_governance_add_approved_script_hash_script".to_string(), + Box::new(decoder::diem_governance_add_approved_script_hash_script), + ); + map.insert( + "diem_governance_assert_can_resolve".to_string(), + Box::new(decoder::diem_governance_assert_can_resolve), + ); + map.insert( + "diem_governance_create_proposal".to_string(), + Box::new(decoder::diem_governance_create_proposal), + ); + map.insert( + "diem_governance_create_proposal_v2".to_string(), + Box::new(decoder::diem_governance_create_proposal_v2), + ); + map.insert( + "diem_governance_ol_create_proposal_v2".to_string(), + Box::new(decoder::diem_governance_ol_create_proposal_v2), + ); + map.insert( + "diem_governance_ol_vote".to_string(), + Box::new(decoder::diem_governance_ol_vote), + ); + map.insert( + "diem_governance_smoke_trigger_epoch".to_string(), + Box::new(decoder::diem_governance_smoke_trigger_epoch), + ); + map.insert( + "diem_governance_trigger_epoch".to_string(), + Box::new(decoder::diem_governance_trigger_epoch), + ); + map.insert( + "diem_governance_vote".to_string(), + Box::new(decoder::diem_governance_vote), + ); + map.insert( + "donor_voice_txs_propose_liquidate_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_liquidate_tx), + ); + map.insert( + "donor_voice_txs_propose_payment_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_payment_tx), + ); + map.insert( + "donor_voice_txs_propose_veto_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_veto_tx), + ); + map.insert( + "donor_voice_txs_vote_liquidation_tx".to_string(), + Box::new(decoder::donor_voice_txs_vote_liquidation_tx), + ); + map.insert( + "donor_voice_txs_vote_veto_tx".to_string(), + Box::new(decoder::donor_voice_txs_vote_veto_tx), + ); + map.insert( + "epoch_boundary_smoke_trigger_epoch".to_string(), + Box::new(decoder::epoch_boundary_smoke_trigger_epoch), + ); + map.insert( + "jail_unjail_by_voucher".to_string(), + Box::new(decoder::jail_unjail_by_voucher), + ); + map.insert( + "libra_coin_claim_mint_capability".to_string(), + Box::new(decoder::libra_coin_claim_mint_capability), + ); + map.insert( + "libra_coin_delegate_mint_capability".to_string(), + Box::new(decoder::libra_coin_delegate_mint_capability), + ); + map.insert( + "libra_coin_mint_to_impl".to_string(), + Box::new(decoder::libra_coin_mint_to_impl), + ); + map.insert( + "multi_action_finalize_and_cage".to_string(), + Box::new(decoder::multi_action_finalize_and_cage), + ); + map.insert( + "multisig_account_add_owner".to_string(), + Box::new(decoder::multisig_account_add_owner), + ); + map.insert( + "multisig_account_add_owners".to_string(), + Box::new(decoder::multisig_account_add_owners), + ); + map.insert( + "multisig_account_approve_transaction".to_string(), + Box::new(decoder::multisig_account_approve_transaction), + ); + map.insert( + "multisig_account_create".to_string(), + Box::new(decoder::multisig_account_create), + ); + map.insert( + "multisig_account_create_transaction".to_string(), + Box::new(decoder::multisig_account_create_transaction), + ); + map.insert( + "multisig_account_create_transaction_with_hash".to_string(), + Box::new(decoder::multisig_account_create_transaction_with_hash), + ); + map.insert( + "multisig_account_create_with_existing_account".to_string(), + Box::new(decoder::multisig_account_create_with_existing_account), + ); + map.insert( + "multisig_account_create_with_owners".to_string(), + Box::new(decoder::multisig_account_create_with_owners), + ); + map.insert( + "multisig_account_execute_rejected_transaction".to_string(), + Box::new(decoder::multisig_account_execute_rejected_transaction), + ); + map.insert( + "multisig_account_migrate_with_owners".to_string(), + Box::new(decoder::multisig_account_migrate_with_owners), + ); + map.insert( + "multisig_account_reject_transaction".to_string(), + Box::new(decoder::multisig_account_reject_transaction), + ); + map.insert( + "multisig_account_remove_owner".to_string(), + Box::new(decoder::multisig_account_remove_owner), + ); + map.insert( + "multisig_account_remove_owners".to_string(), + Box::new(decoder::multisig_account_remove_owners), + ); + map.insert( + "multisig_account_update_metadata".to_string(), + Box::new(decoder::multisig_account_update_metadata), + ); + map.insert( + "multisig_account_update_signatures_required".to_string(), + Box::new(decoder::multisig_account_update_signatures_required), + ); + map.insert( + "multisig_account_vote_transanction".to_string(), + Box::new(decoder::multisig_account_vote_transanction), + ); + map.insert( + "object_transfer_call".to_string(), + Box::new(decoder::object_transfer_call), + ); + map.insert( + "ol_account_create_account".to_string(), + Box::new(decoder::ol_account_create_account), + ); + map.insert( + "ol_account_set_allow_direct_coin_transfers".to_string(), + Box::new(decoder::ol_account_set_allow_direct_coin_transfers), + ); + map.insert( + "ol_account_transfer".to_string(), + Box::new(decoder::ol_account_transfer), + ); + map.insert( + "oracle_init_provider".to_string(), + Box::new(decoder::oracle_init_provider), + ); + map.insert( + "proof_of_fee_init_bidding".to_string(), + Box::new(decoder::proof_of_fee_init_bidding), + ); + map.insert( + "proof_of_fee_pof_retract_bid".to_string(), + Box::new(decoder::proof_of_fee_pof_retract_bid), + ); + map.insert( + "proof_of_fee_pof_update_bid".to_string(), + Box::new(decoder::proof_of_fee_pof_update_bid), + ); + map.insert( + "safe_init_payment_multisig".to_string(), + Box::new(decoder::safe_init_payment_multisig), + ); + map.insert( + "slow_wallet_smoke_test_vm_unlock".to_string(), + Box::new(decoder::slow_wallet_smoke_test_vm_unlock), + ); + map.insert( + "slow_wallet_user_set_slow".to_string(), + Box::new(decoder::slow_wallet_user_set_slow), + ); + map.insert( + "stake_initialize_stake_owner".to_string(), + Box::new(decoder::stake_initialize_stake_owner), + ); + map.insert( + "stake_initialize_validator".to_string(), + Box::new(decoder::stake_initialize_validator), + ); + map.insert( + "stake_rotate_consensus_key".to_string(), + Box::new(decoder::stake_rotate_consensus_key), + ); + map.insert( + "stake_set_operator".to_string(), + Box::new(decoder::stake_set_operator), + ); + map.insert( + "stake_update_network_and_fullnode_addresses".to_string(), + Box::new(decoder::stake_update_network_and_fullnode_addresses), + ); + map.insert( + "tower_state_minerstate_commit".to_string(), + Box::new(decoder::tower_state_minerstate_commit), + ); + map.insert( + "validator_universe_register_validator".to_string(), + Box::new(decoder::validator_universe_register_validator), + ); + map.insert( + "version_set_version".to_string(), + Box::new(decoder::version_set_version), + ); + map.insert( + "vouch_insist_vouch_for".to_string(), + Box::new(decoder::vouch_insist_vouch_for), + ); + map.insert("vouch_revoke".to_string(), Box::new(decoder::vouch_revoke)); + map.insert( + "vouch_vouch_for".to_string(), + Box::new(decoder::vouch_vouch_for), + ); + map + }); diff --git a/compatibility/src/sdk/v7_libra_framework_sdk_builder.rs b/compatibility/src/sdk/v7_libra_framework_sdk_builder.rs new file mode 100644 index 000000000..7d7258282 --- /dev/null +++ b/compatibility/src/sdk/v7_libra_framework_sdk_builder.rs @@ -0,0 +1,3537 @@ +/////// OL //////// +// NOTE: these files are copied from the original version which were at +// the time deployed to production. +// They are originally automatically generated code. +// A minor modification is adding serde de/serializers to the EntryFunctionCall enum. +//////// end //////// + +// Copyright © Diem Foundation +// SPDX-License-Identifier: Apache-2.0 + +// This file was generated. Do not modify! +// +// To update this code, run: `cargo run --release -p 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 `diem-sdk-builder`. + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] +use diem_types::{ + account_address::AccountAddress, + transaction::{EntryFunction, TransactionPayload}, +}; +use move_core_types::{ + ident_str, + language_storage::{ModuleId, TypeTag}, +}; + +type Bytes = Vec; + +/// Structured representation of a call into a known Move entry function. +/// ```ignore +/// impl EntryFunctionCall { +/// pub fn encode(self) -> TransactionPayload { .. } +/// pub fn decode(&TransactionPayload) -> Option { .. } +/// } +/// ``` + +//////// OL /////// +// NOTE: the serde de/serializers were added manually for use in +// explorer and data warehouse +//////// end //////// +#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)] +#[cfg_attr(feature = "fuzzing", derive(proptest_derive::Arbitrary))] +#[cfg_attr(feature = "fuzzing", proptest(no_params))] +pub enum EntryFunctionCall { + /// Offers rotation capability on behalf of `account` to the account at address `recipient_address`. + /// An account can delegate its rotation capability to only one other address at one time. If the account + /// has an existing rotation capability offer, calling this function will update the rotation capability offer with + /// the new `recipient_address`. + /// Here, `rotation_capability_sig_bytes` signature indicates that this key rotation is authorized by the account owner, + /// and prevents the classic "time-of-check time-of-use" attack. + /// For example, users usually rely on what the wallet displays to them as the transaction's outcome. Consider a contract that with 50% probability + /// (based on the current timestamp in Move), rotates somebody's key. The wallet might be unlucky and get an outcome where nothing is rotated, + /// incorrectly telling the user nothing bad will happen. But when the transaction actually gets executed, the attacker gets lucky and + /// the execution path triggers the account key rotation. + /// We prevent such attacks by asking for this extra signature authorizing the key rotation. + /// + /// @param rotation_capability_sig_bytes is the signature by the account owner's key on `RotationCapabilityOfferProofChallengeV2`. + /// @param account_scheme is the scheme of the account (ed25519 or multi_ed25519). + /// @param account_public_key_bytes is the public key of the account owner. + /// @param recipient_address is the address of the recipient of the rotation capability - note that if there's an existing rotation capability + /// offer, calling this function will replace the previous `recipient_address` upon successful verification. + AccountOfferRotationCapability { + rotation_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, + }, + + /// Offers signer capability on behalf of `account` to the account at address `recipient_address`. + /// An account can delegate its signer capability to only one other address at one time. + /// `signer_capability_key_bytes` is the `SignerCapabilityOfferProofChallengeV2` signed by the account owner's key + /// `account_scheme` is the scheme of the account (ed25519 or multi_ed25519). + /// `account_public_key_bytes` is the public key of the account owner. + /// `recipient_address` is the address of the recipient of the signer capability - note that if there's an existing + /// `recipient_address` in the account owner's `SignerCapabilityOffer`, this will replace the + /// previous `recipient_address` upon successful verification (the previous recipient will no longer have access + /// to the account owner's signer capability). + AccountOfferSignerCapability { + signer_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, + }, + + /// Revoke any rotation capability offer in the specified account. + AccountRevokeAnyRotationCapability {}, + + /// Revoke any signer capability offer in the specified account. + AccountRevokeAnySignerCapability {}, + + /// Revoke the rotation capability offer given to `to_be_revoked_recipient_address` from `account` + AccountRevokeRotationCapability { + to_be_revoked_address: AccountAddress, + }, + + /// Revoke the account owner's signer capability offer for `to_be_revoked_address` (i.e., the address that + /// has a signer capability offer from `account` but will be revoked in this function). + AccountRevokeSignerCapability { + to_be_revoked_address: AccountAddress, + }, + + /// Generic authentication key rotation function that allows the user to rotate their authentication key from any scheme to any scheme. + /// To authorize the rotation, we need two signatures: + /// - the first signature `cap_rotate_key` refers to the signature by the account owner's current key on a valid `RotationProofChallenge`, + /// demonstrating that the user intends to and has the capability to rotate the authentication key of this account; + /// - the second signature `cap_update_table` refers to the signature by the new key (that the account owner wants to rotate to) on a + /// valid `RotationProofChallenge`, demonstrating that the user owns the new private key, and has the authority to update the + /// `OriginatingAddress` map with the new address mapping ``. + /// To verify these two signatures, we need their corresponding public key and public key scheme: we use `from_scheme` and `from_public_key_bytes` + /// to verify `cap_rotate_key`, and `to_scheme` and `to_public_key_bytes` to verify `cap_update_table`. + /// A scheme of 0 refers to an Ed25519 key and a scheme of 1 refers to Multi-Ed25519 keys. + /// `originating address` refers to an account's original/first address. + /// + /// Here is an example attack if we don't ask for the second signature `cap_update_table`: + /// Alice has rotated her account `addr_a` to `new_addr_a`. As a result, the following entry is created, to help Alice when recovering her wallet: + /// `OriginatingAddress[new_addr_a]` -> `addr_a` + /// Alice has had bad day: her laptop blew up and she needs to reset her account on a new one. + /// (Fortunately, she still has her secret key `new_sk_a` associated with her new address `new_addr_a`, so she can do this.) + /// + /// But Bob likes to mess with Alice. + /// Bob creates an account `addr_b` and maliciously rotates it to Alice's new address `new_addr_a`. Since we are no longer checking a PoK, + /// Bob can easily do this. + /// + /// Now, the table will be updated to make Alice's new address point to Bob's address: `OriginatingAddress[new_addr_a]` -> `addr_b`. + /// When Alice recovers her account, her wallet will display the attacker's address (Bob's) `addr_b` as her address. + /// Now Alice will give `addr_b` to everyone to pay her, but the money will go to Bob. + /// + /// Because we ask for a valid `cap_update_table`, this kind of attack is not possible. Bob would not have the secret key of Alice's address + /// to rotate his address to Alice's address in the first place. + AccountRotateAuthenticationKey { + from_scheme: u8, + from_public_key_bytes: Vec, + to_scheme: u8, + to_public_key_bytes: Vec, + cap_rotate_key: Vec, + cap_update_table: Vec, + }, + + AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address: AccountAddress, + new_scheme: u8, + new_public_key_bytes: Vec, + cap_update_table: Vec, + }, + + /// User opts into burns being sent to community (recycle burn). + /// default is false (burn is final). + BurnSetSendCommunity { + community: bool, + }, + + /// Same as `publish_package` but as an entry function which can be called as a transaction. Because + /// of current restrictions for txn parameters, the metadata needs to be passed in serialized form. + CodePublishPackageTxn { + metadata_serialized: Vec, + code: Vec>, + }, + + /// Transfers `amount` of coins `CoinType` from `from` to `to`. + CoinTransfer { + coin_type: TypeTag, + to: AccountAddress, + amount: u64, + }, + + /// TODO: Allow to propose change only on the signature threshold + /// Add or remove a signer to/from the multisig, and check if they may be related in the ancestry tree + CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address: AccountAddress, + new_signer: AccountAddress, + is_add_operation: bool, + n_of_m: u64, + vote_duration_epochs: u64, + }, + + /// convenience function to check if the account can be caged + /// after all the structs are in place + CommunityWalletInitFinalizeAndCage { + num_signers: u64, + }, + + CommunityWalletInitInitCommunity { + initial_authorities: Vec, + check_threshold: u64, + }, + + /// Propose offer to the multisig, and check if the signers are not related family + CommunityWalletInitProposeOffer { + new_signers: Vec, + num_signers: u64, + }, + + DiemGovernanceAddApprovedScriptHashScript { + proposal_id: u64, + }, + + DiemGovernanceAssertCanResolve { + proposal_id: u64, + }, + + /// Create a single-step or multi-step proposal + /// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, + /// only the exact script with matching hash can be successfully executed. + DiemGovernanceCreateProposalV2 { + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, + }, + + /// Create a single-step or multi-step proposal + /// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, + /// only the exact script with matching hash can be successfully executed. + DiemGovernanceOlCreateProposalV2 { + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, + }, + + /// Vote on proposal with `proposal_id`. + DiemGovernanceOlVote { + proposal_id: u64, + should_pass: bool, + }, + + DiemGovernanceSmokeTriggerEpoch {}, + + /// Any end user can triger epoch/boundary and reconfiguration + /// as long as the VM set the BoundaryBit to true. + /// We do this because we don't want the VM calling complex + /// logic itself. Any abort would cause a halt. + /// On the other hand, a user can call the function once the VM + /// decides the epoch can change. Any error will just cause the + /// user's transaction to abort, but the chain will continue. + /// Whatever fix is needed can be done online with on-chain governance. + DiemGovernanceTriggerEpoch {}, + + /// Vote on proposal with `proposal_id` + DiemGovernanceVote { + proposal_id: u64, + should_pass: bool, + }, + + DonorVoiceTxsProposeLiquidateTx { + multisig_address: AccountAddress, + }, + + DonorVoiceTxsProposePaymentTx { + multisig_address: AccountAddress, + payee: AccountAddress, + value: u64, + description: Vec, + }, + + DonorVoiceTxsProposeVetoTx { + multisig_address: AccountAddress, + id: u64, + }, + + DonorVoiceTxsVoteLiquidationTx { + multisig_address: AccountAddress, + }, + + /// Entry functiont to vote the veto. + DonorVoiceTxsVoteVetoTx { + multisig_address: AccountAddress, + id: u64, + }, + + EpochBoundarySmokeTriggerEpoch {}, + + /// Only a Voucher of the validator can flip the unjail bit. + /// This is a way to make sure the validator is ready to rejoin. + JailUnjailByVoucher { + addr: AccountAddress, + }, + + /// Only callable in tests and testnets where the core resources account exists. + /// Claim the delegated mint capability and destroy the delegated token. + LibraCoinClaimMintCapability {}, + + /// Only callable in tests and testnets where the core resources account exists. + /// Create delegated token for the address so the account could claim MintCapability later. + LibraCoinDelegateMintCapability { + to: AccountAddress, + }, + + /// Root account can mint to an address. Only used for genesis and tests. + /// The "root" account in smoke tests has some privileges. + LibraCoinMintToImpl { + dst_addr: AccountAddress, + amount: u64, + }, + + MultiActionClaimOffer { + multisig_address: AccountAddress, + }, + + MultiActionInitGovDeprecated {}, + + MultiActionMigrationMigrateOffer { + multisig_address: AccountAddress, + }, + + /// Similar to add_owners, but only allow adding one owner. + MultisigAccountAddOwner { + new_owner: AccountAddress, + }, + + /// Add new owners to the multisig account. This can only be invoked by the multisig account itself, through the + /// proposal flow. + /// + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the owners list. + MultisigAccountAddOwners { + new_owners: Vec, + }, + + /// Approve a multisig transaction. + MultisigAccountApproveTransaction { + multisig_account: AccountAddress, + sequence_number: u64, + }, + + /// Creates a new multisig account and add the signer as a single owner. + MultisigAccountCreate { + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Create a multisig transaction, which will have one approval initially (from the creator). + /// + /// @param target_function The target function to call such as 0x123::module_to_call::function_to_call. + /// @param args Vector of BCS-encoded argument values to invoke the target function with. + MultisigAccountCreateTransaction { + multisig_account: AccountAddress, + payload: Vec, + }, + + /// Create a multisig transaction with a transaction hash instead of the full payload. + /// This means the payload will be stored off chain for gas saving. Later, during execution, the executor will need + /// to provide the full payload, which will be validated against the hash stored on-chain. + /// + /// @param function_hash The sha-256 hash of the function to invoke, e.g. 0x123::module_to_call::function_to_call. + /// @param args_hash The sha-256 hash of the function arguments - a concatenated vector of the bcs-encoded + /// function arguments. + MultisigAccountCreateTransactionWithHash { + multisig_account: AccountAddress, + payload_hash: Vec, + }, + + /// Creates a new multisig account on top of an existing account. + /// + /// This offers a migration path for an existing account with a multi-ed25519 auth key (native multisig account). + /// In order to ensure a malicious module cannot obtain backdoor control over an existing account, a signed message + /// with a valid signature from the account's auth key is required. + MultisigAccountCreateWithExistingAccount { + multisig_address: AccountAddress, + owners: Vec, + num_signatures_required: u64, + account_scheme: u8, + account_public_key: Vec, + create_multisig_account_signed_message: Vec, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Creates a new multisig account with the specified additional owner list and signatures required. + /// + /// @param additional_owners The owner account who calls this function cannot be in the additional_owners and there + /// cannot be any duplicate owners in the list. + /// @param num_signatures_required The number of signatures required to execute a transaction. Must be at least 1 and + /// at most the total number of owners. + MultisigAccountCreateWithOwners { + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Remove the next transaction if it has sufficient owner rejections. + MultisigAccountExecuteRejectedTransaction { + multisig_account: AccountAddress, + }, + + /// keeps the origin account as the ADDRESS + /// rotates the key to ZERO + MultisigAccountMigrateWithOwners { + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, + }, + + /// Reject a multisig transaction. + MultisigAccountRejectTransaction { + multisig_account: AccountAddress, + sequence_number: u64, + }, + + /// Similar to remove_owners, but only allow removing one owner. + MultisigAccountRemoveOwner { + owner_to_remove: AccountAddress, + }, + + /// Remove owners from the multisig account. This can only be invoked by the multisig account itself, through the + /// proposal flow. + /// + /// This function skips any owners who are not in the multisig account's list of owners. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the owners list. + MultisigAccountRemoveOwners { + owners_to_remove: Vec, + }, + + /// Allow the multisig account to update its own metadata. Note that this overrides the entire existing metadata. + /// If any attributes are not specified in the metadata, they will be removed! + /// + /// This can only be invoked by the multisig account itself, through the proposal flow. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the number of signatures required. + MultisigAccountUpdateMetadata { + keys: Vec>, + values: Vec>, + }, + + /// Update the number of signatures required to execute transaction in the specified multisig account. + /// + /// This can only be invoked by the multisig account itself, through the proposal flow. + /// Note that this function is not public so it can only be invoked directly instead of via a module or script. This + /// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to + /// maliciously alter the number of signatures required. + MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required: u64, + }, + + /// Generic function that can be used to either approve or reject a multisig transaction + MultisigAccountVoteTransanction { + multisig_account: AccountAddress, + sequence_number: u64, + approved: bool, + }, + + /// Entry function that can be used to transfer, if allow_ungated_transfer is set true. + ObjectTransferCall { + object: AccountAddress, + to: AccountAddress, + }, + + /// Helper for smoke tests to create acounts. + /// Belt and suspenders + OlAccountCreateAccount { + auth_key: AccountAddress, + }, + + /// Set whether `account` can receive direct transfers of coins that they have not explicitly registered to receive. + OlAccountSetAllowDirectCoinTransfers { + allow: bool, + }, + + /// Convenient function to transfer GAS to a recipient account that might not exist. + /// This would create the recipient account first, which also registers it to receive GAS, before transferring. + OlAccountTransfer { + to: AccountAddress, + amount: u64, + }, + + ProofOfFeeInitBidding {}, + + /// retract bid + ProofOfFeePofRetractBid {}, + + /// update the bid for the sender + ProofOfFeePofUpdateBid { + bid: u64, + epoch_expiry: u64, + }, + + /// This function initiates governance for the multisig. It is called by the sponsor address, and is only callable once. + /// init_gov fails gracefully if the governance is already initialized. + /// init_type will throw errors if the type is already initialized. + SafeInitPaymentMultisig { + authorities: Vec, + }, + + SlowWalletSmokeTestVmUnlock { + user_addr: AccountAddress, + unlocked: u64, + transferred: u64, + }, + + /// Users can change their account to slow, by calling the entry function + /// Warning: this is permanent for the account. There's no way to + /// reverse a "slow wallet". + SlowWalletUserSetSlow {}, + + /// Initialize the validator account and give ownership to the signing account. + StakeInitializeValidator { + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, + }, + + /// Rotate the consensus key of the validator, it'll take effect in next epoch. + StakeRotateConsensusKey { + validator_address: AccountAddress, + new_consensus_pubkey: Vec, + proof_of_possession: Vec, + }, + + /// Update the network and full node addresses of the validator. This only takes effect in the next epoch. + StakeUpdateNetworkAndFullnodeAddresses { + validator_address: AccountAddress, + new_network_addresses: Vec, + new_fullnode_addresses: Vec, + }, + + /// This is the entrypoint for a validator joining the network. + /// Separates the logic of registration from validator election etc. (in stake.move). + /// This prevents dependency cycling issues, since stake.move is a large module. + ValidatorUniverseRegisterValidator { + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, + }, + + /// Updates the major version to a larger version. + /// This can be called by on chain governance. + VersionSetVersion { + major: u64, + }, + + /// you may want to add people who are related to you + /// there are no known use cases for this at the moment. + VouchInsistVouchFor { + friend_account: AccountAddress, + }, + + VouchRevoke { + friend_account: AccountAddress, + }, + + /// will only succesfully vouch if the two are not related by ancestry + /// prevents spending a vouch that would not be counted. + /// to add a vouch and ignore this check use insist_vouch + VouchVouchFor { + friend_account: AccountAddress, + }, +} + +impl EntryFunctionCall { + /// Build an Diem `TransactionPayload` from a structured object `EntryFunctionCall`. + pub fn encode(self) -> TransactionPayload { + use EntryFunctionCall::*; + match self { + AccountOfferRotationCapability { + rotation_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + } => account_offer_rotation_capability( + rotation_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + ), + AccountOfferSignerCapability { + signer_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + } => account_offer_signer_capability( + signer_capability_sig_bytes, + account_scheme, + account_public_key_bytes, + recipient_address, + ), + AccountRevokeAnyRotationCapability {} => account_revoke_any_rotation_capability(), + AccountRevokeAnySignerCapability {} => account_revoke_any_signer_capability(), + AccountRevokeRotationCapability { + to_be_revoked_address, + } => account_revoke_rotation_capability(to_be_revoked_address), + AccountRevokeSignerCapability { + to_be_revoked_address, + } => account_revoke_signer_capability(to_be_revoked_address), + AccountRotateAuthenticationKey { + from_scheme, + from_public_key_bytes, + to_scheme, + to_public_key_bytes, + cap_rotate_key, + cap_update_table, + } => account_rotate_authentication_key( + from_scheme, + from_public_key_bytes, + to_scheme, + to_public_key_bytes, + cap_rotate_key, + cap_update_table, + ), + AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address, + new_scheme, + new_public_key_bytes, + cap_update_table, + } => account_rotate_authentication_key_with_rotation_capability( + rotation_cap_offerer_address, + new_scheme, + new_public_key_bytes, + cap_update_table, + ), + BurnSetSendCommunity { community } => burn_set_send_community(community), + CodePublishPackageTxn { + metadata_serialized, + code, + } => code_publish_package_txn(metadata_serialized, code), + CoinTransfer { + coin_type, + to, + amount, + } => coin_transfer(coin_type, to, amount), + CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address, + new_signer, + is_add_operation, + n_of_m, + vote_duration_epochs, + } => community_wallet_init_change_signer_community_multisig( + multisig_address, + new_signer, + is_add_operation, + n_of_m, + vote_duration_epochs, + ), + CommunityWalletInitFinalizeAndCage { num_signers } => { + community_wallet_init_finalize_and_cage(num_signers) + } + CommunityWalletInitInitCommunity { + initial_authorities, + check_threshold, + } => community_wallet_init_init_community(initial_authorities, check_threshold), + CommunityWalletInitProposeOffer { + new_signers, + num_signers, + } => community_wallet_init_propose_offer(new_signers, num_signers), + DiemGovernanceAddApprovedScriptHashScript { proposal_id } => { + diem_governance_add_approved_script_hash_script(proposal_id) + } + DiemGovernanceAssertCanResolve { proposal_id } => { + diem_governance_assert_can_resolve(proposal_id) + } + DiemGovernanceCreateProposalV2 { + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + } => diem_governance_create_proposal_v2( + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + ), + DiemGovernanceOlCreateProposalV2 { + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + } => diem_governance_ol_create_proposal_v2( + execution_hash, + metadata_location, + metadata_hash, + is_multi_step_proposal, + ), + DiemGovernanceOlVote { + proposal_id, + should_pass, + } => diem_governance_ol_vote(proposal_id, should_pass), + DiemGovernanceSmokeTriggerEpoch {} => diem_governance_smoke_trigger_epoch(), + DiemGovernanceTriggerEpoch {} => diem_governance_trigger_epoch(), + DiemGovernanceVote { + proposal_id, + should_pass, + } => diem_governance_vote(proposal_id, should_pass), + DonorVoiceTxsProposeLiquidateTx { multisig_address } => { + donor_voice_txs_propose_liquidate_tx(multisig_address) + } + DonorVoiceTxsProposePaymentTx { + multisig_address, + payee, + value, + description, + } => donor_voice_txs_propose_payment_tx(multisig_address, payee, value, description), + DonorVoiceTxsProposeVetoTx { + multisig_address, + id, + } => donor_voice_txs_propose_veto_tx(multisig_address, id), + DonorVoiceTxsVoteLiquidationTx { multisig_address } => { + donor_voice_txs_vote_liquidation_tx(multisig_address) + } + DonorVoiceTxsVoteVetoTx { + multisig_address, + id, + } => donor_voice_txs_vote_veto_tx(multisig_address, id), + EpochBoundarySmokeTriggerEpoch {} => epoch_boundary_smoke_trigger_epoch(), + JailUnjailByVoucher { addr } => jail_unjail_by_voucher(addr), + LibraCoinClaimMintCapability {} => libra_coin_claim_mint_capability(), + LibraCoinDelegateMintCapability { to } => libra_coin_delegate_mint_capability(to), + LibraCoinMintToImpl { dst_addr, amount } => libra_coin_mint_to_impl(dst_addr, amount), + MultiActionClaimOffer { multisig_address } => { + multi_action_claim_offer(multisig_address) + } + MultiActionInitGovDeprecated {} => multi_action_init_gov_deprecated(), + MultiActionMigrationMigrateOffer { multisig_address } => { + multi_action_migration_migrate_offer(multisig_address) + } + MultisigAccountAddOwner { new_owner } => multisig_account_add_owner(new_owner), + MultisigAccountAddOwners { new_owners } => multisig_account_add_owners(new_owners), + MultisigAccountApproveTransaction { + multisig_account, + sequence_number, + } => multisig_account_approve_transaction(multisig_account, sequence_number), + MultisigAccountCreate { + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_create(num_signatures_required, metadata_keys, metadata_values), + MultisigAccountCreateTransaction { + multisig_account, + payload, + } => multisig_account_create_transaction(multisig_account, payload), + MultisigAccountCreateTransactionWithHash { + multisig_account, + payload_hash, + } => multisig_account_create_transaction_with_hash(multisig_account, payload_hash), + MultisigAccountCreateWithExistingAccount { + multisig_address, + owners, + num_signatures_required, + account_scheme, + account_public_key, + create_multisig_account_signed_message, + metadata_keys, + metadata_values, + } => multisig_account_create_with_existing_account( + multisig_address, + owners, + num_signatures_required, + account_scheme, + account_public_key, + create_multisig_account_signed_message, + metadata_keys, + metadata_values, + ), + MultisigAccountCreateWithOwners { + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_create_with_owners( + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + ), + MultisigAccountExecuteRejectedTransaction { multisig_account } => { + multisig_account_execute_rejected_transaction(multisig_account) + } + MultisigAccountMigrateWithOwners { + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + } => multisig_account_migrate_with_owners( + additional_owners, + num_signatures_required, + metadata_keys, + metadata_values, + ), + MultisigAccountRejectTransaction { + multisig_account, + sequence_number, + } => multisig_account_reject_transaction(multisig_account, sequence_number), + MultisigAccountRemoveOwner { owner_to_remove } => { + multisig_account_remove_owner(owner_to_remove) + } + MultisigAccountRemoveOwners { owners_to_remove } => { + multisig_account_remove_owners(owners_to_remove) + } + MultisigAccountUpdateMetadata { keys, values } => { + multisig_account_update_metadata(keys, values) + } + MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required, + } => multisig_account_update_signatures_required(new_num_signatures_required), + MultisigAccountVoteTransanction { + multisig_account, + sequence_number, + approved, + } => multisig_account_vote_transanction(multisig_account, sequence_number, approved), + ObjectTransferCall { object, to } => object_transfer_call(object, to), + OlAccountCreateAccount { auth_key } => ol_account_create_account(auth_key), + OlAccountSetAllowDirectCoinTransfers { allow } => { + ol_account_set_allow_direct_coin_transfers(allow) + } + OlAccountTransfer { to, amount } => ol_account_transfer(to, amount), + ProofOfFeeInitBidding {} => proof_of_fee_init_bidding(), + ProofOfFeePofRetractBid {} => proof_of_fee_pof_retract_bid(), + ProofOfFeePofUpdateBid { bid, epoch_expiry } => { + proof_of_fee_pof_update_bid(bid, epoch_expiry) + } + SafeInitPaymentMultisig { authorities } => safe_init_payment_multisig(authorities), + SlowWalletSmokeTestVmUnlock { + user_addr, + unlocked, + transferred, + } => slow_wallet_smoke_test_vm_unlock(user_addr, unlocked, transferred), + SlowWalletUserSetSlow {} => slow_wallet_user_set_slow(), + StakeInitializeValidator { + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + } => stake_initialize_validator( + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + ), + StakeRotateConsensusKey { + validator_address, + new_consensus_pubkey, + proof_of_possession, + } => stake_rotate_consensus_key( + validator_address, + new_consensus_pubkey, + proof_of_possession, + ), + StakeUpdateNetworkAndFullnodeAddresses { + validator_address, + new_network_addresses, + new_fullnode_addresses, + } => stake_update_network_and_fullnode_addresses( + validator_address, + new_network_addresses, + new_fullnode_addresses, + ), + ValidatorUniverseRegisterValidator { + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + } => validator_universe_register_validator( + consensus_pubkey, + proof_of_possession, + network_addresses, + fullnode_addresses, + ), + VersionSetVersion { major } => version_set_version(major), + VouchInsistVouchFor { friend_account } => vouch_insist_vouch_for(friend_account), + VouchRevoke { friend_account } => vouch_revoke(friend_account), + VouchVouchFor { friend_account } => vouch_vouch_for(friend_account), + } + } + + /// Try to recognize an Diem `TransactionPayload` and convert it into a structured object `EntryFunctionCall`. + pub fn decode(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + match SCRIPT_FUNCTION_DECODER_MAP.get(&format!( + "{}_{}", + script.module().name(), + script.function() + )) { + Some(decoder) => decoder(payload), + None => None, + } + } else { + None + } + } +} + +/// Offers rotation capability on behalf of `account` to the account at address `recipient_address`. +/// An account can delegate its rotation capability to only one other address at one time. If the account +/// has an existing rotation capability offer, calling this function will update the rotation capability offer with +/// the new `recipient_address`. +/// Here, `rotation_capability_sig_bytes` signature indicates that this key rotation is authorized by the account owner, +/// and prevents the classic "time-of-check time-of-use" attack. +/// For example, users usually rely on what the wallet displays to them as the transaction's outcome. Consider a contract that with 50% probability +/// (based on the current timestamp in Move), rotates somebody's key. The wallet might be unlucky and get an outcome where nothing is rotated, +/// incorrectly telling the user nothing bad will happen. But when the transaction actually gets executed, the attacker gets lucky and +/// the execution path triggers the account key rotation. +/// We prevent such attacks by asking for this extra signature authorizing the key rotation. +/// +/// @param rotation_capability_sig_bytes is the signature by the account owner's key on `RotationCapabilityOfferProofChallengeV2`. +/// @param account_scheme is the scheme of the account (ed25519 or multi_ed25519). +/// @param account_public_key_bytes is the public key of the account owner. +/// @param recipient_address is the address of the recipient of the rotation capability - note that if there's an existing rotation capability +/// offer, calling this function will replace the previous `recipient_address` upon successful verification. +pub fn account_offer_rotation_capability( + rotation_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("offer_rotation_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&rotation_capability_sig_bytes).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key_bytes).unwrap(), + bcs::to_bytes(&recipient_address).unwrap(), + ], + )) +} + +/// Offers signer capability on behalf of `account` to the account at address `recipient_address`. +/// An account can delegate its signer capability to only one other address at one time. +/// `signer_capability_key_bytes` is the `SignerCapabilityOfferProofChallengeV2` signed by the account owner's key +/// `account_scheme` is the scheme of the account (ed25519 or multi_ed25519). +/// `account_public_key_bytes` is the public key of the account owner. +/// `recipient_address` is the address of the recipient of the signer capability - note that if there's an existing +/// `recipient_address` in the account owner's `SignerCapabilityOffer`, this will replace the +/// previous `recipient_address` upon successful verification (the previous recipient will no longer have access +/// to the account owner's signer capability). +pub fn account_offer_signer_capability( + signer_capability_sig_bytes: Vec, + account_scheme: u8, + account_public_key_bytes: Vec, + recipient_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("offer_signer_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&signer_capability_sig_bytes).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key_bytes).unwrap(), + bcs::to_bytes(&recipient_address).unwrap(), + ], + )) +} + +/// Revoke any rotation capability offer in the specified account. +pub fn account_revoke_any_rotation_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_any_rotation_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Revoke any signer capability offer in the specified account. +pub fn account_revoke_any_signer_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_any_signer_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Revoke the rotation capability offer given to `to_be_revoked_recipient_address` from `account` +pub fn account_revoke_rotation_capability( + to_be_revoked_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_rotation_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to_be_revoked_address).unwrap()], + )) +} + +/// Revoke the account owner's signer capability offer for `to_be_revoked_address` (i.e., the address that +/// has a signer capability offer from `account` but will be revoked in this function). +pub fn account_revoke_signer_capability( + to_be_revoked_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("revoke_signer_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to_be_revoked_address).unwrap()], + )) +} + +/// Generic authentication key rotation function that allows the user to rotate their authentication key from any scheme to any scheme. +/// To authorize the rotation, we need two signatures: +/// - the first signature `cap_rotate_key` refers to the signature by the account owner's current key on a valid `RotationProofChallenge`, +/// demonstrating that the user intends to and has the capability to rotate the authentication key of this account; +/// - the second signature `cap_update_table` refers to the signature by the new key (that the account owner wants to rotate to) on a +/// valid `RotationProofChallenge`, demonstrating that the user owns the new private key, and has the authority to update the +/// `OriginatingAddress` map with the new address mapping ``. +/// To verify these two signatures, we need their corresponding public key and public key scheme: we use `from_scheme` and `from_public_key_bytes` +/// to verify `cap_rotate_key`, and `to_scheme` and `to_public_key_bytes` to verify `cap_update_table`. +/// A scheme of 0 refers to an Ed25519 key and a scheme of 1 refers to Multi-Ed25519 keys. +/// `originating address` refers to an account's original/first address. +/// +/// Here is an example attack if we don't ask for the second signature `cap_update_table`: +/// Alice has rotated her account `addr_a` to `new_addr_a`. As a result, the following entry is created, to help Alice when recovering her wallet: +/// `OriginatingAddress[new_addr_a]` -> `addr_a` +/// Alice has had bad day: her laptop blew up and she needs to reset her account on a new one. +/// (Fortunately, she still has her secret key `new_sk_a` associated with her new address `new_addr_a`, so she can do this.) +/// +/// But Bob likes to mess with Alice. +/// Bob creates an account `addr_b` and maliciously rotates it to Alice's new address `new_addr_a`. Since we are no longer checking a PoK, +/// Bob can easily do this. +/// +/// Now, the table will be updated to make Alice's new address point to Bob's address: `OriginatingAddress[new_addr_a]` -> `addr_b`. +/// When Alice recovers her account, her wallet will display the attacker's address (Bob's) `addr_b` as her address. +/// Now Alice will give `addr_b` to everyone to pay her, but the money will go to Bob. +/// +/// Because we ask for a valid `cap_update_table`, this kind of attack is not possible. Bob would not have the secret key of Alice's address +/// to rotate his address to Alice's address in the first place. +pub fn account_rotate_authentication_key( + from_scheme: u8, + from_public_key_bytes: Vec, + to_scheme: u8, + to_public_key_bytes: Vec, + cap_rotate_key: Vec, + cap_update_table: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("rotate_authentication_key").to_owned(), + vec![], + vec![ + bcs::to_bytes(&from_scheme).unwrap(), + bcs::to_bytes(&from_public_key_bytes).unwrap(), + bcs::to_bytes(&to_scheme).unwrap(), + bcs::to_bytes(&to_public_key_bytes).unwrap(), + bcs::to_bytes(&cap_rotate_key).unwrap(), + bcs::to_bytes(&cap_update_table).unwrap(), + ], + )) +} + +pub fn account_rotate_authentication_key_with_rotation_capability( + rotation_cap_offerer_address: AccountAddress, + new_scheme: u8, + new_public_key_bytes: Vec, + cap_update_table: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("account").to_owned(), + ), + ident_str!("rotate_authentication_key_with_rotation_capability").to_owned(), + vec![], + vec![ + bcs::to_bytes(&rotation_cap_offerer_address).unwrap(), + bcs::to_bytes(&new_scheme).unwrap(), + bcs::to_bytes(&new_public_key_bytes).unwrap(), + bcs::to_bytes(&cap_update_table).unwrap(), + ], + )) +} + +/// User opts into burns being sent to community (recycle burn). +/// default is false (burn is final). +pub fn burn_set_send_community(community: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("burn").to_owned(), + ), + ident_str!("set_send_community").to_owned(), + vec![], + vec![bcs::to_bytes(&community).unwrap()], + )) +} + +/// Same as `publish_package` but as an entry function which can be called as a transaction. Because +/// of current restrictions for txn parameters, the metadata needs to be passed in serialized form. +pub fn code_publish_package_txn( + metadata_serialized: Vec, + code: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("code").to_owned(), + ), + ident_str!("publish_package_txn").to_owned(), + vec![], + vec![ + bcs::to_bytes(&metadata_serialized).unwrap(), + bcs::to_bytes(&code).unwrap(), + ], + )) +} + +/// Transfers `amount` of coins `CoinType` from `from` to `to`. +pub fn coin_transfer(coin_type: TypeTag, to: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("coin").to_owned(), + ), + ident_str!("transfer").to_owned(), + vec![coin_type], + vec![bcs::to_bytes(&to).unwrap(), bcs::to_bytes(&amount).unwrap()], + )) +} + +/// TODO: Allow to propose change only on the signature threshold +/// Add or remove a signer to/from the multisig, and check if they may be related in the ancestry tree +pub fn community_wallet_init_change_signer_community_multisig( + multisig_address: AccountAddress, + new_signer: AccountAddress, + is_add_operation: bool, + n_of_m: u64, + vote_duration_epochs: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("change_signer_community_multisig").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&new_signer).unwrap(), + bcs::to_bytes(&is_add_operation).unwrap(), + bcs::to_bytes(&n_of_m).unwrap(), + bcs::to_bytes(&vote_duration_epochs).unwrap(), + ], + )) +} + +/// convenience function to check if the account can be caged +/// after all the structs are in place +pub fn community_wallet_init_finalize_and_cage(num_signers: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("finalize_and_cage").to_owned(), + vec![], + vec![bcs::to_bytes(&num_signers).unwrap()], + )) +} + +pub fn community_wallet_init_init_community( + initial_authorities: Vec, + check_threshold: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("init_community").to_owned(), + vec![], + vec![ + bcs::to_bytes(&initial_authorities).unwrap(), + bcs::to_bytes(&check_threshold).unwrap(), + ], + )) +} + +/// Propose offer to the multisig, and check if the signers are not related family +pub fn community_wallet_init_propose_offer( + new_signers: Vec, + num_signers: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("community_wallet_init").to_owned(), + ), + ident_str!("propose_offer").to_owned(), + vec![], + vec![ + bcs::to_bytes(&new_signers).unwrap(), + bcs::to_bytes(&num_signers).unwrap(), + ], + )) +} + +pub fn diem_governance_add_approved_script_hash_script(proposal_id: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("add_approved_script_hash_script").to_owned(), + vec![], + vec![bcs::to_bytes(&proposal_id).unwrap()], + )) +} + +pub fn diem_governance_assert_can_resolve(proposal_id: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("assert_can_resolve").to_owned(), + vec![], + vec![bcs::to_bytes(&proposal_id).unwrap()], + )) +} + +/// Create a single-step or multi-step proposal +/// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, +/// only the exact script with matching hash can be successfully executed. +pub fn diem_governance_create_proposal_v2( + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("create_proposal_v2").to_owned(), + vec![], + vec![ + bcs::to_bytes(&execution_hash).unwrap(), + bcs::to_bytes(&metadata_location).unwrap(), + bcs::to_bytes(&metadata_hash).unwrap(), + bcs::to_bytes(&is_multi_step_proposal).unwrap(), + ], + )) +} + +/// Create a single-step or multi-step proposal +/// @param execution_hash Required. This is the hash of the resolution script. When the proposal is resolved, +/// only the exact script with matching hash can be successfully executed. +pub fn diem_governance_ol_create_proposal_v2( + execution_hash: Vec, + metadata_location: Vec, + metadata_hash: Vec, + is_multi_step_proposal: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("ol_create_proposal_v2").to_owned(), + vec![], + vec![ + bcs::to_bytes(&execution_hash).unwrap(), + bcs::to_bytes(&metadata_location).unwrap(), + bcs::to_bytes(&metadata_hash).unwrap(), + bcs::to_bytes(&is_multi_step_proposal).unwrap(), + ], + )) +} + +/// Vote on proposal with `proposal_id`. +pub fn diem_governance_ol_vote(proposal_id: u64, should_pass: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("ol_vote").to_owned(), + vec![], + vec![ + bcs::to_bytes(&proposal_id).unwrap(), + bcs::to_bytes(&should_pass).unwrap(), + ], + )) +} + +pub fn diem_governance_smoke_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("smoke_trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Any end user can triger epoch/boundary and reconfiguration +/// as long as the VM set the BoundaryBit to true. +/// We do this because we don't want the VM calling complex +/// logic itself. Any abort would cause a halt. +/// On the other hand, a user can call the function once the VM +/// decides the epoch can change. Any error will just cause the +/// user's transaction to abort, but the chain will continue. +/// Whatever fix is needed can be done online with on-chain governance. +pub fn diem_governance_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Vote on proposal with `proposal_id` +pub fn diem_governance_vote(proposal_id: u64, should_pass: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("diem_governance").to_owned(), + ), + ident_str!("vote").to_owned(), + vec![], + vec![ + bcs::to_bytes(&proposal_id).unwrap(), + bcs::to_bytes(&should_pass).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_propose_liquidate_tx( + multisig_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_liquidate_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +pub fn donor_voice_txs_propose_payment_tx( + multisig_address: AccountAddress, + payee: AccountAddress, + value: u64, + description: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_payment_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&payee).unwrap(), + bcs::to_bytes(&value).unwrap(), + bcs::to_bytes(&description).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_propose_veto_tx( + multisig_address: AccountAddress, + id: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("propose_veto_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&id).unwrap(), + ], + )) +} + +pub fn donor_voice_txs_vote_liquidation_tx(multisig_address: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("vote_liquidation_tx").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +/// Entry functiont to vote the veto. +pub fn donor_voice_txs_vote_veto_tx( + multisig_address: AccountAddress, + id: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("donor_voice_txs").to_owned(), + ), + ident_str!("vote_veto_tx").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&id).unwrap(), + ], + )) +} + +pub fn epoch_boundary_smoke_trigger_epoch() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("epoch_boundary").to_owned(), + ), + ident_str!("smoke_trigger_epoch").to_owned(), + vec![], + vec![], + )) +} + +/// Only a Voucher of the validator can flip the unjail bit. +/// This is a way to make sure the validator is ready to rejoin. +pub fn jail_unjail_by_voucher(addr: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("jail").to_owned(), + ), + ident_str!("unjail_by_voucher").to_owned(), + vec![], + vec![bcs::to_bytes(&addr).unwrap()], + )) +} + +/// Only callable in tests and testnets where the core resources account exists. +/// Claim the delegated mint capability and destroy the delegated token. +pub fn libra_coin_claim_mint_capability() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("claim_mint_capability").to_owned(), + vec![], + vec![], + )) +} + +/// Only callable in tests and testnets where the core resources account exists. +/// Create delegated token for the address so the account could claim MintCapability later. +pub fn libra_coin_delegate_mint_capability(to: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("delegate_mint_capability").to_owned(), + vec![], + vec![bcs::to_bytes(&to).unwrap()], + )) +} + +/// Root account can mint to an address. Only used for genesis and tests. +/// The "root" account in smoke tests has some privileges. +pub fn libra_coin_mint_to_impl(dst_addr: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("libra_coin").to_owned(), + ), + ident_str!("mint_to_impl").to_owned(), + vec![], + vec![ + bcs::to_bytes(&dst_addr).unwrap(), + bcs::to_bytes(&amount).unwrap(), + ], + )) +} + +pub fn multi_action_claim_offer(multisig_address: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multi_action").to_owned(), + ), + ident_str!("claim_offer").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +pub fn multi_action_init_gov_deprecated() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multi_action").to_owned(), + ), + ident_str!("init_gov_deprecated").to_owned(), + vec![], + vec![], + )) +} + +pub fn multi_action_migration_migrate_offer( + multisig_address: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multi_action_migration").to_owned(), + ), + ident_str!("migrate_offer").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_address).unwrap()], + )) +} + +/// Similar to add_owners, but only allow adding one owner. +pub fn multisig_account_add_owner(new_owner: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("add_owner").to_owned(), + vec![], + vec![bcs::to_bytes(&new_owner).unwrap()], + )) +} + +/// Add new owners to the multisig account. This can only be invoked by the multisig account itself, through the +/// proposal flow. +/// +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the owners list. +pub fn multisig_account_add_owners(new_owners: Vec) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("add_owners").to_owned(), + vec![], + vec![bcs::to_bytes(&new_owners).unwrap()], + )) +} + +/// Approve a multisig transaction. +pub fn multisig_account_approve_transaction( + multisig_account: AccountAddress, + sequence_number: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("approve_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + ], + )) +} + +/// Creates a new multisig account and add the signer as a single owner. +pub fn multisig_account_create( + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create").to_owned(), + vec![], + vec![ + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Create a multisig transaction, which will have one approval initially (from the creator). +/// +/// @param target_function The target function to call such as 0x123::module_to_call::function_to_call. +/// @param args Vector of BCS-encoded argument values to invoke the target function with. +pub fn multisig_account_create_transaction( + multisig_account: AccountAddress, + payload: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&payload).unwrap(), + ], + )) +} + +/// Create a multisig transaction with a transaction hash instead of the full payload. +/// This means the payload will be stored off chain for gas saving. Later, during execution, the executor will need +/// to provide the full payload, which will be validated against the hash stored on-chain. +/// +/// @param function_hash The sha-256 hash of the function to invoke, e.g. 0x123::module_to_call::function_to_call. +/// @param args_hash The sha-256 hash of the function arguments - a concatenated vector of the bcs-encoded +/// function arguments. +pub fn multisig_account_create_transaction_with_hash( + multisig_account: AccountAddress, + payload_hash: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_transaction_with_hash").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&payload_hash).unwrap(), + ], + )) +} + +/// Creates a new multisig account on top of an existing account. +/// +/// This offers a migration path for an existing account with a multi-ed25519 auth key (native multisig account). +/// In order to ensure a malicious module cannot obtain backdoor control over an existing account, a signed message +/// with a valid signature from the account's auth key is required. +pub fn multisig_account_create_with_existing_account( + multisig_address: AccountAddress, + owners: Vec, + num_signatures_required: u64, + account_scheme: u8, + account_public_key: Vec, + create_multisig_account_signed_message: Vec, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_with_existing_account").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_address).unwrap(), + bcs::to_bytes(&owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&account_scheme).unwrap(), + bcs::to_bytes(&account_public_key).unwrap(), + bcs::to_bytes(&create_multisig_account_signed_message).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Creates a new multisig account with the specified additional owner list and signatures required. +/// +/// @param additional_owners The owner account who calls this function cannot be in the additional_owners and there +/// cannot be any duplicate owners in the list. +/// @param num_signatures_required The number of signatures required to execute a transaction. Must be at least 1 and +/// at most the total number of owners. +pub fn multisig_account_create_with_owners( + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("create_with_owners").to_owned(), + vec![], + vec![ + bcs::to_bytes(&additional_owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Remove the next transaction if it has sufficient owner rejections. +pub fn multisig_account_execute_rejected_transaction( + multisig_account: AccountAddress, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("execute_rejected_transaction").to_owned(), + vec![], + vec![bcs::to_bytes(&multisig_account).unwrap()], + )) +} + +/// keeps the origin account as the ADDRESS +/// rotates the key to ZERO +pub fn multisig_account_migrate_with_owners( + additional_owners: Vec, + num_signatures_required: u64, + metadata_keys: Vec>, + metadata_values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("migrate_with_owners").to_owned(), + vec![], + vec![ + bcs::to_bytes(&additional_owners).unwrap(), + bcs::to_bytes(&num_signatures_required).unwrap(), + bcs::to_bytes(&metadata_keys).unwrap(), + bcs::to_bytes(&metadata_values).unwrap(), + ], + )) +} + +/// Reject a multisig transaction. +pub fn multisig_account_reject_transaction( + multisig_account: AccountAddress, + sequence_number: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("reject_transaction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + ], + )) +} + +/// Similar to remove_owners, but only allow removing one owner. +pub fn multisig_account_remove_owner(owner_to_remove: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("remove_owner").to_owned(), + vec![], + vec![bcs::to_bytes(&owner_to_remove).unwrap()], + )) +} + +/// Remove owners from the multisig account. This can only be invoked by the multisig account itself, through the +/// proposal flow. +/// +/// This function skips any owners who are not in the multisig account's list of owners. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the owners list. +pub fn multisig_account_remove_owners(owners_to_remove: Vec) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("remove_owners").to_owned(), + vec![], + vec![bcs::to_bytes(&owners_to_remove).unwrap()], + )) +} + +/// Allow the multisig account to update its own metadata. Note that this overrides the entire existing metadata. +/// If any attributes are not specified in the metadata, they will be removed! +/// +/// This can only be invoked by the multisig account itself, through the proposal flow. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the number of signatures required. +pub fn multisig_account_update_metadata( + keys: Vec>, + values: Vec>, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("update_metadata").to_owned(), + vec![], + vec![ + bcs::to_bytes(&keys).unwrap(), + bcs::to_bytes(&values).unwrap(), + ], + )) +} + +/// Update the number of signatures required to execute transaction in the specified multisig account. +/// +/// This can only be invoked by the multisig account itself, through the proposal flow. +/// Note that this function is not public so it can only be invoked directly instead of via a module or script. This +/// ensures that a multisig transaction cannot lead to another module obtaining the multisig signer and using it to +/// maliciously alter the number of signatures required. +pub fn multisig_account_update_signatures_required( + new_num_signatures_required: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("update_signatures_required").to_owned(), + vec![], + vec![bcs::to_bytes(&new_num_signatures_required).unwrap()], + )) +} + +/// Generic function that can be used to either approve or reject a multisig transaction +pub fn multisig_account_vote_transanction( + multisig_account: AccountAddress, + sequence_number: u64, + approved: bool, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("multisig_account").to_owned(), + ), + ident_str!("vote_transanction").to_owned(), + vec![], + vec![ + bcs::to_bytes(&multisig_account).unwrap(), + bcs::to_bytes(&sequence_number).unwrap(), + bcs::to_bytes(&approved).unwrap(), + ], + )) +} + +/// Entry function that can be used to transfer, if allow_ungated_transfer is set true. +pub fn object_transfer_call(object: AccountAddress, to: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("object").to_owned(), + ), + ident_str!("transfer_call").to_owned(), + vec![], + vec![bcs::to_bytes(&object).unwrap(), bcs::to_bytes(&to).unwrap()], + )) +} + +/// Helper for smoke tests to create acounts. +/// Belt and suspenders +pub fn ol_account_create_account(auth_key: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("create_account").to_owned(), + vec![], + vec![bcs::to_bytes(&auth_key).unwrap()], + )) +} + +/// Set whether `account` can receive direct transfers of coins that they have not explicitly registered to receive. +pub fn ol_account_set_allow_direct_coin_transfers(allow: bool) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("set_allow_direct_coin_transfers").to_owned(), + vec![], + vec![bcs::to_bytes(&allow).unwrap()], + )) +} + +/// Convenient function to transfer GAS to a recipient account that might not exist. +/// This would create the recipient account first, which also registers it to receive GAS, before transferring. +pub fn ol_account_transfer(to: AccountAddress, amount: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("ol_account").to_owned(), + ), + ident_str!("transfer").to_owned(), + vec![], + vec![bcs::to_bytes(&to).unwrap(), bcs::to_bytes(&amount).unwrap()], + )) +} + +pub fn proof_of_fee_init_bidding() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("init_bidding").to_owned(), + vec![], + vec![], + )) +} + +/// retract bid +pub fn proof_of_fee_pof_retract_bid() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("pof_retract_bid").to_owned(), + vec![], + vec![], + )) +} + +/// update the bid for the sender +pub fn proof_of_fee_pof_update_bid(bid: u64, epoch_expiry: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("proof_of_fee").to_owned(), + ), + ident_str!("pof_update_bid").to_owned(), + vec![], + vec![ + bcs::to_bytes(&bid).unwrap(), + bcs::to_bytes(&epoch_expiry).unwrap(), + ], + )) +} + +/// This function initiates governance for the multisig. It is called by the sponsor address, and is only callable once. +/// init_gov fails gracefully if the governance is already initialized. +/// init_type will throw errors if the type is already initialized. +pub fn safe_init_payment_multisig(authorities: Vec) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("safe").to_owned(), + ), + ident_str!("init_payment_multisig").to_owned(), + vec![], + vec![bcs::to_bytes(&authorities).unwrap()], + )) +} + +pub fn slow_wallet_smoke_test_vm_unlock( + user_addr: AccountAddress, + unlocked: u64, + transferred: u64, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("slow_wallet").to_owned(), + ), + ident_str!("smoke_test_vm_unlock").to_owned(), + vec![], + vec![ + bcs::to_bytes(&user_addr).unwrap(), + bcs::to_bytes(&unlocked).unwrap(), + bcs::to_bytes(&transferred).unwrap(), + ], + )) +} + +/// Users can change their account to slow, by calling the entry function +/// Warning: this is permanent for the account. There's no way to +/// reverse a "slow wallet". +pub fn slow_wallet_user_set_slow() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("slow_wallet").to_owned(), + ), + ident_str!("user_set_slow").to_owned(), + vec![], + vec![], + )) +} + +/// Initialize the validator account and give ownership to the signing account. +pub fn stake_initialize_validator( + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("initialize_validator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + bcs::to_bytes(&network_addresses).unwrap(), + bcs::to_bytes(&fullnode_addresses).unwrap(), + ], + )) +} + +/// Rotate the consensus key of the validator, it'll take effect in next epoch. +pub fn stake_rotate_consensus_key( + validator_address: AccountAddress, + new_consensus_pubkey: Vec, + proof_of_possession: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("rotate_consensus_key").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_address).unwrap(), + bcs::to_bytes(&new_consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + ], + )) +} + +/// Update the network and full node addresses of the validator. This only takes effect in the next epoch. +pub fn stake_update_network_and_fullnode_addresses( + validator_address: AccountAddress, + new_network_addresses: Vec, + new_fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("stake").to_owned(), + ), + ident_str!("update_network_and_fullnode_addresses").to_owned(), + vec![], + vec![ + bcs::to_bytes(&validator_address).unwrap(), + bcs::to_bytes(&new_network_addresses).unwrap(), + bcs::to_bytes(&new_fullnode_addresses).unwrap(), + ], + )) +} + +/// This is the entrypoint for a validator joining the network. +/// Separates the logic of registration from validator election etc. (in stake.move). +/// This prevents dependency cycling issues, since stake.move is a large module. +pub fn validator_universe_register_validator( + consensus_pubkey: Vec, + proof_of_possession: Vec, + network_addresses: Vec, + fullnode_addresses: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("validator_universe").to_owned(), + ), + ident_str!("register_validator").to_owned(), + vec![], + vec![ + bcs::to_bytes(&consensus_pubkey).unwrap(), + bcs::to_bytes(&proof_of_possession).unwrap(), + bcs::to_bytes(&network_addresses).unwrap(), + bcs::to_bytes(&fullnode_addresses).unwrap(), + ], + )) +} + +/// Updates the major version to a larger version. +/// This can be called by on chain governance. +pub fn version_set_version(major: u64) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("version").to_owned(), + ), + ident_str!("set_version").to_owned(), + vec![], + vec![bcs::to_bytes(&major).unwrap()], + )) +} + +/// you may want to add people who are related to you +/// there are no known use cases for this at the moment. +pub fn vouch_insist_vouch_for(friend_account: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("insist_vouch_for").to_owned(), + vec![], + vec![bcs::to_bytes(&friend_account).unwrap()], + )) +} + +pub fn vouch_revoke(friend_account: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("revoke").to_owned(), + vec![], + vec![bcs::to_bytes(&friend_account).unwrap()], + )) +} + +/// will only succesfully vouch if the two are not related by ancestry +/// prevents spending a vouch that would not be counted. +/// to add a vouch and ignore this check use insist_vouch +pub fn vouch_vouch_for(friend_account: AccountAddress) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("vouch").to_owned(), + ), + ident_str!("vouch_for").to_owned(), + vec![], + vec![bcs::to_bytes(&friend_account).unwrap()], + )) +} +mod decoder { + use super::*; + pub fn account_offer_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountOfferRotationCapability { + rotation_capability_sig_bytes: bcs::from_bytes(script.args().first()?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + account_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + recipient_address: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn account_offer_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountOfferSignerCapability { + signer_capability_sig_bytes: bcs::from_bytes(script.args().first()?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + account_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + recipient_address: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn account_revoke_any_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::AccountRevokeAnyRotationCapability {}) + } else { + None + } + } + + pub fn account_revoke_any_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::AccountRevokeAnySignerCapability {}) + } else { + None + } + } + + pub fn account_revoke_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRevokeRotationCapability { + to_be_revoked_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn account_revoke_signer_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRevokeSignerCapability { + to_be_revoked_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn account_rotate_authentication_key( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::AccountRotateAuthenticationKey { + from_scheme: bcs::from_bytes(script.args().first()?).ok()?, + from_public_key_bytes: bcs::from_bytes(script.args().get(1)?).ok()?, + to_scheme: bcs::from_bytes(script.args().get(2)?).ok()?, + to_public_key_bytes: bcs::from_bytes(script.args().get(3)?).ok()?, + cap_rotate_key: bcs::from_bytes(script.args().get(4)?).ok()?, + cap_update_table: bcs::from_bytes(script.args().get(5)?).ok()?, + }) + } else { + None + } + } + + pub fn account_rotate_authentication_key_with_rotation_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::AccountRotateAuthenticationKeyWithRotationCapability { + rotation_cap_offerer_address: bcs::from_bytes(script.args().first()?).ok()?, + new_scheme: bcs::from_bytes(script.args().get(1)?).ok()?, + new_public_key_bytes: bcs::from_bytes(script.args().get(2)?).ok()?, + cap_update_table: bcs::from_bytes(script.args().get(3)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn burn_set_send_community(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::BurnSetSendCommunity { + community: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn code_publish_package_txn(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CodePublishPackageTxn { + metadata_serialized: bcs::from_bytes(script.args().first()?).ok()?, + code: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn coin_transfer(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CoinTransfer { + coin_type: script.ty_args().first()?.clone(), + to: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn community_wallet_init_change_signer_community_multisig( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::CommunityWalletInitChangeSignerCommunityMultisig { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + new_signer: bcs::from_bytes(script.args().get(1)?).ok()?, + is_add_operation: bcs::from_bytes(script.args().get(2)?).ok()?, + n_of_m: bcs::from_bytes(script.args().get(3)?).ok()?, + vote_duration_epochs: bcs::from_bytes(script.args().get(4)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn community_wallet_init_finalize_and_cage( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CommunityWalletInitFinalizeAndCage { + num_signers: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn community_wallet_init_init_community( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CommunityWalletInitInitCommunity { + initial_authorities: bcs::from_bytes(script.args().first()?).ok()?, + check_threshold: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn community_wallet_init_propose_offer( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CommunityWalletInitProposeOffer { + new_signers: bcs::from_bytes(script.args().first()?).ok()?, + num_signers: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_add_approved_script_hash_script( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::DiemGovernanceAddApprovedScriptHashScript { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + }, + ) + } else { + None + } + } + + pub fn diem_governance_assert_can_resolve( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceAssertCanResolve { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_create_proposal_v2( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceCreateProposalV2 { + execution_hash: bcs::from_bytes(script.args().first()?).ok()?, + metadata_location: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_hash: bcs::from_bytes(script.args().get(2)?).ok()?, + is_multi_step_proposal: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_ol_create_proposal_v2( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceOlCreateProposalV2 { + execution_hash: bcs::from_bytes(script.args().first()?).ok()?, + metadata_location: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_hash: bcs::from_bytes(script.args().get(2)?).ok()?, + is_multi_step_proposal: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_ol_vote(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceOlVote { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + should_pass: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn diem_governance_smoke_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::DiemGovernanceSmokeTriggerEpoch {}) + } else { + None + } + } + + pub fn diem_governance_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::DiemGovernanceTriggerEpoch {}) + } else { + None + } + } + + pub fn diem_governance_vote(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DiemGovernanceVote { + proposal_id: bcs::from_bytes(script.args().first()?).ok()?, + should_pass: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_liquidate_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposeLiquidateTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_payment_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposePaymentTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + payee: bcs::from_bytes(script.args().get(1)?).ok()?, + value: bcs::from_bytes(script.args().get(2)?).ok()?, + description: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_propose_veto_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsProposeVetoTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + id: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_vote_liquidation_tx( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsVoteLiquidationTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn donor_voice_txs_vote_veto_tx(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::DonorVoiceTxsVoteVetoTx { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + id: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn epoch_boundary_smoke_trigger_epoch( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::EpochBoundarySmokeTriggerEpoch {}) + } else { + None + } + } + + pub fn jail_unjail_by_voucher(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::JailUnjailByVoucher { + addr: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn libra_coin_claim_mint_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::LibraCoinClaimMintCapability {}) + } else { + None + } + } + + pub fn libra_coin_delegate_mint_capability( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::LibraCoinDelegateMintCapability { + to: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn libra_coin_mint_to_impl(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::LibraCoinMintToImpl { + dst_addr: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multi_action_claim_offer(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultiActionClaimOffer { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multi_action_init_gov_deprecated( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::MultiActionInitGovDeprecated {}) + } else { + None + } + } + + pub fn multi_action_migration_migrate_offer( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultiActionMigrationMigrateOffer { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_add_owner(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountAddOwner { + new_owner: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_add_owners(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountAddOwners { + new_owners: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_approve_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountApproveTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreate { + num_signatures_required: bcs::from_bytes(script.args().first()?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreateTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + payload: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_create_transaction_with_hash( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountCreateTransactionWithHash { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + payload_hash: bcs::from_bytes(script.args().get(1)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_create_with_existing_account( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountCreateWithExistingAccount { + multisig_address: bcs::from_bytes(script.args().first()?).ok()?, + owners: bcs::from_bytes(script.args().get(1)?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(2)?).ok()?, + account_scheme: bcs::from_bytes(script.args().get(3)?).ok()?, + account_public_key: bcs::from_bytes(script.args().get(4)?).ok()?, + create_multisig_account_signed_message: bcs::from_bytes(script.args().get(5)?) + .ok()?, + metadata_keys: bcs::from_bytes(script.args().get(6)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(7)?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_create_with_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountCreateWithOwners { + additional_owners: bcs::from_bytes(script.args().first()?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_execute_rejected_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some( + EntryFunctionCall::MultisigAccountExecuteRejectedTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + }, + ) + } else { + None + } + } + + pub fn multisig_account_migrate_with_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountMigrateWithOwners { + additional_owners: bcs::from_bytes(script.args().first()?).ok()?, + num_signatures_required: bcs::from_bytes(script.args().get(1)?).ok()?, + metadata_keys: bcs::from_bytes(script.args().get(2)?).ok()?, + metadata_values: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_reject_transaction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRejectTransaction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_remove_owner( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRemoveOwner { + owner_to_remove: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_remove_owners( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountRemoveOwners { + owners_to_remove: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_update_metadata( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountUpdateMetadata { + keys: bcs::from_bytes(script.args().first()?).ok()?, + values: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_update_signatures_required( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountUpdateSignaturesRequired { + new_num_signatures_required: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn multisig_account_vote_transanction( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::MultisigAccountVoteTransanction { + multisig_account: bcs::from_bytes(script.args().first()?).ok()?, + sequence_number: bcs::from_bytes(script.args().get(1)?).ok()?, + approved: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn object_transfer_call(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ObjectTransferCall { + object: bcs::from_bytes(script.args().first()?).ok()?, + to: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_create_account(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountCreateAccount { + auth_key: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_set_allow_direct_coin_transfers( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountSetAllowDirectCoinTransfers { + allow: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn ol_account_transfer(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::OlAccountTransfer { + to: bcs::from_bytes(script.args().first()?).ok()?, + amount: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn proof_of_fee_init_bidding(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::ProofOfFeeInitBidding {}) + } else { + None + } + } + + pub fn proof_of_fee_pof_retract_bid(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::ProofOfFeePofRetractBid {}) + } else { + None + } + } + + pub fn proof_of_fee_pof_update_bid(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ProofOfFeePofUpdateBid { + bid: bcs::from_bytes(script.args().first()?).ok()?, + epoch_expiry: bcs::from_bytes(script.args().get(1)?).ok()?, + }) + } else { + None + } + } + + pub fn safe_init_payment_multisig(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::SafeInitPaymentMultisig { + authorities: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn slow_wallet_smoke_test_vm_unlock( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::SlowWalletSmokeTestVmUnlock { + user_addr: bcs::from_bytes(script.args().first()?).ok()?, + unlocked: bcs::from_bytes(script.args().get(1)?).ok()?, + transferred: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn slow_wallet_user_set_slow(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::SlowWalletUserSetSlow {}) + } else { + None + } + } + + pub fn stake_initialize_validator(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeInitializeValidator { + consensus_pubkey: bcs::from_bytes(script.args().first()?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(1)?).ok()?, + network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn stake_rotate_consensus_key(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeRotateConsensusKey { + validator_address: bcs::from_bytes(script.args().first()?).ok()?, + new_consensus_pubkey: bcs::from_bytes(script.args().get(1)?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn stake_update_network_and_fullnode_addresses( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::StakeUpdateNetworkAndFullnodeAddresses { + validator_address: bcs::from_bytes(script.args().first()?).ok()?, + new_network_addresses: bcs::from_bytes(script.args().get(1)?).ok()?, + new_fullnode_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + }) + } else { + None + } + } + + pub fn validator_universe_register_validator( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::ValidatorUniverseRegisterValidator { + consensus_pubkey: bcs::from_bytes(script.args().first()?).ok()?, + proof_of_possession: bcs::from_bytes(script.args().get(1)?).ok()?, + network_addresses: bcs::from_bytes(script.args().get(2)?).ok()?, + fullnode_addresses: bcs::from_bytes(script.args().get(3)?).ok()?, + }) + } else { + None + } + } + + pub fn version_set_version(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VersionSetVersion { + major: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_insist_vouch_for(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchInsistVouchFor { + friend_account: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_revoke(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchRevoke { + friend_account: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } + + pub fn vouch_vouch_for(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::VouchVouchFor { + friend_account: bcs::from_bytes(script.args().first()?).ok()?, + }) + } else { + None + } + } +} + +type EntryFunctionDecoderMap = std::collections::HashMap< + String, + Box< + dyn Fn(&TransactionPayload) -> Option + + std::marker::Sync + + std::marker::Send, + >, +>; + +static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = + once_cell::sync::Lazy::new(|| { + let mut map: EntryFunctionDecoderMap = std::collections::HashMap::new(); + map.insert( + "account_offer_rotation_capability".to_string(), + Box::new(decoder::account_offer_rotation_capability), + ); + map.insert( + "account_offer_signer_capability".to_string(), + Box::new(decoder::account_offer_signer_capability), + ); + map.insert( + "account_revoke_any_rotation_capability".to_string(), + Box::new(decoder::account_revoke_any_rotation_capability), + ); + map.insert( + "account_revoke_any_signer_capability".to_string(), + Box::new(decoder::account_revoke_any_signer_capability), + ); + map.insert( + "account_revoke_rotation_capability".to_string(), + Box::new(decoder::account_revoke_rotation_capability), + ); + map.insert( + "account_revoke_signer_capability".to_string(), + Box::new(decoder::account_revoke_signer_capability), + ); + map.insert( + "account_rotate_authentication_key".to_string(), + Box::new(decoder::account_rotate_authentication_key), + ); + map.insert( + "account_rotate_authentication_key_with_rotation_capability".to_string(), + Box::new(decoder::account_rotate_authentication_key_with_rotation_capability), + ); + map.insert( + "burn_set_send_community".to_string(), + Box::new(decoder::burn_set_send_community), + ); + map.insert( + "code_publish_package_txn".to_string(), + Box::new(decoder::code_publish_package_txn), + ); + map.insert( + "coin_transfer".to_string(), + Box::new(decoder::coin_transfer), + ); + map.insert( + "community_wallet_init_change_signer_community_multisig".to_string(), + Box::new(decoder::community_wallet_init_change_signer_community_multisig), + ); + map.insert( + "community_wallet_init_finalize_and_cage".to_string(), + Box::new(decoder::community_wallet_init_finalize_and_cage), + ); + map.insert( + "community_wallet_init_init_community".to_string(), + Box::new(decoder::community_wallet_init_init_community), + ); + map.insert( + "community_wallet_init_propose_offer".to_string(), + Box::new(decoder::community_wallet_init_propose_offer), + ); + map.insert( + "diem_governance_add_approved_script_hash_script".to_string(), + Box::new(decoder::diem_governance_add_approved_script_hash_script), + ); + map.insert( + "diem_governance_assert_can_resolve".to_string(), + Box::new(decoder::diem_governance_assert_can_resolve), + ); + map.insert( + "diem_governance_create_proposal_v2".to_string(), + Box::new(decoder::diem_governance_create_proposal_v2), + ); + map.insert( + "diem_governance_ol_create_proposal_v2".to_string(), + Box::new(decoder::diem_governance_ol_create_proposal_v2), + ); + map.insert( + "diem_governance_ol_vote".to_string(), + Box::new(decoder::diem_governance_ol_vote), + ); + map.insert( + "diem_governance_smoke_trigger_epoch".to_string(), + Box::new(decoder::diem_governance_smoke_trigger_epoch), + ); + map.insert( + "diem_governance_trigger_epoch".to_string(), + Box::new(decoder::diem_governance_trigger_epoch), + ); + map.insert( + "diem_governance_vote".to_string(), + Box::new(decoder::diem_governance_vote), + ); + map.insert( + "donor_voice_txs_propose_liquidate_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_liquidate_tx), + ); + map.insert( + "donor_voice_txs_propose_payment_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_payment_tx), + ); + map.insert( + "donor_voice_txs_propose_veto_tx".to_string(), + Box::new(decoder::donor_voice_txs_propose_veto_tx), + ); + map.insert( + "donor_voice_txs_vote_liquidation_tx".to_string(), + Box::new(decoder::donor_voice_txs_vote_liquidation_tx), + ); + map.insert( + "donor_voice_txs_vote_veto_tx".to_string(), + Box::new(decoder::donor_voice_txs_vote_veto_tx), + ); + map.insert( + "epoch_boundary_smoke_trigger_epoch".to_string(), + Box::new(decoder::epoch_boundary_smoke_trigger_epoch), + ); + map.insert( + "jail_unjail_by_voucher".to_string(), + Box::new(decoder::jail_unjail_by_voucher), + ); + map.insert( + "libra_coin_claim_mint_capability".to_string(), + Box::new(decoder::libra_coin_claim_mint_capability), + ); + map.insert( + "libra_coin_delegate_mint_capability".to_string(), + Box::new(decoder::libra_coin_delegate_mint_capability), + ); + map.insert( + "libra_coin_mint_to_impl".to_string(), + Box::new(decoder::libra_coin_mint_to_impl), + ); + map.insert( + "multi_action_claim_offer".to_string(), + Box::new(decoder::multi_action_claim_offer), + ); + map.insert( + "multi_action_init_gov_deprecated".to_string(), + Box::new(decoder::multi_action_init_gov_deprecated), + ); + map.insert( + "multi_action_migration_migrate_offer".to_string(), + Box::new(decoder::multi_action_migration_migrate_offer), + ); + map.insert( + "multisig_account_add_owner".to_string(), + Box::new(decoder::multisig_account_add_owner), + ); + map.insert( + "multisig_account_add_owners".to_string(), + Box::new(decoder::multisig_account_add_owners), + ); + map.insert( + "multisig_account_approve_transaction".to_string(), + Box::new(decoder::multisig_account_approve_transaction), + ); + map.insert( + "multisig_account_create".to_string(), + Box::new(decoder::multisig_account_create), + ); + map.insert( + "multisig_account_create_transaction".to_string(), + Box::new(decoder::multisig_account_create_transaction), + ); + map.insert( + "multisig_account_create_transaction_with_hash".to_string(), + Box::new(decoder::multisig_account_create_transaction_with_hash), + ); + map.insert( + "multisig_account_create_with_existing_account".to_string(), + Box::new(decoder::multisig_account_create_with_existing_account), + ); + map.insert( + "multisig_account_create_with_owners".to_string(), + Box::new(decoder::multisig_account_create_with_owners), + ); + map.insert( + "multisig_account_execute_rejected_transaction".to_string(), + Box::new(decoder::multisig_account_execute_rejected_transaction), + ); + map.insert( + "multisig_account_migrate_with_owners".to_string(), + Box::new(decoder::multisig_account_migrate_with_owners), + ); + map.insert( + "multisig_account_reject_transaction".to_string(), + Box::new(decoder::multisig_account_reject_transaction), + ); + map.insert( + "multisig_account_remove_owner".to_string(), + Box::new(decoder::multisig_account_remove_owner), + ); + map.insert( + "multisig_account_remove_owners".to_string(), + Box::new(decoder::multisig_account_remove_owners), + ); + map.insert( + "multisig_account_update_metadata".to_string(), + Box::new(decoder::multisig_account_update_metadata), + ); + map.insert( + "multisig_account_update_signatures_required".to_string(), + Box::new(decoder::multisig_account_update_signatures_required), + ); + map.insert( + "multisig_account_vote_transanction".to_string(), + Box::new(decoder::multisig_account_vote_transanction), + ); + map.insert( + "object_transfer_call".to_string(), + Box::new(decoder::object_transfer_call), + ); + map.insert( + "ol_account_create_account".to_string(), + Box::new(decoder::ol_account_create_account), + ); + map.insert( + "ol_account_set_allow_direct_coin_transfers".to_string(), + Box::new(decoder::ol_account_set_allow_direct_coin_transfers), + ); + map.insert( + "ol_account_transfer".to_string(), + Box::new(decoder::ol_account_transfer), + ); + map.insert( + "proof_of_fee_init_bidding".to_string(), + Box::new(decoder::proof_of_fee_init_bidding), + ); + map.insert( + "proof_of_fee_pof_retract_bid".to_string(), + Box::new(decoder::proof_of_fee_pof_retract_bid), + ); + map.insert( + "proof_of_fee_pof_update_bid".to_string(), + Box::new(decoder::proof_of_fee_pof_update_bid), + ); + map.insert( + "safe_init_payment_multisig".to_string(), + Box::new(decoder::safe_init_payment_multisig), + ); + map.insert( + "slow_wallet_smoke_test_vm_unlock".to_string(), + Box::new(decoder::slow_wallet_smoke_test_vm_unlock), + ); + map.insert( + "slow_wallet_user_set_slow".to_string(), + Box::new(decoder::slow_wallet_user_set_slow), + ); + map.insert( + "stake_initialize_validator".to_string(), + Box::new(decoder::stake_initialize_validator), + ); + map.insert( + "stake_rotate_consensus_key".to_string(), + Box::new(decoder::stake_rotate_consensus_key), + ); + map.insert( + "stake_update_network_and_fullnode_addresses".to_string(), + Box::new(decoder::stake_update_network_and_fullnode_addresses), + ); + map.insert( + "validator_universe_register_validator".to_string(), + Box::new(decoder::validator_universe_register_validator), + ); + map.insert( + "version_set_version".to_string(), + Box::new(decoder::version_set_version), + ); + map.insert( + "vouch_insist_vouch_for".to_string(), + Box::new(decoder::vouch_insist_vouch_for), + ); + map.insert("vouch_revoke".to_string(), Box::new(decoder::vouch_revoke)); + map.insert( + "vouch_vouch_for".to_string(), + Box::new(decoder::vouch_vouch_for), + ); + map + }); diff --git a/compatibility/src/version_five/account_blob_v5.rs b/compatibility/src/version_five/account_blob_v5.rs new file mode 100644 index 000000000..f77febb40 --- /dev/null +++ b/compatibility/src/version_five/account_blob_v5.rs @@ -0,0 +1,119 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 +#![allow(dead_code)] + +use crate::version_five::move_resource_v5::MoveResourceV5; +use crate::version_five::{ + core_account_v5::AccountResourceV5, diem_account_v5::DiemAccountResourceV5, + language_storage_v5::StructTagV5, legacy_address_v5::LegacyAddressV5, +}; +use anyhow::{bail, Context, Result}; +use diem_crypto::{ + hash::{CryptoHash, CryptoHasher}, + HashValue, +}; + +use diem_crypto_derive::CryptoHasher; +use serde::{Deserialize, Deserializer, Serialize}; +use std::collections::BTreeMap; + +#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] +pub struct AccountStateV5(pub BTreeMap, Vec>); + +impl AccountStateV5 { + pub fn get_resource_data(&self) -> Result<&[u8]> { + // NOTE: when encoding you should use access_vector: since there's a magic a bit prepended to flag resources. + + let key = T::struct_tag().access_vector(); + + let errmsg = format!( + "could not find in btree type {:?}", + &T::struct_tag().module_id() + ); + + Ok(self.0.get(&key).context(errmsg)?) + } + + pub fn find_bytes_legacy_struct_tag_v5( + &self, + legacy_struct_tag: &StructTagV5, + ) -> Result<&[u8]> { + let key = legacy_struct_tag.access_vector(); + + dbg!(&hex::encode(&key)); + let errmsg = format!("could not find in btree type {}", legacy_struct_tag.module); + + Ok(self.0.get(&key).context(errmsg)?) + } + + pub fn get_resource(&self) -> Result { + let bytes = self.get_resource_data::()?; + Ok(bcs::from_bytes(bytes)?) + } + + pub fn get_address(&self) -> Result { + let dr = self.get_diem_account_resource()?; + Ok(dr.address()) + } + + pub fn get_diem_account_resource(&self) -> Result { + self.get_resource::() + } + + pub fn get_account_resource(&self) -> Result { + match self.get_resource::() { + Ok(x) => Ok(x), + _ => match self.get_resource::() { + Ok(diem_ar) => Ok(AccountResourceV5::new( + diem_ar.sequence_number(), + diem_ar.authentication_key().to_vec(), + diem_ar.address(), + )), + _ => bail!("can't find an AccountResource or DiemAccountResource"), + }, + } + } +} +#[derive(Clone, Eq, PartialEq, Serialize, CryptoHasher)] +pub struct AccountStateBlob { + pub blob: Vec, + #[serde(skip)] + hash: HashValue, +} + +impl<'de> Deserialize<'de> for AccountStateBlob { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + #[derive(Deserialize)] + #[serde(rename = "AccountStateBlob")] + struct RawBlob { + blob: Vec, + } + let blob = RawBlob::deserialize(deserializer)?; + + Ok(Self::new(blob.blob)) + } +} + +impl AccountStateBlob { + fn new(blob: Vec) -> Self { + let mut hasher = AccountStateBlobHasher::default(); + hasher.update(&blob); + let hash = hasher.finish(); + Self { blob, hash } + } + // convert from vec to btree k-v representation + pub fn to_account_state(&self) -> Result { + Ok(bcs::from_bytes(&self.blob)?) + } +} + +impl CryptoHash for AccountStateBlob { + type Hasher = AccountStateBlobHasher; + + fn hash(&self) -> HashValue { + self.hash + } +} diff --git a/compatibility/src/version_five/balance_v5.rs b/compatibility/src/version_five/balance_v5.rs new file mode 100644 index 000000000..13f53cadd --- /dev/null +++ b/compatibility/src/version_five/balance_v5.rs @@ -0,0 +1,43 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use crate::version_five::{ + language_storage_v5::{StructTagV5, TypeTagV5}, + legacy_address_v5::LEGACY_CORE_CODE_ADDRESS, + move_resource_v5::MoveResourceV5, + move_resource_v5::MoveStructTypeV5, +}; + +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; +/// The balance resource held under an account. +#[derive(Debug, Serialize, Deserialize)] +pub struct BalanceResourceV5 { + coin: u64, +} + +impl BalanceResourceV5 { + pub fn new(coin: u64) -> Self { + Self { coin } + } + + pub fn coin(&self) -> u64 { + self.coin + } +} + +impl MoveStructTypeV5 for BalanceResourceV5 { + const MODULE_NAME: &'static IdentStr = ident_str!("DiemAccount"); + const STRUCT_NAME: &'static IdentStr = ident_str!("Balance"); + + fn type_params() -> Vec { + vec![TypeTagV5::Struct(Box::new(StructTagV5 { + address: LEGACY_CORE_CODE_ADDRESS, + module: ident_str!("GAS").into(), + name: ident_str!("GAS").into(), + type_params: vec![], + }))] + } +} + +impl MoveResourceV5 for BalanceResourceV5 {} diff --git a/compatibility/src/version_five/core_account_v5.rs b/compatibility/src/version_five/core_account_v5.rs new file mode 100644 index 000000000..ec9b4046f --- /dev/null +++ b/compatibility/src/version_five/core_account_v5.rs @@ -0,0 +1,67 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use move_core_types::ident_str; +use move_core_types::identifier::IdentStr; +use serde::{Deserialize, Serialize}; + +use super::legacy_address_v5::LegacyAddressV5; +use super::move_resource_v5::{MoveResourceV5, MoveStructTypeV5}; + +pub const CORE_ACCOUNT_MODULE_IDENTIFIER: &IdentStr = ident_str!("Account"); + +/// A Rust representation of an Account resource. +/// This is not how the Account is represented in the VM but it's a convenient representation. +#[derive(Debug, Serialize, Deserialize)] +pub struct AccountResourceV5 { + authentication_key: Vec, + sequence_number: u64, + self_address: LegacyAddressV5, +} + +impl AccountResourceV5 { + /// Constructs an Account resource. + pub fn new( + sequence_number: u64, + authentication_key: Vec, + self_address: LegacyAddressV5, + ) -> Self { + AccountResourceV5 { + authentication_key, + sequence_number, + self_address, + } + } + + /// Return the sequence_number field for the given AccountResourceV5 + pub fn sequence_number(&self) -> u64 { + self.sequence_number + } + + /// Return the authentication_key field for the given AccountResourceV5 + pub fn authentication_key(&self) -> &[u8] { + &self.authentication_key + } + + pub fn address(&self) -> LegacyAddressV5 { + self.self_address + } + + //////// 0L ///////// + /// Replace the authkey in place + pub fn rotate_auth_key(mut self, new_key: Vec) -> Self { + self.authentication_key = new_key; + self + } + + // pub fn legacy_struct_tag(&self) -> StructTagV5 { + + // } +} + +impl MoveStructTypeV5 for AccountResourceV5 { + const MODULE_NAME: &'static IdentStr = CORE_ACCOUNT_MODULE_IDENTIFIER; + const STRUCT_NAME: &'static IdentStr = CORE_ACCOUNT_MODULE_IDENTIFIER; +} + +impl MoveResourceV5 for AccountResourceV5 {} diff --git a/compatibility/src/version_five/diem_account_v5.rs b/compatibility/src/version_five/diem_account_v5.rs new file mode 100644 index 000000000..67503be27 --- /dev/null +++ b/compatibility/src/version_five/diem_account_v5.rs @@ -0,0 +1,129 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use crate::version_five::event_v5::EventHandleV5; +use crate::version_five::language_storage_v5::StructTagV5; +use crate::version_five::legacy_address_v5::LegacyAddressV5; + +use move_core_types::ident_str; +use move_core_types::identifier::IdentStr; +use serde::{Deserialize, Serialize}; + +use super::legacy_address_v5::LEGACY_CORE_CODE_ADDRESS; +use super::move_resource_v5::{MoveResourceV5, MoveStructTypeV5}; + +/// The Identifier for the Account module. +pub const DIEM_ACCOUNT_MODULE_IDENTIFIER: &IdentStr = ident_str!("DiemAccount"); +/// A Rust representation of an Account resource. +/// This is not how the Account is represented in the VM but it's a convenient representation. +#[derive(Debug, Serialize, Deserialize)] +pub struct DiemAccountResourceV5 { + authentication_key: Vec, + withdrawal_capability: Option, + key_rotation_capability: Option, + received_events: EventHandleV5, + sent_events: EventHandleV5, + sequence_number: u64, +} + +impl DiemAccountResourceV5 { + /// Constructs an Account resource. + pub fn new( + sequence_number: u64, + authentication_key: Vec, + sent_events: EventHandleV5, + received_events: EventHandleV5, + ) -> Self { + DiemAccountResourceV5 { + authentication_key, + withdrawal_capability: None, + key_rotation_capability: None, + received_events, + sent_events, + sequence_number, + } + } + + /// Return the sequence_number field for the given AccountResource + pub fn sequence_number(&self) -> u64 { + self.sequence_number + } + + /// Returns if this account has delegated its withdrawal capability + pub fn has_delegated_withdrawal_capability(&self) -> bool { + self.withdrawal_capability.is_none() + } + + /// Returns if this account has delegated its key rotation capability + pub fn has_delegated_key_rotation_capability(&self) -> bool { + self.key_rotation_capability.is_none() + } + + /// Return the authentication_key field for the given AccountResource + pub fn authentication_key(&self) -> &[u8] { + &self.authentication_key + } + + /// Return the sent_events handle for the given AccountResource + pub fn sent_events(&self) -> &EventHandleV5 { + &self.sent_events + } + + /// Return the received_events handle for the given AccountResource + pub fn received_events(&self) -> &EventHandleV5 { + &self.received_events + } + + pub fn address(&self) -> LegacyAddressV5 { + // cast address from + LegacyAddressV5::from_hex_literal( + &self + .sent_events() + .key() + .get_creator_address() + .to_hex_literal(), + ) + .expect("cannot decode DiemAccount address") + } + + // for compatibility, the struct tag uses different address format + pub fn v5_legacy_struct_tag() -> StructTagV5 { + StructTagV5 { + address: LEGACY_CORE_CODE_ADDRESS, + module: ident_str!("DiemAccount").into(), + name: ident_str!("DiemAccount").into(), + type_params: vec![], + } + } +} + +impl MoveStructTypeV5 for DiemAccountResourceV5 { + const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER; + const STRUCT_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER; +} + +impl MoveResourceV5 for DiemAccountResourceV5 {} + +#[derive(Debug, Serialize, Deserialize)] +pub struct WithdrawCapabilityResource { + account_address: LegacyAddressV5, +} + +impl MoveStructTypeV5 for WithdrawCapabilityResource { + const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER; + const STRUCT_NAME: &'static IdentStr = ident_str!("WithdrawCapability"); +} + +impl MoveResourceV5 for WithdrawCapabilityResource {} + +#[derive(Debug, Serialize, Deserialize)] +pub struct KeyRotationCapabilityResource { + account_address: LegacyAddressV5, +} + +impl MoveStructTypeV5 for KeyRotationCapabilityResource { + const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER; + const STRUCT_NAME: &'static IdentStr = ident_str!("KeyRotationCapability"); +} + +impl MoveResourceV5 for KeyRotationCapabilityResource {} diff --git a/compatibility/src/version_five/event_v5.rs b/compatibility/src/version_five/event_v5.rs new file mode 100644 index 000000000..c7244ca33 --- /dev/null +++ b/compatibility/src/version_five/event_v5.rs @@ -0,0 +1,275 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use hex::FromHex; +use serde::{de, ser, Deserialize, Serialize}; +use std::{ + convert::{TryFrom, TryInto}, + fmt, + str::FromStr, +}; + +use super::legacy_address_v5::LegacyAddressV5; + +/// A struct that represents a globally unique id for an Event stream that a user can listen to. +/// By design, the lower part of EventKey is the same as account address. +#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] + +pub struct EventKeyV5([u8; EventKeyV5::LENGTH]); + +impl EventKeyV5 { + /// Construct a new EventKey from a byte array slice. + pub fn new(key: [u8; Self::LENGTH]) -> Self { + EventKeyV5(key) + } + + /// The number of bytes in an EventKey. + pub const LENGTH: usize = LegacyAddressV5::LENGTH + 8; + + /// Get the byte representation of the event key. + pub fn as_bytes(&self) -> &[u8] { + &self.0 + } + + /// Convert event key into a byte array. + pub fn to_vec(self) -> Vec { + self.0.to_vec() + } + + /// Get the account address part in this event key + pub fn get_creator_address(&self) -> LegacyAddressV5 { + LegacyAddressV5::try_from(&self.0[EventKeyV5::LENGTH - LegacyAddressV5::LENGTH..]) + .expect("get_creator_address failed") + } + + /// If this is the `ith` EventKey` created by `get_creator_address()`, return `i` + pub fn get_creation_number(&self) -> u64 { + u64::from_le_bytes(self.0[0..8].try_into().unwrap()) + } + + // #[cfg(any(test, feature = "fuzzing"))] + // /// Create a random event key for testing + // pub fn random() -> Self { + // let mut rng = OsRng; + // let salt = rng.next_u64(); + // EventKey::new_from_address(&AccountAddress::random(), salt) + // } + + /// Create a unique handle by using an AccountAddress and a counter. + pub fn new_from_address(addr: &LegacyAddressV5, salt: u64) -> Self { + let mut output_bytes = [0; Self::LENGTH]; + let (lhs, rhs) = output_bytes.split_at_mut(8); + lhs.copy_from_slice(&salt.to_le_bytes()); + rhs.copy_from_slice(addr.as_ref()); + EventKeyV5(output_bytes) + } + + pub fn from_hex>(hex: T) -> Result { + <[u8; Self::LENGTH]>::from_hex(hex) + .map_err(|_| EventKeyParseError) + .map(Self) + } + + pub fn from_bytes>(bytes: T) -> Result { + <[u8; Self::LENGTH]>::try_from(bytes.as_ref()) + .map_err(|_| EventKeyParseError) + .map(Self) + } +} + +impl FromStr for EventKeyV5 { + type Err = EventKeyParseError; + + fn from_str(s: &str) -> Result { + EventKeyV5::from_hex(s) + } +} + +impl From for [u8; EventKeyV5::LENGTH] { + fn from(event_key: EventKeyV5) -> Self { + event_key.0 + } +} + +impl From<&EventKeyV5> for [u8; EventKeyV5::LENGTH] { + fn from(event_key: &EventKeyV5) -> Self { + event_key.0 + } +} + +impl ser::Serialize for EventKeyV5 { + fn serialize(&self, serializer: S) -> Result + where + S: ser::Serializer, + { + if serializer.is_human_readable() { + self.to_string().serialize(serializer) + } else { + // In order to preserve the Serde data model and help analysis tools, + // make sure to wrap our value in a container with the same name + // as the original type. + serializer.serialize_newtype_struct("EventKey", serde_bytes::Bytes::new(&self.0)) + } + } +} + +impl<'de> de::Deserialize<'de> for EventKeyV5 { + fn deserialize(deserializer: D) -> Result + where + D: de::Deserializer<'de>, + { + use serde::de::Error; + + if deserializer.is_human_readable() { + let s = ::deserialize(deserializer)?; + EventKeyV5::from_hex(s).map_err(D::Error::custom) + } else { + // See comment in serialize. + #[derive(::serde::Deserialize)] + #[serde(rename = "EventKey")] + struct Value<'a>(&'a [u8]); + + let value = Value::deserialize(deserializer)?; + Self::try_from(value.0).map_err(D::Error::custom) + } + } +} + +impl fmt::LowerHex for EventKeyV5 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + write!(f, "0x")?; + } + + for byte in &self.0 { + write!(f, "{:02x}", byte)?; + } + + Ok(()) + } +} + +impl fmt::Display for EventKeyV5 { + fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { + write!(f, "{:x}", self) + } +} + +impl fmt::Debug for EventKeyV5 { + fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { + write!(f, "EventKey({:x})", self) + } +} + +impl TryFrom<&[u8]> for EventKeyV5 { + type Error = EventKeyParseError; + + /// Tries to convert the provided byte array into Event Key. + fn try_from(bytes: &[u8]) -> Result { + Self::from_bytes(bytes) + } +} + +#[derive(Clone, Copy, Debug)] +pub struct EventKeyParseError; + +impl fmt::Display for EventKeyParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { + write!(f, "unable to parse EventKey") + } +} + +impl std::error::Error for EventKeyParseError {} + +/// A Rust representation of an Event Handle Resource. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct EventHandleV5 { + /// Number of events in the event stream. + count: u64, + /// The associated globally unique key that is used as the key to the EventStore. + key: EventKeyV5, +} + +impl EventHandleV5 { + /// Constructs a new Event Handle + pub fn new(key: EventKeyV5, count: u64) -> Self { + EventHandleV5 { count, key } + } + + /// Return the key to where this event is stored in EventStore. + pub fn key(&self) -> &EventKeyV5 { + &self.key + } + + /// Return the counter for the handle + pub fn count(&self) -> u64 { + self.count + } + + // #[cfg(any(test, feature = "fuzzing"))] + // pub fn count_mut(&mut self) -> &mut u64 { + // &mut self.count + // } + + // #[cfg(any(test, feature = "fuzzing"))] + // /// Create a random event handle for testing + // pub fn random_handle(count: u64) -> Self { + // Self { + // key: EventKey::random(), + // count, + // } + // } + + // #[cfg(any(test, feature = "fuzzing"))] + // /// Derive a unique handle by using an AccountAddress and a counter. + // pub fn new_from_address(addr: &AccountAddress, salt: u64) -> Self { + // Self { + // key: EventKey::new_from_address(addr, salt), + // count: 0, + // } + // } +} +#[cfg(test)] +mod tests { + use super::EventKeyV5; + + #[test] + fn test_display_impls() { + let hex = "1000000000000000ca843279e3427144cead5e4d5999a3d0"; + + let key = EventKeyV5::from_hex(hex).unwrap(); + + assert_eq!(format!("{}", key), hex); + assert_eq!(format!("{:x}", key), hex); + + assert_eq!(format!("{:#x}", key), format!("0x{}", hex)); + } + + #[test] + fn test_invalid_length() { + let bytes = vec![1; 123]; + EventKeyV5::from_bytes(bytes).unwrap_err(); + } + + // #[test] + // fn test_deserialize_from_json_value() { + // let key = EventKey::random(); + // let json_value = serde_json::to_value(key).unwrap(); + // let key2: EventKey = serde_json::from_value(json_value).unwrap(); + // assert_eq!(key, key2); + // } + + #[test] + fn test_serde_json() { + let hex = "1000000000000000ca843279e3427144cead5e4d5999a3d0"; + let json_hex = "\"1000000000000000ca843279e3427144cead5e4d5999a3d0\""; + + let key = EventKeyV5::from_hex(hex).unwrap(); + + let json = serde_json::to_string(&key).unwrap(); + let json_key: EventKeyV5 = serde_json::from_str(json_hex).unwrap(); + + assert_eq!(json, json_hex); + assert_eq!(key, json_key); + } +} diff --git a/compatibility/src/version_five/freezing_v5.rs b/compatibility/src/version_five/freezing_v5.rs new file mode 100644 index 000000000..685379750 --- /dev/null +++ b/compatibility/src/version_five/freezing_v5.rs @@ -0,0 +1,26 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use super::move_resource_v5::{MoveResourceV5, MoveStructTypeV5}; + +use move_core_types::{ident_str, identifier::IdentStr}; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct FreezingBit { + is_frozen: bool, +} + +impl FreezingBit { + pub fn is_frozen(&self) -> bool { + self.is_frozen + } +} + +impl MoveStructTypeV5 for FreezingBit { + const MODULE_NAME: &'static IdentStr = ident_str!("AccountFreezing"); + const STRUCT_NAME: &'static IdentStr = ident_str!("FreezingBit"); +} + +impl MoveResourceV5 for FreezingBit {} diff --git a/compatibility/src/version_five/hash_value_v5.rs b/compatibility/src/version_five/hash_value_v5.rs new file mode 100644 index 000000000..d1ac9461e --- /dev/null +++ b/compatibility/src/version_five/hash_value_v5.rs @@ -0,0 +1,691 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +//! This module defines traits and implementations of +//! [cryptographic hash functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function) +//! for the Diem project. +//! +//! It is designed to help authors protect against two types of real world attacks: +//! +//! 1. **Semantic Ambiguity**: imagine that Alice has a private key and is using +//! two different applications, X and Y. X asks Alice to sign a message saying +//! "I am Alice". Alice accepts to sign this message in the context of X. However, +//! unbeknownst to Alice, in application Y, messages beginning with the letter "I" +//! represent transfers. " am " represents a transfer of 500 coins and "Alice" +//! can be interpreted as a destination address. When Alice signed the message she +//! needed to be aware of how other applications might interpret that message. +//! +//! 2. **Format Ambiguity**: imagine a program that hashes a pair of strings. +//! To hash the strings `a` and `b` it hashes `a + "||" + b`. The pair of +//! strings `a="foo||", b = "bar"` and `a="foo", b = "||bar"` result in the +//! same input to the hash function and therefore the same hash. This +//! creates a collision. +//! +//! Regarding (1), this library makes it easy for Diem developers to create as +//! many new "hashable" Rust types as needed so that each Rust type hashed and signed +//! in Diem has a unique meaning, that is, unambiguously captures the intent of a signer. +//! +//! Regarding (2), this library provides the `CryptoHasher` abstraction to easily manage +//! cryptographic seeds for hashing. Hashing seeds aim to ensure that +//! the hashes of values of a given type `MyNewStruct` never collide with hashes of values +//! from another type. +//! +//! Finally, to prevent format ambiguity within a same type `MyNewStruct` and facilitate protocol +//! specifications, we use [Binary Canonical Serialization (BCS)](https://docs.rs/bcs/) +//! as the recommended solution to write Rust values into a hasher. +//! +//! # Quick Start +//! +//! To obtain a `hash()` method for any new type `MyNewStruct`, it is (strongly) recommended to +//! use the derive macros of `serde` and `diem_crypto_derive` as follows: +//! ``` +//! use diem_crypto::hash::CryptoHash; +//! use diem_crypto_derive::{CryptoHasher, BCSCryptoHash}; +//! use serde::{Deserialize, Serialize}; +//! #[derive(Serialize, Deserialize, CryptoHasher, BCSCryptoHash)] +//! struct MyNewStruct { /*...*/ } +//! +//! let value = MyNewStruct { /*...*/ }; +//! value.hash(); +//! ``` +//! +//! Under the hood, this will generate a new implementation `MyNewStructHasher` for the trait +//! `CryptoHasher` and implement the trait `CryptoHash` for `MyNewStruct` using BCS. +//! +//! # Implementing New Hashers +//! +//! The trait `CryptoHasher` captures the notion of a pre-seeded hash function, aka a "hasher". +//! New implementations can be defined in two ways. +//! +//! ## Derive macro (recommended) +//! +//! For any new structure `MyNewStruct` that needs to be hashed, it is recommended to simply +//! use the derive macro [`CryptoHasher`](https://doc.rust-lang.org/reference/procedural-macros.html). +//! +//! ``` +//! use diem_crypto_derive::CryptoHasher; +//! use serde::Deserialize; +//! #[derive(Deserialize, CryptoHasher)] +//! #[serde(rename = "OptionalCustomSerdeName")] +//! struct MyNewStruct { /*...*/ } +//! ``` +//! +//! The macro `CryptoHasher` will define a hasher automatically called `MyNewStructHasher`, and derive a salt +//! using the name of the type as seen by the Serde library. In the example above, this name +//! was changed using the Serde parameter `rename`: the salt will be based on the value `OptionalCustomSerdeName` +//! instead of the default name `MyNewStruct`. +//! +//! ## Customized hashers +//! +//! **IMPORTANT:** Do NOT use this for new code unless you know what you are doing. +//! +//! This library also provides a few customized hashers defined in the code as follows: +//! +//! ``` +//! # // To get around that there's no way to doc-test a non-exported macro: +//! # macro_rules! define_hasher { ($e:expr) => () } +//! define_hasher! { (MyNewDataHasher, MY_NEW_DATA_HASHER, MY_NEW_DATA_SEED, b"MyUniqueSaltString") } +//! ``` +//! +//! # Using a hasher directly +//! +//! **IMPORTANT:** Do NOT use this for new code unless you know what you are doing. +//! +//! ``` +//! use diem_crypto::hash::{CryptoHasher, TestOnlyHasher}; +//! +//! let mut hasher = TestOnlyHasher::default(); +//! hasher.update("Test message".as_bytes()); +//! let hash_value = hasher.finish(); +//! ``` +#![allow(clippy::arithmetic_side_effects)] +use bytes::Bytes; +use hex::FromHex; +// use mirai_annotations::*; +// use once_cell::sync::{Lazy, OnceCell}; + +use rand::{rngs::OsRng, Rng}; +use serde::{de, ser}; +use std::{ + self, + convert::{AsRef, TryFrom}, + fmt, + str::FromStr, +}; +use tiny_keccak::{Hasher, Sha3}; + +/// A prefix used to begin the salt of every diem hashable structure. The salt +/// consists in this global prefix, concatenated with the specified +/// serialization name of the struct. +// pub(crate) const DIEM_HASH_PREFIX: &[u8] = b"DIEM::"; + +/// Output value of our hash function. Intentionally opaque for safety and modularity. +#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)] +pub struct HashValueV5 { + hash: [u8; HashValueV5::LENGTH], +} + +impl HashValueV5 { + /// The length of the hash in bytes. + pub const LENGTH: usize = 32; + /// The length of the hash in bits. + pub const LENGTH_IN_BITS: usize = Self::LENGTH * 8; + + /// Create a new [`HashValue`] from a byte array. + pub fn new(hash: [u8; HashValueV5::LENGTH]) -> Self { + HashValueV5 { hash } + } + + /// Create from a slice (e.g. retrieved from storage). + pub fn from_slice>(bytes: T) -> Result { + <[u8; Self::LENGTH]>::try_from(bytes.as_ref()) + .map_err(|_| HashValueParseError) + .map(Self::new) + } + + /// Dumps into a vector. + pub fn to_vec(self) -> Vec { + self.hash.to_vec() + } + + /// Creates a zero-initialized instance. + pub const fn zero() -> Self { + HashValueV5 { + hash: [0; HashValueV5::LENGTH], + } + } + + /// Create a cryptographically random instance. + pub fn random() -> Self { + let mut rng = OsRng; + let hash: [u8; HashValueV5::LENGTH] = rng.gen(); + HashValueV5 { hash } + } + + /// Creates a random instance with given rng. Useful in unit tests. + pub fn random_with_rng(rng: &mut R) -> Self { + let hash: [u8; HashValueV5::LENGTH] = rng.gen(); + HashValueV5 { hash } + } + + /// Convenience function that computes a `HashValue` internally equal to + /// the sha3_256 of a byte buffer. It will handle hasher creation, data + /// feeding and finalization. + /// + /// Note this will not result in the `::hash()` for any + /// reasonable struct T, as this computes a sha3 without any ornaments. + pub fn sha3_256_of(buffer: &[u8]) -> Self { + let mut sha3 = Sha3::v256(); + sha3.update(buffer); + HashValueV5::from_keccak(sha3) + } + + #[cfg(test)] + pub fn from_iter_sha3<'a, I>(buffers: I) -> Self + where + I: IntoIterator, + { + let mut sha3 = Sha3::v256(); + for buffer in buffers { + sha3.update(buffer); + } + HashValueV5::from_keccak(sha3) + } + + fn as_ref_mut(&mut self) -> &mut [u8] { + &mut self.hash[..] + } + + fn from_keccak(state: Sha3) -> Self { + let mut hash = Self::zero(); + state.finalize(hash.as_ref_mut()); + hash + } + + /// Returns the `index`-th bit in the bytes. + pub fn bit(&self, index: usize) -> bool { + assert!(index < Self::LENGTH_IN_BITS); // assumed precondition + let pos = index / 8; + let bit = 7 - index % 8; + (self.hash[pos] >> bit) & 1 != 0 + } + + /// Returns the `index`-th nibble in the bytes. + pub fn nibble(&self, index: usize) -> u8 { + assert!(index < Self::LENGTH * 2); // assumed precondition + let pos = index / 2; + let shift = if index % 2 == 0 { 4 } else { 0 }; + (self.hash[pos] >> shift) & 0x0f + } + + /// Returns a `HashValueBitIterator` over all the bits that represent this `HashValue`. + pub fn iter_bits(&self) -> HashValueBitIterator<'_> { + HashValueBitIterator::new(self) + } + + /// Constructs a `HashValue` from an iterator of bits. + pub fn from_bit_iter( + iter: impl ExactSizeIterator, + ) -> Result { + if iter.len() != Self::LENGTH_IN_BITS { + return Err(HashValueParseError); + } + + let mut buf = [0; Self::LENGTH]; + for (i, bit) in iter.enumerate() { + if bit { + buf[i / 8] |= 1 << (7 - i % 8); + } + } + Ok(Self::new(buf)) + } + + /// Returns the length of common prefix of `self` and `other` in bits. + pub fn common_prefix_bits_len(&self, other: HashValueV5) -> usize { + self.iter_bits() + .zip(other.iter_bits()) + .take_while(|(x, y)| x == y) + .count() + } + + /// Full hex representation of a given hash value. + pub fn to_hex(self) -> String { + format!("{:x}", &self) + } + + /// Full hex representation of a given hash value with `0x` prefix. + pub fn to_hex_literal(self) -> String { + format!("{:#x}", &self) + } + + /// Parse a given hex string to a hash value. + pub fn from_hex>(hex: T) -> Result { + <[u8; Self::LENGTH]>::from_hex(hex) + .map_err(|_| HashValueParseError) + .map(Self::new) + } + + /// Create a hash value whose contents are just the given integer. Useful for + /// generating basic mock hash values. + /// + /// Ex: HashValue::from_u64(0x1234) => HashValue([0, .., 0, 0x12, 0x34]) + #[cfg(any(test, feature = "fuzzing"))] + pub fn from_u64(v: u64) -> Self { + let mut hash = [0u8; Self::LENGTH]; + let bytes = v.to_be_bytes(); + hash[Self::LENGTH - bytes.len()..].copy_from_slice(&bytes[..]); + Self::new(hash) + } +} + +impl ser::Serialize for HashValueV5 { + fn serialize(&self, serializer: S) -> Result + where + S: ser::Serializer, + { + if serializer.is_human_readable() { + serializer.serialize_str(&self.to_hex()) + } else { + // In order to preserve the Serde data model and help analysis tools, + // make sure to wrap our value in a container with the same name + // as the original type. + serializer + .serialize_newtype_struct("HashValue", serde_bytes::Bytes::new(&self.hash[..])) + } + } +} + +impl<'de> de::Deserialize<'de> for HashValueV5 { + fn deserialize(deserializer: D) -> Result + where + D: de::Deserializer<'de>, + { + if deserializer.is_human_readable() { + let encoded_hash = ::deserialize(deserializer)?; + HashValueV5::from_hex(encoded_hash.as_str()) + .map_err(::custom) + } else { + // See comment in serialize. + #[derive(::serde::Deserialize)] + #[serde(rename = "HashValue")] + struct Value<'a>(&'a [u8]); + + let value = Value::deserialize(deserializer)?; + Self::from_slice(value.0).map_err(::custom) + } + } +} + +impl Default for HashValueV5 { + fn default() -> Self { + HashValueV5::zero() + } +} + +impl AsRef<[u8; HashValueV5::LENGTH]> for HashValueV5 { + fn as_ref(&self) -> &[u8; HashValueV5::LENGTH] { + &self.hash + } +} + +impl std::ops::Deref for HashValueV5 { + type Target = [u8; Self::LENGTH]; + + fn deref(&self) -> &Self::Target { + &self.hash + } +} + +impl std::ops::Index for HashValueV5 { + type Output = u8; + + fn index(&self, s: usize) -> &u8 { + self.hash.index(s) + } +} + +impl fmt::Binary for HashValueV5 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + for byte in &self.hash { + write!(f, "{:08b}", byte)?; + } + Ok(()) + } +} + +impl fmt::LowerHex for HashValueV5 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + write!(f, "0x")?; + } + for byte in &self.hash { + write!(f, "{:02x}", byte)?; + } + Ok(()) + } +} + +impl fmt::Debug for HashValueV5 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "HashValue(")?; + ::fmt(self, f)?; + write!(f, ")")?; + Ok(()) + } +} + +/// Will print shortened (4 bytes) hash +impl fmt::Display for HashValueV5 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for byte in self.hash.iter().take(4) { + write!(f, "{:02x}", byte)?; + } + Ok(()) + } +} + +impl From for Bytes { + fn from(value: HashValueV5) -> Bytes { + Bytes::copy_from_slice(value.hash.as_ref()) + } +} + +impl FromStr for HashValueV5 { + type Err = HashValueParseError; + + fn from_str(s: &str) -> Result { + HashValueV5::from_hex(s) + } +} + +/// Parse error when attempting to construct a HashValue +#[derive(Clone, Copy, Debug)] +pub struct HashValueParseError; + +impl fmt::Display for HashValueParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "unable to parse HashValue") + } +} + +impl std::error::Error for HashValueParseError {} + +/// An iterator over `HashValue` that generates one bit for each iteration. +pub struct HashValueBitIterator<'a> { + /// The reference to the bytes that represent the `HashValue`. + hash_bytes: &'a [u8], + pos: std::ops::Range, + // invariant hash_bytes.len() == HashValue::LENGTH; + // invariant pos.end == hash_bytes.len() * 8; +} + +impl<'a> HashValueBitIterator<'a> { + /// Constructs a new `HashValueBitIterator` using given `HashValue`. + fn new(hash_value: &'a HashValueV5) -> Self { + HashValueBitIterator { + hash_bytes: hash_value.as_ref(), + pos: (0..HashValueV5::LENGTH_IN_BITS), + } + } + + /// Returns the `index`-th bit in the bytes. + fn get_bit(&self, index: usize) -> bool { + assert!(index < self.pos.end); // assumed precondition + assert!(self.hash_bytes.len() == HashValueV5::LENGTH); // invariant + assert!(self.pos.end == self.hash_bytes.len() * 8); // invariant + let pos = index / 8; + let bit = 7 - index % 8; + (self.hash_bytes[pos] >> bit) & 1 != 0 + } +} + +impl<'a> std::iter::Iterator for HashValueBitIterator<'a> { + type Item = bool; + + fn next(&mut self) -> Option { + self.pos.next().map(|x| self.get_bit(x)) + } + + fn size_hint(&self) -> (usize, Option) { + self.pos.size_hint() + } +} + +impl<'a> std::iter::DoubleEndedIterator for HashValueBitIterator<'a> { + fn next_back(&mut self) -> Option { + self.pos.next_back().map(|x| self.get_bit(x)) + } +} + +impl<'a> std::iter::ExactSizeIterator for HashValueBitIterator<'a> {} + +// /// A type that can be cryptographically hashed to produce a `HashValue`. +// /// +// /// In most cases, this trait should not be implemented manually but rather derived using +// /// the macros `serde::Serialize`, `CryptoHasher`, and `BCSCryptoHash`. +// pub trait CryptoHash { +// /// The associated `Hasher` type which comes with a unique salt for this type. +// type Hasher: CryptoHasher; + +// /// Hashes the object and produces a `HashValue`. +// fn hash(&self) -> HashValue; +// } + +// /// A trait for representing the state of a cryptographic hasher. +// pub trait CryptoHasher: Default + std::io::Write { +// /// the seed used to initialize hashing `Self` before the serialization bytes of the actual value +// fn seed() -> &'static [u8; 32]; + +// /// Write bytes into the hasher. +// fn update(&mut self, bytes: &[u8]); + +// /// Finish constructing the [`HashValue`]. +// fn finish(self) -> HashValue; + +// /// Convenience method to compute the hash of a complete byte slice. +// fn hash_all(bytes: &[u8]) -> HashValue { +// let mut hasher = Self::default(); +// hasher.update(bytes); +// hasher.finish() +// } +// } + +// /// The default hasher underlying generated implementations of `CryptoHasher`. +// #[doc(hidden)] +// #[derive(Clone)] +// pub struct DefaultHasher { +// state: Sha3, +// } + +// impl DefaultHasher { +// #[doc(hidden)] +// /// This function does not return a HashValue in the sense of our usual +// /// hashes, but a construction of initial bytes that are fed into any hash +// /// provided we're passed a (bcs) serialization name as argument. +// pub fn prefixed_hash(buffer: &[u8]) -> [u8; HashValue::LENGTH] { +// // The salt is initial material we prefix to actual value bytes for +// // domain separation. Its length is variable. +// let salt: Vec = [DIEM_HASH_PREFIX, buffer].concat(); +// // The seed is a fixed-length hash of the salt, thereby preventing +// // suffix attacks on the domain separation bytes. +// HashValue::sha3_256_of(&salt[..]).hash +// } + +// #[doc(hidden)] +// pub fn new(typename: &[u8]) -> Self { +// let mut state = Sha3::v256(); +// if !typename.is_empty() { +// state.update(&Self::prefixed_hash(typename)); +// } +// DefaultHasher { state } +// } + +// #[doc(hidden)] +// pub fn update(&mut self, bytes: &[u8]) { +// self.state.update(bytes); +// } + +// #[doc(hidden)] +// pub fn finish(self) -> HashValue { +// let mut hasher = HashValue::default(); +// self.state.finalize(hasher.as_ref_mut()); +// hasher +// } +// } + +// impl fmt::Debug for DefaultHasher { +// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +// write!(f, "DefaultHasher: state = Sha3") +// } +// } + +// macro_rules! define_hasher { +// ( +// $(#[$attr:meta])* +// ($hasher_type: ident, $hasher_name: ident, $seed_name: ident, $salt: expr) +// ) => { + +// #[derive(Clone, Debug)] +// $(#[$attr])* +// pub struct $hasher_type(DefaultHasher); + +// impl $hasher_type { +// fn new() -> Self { +// $hasher_type(DefaultHasher::new($salt)) +// } +// } + +// static $hasher_name: Lazy<$hasher_type> = Lazy::new(|| { $hasher_type::new() }); +// static $seed_name: OnceCell<[u8; 32]> = OnceCell::new(); + +// impl Default for $hasher_type { +// fn default() -> Self { +// $hasher_name.clone() +// } +// } + +// impl CryptoHasher for $hasher_type { +// fn seed() -> &'static [u8;32] { +// $seed_name.get_or_init(|| { +// DefaultHasher::prefixed_hash($salt) +// }) +// } + +// fn update(&mut self, bytes: &[u8]) { +// self.0.update(bytes); +// } + +// fn finish(self) -> HashValue { +// self.0.finish() +// } +// } + +// impl std::io::Write for $hasher_type { +// fn write(&mut self, bytes: &[u8]) -> std::io::Result { +// self.0.update(bytes); +// Ok(bytes.len()) +// } +// fn flush(&mut self) -> std::io::Result<()> { +// Ok(()) +// } +// } +// }; +// } + +// define_hasher! { +// /// The hasher used to compute the hash of an internal node in the transaction accumulator. +// ( +// TransactionAccumulatorHasher, +// TRANSACTION_ACCUMULATOR_HASHER, +// TRANSACTION_ACCUMULATOR_SEED, +// b"TransactionAccumulator" +// ) +// } + +// define_hasher! { +// /// The hasher used to compute the hash of an internal node in the event accumulator. +// ( +// EventAccumulatorHasher, +// EVENT_ACCUMULATOR_HASHER, +// EVENT_ACCUMULATOR_SEED, +// b"EventAccumulator" +// ) +// } + +// define_hasher! { +// /// The hasher used to compute the hash of an internal node in the Sparse Merkle Tree. +// ( +// SparseMerkleInternalHasher, +// SPARSE_MERKLE_INTERNAL_HASHER, +// SPARSE_MERKLE_INTERNAL_SEED, +// b"SparseMerkleInternal" +// ) +// } + +// define_hasher! { +// /// The hasher used to compute the hash of an internal node in the transaction accumulator. +// ( +// VoteProposalHasher, +// VOTE_PROPOSAL_HASHER, +// VOTE_PROPOSAL_SEED, +// b"VoteProposalHasher" +// ) +// } + +// define_hasher! { +// /// The hasher used only for testing. It doesn't have a salt. +// (TestOnlyHasher, TEST_ONLY_HASHER, TEST_ONLY_SEED, b"") +// } + +// fn create_literal_hash(word: &str) -> HashValue { +// let mut s = word.as_bytes().to_vec(); +// assert!(s.len() <= HashValue::LENGTH); +// s.resize(HashValue::LENGTH, 0); +// HashValue::from_slice(&s).expect("Cannot fail") +// } + +// /// Placeholder hash of `Accumulator`. +// pub static ACCUMULATOR_PLACEHOLDER_HASH: Lazy = +// Lazy::new(|| create_literal_hash("ACCUMULATOR_PLACEHOLDER_HASH")); + +// /// Placeholder hash of `SparseMerkleTree`. +// pub static SPARSE_MERKLE_PLACEHOLDER_HASH: Lazy = +// Lazy::new(|| create_literal_hash("SPARSE_MERKLE_PLACEHOLDER_HASH")); + +// /// Block id reserved as the id of parent block of the genesis block. +// pub static PRE_GENESIS_BLOCK_ID: Lazy = +// Lazy::new(|| create_literal_hash("PRE_GENESIS_BLOCK_ID")); + +// /// Genesis block id is used as a parent of the very first block executed by the executor. +// pub static GENESIS_BLOCK_ID: Lazy = Lazy::new(|| { +// // This maintains the invariant that block.id() == block.hash(), for +// // the genesis block and allows us to (de/)serialize it consistently +// HashValue::new([ +// 0x5e, 0x10, 0xba, 0xd4, 0x5b, 0x35, 0xed, 0x92, 0x9c, 0xd6, 0xd2, 0xc7, 0x09, 0x8b, 0x13, +// 0x5d, 0x02, 0xdd, 0x25, 0x9a, 0xe8, 0x8a, 0x8d, 0x09, 0xf4, 0xeb, 0x5f, 0xba, 0xe9, 0xa6, +// 0xf6, 0xe4, +// ]) +// }); + +// /// Provides a test_only_hash() method that can be used in tests on types that implement +// /// `serde::Serialize`. +// /// +// /// # Example +// /// ``` +// /// use diem_crypto::hash::TestOnlyHash; +// /// +// /// b"hello world".test_only_hash(); +// /// ``` +// pub trait TestOnlyHash { +// /// Generates a hash used only for tests. +// fn test_only_hash(&self) -> HashValue; +// } + +// impl TestOnlyHash for T { +// fn test_only_hash(&self) -> HashValue { +// let bytes = bcs::to_bytes(self).expect("serialize failed during hash."); +// let mut hasher = TestOnlyHasher::default(); +// hasher.update(&bytes); +// hasher.finish() +// } +// } diff --git a/compatibility/src/version_five/language_storage_v5.rs b/compatibility/src/version_five/language_storage_v5.rs new file mode 100644 index 000000000..7b14ab548 --- /dev/null +++ b/compatibility/src/version_five/language_storage_v5.rs @@ -0,0 +1,171 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 +#![allow(dead_code)] + +use crate::version_five::{legacy_address_v5::LegacyAddressV5, safe_serialize_v5}; +use move_core_types::identifier::{IdentStr, Identifier}; +use serde::{Deserialize, Serialize}; +use std::fmt::{Display, Formatter}; + +pub const CODE_TAG: u8 = 0; +pub const RESOURCE_TAG: u8 = 1; + +pub const CORE_CODE_ADDRESS: LegacyAddressV5 = LegacyAddressV5::new([ + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, +]); + +#[derive(Serialize, Deserialize, Debug, PartialEq, Hash, Eq, Clone, PartialOrd, Ord)] +pub enum TypeTagV5 { + Bool, + U8, + U64, + U128, + Address, + Signer, + Vector( + #[serde( + serialize_with = "safe_serialize_v5::type_tag_recursive_serialize", + deserialize_with = "safe_serialize_v5::type_tag_recursive_deserialize" + )] + Box, + ), + Struct( + #[serde( + serialize_with = "safe_serialize_v5::type_tag_recursive_serialize", + deserialize_with = "safe_serialize_v5::type_tag_recursive_deserialize" + )] + Box, + ), +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Hash, Eq, Clone, PartialOrd, Ord)] +pub struct StructTagV5 { + pub address: LegacyAddressV5, + pub module: Identifier, + pub name: Identifier, + pub type_params: Vec, +} + +impl StructTagV5 { + pub fn access_vector(&self) -> Vec { + let mut key = vec![RESOURCE_TAG]; + key.append(&mut bcs::to_bytes(self).unwrap()); + key + } + + pub fn module_id(&self) -> ModuleIdV5 { + ModuleIdV5::new(self.address, self.module.to_owned()) + } +} + +/// Represents the initial key into global storage where we first index by the address, and then +/// the struct tag +#[derive(Serialize, Deserialize, Debug, PartialEq, Hash, Eq, Clone, PartialOrd, Ord)] +pub struct ResourceKeyV5 { + pub address: LegacyAddressV5, + pub type_: StructTagV5, +} + +impl ResourceKeyV5 { + pub fn address(&self) -> LegacyAddressV5 { + self.address + } + + pub fn type_(&self) -> &StructTagV5 { + &self.type_ + } +} + +impl ResourceKeyV5 { + pub fn new(address: LegacyAddressV5, type_: StructTagV5) -> Self { + ResourceKeyV5 { address, type_ } + } +} + +/// Represents the initial key into global storage where we first index by the address, and then +/// the struct tag +#[derive(Serialize, Deserialize, Debug, PartialEq, Hash, Eq, Clone, PartialOrd, Ord)] +pub struct ModuleIdV5 { + address: LegacyAddressV5, + name: Identifier, +} + +impl From for (LegacyAddressV5, Identifier) { + fn from(module_id: ModuleIdV5) -> Self { + (module_id.address, module_id.name) + } +} + +impl ModuleIdV5 { + pub fn new(address: LegacyAddressV5, name: Identifier) -> Self { + ModuleIdV5 { address, name } + } + + pub fn name(&self) -> &IdentStr { + &self.name + } + + pub fn address(&self) -> &LegacyAddressV5 { + &self.address + } + + pub fn access_vector(&self) -> Vec { + let mut key = vec![CODE_TAG]; + key.append(&mut bcs::to_bytes(self).unwrap()); + key + } +} + +impl Display for ModuleIdV5 { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + write!(f, "{}::{}", self.address, self.name) + } +} + +impl Display for StructTagV5 { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + write!( + f, + "0x{}::{}::{}", + self.address.short_str_lossless(), + self.module, + self.name + )?; + if let Some(first_ty) = self.type_params.first() { + write!(f, "<")?; + write!(f, "{}", first_ty)?; + for ty in self.type_params.iter().skip(1) { + write!(f, ", {}", ty)?; + } + write!(f, ">")?; + } + Ok(()) + } +} + +impl Display for TypeTagV5 { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + match self { + TypeTagV5::Struct(s) => write!(f, "{}", s), + TypeTagV5::Vector(ty) => write!(f, "vector<{}>", ty), + TypeTagV5::U8 => write!(f, "u8"), + TypeTagV5::U64 => write!(f, "u64"), + TypeTagV5::U128 => write!(f, "u128"), + TypeTagV5::Address => write!(f, "address"), + TypeTagV5::Signer => write!(f, "signer"), + TypeTagV5::Bool => write!(f, "bool"), + } + } +} + +impl Display for ResourceKeyV5 { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + write!(f, "0x{}/{}", self.address.short_str_lossless(), self.type_) + } +} + +impl From for TypeTagV5 { + fn from(t: StructTagV5) -> TypeTagV5 { + TypeTagV5::Struct(Box::new(t)) + } +} diff --git a/tools/wallet/src/legacy/legacy_address.rs b/compatibility/src/version_five/legacy_address_v5.rs similarity index 60% rename from tools/wallet/src/legacy/legacy_address.rs rename to compatibility/src/version_five/legacy_address_v5.rs index 1c82c183d..ebd51cdcf 100644 --- a/tools/wallet/src/legacy/legacy_address.rs +++ b/compatibility/src/version_five/legacy_address_v5.rs @@ -3,22 +3,24 @@ // This struct lives here for convenience to use in Genesis where we load // previous data. - // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 - use hex::FromHex; use rand::{rngs::OsRng, Rng}; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; use std::{convert::TryFrom, fmt, str::FromStr}; +pub const LEGACY_CORE_CODE_ADDRESS: LegacyAddressV5 = LegacyAddressV5::new([ + 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, +]); + /// A struct that represents an account address. #[derive(Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)] -// #[cfg_attr(any(test, feature = "fuzzing"), derive(proptest_derive::Arbitrary))] -pub struct LegacyAddress([u8; LegacyAddress::LENGTH]); -impl LegacyAddress { +pub struct LegacyAddressV5([u8; LegacyAddressV5::LENGTH]); + +impl LegacyAddressV5 { pub const fn new(address: [u8; Self::LENGTH]) -> Self { Self(address) } @@ -29,7 +31,7 @@ impl LegacyAddress { /// Hex address: 0x0 pub const ZERO: Self = Self([0u8; Self::LENGTH]); - /// Generates a random LegacyAddress. + /// Generates a random LegacyAddressV5. pub fn random() -> Self { let mut rng = OsRng; let buf: [u8; Self::LENGTH] = rng.gen(); @@ -38,7 +40,7 @@ impl LegacyAddress { /// Returns a shortened hexadecimal string representation of the address without leading zeros. pub fn short_str_lossless(&self) -> String { - let hex_str = hex::encode(&self.0).trim_start_matches('0').to_string(); + let hex_str = hex::encode(self.0).trim_start_matches('0').to_string(); if hex_str.is_empty() { "0".to_string() } else { @@ -56,7 +58,7 @@ impl LegacyAddress { self.0 } - /// Parses a hexadecimal string with an optional "0x" prefix into a LegacyAddress. + /// Parses a hexadecimal string with an optional "0x" prefix into a LegacyAddressV5. pub fn from_hex_literal(literal: &str) -> Result { if !literal.starts_with("0x") { return Err(AccountAddressParseError); @@ -71,9 +73,9 @@ impl LegacyAddress { hex_str.push('0'); } hex_str.push_str(&literal[2..]); - LegacyAddress::from_hex(hex_str) + LegacyAddressV5::from_hex(hex_str) } else { - LegacyAddress::from_hex(&literal[2..]) + LegacyAddressV5::from_hex(&literal[2..]) } } @@ -82,7 +84,7 @@ impl LegacyAddress { format!("0x{}", self.short_str_lossless()) } - /// Parses a hexadecimal string into a LegacyAddress. + /// Parses a hexadecimal string into a LegacyAddressV5. pub fn from_hex>(hex: T) -> Result { <[u8; Self::LENGTH]>::from_hex(hex) .map_err(|_| AccountAddressParseError) @@ -94,7 +96,7 @@ impl LegacyAddress { format!("{:x}", self) } - /// Creates a LegacyAddress from a byte slice. + /// Creates a LegacyAddressV5 from a byte slice. pub fn from_bytes>(bytes: T) -> Result { <[u8; Self::LENGTH]>::try_from(bytes.as_ref()) .map_err(|_| AccountAddressParseError) @@ -102,15 +104,15 @@ impl LegacyAddress { } } -/// Converts the LegacyAddress into a byte slice reference. -impl AsRef<[u8]> for LegacyAddress { +/// Converts the LegacyAddressV5 into a byte slice reference. +impl AsRef<[u8]> for LegacyAddressV5 { fn as_ref(&self) -> &[u8] { &self.0 } } -/// Allows dereferencing the LegacyAddress to a byte array. -impl std::ops::Deref for LegacyAddress { +/// Allows dereferencing the LegacyAddressV5 to a byte array. +impl std::ops::Deref for LegacyAddressV5 { type Target = [u8; Self::LENGTH]; fn deref(&self) -> &Self::Target { @@ -118,23 +120,22 @@ impl std::ops::Deref for LegacyAddress { } } -/// Formats the LegacyAddress as a string. -impl fmt::Display for LegacyAddress { +/// Formats the LegacyAddressV5 as a string. +impl fmt::Display for LegacyAddressV5 { fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { write!(f, "{:X}", self) } } -/// Formats the LegacyAddress for debugging. -impl fmt::Debug for LegacyAddress { +/// Formats the LegacyAddressV5 for debugging. +impl fmt::Debug for LegacyAddressV5 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:X}", self) } } - -/// Formats the LegacyAddress as a lowercase hexadecimal string. -impl fmt::LowerHex for LegacyAddress { +/// Formats the LegacyAddressV5 as a lowercase hexadecimal string. +impl fmt::LowerHex for LegacyAddressV5 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if f.alternate() { write!(f, "0x")?; @@ -148,8 +149,8 @@ impl fmt::LowerHex for LegacyAddress { } } -/// Formats the LegacyAddress as an uppercase hexadecimal string. -impl fmt::UpperHex for LegacyAddress { +/// Formats the LegacyAddressV5 as an uppercase hexadecimal string. +impl fmt::UpperHex for LegacyAddressV5 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if f.alternate() { write!(f, "0x")?; @@ -163,79 +164,79 @@ impl fmt::UpperHex for LegacyAddress { } } -/// Converts a byte array into a LegacyAddress. -impl From<[u8; LegacyAddress::LENGTH]> for LegacyAddress { - fn from(bytes: [u8; LegacyAddress::LENGTH]) -> Self { +/// Converts a byte array into a LegacyAddressV5. +impl From<[u8; LegacyAddressV5::LENGTH]> for LegacyAddressV5 { + fn from(bytes: [u8; LegacyAddressV5::LENGTH]) -> Self { Self::new(bytes) } } -/// Tries to convert a byte slice into a LegacyAddress. -impl TryFrom<&[u8]> for LegacyAddress { +/// Tries to convert a byte slice into a LegacyAddressV5. +impl TryFrom<&[u8]> for LegacyAddressV5 { type Error = AccountAddressParseError; /// Tries to convert the provided byte array into Address. - fn try_from(bytes: &[u8]) -> Result { + fn try_from(bytes: &[u8]) -> Result { Self::from_bytes(bytes) } } -/// Tries to convert a vector of bytes into a LegacyAddress. -impl TryFrom> for LegacyAddress { +/// Tries to convert a vector of bytes into a LegacyAddressV5. +impl TryFrom> for LegacyAddressV5 { type Error = AccountAddressParseError; /// Tries to convert the provided byte buffer into Address. - fn try_from(bytes: Vec) -> Result { + fn try_from(bytes: Vec) -> Result { Self::from_bytes(bytes) } } -/// Converts a LegacyAddress into a vector of bytes. -impl From for Vec { - fn from(addr: LegacyAddress) -> Vec { +/// Converts a LegacyAddressV5 into a vector of bytes. +impl From for Vec { + fn from(addr: LegacyAddressV5) -> Vec { addr.0.to_vec() } } -/// Converts a reference to a LegacyAddress into a vector of bytes. -impl From<&LegacyAddress> for Vec { - fn from(addr: &LegacyAddress) -> Vec { +/// Converts a reference to a LegacyAddressV5 into a vector of bytes. +impl From<&LegacyAddressV5> for Vec { + fn from(addr: &LegacyAddressV5) -> Vec { addr.0.to_vec() } } -/// Converts a LegacyAddress into a byte array. -impl From for [u8; LegacyAddress::LENGTH] { - fn from(addr: LegacyAddress) -> Self { +/// Converts a LegacyAddressV5 into a byte array. +impl From for [u8; LegacyAddressV5::LENGTH] { + fn from(addr: LegacyAddressV5) -> Self { addr.0 } } -/// Converts a reference to a LegacyAddress into a byte array. -impl From<&LegacyAddress> for [u8; LegacyAddress::LENGTH] { - fn from(addr: &LegacyAddress) -> Self { +/// Converts a reference to a LegacyAddressV5 into a byte array. +impl From<&LegacyAddressV5> for [u8; LegacyAddressV5::LENGTH] { + fn from(addr: &LegacyAddressV5) -> Self { addr.0 } } -/// Converts a reference to a LegacyAddress into a hexadecimal string. -impl From<&LegacyAddress> for String { - fn from(addr: &LegacyAddress) -> String { +/// Converts a reference to a LegacyAddressV5 into a hexadecimal string. +impl From<&LegacyAddressV5> for String { + fn from(addr: &LegacyAddressV5) -> String { ::hex::encode(addr.as_ref()) } } -/// Tries to convert a string into a LegacyAddress. -impl TryFrom for LegacyAddress { +/// Tries to convert a string into a LegacyAddressV5. +impl TryFrom for LegacyAddressV5 { type Error = AccountAddressParseError; - fn try_from(s: String) -> Result { + fn try_from(s: String) -> Result { Self::from_hex(s) } } -/// Tries to convert a string slice into a LegacyAddress. -impl FromStr for LegacyAddress { +/// Tries to convert a string slice into a LegacyAddressV5. +impl FromStr for LegacyAddressV5 { type Err = AccountAddressParseError; fn from_str(s: &str) -> Result { @@ -243,31 +244,31 @@ impl FromStr for LegacyAddress { } } -/// Deserialization implementation for LegacyAddress. -impl<'de> Deserialize<'de> for LegacyAddress { +/// Deserialization implementation for LegacyAddressV5. +impl<'de> Deserialize<'de> for LegacyAddressV5 { fn deserialize(deserializer: D) -> std::result::Result where D: Deserializer<'de>, { if deserializer.is_human_readable() { let s = ::deserialize(deserializer)?; - LegacyAddress::from_hex(s).map_err(D::Error::custom) + LegacyAddressV5::from_hex(s).map_err(D::Error::custom) } else { // In order to preserve the Serde data model and help analysis tools, // make sure to wrap our value in a container with the same name // as the original type. #[derive(::serde::Deserialize)] - #[serde(rename = "LegacyAddress")] - struct Value([u8; LegacyAddress::LENGTH]); + #[serde(rename = "LegacyAddressV5")] + struct Value([u8; LegacyAddressV5::LENGTH]); let value = Value::deserialize(deserializer)?; - Ok(LegacyAddress::new(value.0)) + Ok(LegacyAddressV5::new(value.0)) } } } -/// Serialization implementation for LegacyAddress. -impl Serialize for LegacyAddress { +/// Serialization implementation for LegacyAddressV5. +impl Serialize for LegacyAddressV5 { fn serialize(&self, serializer: S) -> std::result::Result where S: Serializer, @@ -276,7 +277,7 @@ impl Serialize for LegacyAddress { self.to_hex().serialize(serializer) } else { // See comment in deserialize. - serializer.serialize_newtype_struct("LegacyAddress", &self.0) + serializer.serialize_newtype_struct("LegacyAddressV5", &self.0) } } } @@ -296,21 +297,21 @@ impl std::error::Error for AccountAddressParseError {} #[cfg(test)] mod tests { - use super::LegacyAddress; + use super::LegacyAddressV5; use hex::FromHex; - use proptest::prelude::*; + // use proptest::prelude::*; use std::{ convert::{AsRef, TryFrom}, str::FromStr, }; - /// Test display implementations for LegacyAddress. + /// Test display implementations for LegacyAddressV5. #[test] fn test_display_impls() { let hex = "ca843279e3427144cead5e4d5999a3d0"; let upper_hex = "CA843279E3427144CEAD5E4D5999A3D0"; - let address = LegacyAddress::from_hex(hex).unwrap(); + let address = LegacyAddressV5::from_hex(hex).unwrap(); assert_eq!(format!("{}", address), upper_hex); assert_eq!(format!("{:?}", address), upper_hex); @@ -321,10 +322,10 @@ mod tests { assert_eq!(format!("{:#X}", address), format!("0x{}", upper_hex)); } - /// Test the short string lossless representation for LegacyAddress. + /// Test the short string lossless representation for LegacyAddressV5. #[test] fn test_short_str_lossless() { - let address = LegacyAddress::from_hex("00c0f1f95c5b1c5f0eda533eff269000").unwrap(); + let address = LegacyAddressV5::from_hex("00c0f1f95c5b1c5f0eda533eff269000").unwrap(); assert_eq!( address.short_str_lossless(), @@ -335,7 +336,7 @@ mod tests { /// Test the short string lossless representation for a zero address. #[test] fn test_short_str_lossless_zero() { - let address = LegacyAddress::from_hex("00000000000000000000000000000000").unwrap(); + let address = LegacyAddressV5::from_hex("00000000000000000000000000000000").unwrap(); assert_eq!(address.short_str_lossless(), "0"); } @@ -348,14 +349,14 @@ mod tests { assert_eq!( bytes.len(), - LegacyAddress::LENGTH as usize, + { LegacyAddressV5::LENGTH }, "Address {:?} is not {}-bytes long. Addresses must be {} bytes", bytes, - LegacyAddress::LENGTH, - LegacyAddress::LENGTH, + LegacyAddressV5::LENGTH, + LegacyAddressV5::LENGTH, ); - let address = LegacyAddress::from_hex(hex).unwrap(); + let address = LegacyAddressV5::from_hex(hex).unwrap(); assert_eq!(address.as_ref().to_vec(), bytes); } @@ -366,22 +367,22 @@ mod tests { let hex_literal = "0x1"; let hex = "00000000000000000000000000000001"; - let address_from_literal = LegacyAddress::from_hex_literal(hex_literal).unwrap(); - let address = LegacyAddress::from_hex(hex).unwrap(); + let address_from_literal = LegacyAddressV5::from_hex_literal(hex_literal).unwrap(); + let address = LegacyAddressV5::from_hex(hex).unwrap(); assert_eq!(address_from_literal, address); assert_eq!(hex_literal, address.to_hex_literal()); // Missing '0x' - LegacyAddress::from_hex_literal(hex).unwrap_err(); + LegacyAddressV5::from_hex_literal(hex).unwrap_err(); // Too long - LegacyAddress::from_hex_literal("0x100000000000000000000000000000001").unwrap_err(); + LegacyAddressV5::from_hex_literal("0x100000000000000000000000000000001").unwrap_err(); } - /// Test reference conversion for LegacyAddress. + /// Test reference conversion for LegacyAddressV5. #[test] fn test_ref() { - let address = LegacyAddress::new([1u8; LegacyAddress::LENGTH]); + let address = LegacyAddressV5::new([1u8; LegacyAddressV5::LENGTH]); let _: &[u8] = address.as_ref(); } @@ -389,29 +390,29 @@ mod tests { #[test] fn test_address_from_proto_invalid_length() { let bytes = vec![1; 123]; - LegacyAddress::from_bytes(bytes).unwrap_err(); + LegacyAddressV5::from_bytes(bytes).unwrap_err(); } - /// Test JSON deserialization for LegacyAddress. + /// Test JSON deserialization for LegacyAddressV5. #[test] fn test_deserialize_from_json_value() { - let address = LegacyAddress::random(); + let address = LegacyAddressV5::random(); let json_value = serde_json::to_value(address).expect("serde_json::to_value fail."); - let address2: LegacyAddress = + let address2: LegacyAddressV5 = serde_json::from_value(json_value).expect("serde_json::from_value fail."); assert_eq!(address, address2) } - /// Test JSON serialization for LegacyAddress. + /// Test JSON serialization for LegacyAddressV5. #[test] fn test_serde_json() { let hex = "ca843279e3427144cead5e4d5999a3d0"; let json_hex = "\"ca843279e3427144cead5e4d5999a3d0\""; - let address = LegacyAddress::from_hex(hex).unwrap(); + let address = LegacyAddressV5::from_hex(hex).unwrap(); let json = serde_json::to_string(&address).unwrap(); - let json_address: LegacyAddress = serde_json::from_str(json_hex).unwrap(); + let json_address: LegacyAddressV5 = serde_json::from_str(json_hex).unwrap(); assert_eq!(json, json_hex); assert_eq!(address, json_address); @@ -420,27 +421,27 @@ mod tests { /// Test error handling for empty string address creation. #[test] fn test_address_from_empty_string() { - assert!(LegacyAddress::try_from("".to_string()).is_err()); - assert!(LegacyAddress::from_str("").is_err()); - } - - proptest! { - - /// Test string roundtrip conversion for LegacyAddress using property-based testing. - #[test] - fn test_address_string_roundtrip(addr in any::()) { - let s = String::from(&addr); - let addr2 = LegacyAddress::try_from(s).expect("roundtrip to string should work"); - prop_assert_eq!(addr, addr2); - } - - /// Test protobuf roundtrip conversion for LegacyAddress using property-based testing. - #[test] - fn test_address_protobuf_roundtrip(addr in any::()) { - let bytes = addr.to_vec(); - prop_assert_eq!(bytes.clone(), addr.as_ref()); - let addr2 = LegacyAddress::try_from(&bytes[..]).unwrap(); - prop_assert_eq!(addr, addr2); - } - } + assert!(LegacyAddressV5::try_from("".to_string()).is_err()); + assert!(LegacyAddressV5::from_str("").is_err()); + } + + // proptest! { + + // /// Test string roundtrip conversion for LegacyAddressV5 using property-based testing. + // #[test] + // fn test_address_string_roundtrip(addr in any::()) { + // let s = String::from(&addr); + // let addr2 = LegacyAddressV5::try_from(s).expect("roundtrip to string should work"); + // prop_assert_eq!(addr, addr2); + // } + + // /// Test protobuf roundtrip conversion for LegacyAddressV5 using property-based testing. + // #[test] + // fn test_address_protobuf_roundtrip(addr in any::()) { + // let bytes = addr.to_vec(); + // prop_assert_eq!(bytes.clone(), addr.as_ref()); + // let addr2 = LegacyAddressV5::try_from(&bytes[..]).unwrap(); + // prop_assert_eq!(addr, addr2); + // } + // } } diff --git a/compatibility/src/version_five/mod.rs b/compatibility/src/version_five/mod.rs new file mode 100644 index 000000000..4799da1c2 --- /dev/null +++ b/compatibility/src/version_five/mod.rs @@ -0,0 +1,30 @@ +pub mod balance_v5; +pub mod core_account_v5; +pub mod diem_account_v5; +pub mod freezing_v5; +pub mod legacy_address_v5; +pub mod module_v5; +pub mod new_epoch_v5; +pub mod ol_ancestry; +pub mod ol_cumulative_deposit; +pub mod ol_receipts; +pub mod ol_tower_state; +pub mod ol_wallet; +pub mod script_v5; +pub mod state_snapshot_v5; +pub mod transaction_argument_v5; +pub mod transaction_manifest_v5; +pub mod transaction_restore_v5; +pub mod transaction_type_v5; +pub mod transaction_view_v5; + +// NOTE: the ones below should likely be private always, +// so that they do not get suggested in the place of +// up-to-date structs of the same name. + +pub mod account_blob_v5; +pub mod event_v5; +pub mod hash_value_v5; +pub mod language_storage_v5; +pub mod move_resource_v5; +pub mod safe_serialize_v5; diff --git a/compatibility/src/version_five/module_v5.rs b/compatibility/src/version_five/module_v5.rs new file mode 100644 index 000000000..bc2e79301 --- /dev/null +++ b/compatibility/src/version_five/module_v5.rs @@ -0,0 +1,83 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use serde::{Deserialize, Serialize}; +use std::fmt; + +#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct Module { + #[serde(with = "serde_bytes")] + code: Vec, +} + +impl Module { + pub fn new(code: Vec) -> Module { + Module { code } + } + + pub fn code(&self) -> &[u8] { + &self.code + } + + pub fn into_inner(self) -> Vec { + self.code + } +} + +impl fmt::Debug for Module { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Module") + .field("code", &hex::encode(&self.code)) + .finish() + } +} + +#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct ModuleBundle { + codes: Vec, +} + +impl ModuleBundle { + pub fn new(codes: Vec>) -> ModuleBundle { + ModuleBundle { + codes: codes.into_iter().map(Module::new).collect(), + } + } + + pub fn singleton(code: Vec) -> ModuleBundle { + ModuleBundle { + codes: vec![Module::new(code)], + } + } + + pub fn into_inner(self) -> Vec> { + self.codes.into_iter().map(Module::into_inner).collect() + } + + pub fn iter(&self) -> impl Iterator { + self.codes.iter() + } +} + +impl fmt::Debug for ModuleBundle { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ModuleBundle") + .field("codes", &self.codes) + .finish() + } +} + +impl From for ModuleBundle { + fn from(m: Module) -> ModuleBundle { + ModuleBundle { codes: vec![m] } + } +} + +impl IntoIterator for ModuleBundle { + type Item = Module; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.codes.into_iter() + } +} diff --git a/compatibility/src/version_five/move_resource_v5.rs b/compatibility/src/version_five/move_resource_v5.rs new file mode 100644 index 000000000..1c90d80db --- /dev/null +++ b/compatibility/src/version_five/move_resource_v5.rs @@ -0,0 +1,42 @@ +// Copyright (c) The Diem Core Contributors +// Copyright (c) The Move Contributors +// SPDX-License-Identifier: Apache-2.0 +use super::{ + language_storage_v5::{StructTagV5, TypeTagV5}, + legacy_address_v5::{LegacyAddressV5, LEGACY_CORE_CODE_ADDRESS}, +}; +use move_core_types::identifier::{IdentStr, Identifier}; +use serde::de::DeserializeOwned; + +pub trait MoveStructTypeV5 { + const ADDRESS: LegacyAddressV5 = LEGACY_CORE_CODE_ADDRESS; + const MODULE_NAME: &'static IdentStr; + const STRUCT_NAME: &'static IdentStr; + + fn module_identifier() -> Identifier { + Self::MODULE_NAME.to_owned() + } + + fn struct_identifier() -> Identifier { + Self::STRUCT_NAME.to_owned() + } + + fn type_params() -> Vec { + vec![] + } + + fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: Self::ADDRESS, + name: Self::struct_identifier(), + module: Self::module_identifier(), + type_params: Self::type_params(), + } + } +} + +pub trait MoveResourceV5: MoveStructTypeV5 + DeserializeOwned { + fn resource_path() -> Vec { + Self::struct_tag().access_vector() + } +} diff --git a/compatibility/src/version_five/new_epoch_v5.rs b/compatibility/src/version_five/new_epoch_v5.rs new file mode 100644 index 000000000..d06c42a38 --- /dev/null +++ b/compatibility/src/version_five/new_epoch_v5.rs @@ -0,0 +1,29 @@ +use crate::version_five::move_resource_v5::MoveStructTypeV5; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +/// Struct that represents a NewEpochEvent. +#[derive(Debug, Serialize, Deserialize)] +pub struct NewEpochEventV5 { + epoch: u64, +} + +impl NewEpochEventV5 { + pub fn new(epoch: u64) -> Self { + NewEpochEventV5 { epoch } + } + + pub fn epoch(&self) -> u64 { + self.epoch + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} + +impl MoveStructTypeV5 for NewEpochEventV5 { + const MODULE_NAME: &'static IdentStr = ident_str!("DiemConfig"); + const STRUCT_NAME: &'static IdentStr = ident_str!("NewEpochEvent"); +} diff --git a/compatibility/src/version_five/ol_ancestry.rs b/compatibility/src/version_five/ol_ancestry.rs new file mode 100644 index 000000000..949fa0282 --- /dev/null +++ b/compatibility/src/version_five/ol_ancestry.rs @@ -0,0 +1,36 @@ +use crate::version_five::{ + language_storage_v5::StructTagV5, move_resource_v5::MoveResourceV5, + move_resource_v5::MoveStructTypeV5, +}; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +use super::{language_storage_v5::CORE_CODE_ADDRESS, legacy_address_v5::LegacyAddressV5}; + +/// Struct that represents a AutoPay resource +#[derive(Debug, Serialize, Deserialize)] +pub struct AncestryResource { + pub tree: Vec, +} + +impl MoveStructTypeV5 for AncestryResource { + const MODULE_NAME: &'static IdentStr = ident_str!("Ancestry"); + const STRUCT_NAME: &'static IdentStr = ident_str!("Ancestry"); +} +impl MoveResourceV5 for AncestryResource {} + +impl AncestryResource { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: AncestryResource::module_identifier(), + name: AncestryResource::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} diff --git a/compatibility/src/version_five/ol_cumulative_deposit.rs b/compatibility/src/version_five/ol_cumulative_deposit.rs new file mode 100644 index 000000000..6907953b3 --- /dev/null +++ b/compatibility/src/version_five/ol_cumulative_deposit.rs @@ -0,0 +1,35 @@ +use crate::version_five::{language_storage_v5::StructTagV5, move_resource_v5::MoveStructTypeV5}; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +use super::{language_storage_v5::CORE_CODE_ADDRESS, move_resource_v5::MoveResourceV5}; + +/// Struct that represents a CurrencyInfo resource +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CumulativeDepositResource { + pub value: u64, + pub index: u64, +} + +impl MoveStructTypeV5 for CumulativeDepositResource { + const MODULE_NAME: &'static IdentStr = ident_str!("DiemAccount"); + const STRUCT_NAME: &'static IdentStr = ident_str!("CumulativeDeposits"); +} + +impl MoveResourceV5 for CumulativeDepositResource {} + +impl CumulativeDepositResource { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: CumulativeDepositResource::module_identifier(), + name: CumulativeDepositResource::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} diff --git a/compatibility/src/version_five/ol_receipts.rs b/compatibility/src/version_five/ol_receipts.rs new file mode 100644 index 000000000..71202d2cc --- /dev/null +++ b/compatibility/src/version_five/ol_receipts.rs @@ -0,0 +1,40 @@ +use crate::version_five::{language_storage_v5::StructTagV5, move_resource_v5::MoveStructTypeV5}; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +use super::{ + language_storage_v5::CORE_CODE_ADDRESS, legacy_address_v5::LegacyAddressV5, + move_resource_v5::MoveResourceV5, +}; + +/// Struct that represents a CurrencyInfo resource +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ReceiptsResource { + pub destination: Vec, + pub cumulative: Vec, + pub last_payment_timestamp: Vec, + pub last_payment_value: Vec, +} + +impl MoveStructTypeV5 for ReceiptsResource { + const MODULE_NAME: &'static IdentStr = ident_str!("Receipts"); + const STRUCT_NAME: &'static IdentStr = ident_str!("UserReceipts"); +} + +impl MoveResourceV5 for ReceiptsResource {} + +impl ReceiptsResource { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: ReceiptsResource::module_identifier(), + name: ReceiptsResource::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} diff --git a/compatibility/src/version_five/ol_tower_state.rs b/compatibility/src/version_five/ol_tower_state.rs new file mode 100644 index 000000000..3361128d1 --- /dev/null +++ b/compatibility/src/version_five/ol_tower_state.rs @@ -0,0 +1,39 @@ +use crate::version_five::{language_storage_v5::StructTagV5, move_resource_v5::MoveStructTypeV5}; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +use super::{language_storage_v5::CORE_CODE_ADDRESS, move_resource_v5::MoveResourceV5}; +/// Struct that represents a CurrencyInfo resource +#[derive(Debug, Serialize, Deserialize)] +pub struct TowerStateResource { + pub previous_proof_hash: Vec, + /// user's latest verified_tower_height + pub verified_tower_height: u64, + pub latest_epoch_mining: u64, + pub count_proofs_in_epoch: u64, + pub epochs_validating_and_mining: u64, + pub contiguous_epochs_validating_and_mining: u64, + pub epochs_since_last_account_creation: u64, +} + +impl MoveStructTypeV5 for TowerStateResource { + const MODULE_NAME: &'static IdentStr = ident_str!("TowerState"); + const STRUCT_NAME: &'static IdentStr = ident_str!("TowerProofHistory"); +} +impl MoveResourceV5 for TowerStateResource {} + +impl TowerStateResource { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: TowerStateResource::module_identifier(), + name: TowerStateResource::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} diff --git a/compatibility/src/version_five/ol_wallet.rs b/compatibility/src/version_five/ol_wallet.rs new file mode 100644 index 000000000..2b86e245b --- /dev/null +++ b/compatibility/src/version_five/ol_wallet.rs @@ -0,0 +1,93 @@ +use crate::version_five::{language_storage_v5::StructTagV5, move_resource_v5::MoveStructTypeV5}; +use anyhow::Result; +use move_core_types::{ident_str, identifier::IdentStr}; +use serde::{Deserialize, Serialize}; + +use super::{ + language_storage_v5::CORE_CODE_ADDRESS, legacy_address_v5::LegacyAddressV5, + move_resource_v5::MoveResourceV5, +}; + +// NOTE: these are legacy structs for v5 + +/// Struct that represents a CommunityWallet resource +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CommunityWalletsResourceLegacyV5 { + /// List + pub list: Vec, +} + +impl MoveStructTypeV5 for CommunityWalletsResourceLegacyV5 { + const MODULE_NAME: &'static IdentStr = ident_str!("Wallet"); + const STRUCT_NAME: &'static IdentStr = ident_str!("CommunityWalletList"); +} + +impl CommunityWalletsResourceLegacyV5 { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: CommunityWalletsResourceLegacyV5::module_identifier(), + name: CommunityWalletsResourceLegacyV5::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} + +/// Struct that represents a SlowWallet resource +#[derive(Debug, Serialize, Deserialize)] +pub struct SlowWalletResourceV5 { + pub unlocked: u64, + pub transferred: u64, +} + +impl MoveStructTypeV5 for SlowWalletResourceV5 { + const MODULE_NAME: &'static IdentStr = ident_str!("DiemAccount"); + const STRUCT_NAME: &'static IdentStr = ident_str!("SlowWallet"); +} + +impl MoveResourceV5 for SlowWalletResourceV5 {} + +impl SlowWalletResourceV5 { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: SlowWalletResourceV5::module_identifier(), + name: SlowWalletResourceV5::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} + +/// Struct that represents a SlowWallet resource +#[derive(Debug, Serialize, Deserialize)] +pub struct SlowWalletListResourceV5 { + pub list: Vec, +} + +impl MoveStructTypeV5 for SlowWalletListResourceV5 { + const MODULE_NAME: &'static IdentStr = ident_str!("DiemAccount"); + const STRUCT_NAME: &'static IdentStr = ident_str!("SlowWalletList"); +} + +impl SlowWalletListResourceV5 { + pub fn struct_tag() -> StructTagV5 { + StructTagV5 { + address: CORE_CODE_ADDRESS, + module: SlowWalletListResourceV5::module_identifier(), + name: SlowWalletListResourceV5::struct_identifier(), + type_params: vec![], + } + } + + pub fn try_from_bytes(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} diff --git a/compatibility/src/version_five/safe_serialize_v5.rs b/compatibility/src/version_five/safe_serialize_v5.rs new file mode 100644 index 000000000..ecec9c75f --- /dev/null +++ b/compatibility/src/version_five/safe_serialize_v5.rs @@ -0,0 +1,69 @@ +// Copyright (c) The Diem Core Contributors +// Copyright (c) The Move Contributors +// SPDX-License-Identifier: Apache-2.0 + +//! Custom serializers which track recursion nesting with a thread local, +//! and otherwise delegate to the derived serializers. +//! +//! This is currently only implemented for type tags, but can be easily +//! generalized, as the the only type-tag specific thing is the allowed nesting. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::cell::RefCell; + +pub(crate) const MAX_TYPE_TAG_NESTING: u8 = 9; + +thread_local! { + static TYPE_TAG_DEPTH: RefCell = const { RefCell::new(0) }; +} + +pub(crate) fn type_tag_recursive_serialize(t: &T, s: S) -> Result +where + S: Serializer, + T: Serialize, +{ + use serde::ser::Error; + + TYPE_TAG_DEPTH.with(|depth| { + let mut r = depth.borrow_mut(); + if *r >= MAX_TYPE_TAG_NESTING { + // for testability, we allow one level more + return Err(S::Error::custom( + "type tag nesting exceeded during serialization", + )); + } + *r += 1; + Ok(()) + })?; + let res = t.serialize(s); + TYPE_TAG_DEPTH.with(|depth| { + let mut r = depth.borrow_mut(); + *r -= 1; + }); + res +} + +pub(crate) fn type_tag_recursive_deserialize<'de, D, T>(d: D) -> Result +where + D: Deserializer<'de>, + T: Deserialize<'de>, +{ + use serde::de::Error; + TYPE_TAG_DEPTH.with(|depth| { + let mut r = depth.borrow_mut(); + // For testability, we allow to serialize one more level than deserialize. + if *r >= MAX_TYPE_TAG_NESTING - 1 { + return Err(D::Error::custom( + "type tag nesting exceeded during deserialization", + )); + } + *r += 1; + Ok(()) + })?; + let res = T::deserialize(d); + TYPE_TAG_DEPTH.with(|depth| { + let mut r = depth.borrow_mut(); + *r -= 1; + }); + res +} diff --git a/compatibility/src/version_five/script_v5.rs b/compatibility/src/version_five/script_v5.rs new file mode 100644 index 000000000..8928bccd6 --- /dev/null +++ b/compatibility/src/version_five/script_v5.rs @@ -0,0 +1,289 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use super::{ + language_storage_v5::{ModuleIdV5 as ModuleId, TypeTagV5 as TypeTag}, + transaction_argument_v5::TransactionArgument, +}; +use diem_types::serde_helper::vec_bytes; +use move_core_types::identifier::{IdentStr, Identifier}; +use serde::{Deserialize, Serialize}; +use std::fmt; + +/// Call a Move script. +#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct Script { + #[serde(with = "serde_bytes")] + code: Vec, + ty_args: Vec, + args: Vec, +} + +impl Script { + pub fn new(code: Vec, ty_args: Vec, args: Vec) -> Self { + Script { + code, + ty_args, + args, + } + } + + pub fn code(&self) -> &[u8] { + &self.code + } + + pub fn ty_args(&self) -> &[TypeTag] { + &self.ty_args + } + + pub fn args(&self) -> &[TransactionArgument] { + &self.args + } + + pub fn into_inner(self) -> (Vec, Vec) { + (self.code, self.args) + } +} + +impl fmt::Debug for Script { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Script") + .field("code", &hex::encode(&self.code)) + .field("ty_args", &self.ty_args) + .field("args", &self.args) + .finish() + } +} + +/// How to call a particular Move script (aka. an "ABI"). +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub enum ScriptABI { + TransactionScript(TransactionScriptABI), + ScriptFunction(ScriptFunctionABI), +} + +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct ScriptFunctionABI { + /// The public name of the script. + name: String, + /// The module name where the script lives. + module_name: ModuleId, + /// Some text comment. + doc: String, + /// The names of the type arguments. + ty_args: Vec, + /// The description of regular arguments. + args: Vec, +} + +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct TransactionScriptABI { + /// The public name of the script. + name: String, + /// Some text comment. + doc: String, + /// The `code` value to set in the `Script` object. + #[serde(with = "serde_bytes")] + code: Vec, + /// The names of the type arguments. + ty_args: Vec, + /// The description of regular arguments. + args: Vec, +} + +/// The description of a (regular) argument in a script. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct ArgumentABI { + /// The name of the argument. + name: String, + /// The expected type. + /// In Move scripts, this does contain generics type parameters. + type_tag: TypeTag, +} + +/// The description of a type argument in a script. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct TypeArgumentABI { + /// The name of the argument. + name: String, +} + +impl TransactionScriptABI { + pub fn new( + name: String, + doc: String, + code: Vec, + ty_args: Vec, + args: Vec, + ) -> Self { + Self { + name, + doc, + code, + ty_args, + args, + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn doc(&self) -> &str { + &self.doc + } + + pub fn code(&self) -> &[u8] { + &self.code + } + + pub fn ty_args(&self) -> &[TypeArgumentABI] { + &self.ty_args + } + + pub fn args(&self) -> &[ArgumentABI] { + &self.args + } +} + +impl ScriptFunctionABI { + pub fn new( + name: String, + module_name: ModuleId, + doc: String, + ty_args: Vec, + args: Vec, + ) -> Self { + Self { + name, + module_name, + doc, + ty_args, + args, + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn module_name(&self) -> &ModuleId { + &self.module_name + } + + pub fn doc(&self) -> &str { + &self.doc + } + + pub fn ty_args(&self) -> &[TypeArgumentABI] { + &self.ty_args + } + + pub fn args(&self) -> &[ArgumentABI] { + &self.args + } +} + +impl ScriptABI { + pub fn is_script_fun_abi(&self) -> bool { + matches!(self, Self::ScriptFunction(_)) + } + + pub fn is_transaction_script_abi(&self) -> bool { + matches!(self, Self::TransactionScript(_)) + } + + pub fn name(&self) -> &str { + match self { + Self::TransactionScript(abi) => abi.name(), + Self::ScriptFunction(abi) => abi.name(), + } + } + + pub fn doc(&self) -> &str { + match self { + Self::TransactionScript(abi) => abi.doc(), + Self::ScriptFunction(abi) => abi.doc(), + } + } + + pub fn ty_args(&self) -> &[TypeArgumentABI] { + match self { + Self::TransactionScript(abi) => abi.ty_args(), + Self::ScriptFunction(abi) => abi.ty_args(), + } + } + + pub fn args(&self) -> &[ArgumentABI] { + match self { + Self::TransactionScript(abi) => abi.args(), + Self::ScriptFunction(abi) => abi.args(), + } + } +} + +impl ArgumentABI { + pub fn new(name: String, type_tag: TypeTag) -> Self { + Self { name, type_tag } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn type_tag(&self) -> &TypeTag { + &self.type_tag + } +} + +impl TypeArgumentABI { + pub fn new(name: String) -> Self { + Self { name } + } + + pub fn name(&self) -> &str { + &self.name + } +} + +/// Call a Move script function. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub struct ScriptFunction { + module: ModuleId, + function: Identifier, + ty_args: Vec, + #[serde(with = "vec_bytes")] + args: Vec>, +} + +impl ScriptFunction { + pub fn new( + module: ModuleId, + function: Identifier, + ty_args: Vec, + args: Vec>, + ) -> Self { + ScriptFunction { + module, + function, + ty_args, + args, + } + } + + pub fn module(&self) -> &ModuleId { + &self.module + } + + pub fn function(&self) -> &IdentStr { + &self.function + } + + pub fn ty_args(&self) -> &[TypeTag] { + &self.ty_args + } + + pub fn args(&self) -> &[Vec] { + &self.args + } +} diff --git a/compatibility/src/version_five/state_snapshot_v5.rs b/compatibility/src/version_five/state_snapshot_v5.rs new file mode 100644 index 000000000..8849bc12f --- /dev/null +++ b/compatibility/src/version_five/state_snapshot_v5.rs @@ -0,0 +1,230 @@ +//! read-archive + +use crate::version_five::{account_blob_v5::AccountStateBlob, hash_value_v5::HashValueV5}; + +use anyhow::{anyhow, Context, Error, Result}; +use diem_backup_cli::{ + backup_types::state_snapshot::manifest::StateSnapshotChunk, + storage::{FileHandle, FileHandleRef}, + utils::read_record_bytes::ReadRecordBytes, +}; +use diem_types::transaction::Version; +use serde::{Deserialize, Serialize}; +use std::path::Path; +use tokio::{fs::OpenOptions, io::AsyncRead}; + +#[derive(Deserialize, Serialize)] +pub struct StateSnapshotBackupV5 { + /// Version at which this state snapshot is taken. + pub version: Version, + /// Hash of the state tree root. + pub root_hash: HashValueV5, + /// All account blobs in chunks. + pub chunks: Vec, + /// BCS serialized + /// `Tuple(TransactionInfoWithProof, LedgerInfoWithSignatures)`. + /// - The `TransactionInfoWithProof` is at `Version` above, and carries the same `root_hash` + /// above; It proves that at specified version the root hash is as specified in a chain + /// represented by the LedgerInfo below. + /// - The signatures on the `LedgerInfoWithSignatures` has a version greater than or equal to + /// the version of this backup but is within the same epoch, so the signatures on it can be + /// verified by the validator set in the same epoch, which can be provided by an + /// `EpochStateBackup` recovered prior to this to the DB; Requiring it to be in the same epoch + /// limits the requirement on such `EpochStateBackup` to no older than the same epoch. + pub proof: FileHandle, +} + +/// The tuple in which all account bytes are stored as +/// All backup records are stored with the data byte length. See ReadRecordBytes. +/// An account's on-chain bytes are represented in storage files as an AccountStateBlob. However, the chunks are stored with a tuple of HashValue of the bytes prior to they bytes themselves. +// NOTE: Paradoxically the data layout of the AccountStateBlob also has a `hash` field, but this one is not serialized. Unclear why the tuple is needed when the blob could have been de/serialized fully. Alas. + +#[derive(Clone, Deserialize, Serialize)] +pub struct AccountStateBlobRecord(HashValueV5, AccountStateBlob); + +////// SNAPSHOT FILE IO ////// +/// read snapshot manifest file into struct +pub fn v5_read_from_snapshot_manifest(path: &Path) -> Result { + let config = std::fs::read_to_string(path).map_err(|e| { + format!("Error: cannot read file {:?}, error: {:?}", &path, &e); + e + })?; + + let map: StateSnapshotBackupV5 = serde_json::from_str(&config)?; + + Ok(map) +} + +/// parse each chunk of a state snapshot manifest +pub async fn read_account_state_chunk( + file_handle: FileHandle, + archive_path: &Path, +) -> Result, Error> { + let full_handle = archive_path + .parent() + .expect("could not read archive path") + .join(file_handle); + let handle_str = full_handle.to_str().unwrap(); + assert!(full_handle.exists(), "file does not exist"); + + let mut file = open_for_read(handle_str) + .await + .map_err(|e| anyhow!("snapshot chunk {:?}, {:?}", &handle_str, e))?; + + let mut chunk = vec![]; + + while let Some(record_bytes) = file.read_record_bytes().await? { + let bcs = bcs::from_bytes(&record_bytes).context("could not deserialize bcs chunk")?; + chunk.push(bcs); + } + Ok(chunk) +} + +pub async fn open_for_read( + file_handle: &FileHandleRef, +) -> Result> { + let file = OpenOptions::new().read(true).open(file_handle).await?; + Ok(Box::new(file)) +} + +/// Tokio async parsing of state snapshot into blob +pub async fn v5_accounts_from_snapshot_backup( + manifest: StateSnapshotBackupV5, + archive_path: &Path, +) -> Result, Error> { + // parse AccountStateBlob from chunks of the archive + let mut account_state_blobs: Vec = Vec::new(); + + for chunk in manifest.chunks { + let records = read_account_state_chunk(chunk.blobs, archive_path).await?; + + for rec in records { + account_state_blobs.push(rec.1) + } + } + + Ok(account_state_blobs) +} + +/// one step extraction of account state blobs from a manifest path +pub async fn v5_accounts_from_manifest_path(manifest_file: &Path) -> Result> { + let archive_path = manifest_file + .parent() + .context("could not get archive path from manifest file")?; + let manifest = v5_read_from_snapshot_manifest(manifest_file)?; + v5_accounts_from_snapshot_backup(manifest, archive_path).await +} + +#[test] +fn decode_record_from_string() { + use super::account_blob_v5::AccountStateV5; + use super::balance_v5::BalanceResourceV5; + use super::freezing_v5::FreezingBit; + + let bytes = b" \0\x03Z|\x96)\xb7\xe5.\x94\xdee\xe6\xa8\x92p\x1f\xe2\x83Q\x18d\x05\xbe\x96\xed#\xf4\xb1%/z\xd4\x03\x06\x1f\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x05Roles\x06RoleId\0\x08\n\0\0\0\0\0\0\0(\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x08Receipts\x0cUserReceipts\0\x04\0\0\0\0*\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x0bDiemAccount\x0bDiemAccount\0\x8d\x01 \x89EP$\xb0\xc9\x15|ja\x03\xaf-\xb4\x98\xf4\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b\x01\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b\x01\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b\x01\0\0\0\0\0\0\0\x18\0\0\0\0\0\0\0\0\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b\0\0\0\0\0\0\0\0\x18\x01\0\0\0\0\0\0\0\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b\0\0\0\0\0\0\0\0-\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x05Event\x14EventHandleGenerator\0\x18\x02\0\0\0\0\0\0\0\xc4\x8f\xd6\xf9\x82\x92\xda3\xb1\x1cHx\xb3m\xde\x1b.\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x0fAccountFreezing\x0bFreezingBit\0\x01\0@\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x0bDiemAccount\x07Balance\x01\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x03GAS\x03GAS\0\x08@B\x0f\0\0\0\0\0"; + + let (_h, b): (HashValueV5, AccountStateBlob) = bcs::from_bytes(bytes).expect("cant decode"); + + let acc_state: AccountStateV5 = bcs::from_bytes(&b.blob).unwrap(); + + // We should be able to get the resource directly using a method on AccountStateV5. + // Among other things, a FreezingBit resource would be found on a backup + // record. Note it is the simplest structure did not use an AccountAddress + // for example, which makes it easier to check. + + let s = acc_state.get_resource::().unwrap(); + assert!(!s.is_frozen()); + + // Sanity check that our access_path_vector we generate + // can be used to access a value in the K-V store + // NOTE: this is a complex access path because it involves a Struct with a Generic. i.e. a StructTag with a TypeTag. + let balance_key = hex::decode("01000000000000000000000000000000010b4469656d4163636f756e740742616c616e6365010700000000000000000000000000000001034741530347415300").unwrap(); + let b = acc_state.0.get(&balance_key).unwrap(); + assert!(!b.is_empty()); + + // also check that a simple BalanceResource can be found in the bytes + let res: BalanceResourceV5 = bcs::from_bytes(b).unwrap(); + assert!(res.coin() == 1000000); + + // Finally a DiemAccount resource should be found in this payload. + // This is the most complex structure, since involves some + // nested types like EventHandle and WithdrawCapability + let ar = acc_state.get_account_resource().unwrap(); + assert!(ar.sequence_number() == 0); + + let address = ar.address(); + assert!(address.len() > 0); +} + +#[test] +fn sanity_test_bcs() { + use serde::{Deserialize, Serialize}; + + #[derive(Debug, Deserialize, Serialize)] + struct Ip([u8; 4]); + + #[derive(Debug, Deserialize, Serialize)] + struct Port(u16); + + #[derive(Debug, Deserialize, Serialize)] + struct SocketAddr { + ip: Ip, + port: Port, + } + + let s = SocketAddr { + ip: Ip([127, 0, 0, 1]), + port: Port(8001), + }; + let b = bcs::to_bytes(&s).unwrap(); + dbg!(&b); + let expected_bytes = vec![0x7f, 0x00, 0x00, 0x01, 0x41, 0x1f]; + + assert!(b == expected_bytes, "not match"); + + let socket_addr: SocketAddr = bcs::from_bytes(&expected_bytes).unwrap(); + + dbg!(&socket_addr); + + assert_eq!(socket_addr.ip.0, [127, 0, 0, 1]); + assert_eq!(socket_addr.port.0, 8001); +} + +#[test] +fn decode_encode_v5_struct_tag() { + use super::language_storage_v5::StructTagV5; + use super::legacy_address_v5::LEGACY_CORE_CODE_ADDRESS; + use move_core_types::ident_str; + let s = StructTagV5 { + address: LEGACY_CORE_CODE_ADDRESS, + module: ident_str!("DiemAccount").into(), + name: ident_str!("DiemAccount").into(), + type_params: vec![], + }; + + let bytes = bcs::to_bytes(&s).unwrap(); + let h = hex::encode(bytes); + dbg!(&h); + + let expected_key = + "000000000000000000000000000000010b4469656d4163636f756e740b4469656d4163636f756e7400"; + + assert!(expected_key == h); + + let patch_expected_key = + "01000000000000000000000000000000010b4469656d4163636f756e740b4469656d4163636f756e7400"; + // lookup will fail unless it's using the access_vector() bit + // "resource keys" have prepended 01 + assert!(hex::encode(s.access_vector()) == patch_expected_key); +} + +#[test] +fn nested_generic_structs() { + use crate::version_five::balance_v5::BalanceResourceV5; + use crate::version_five::move_resource_v5::MoveStructTypeV5; + // This is the balance resource access_path as vector in storage + let balance_key = hex::decode("01000000000000000000000000000000010b4469656d4163636f756e740742616c616e6365010700000000000000000000000000000001034741530347415300").unwrap(); + + let vec = BalanceResourceV5::struct_tag().access_vector(); + assert!(balance_key == vec); +} diff --git a/compatibility/src/version_five/transaction_argument_v5.rs b/compatibility/src/version_five/transaction_argument_v5.rs new file mode 100644 index 000000000..654517c68 --- /dev/null +++ b/compatibility/src/version_five/transaction_argument_v5.rs @@ -0,0 +1,60 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use super::legacy_address_v5::LegacyAddressV5 as AccountAddress; + +use serde::{Deserialize, Serialize}; +use std::fmt; + +#[derive(Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub enum TransactionArgument { + U8(u8), + U64(u64), + U128(u128), + Address(AccountAddress), + U8Vector(#[serde(with = "serde_bytes")] Vec), + //TODO(0L): AddressVector is not implemented anywhere. Though there were plans to include this in tx scripts. + AddressVector(Vec), //////// 0L //////// + Bool(bool), +} + +impl fmt::Debug for TransactionArgument { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + TransactionArgument::U8(value) => write!(f, "{{U8: {}}}", value), + TransactionArgument::U64(value) => write!(f, "{{U64: {}}}", value), + TransactionArgument::U128(value) => write!(f, "{{U128: {}}}", value), + TransactionArgument::Bool(boolean) => write!(f, "{{BOOL: {}}}", boolean), + TransactionArgument::Address(address) => write!(f, "{{ADDRESS: {:?}}}", address), + TransactionArgument::U8Vector(vector) => { + write!(f, "{{U8Vector: 0x{}}}", hex::encode(vector)) + } + //////// 0L //////// + TransactionArgument::AddressVector(vector) => { + write!(f, "{{AddressVector: {:?}}}", vector) + } + } + } +} + +// TODO no need to encode bytes in the compatibility library + +// /// Convert the transaction arguments into Move values. +// pub fn convert_txn_args(args: &[TransactionArgument]) -> Vec> { +// args.iter() +// .map(|arg| { +// let mv = match arg { +// TransactionArgument::U8(i) => MoveValue::U8(*i), +// TransactionArgument::U64(i) => MoveValue::U64(*i), +// TransactionArgument::U128(i) => MoveValue::U128(*i), +// TransactionArgument::Address(a) => MoveValue::Address(*a), +// TransactionArgument::Bool(b) => MoveValue::Bool(*b), +// TransactionArgument::U8Vector(v) => MoveValue::vector_u8(v.clone()), +// //////// 0L //////// +// TransactionArgument::AddressVector(v) => MoveValue::vector_address(v.clone()), +// }; +// mv.simple_serialize() +// .expect("transaction arguments must serialize") +// }) +// .collect() +// } diff --git a/compatibility/src/version_five/transaction_manifest_v5.rs b/compatibility/src/version_five/transaction_manifest_v5.rs new file mode 100644 index 000000000..7a35ec535 --- /dev/null +++ b/compatibility/src/version_five/transaction_manifest_v5.rs @@ -0,0 +1,89 @@ +// Copyright (c) The Diem Core Contributors +// SPDX-License-Identifier: Apache-2.0 +use anyhow::{ensure, Result}; +use diem_backup_cli::storage::FileHandle; +use diem_types::transaction::Version; +use serde::{Deserialize, Serialize}; +use std::path::Path; + +/// A chunk of a transaction backup manifest to represent the +/// [`first_version`, `last_version`] range (right side inclusive). +#[derive(Clone, Deserialize, Serialize)] +// NOTE: this is a sub-manifest, listing the component parts of each file chunk. +pub struct TransactionChunk { + pub first_version: Version, + pub last_version: Version, + /// Repeated `len(record) + record`, where `record` is BCS serialized tuple + /// `(Transaction, TransactionInfo)` + pub transactions: FileHandle, + /// BCS serialized `(TransactionAccumulatorRangeProof, LedgerInfoWithSignatures)`. + /// The `TransactionAccumulatorRangeProof` links the transactions to the + /// `LedgerInfoWithSignatures`, and the `LedgerInfoWithSignatures` can be verified by the + /// signatures it carries, against the validator set in the epoch. (Hence proper + /// `EpochEndingBackup` is needed for verification.) + pub proof: FileHandle, +} + +/// Transaction backup manifest, representing transactions in the +/// [`first_version`, `last_version`] range (right side inclusive). +#[derive(Deserialize, Serialize)] +pub struct TransactionBackup { + pub first_version: Version, + pub last_version: Version, + pub chunks: Vec, +} + +impl TransactionBackup { + pub fn verify(&self) -> Result<()> { + // check number of waypoints + ensure!( + self.first_version <= self.last_version, + "Bad version range: [{}, {}]", + self.first_version, + self.last_version, + ); + + // check chunk ranges + ensure!(!self.chunks.is_empty(), "No chunks."); + + let mut next_version = self.first_version; + for chunk in &self.chunks { + ensure!( + chunk.first_version == next_version, + "Chunk ranges not continuous. Expected first version: {}, actual: {}.", + next_version, + chunk.first_version, + ); + ensure!( + chunk.last_version >= chunk.first_version, + "Chunk range invalid. [{}, {}]", + chunk.first_version, + chunk.last_version, + ); + next_version = chunk.last_version + 1; + } + + // check last version in chunk matches manifest + ensure!( + next_version - 1 == self.last_version, // okay to -1 because chunks is not empty. + "Last version in chunks: {}, in manifest: {}", + next_version - 1, + self.last_version, + ); + + Ok(()) + } +} + +////// TX FILES IO ////// +/// read tx manifest file into struct +pub fn v5_read_from_transaction_manifest(path: &Path) -> Result { + let config = std::fs::read_to_string(path).map_err(|e| { + format!("Error: cannot read file {:?}, error: {:?}", &path, &e); + e + })?; + + let map: TransactionBackup = serde_json::from_str(&config)?; + + Ok(map) +} diff --git a/compatibility/src/version_five/transaction_restore_v5.rs b/compatibility/src/version_five/transaction_restore_v5.rs new file mode 100644 index 000000000..93068b39e --- /dev/null +++ b/compatibility/src/version_five/transaction_restore_v5.rs @@ -0,0 +1,42 @@ +use crate::version_five::state_snapshot_v5::open_for_read; +use crate::version_five::transaction_type_v5::ContractEventV5; +use crate::version_five::transaction_type_v5::TransactionInfoV5; +use crate::version_five::transaction_type_v5::TransactionV5; +use std::path::Path; + +use anyhow::{anyhow, Result}; + +use diem_backup_cli::storage::FileHandle; +use diem_backup_cli::utils::read_record_bytes::ReadRecordBytes; +use serde::{Deserialize, Serialize}; + +/// Byte layout for the transaction records produced by backup-cli +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct TxRecord(TransactionV5, TransactionInfoV5, Vec); + +/// parse each chunk of a state snapshot manifest +pub async fn read_transaction_chunk( + file_handle: &FileHandle, + archive_path: &Path, +) -> Result> { + let full_handle = archive_path + .parent() + .expect("could not read archive path") + .join(file_handle); + let handle_str = full_handle.to_str().unwrap(); + assert!(full_handle.exists(), "file does not exist"); + + let mut file = open_for_read(handle_str) + .await + .map_err(|e| anyhow!("transaction chunk {:?}, {:?}", &handle_str, e))?; + + let mut txns = vec![]; + while let Some(record_bytes) = file.read_record_bytes().await? { + let txn: TxRecord = bcs::from_bytes(&record_bytes)?; + dbg!(&txn.0); + dbg!(&txn.1); + // dbg!(&txn.2); + txns.push(txn); + } + Ok(txns) +} diff --git a/compatibility/src/version_five/transaction_type_v5.rs b/compatibility/src/version_five/transaction_type_v5.rs new file mode 100644 index 000000000..3fd9142ae --- /dev/null +++ b/compatibility/src/version_five/transaction_type_v5.rs @@ -0,0 +1,227 @@ +use crate::version_five::{ + event_v5::EventKeyV5, + hash_value_v5::HashValueV5, + language_storage_v5::{ModuleIdV5, TypeTagV5}, + legacy_address_v5::LegacyAddressV5, + module_v5::ModuleBundle, + script_v5::Script, +}; + +use diem_crypto::{ + ed25519::{Ed25519PublicKey, Ed25519Signature}, + multi_ed25519::{MultiEd25519PublicKey, MultiEd25519Signature}, +}; + +use diem_types::transaction::ChangeSet; + +use diem_types::{chain_id::ChainId, transaction::authenticator::AccountAuthenticator}; +use serde::{Deserialize, Serialize}; + +use super::script_v5::ScriptFunction; + +#[allow(clippy::large_enum_variant)] +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum TransactionV5 { + /// Transaction submitted by the user. e.g: P2P payment transaction, publishing module + /// transaction, etc. + /// TODO: We need to rename SignedTransaction to SignedUserTransaction, as well as all the other + /// transaction types we had in our codebase. + UserTransaction(SignedTransaction), + + /// Transaction that applies a WriteSet to the current storage, it's applied manually via db-bootstrapper. + GenesisTransaction(WriteSetPayload), + + /// Transaction to update the block metadata resource at the beginning of a block. + BlockMetadata(BlockMetadata), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SignedTransaction { + /// The raw transaction + pub raw_txn: RawTransaction, + + /// Public key and signature to authenticate + pub authenticator: TransactionAuthenticator, +} + +/// Two different kinds of WriteSet transactions. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub enum WriteSetPayload { + /// Directly passing in the WriteSet. + Direct(ChangeSet), + /// Generate the WriteSet by running a script. + Script { + /// Execute the script as the designated signer. + execute_as: LegacyAddressV5, + /// Script body that gets executed. + script: Script, + }, +} + +impl WriteSetPayload { + pub fn should_trigger_reconfiguration_by_default(&self) -> bool { + match self { + Self::Direct(_) => true, + Self::Script { .. } => false, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct BlockMetadata { + id: HashValueV5, + round: u64, + timestamp_usecs: u64, + // The vector has to be sorted to ensure consistent result among all nodes + previous_block_votes: Vec, + proposer: LegacyAddressV5, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct TransactionInfoV5 { + /// The hash of this transaction. + transaction_hash: HashValueV5, + + /// The root hash of Sparse Merkle Tree describing the world state at the end of this + /// transaction. + state_root_hash: HashValueV5, + + /// The root hash of Merkle Accumulator storing all events emitted during this transaction. + event_root_hash: HashValueV5, + + /// The amount of gas used. + gas_used: u64, + + /// The vm status. If it is not `Executed`, this will provide the general error class. Execution + /// failures and Move abort's recieve more detailed information. But other errors are generally + /// categorized with no status code or other information + status: KeptVMStatus, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +enum KeptVMStatus { + Executed, + OutOfGas, + MoveAbort(AbortLocation, /* code */ u64), + ExecutionFailure { + location: AbortLocation, + function: u16, + code_offset: u16, + }, + MiscellaneousError, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum AbortLocation { + /// Indicates `abort` occurred in the specified module + Module(ModuleIdV5), + /// Indicates the `abort` occurred in a script + Script, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RawTransaction { + /// Sender's address. + pub sender: LegacyAddressV5, + + /// Sequence number of this transaction. This must match the sequence number + /// stored in the sender's account at the time the transaction executes. + pub sequence_number: u64, + + /// The transaction payload, e.g., a script to execute. + pub payload: TransactionPayload, + + /// Maximal total gas to spend for this transaction. + pub max_gas_amount: u64, + + /// Price to be paid per gas unit. + pub gas_unit_price: u64, + + /// The currency code, e.g., "XUS", used to pay for gas. The `max_gas_amount` + /// and `gas_unit_price` values refer to units of this currency. + pub gas_currency_code: String, + + /// Expiration timestamp for this transaction, represented + /// as seconds from the Unix Epoch. If the current blockchain timestamp + /// is greater than or equal to this time, then the transaction has + /// expired and will be discarded. This can be set to a large value far + /// in the future to indicate that a transaction does not expire. + pub expiration_timestamp_secs: u64, + + /// Chain ID of the Diem network this transaction is intended for. + pub chain_id: ChainId, +} + +impl RawTransaction { + pub fn into_payload(self) -> TransactionPayload { + self.payload + } +} + +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub enum TransactionPayload { + /// A system maintenance transaction. + WriteSet(WriteSetPayload), + /// A transaction that executes code. + Script(Script), + /// A transaction that publishes multiple modules at the same time. + ModuleBundle(ModuleBundle), + /// A transaction that executes an existing script function published on-chain. + ScriptFunction(ScriptFunction), +} + +impl TransactionPayload { + pub fn should_trigger_reconfiguration_by_default(&self) -> bool { + match self { + Self::WriteSet(ws) => ws.should_trigger_reconfiguration_by_default(), + Self::Script(_) | Self::ScriptFunction(_) | Self::ModuleBundle(_) => false, + } + } + + pub fn into_script_function(self) -> ScriptFunction { + match self { + Self::ScriptFunction(f) => f, + payload => panic!("Expected ScriptFunction(_) payload, found: {:#?}", payload), + } + } +} + +#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +pub enum TransactionAuthenticator { + /// Single signature + Ed25519 { + public_key: Ed25519PublicKey, + signature: Ed25519Signature, + }, + /// K-of-N multisignature + MultiEd25519 { + public_key: MultiEd25519PublicKey, + signature: MultiEd25519Signature, + }, + /// Multi-agent transaction. + MultiAgent { + sender: AccountAuthenticator, + secondary_signer_addresses: Vec, + secondary_signers: Vec, + }, +} + +/// Support versioning of the data structure. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum ContractEventV5 { + V0(ContractEventV0), +} + +/// Entry produced via a call to the `emit_event` builtin. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ContractEventV0 { + /// The unique key that the event was emitted to + key: EventKeyV5, + /// The number of messages that have been emitted to the path previously + sequence_number: u64, + /// The type of the data + type_tag: TypeTagV5, + /// The data payload of the event + #[serde(with = "serde_bytes")] + event_data: Vec, +} diff --git a/compatibility/src/version_five/transaction_view_v5.rs b/compatibility/src/version_five/transaction_view_v5.rs new file mode 100644 index 000000000..a10151299 --- /dev/null +++ b/compatibility/src/version_five/transaction_view_v5.rs @@ -0,0 +1,468 @@ +// NOTE: ported from libra-legacy-v6/json-rpc/types/src/views.rs +use anyhow::Result; +// use diem_crypto::HashValue; +use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; + +use crate::version_five::{ + event_v5::EventKeyV5 as EventKey, hash_value_v5::HashValueV5 as HashValue, + legacy_address_v5::LegacyAddressV5 as AccountAddress, +}; + +use hex::FromHex; +/// This is the output of a JSON API request on the V5 data +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub struct TransactionViewV5 { + pub version: u64, + pub transaction: TransactionDataView, + pub hash: HashValue, + pub bytes: BytesView, + pub events: Vec, + pub vm_status: VMStatusView, + pub gas_used: u64, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[serde(tag = "type")] +#[serde(rename_all = "snake_case")] +pub enum VMStatusView { + Executed, + OutOfGas, + MoveAbort { + location: String, + abort_code: u64, + explanation: Option, + }, + ExecutionFailure { + location: String, + function_index: u16, + code_offset: u16, + }, + MiscellaneousError, + VerificationError, + DeserializationError, + PublishingFailure, + #[serde(other)] + Unknown, +} + +impl VMStatusView { + pub fn is_executed(&self) -> bool { + matches!(self, Self::Executed) + } +} + +impl std::fmt::Display for VMStatusView { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VMStatusView::Executed => write!(f, "Executed"), + VMStatusView::OutOfGas => write!(f, "Out of Gas"), + VMStatusView::MoveAbort { + location, + abort_code, + explanation, + } => { + write!(f, "Move Abort: {} at {}", abort_code, location)?; + if let Some(explanation) = explanation { + write!(f, "\nExplanation:\n{:?}", explanation)? + } + Ok(()) + } + VMStatusView::ExecutionFailure { + location, + function_index, + code_offset, + } => write!( + f, + "Execution failure: {} {} {}", + location, function_index, code_offset + ), + VMStatusView::MiscellaneousError => write!(f, "Miscellaneous Error"), + VMStatusView::VerificationError => write!(f, "Verification Error"), + VMStatusView::DeserializationError => write!(f, "Deserialization Error"), + VMStatusView::PublishingFailure => write!(f, "Publishing Failure"), + VMStatusView::Unknown => write!(f, "Unknown Error"), + } + } +} + +#[allow(clippy::large_enum_variant)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[serde(tag = "type")] +pub enum TransactionDataView { + #[serde(rename = "blockmetadata")] + BlockMetadata { timestamp_usecs: u64 }, + #[serde(rename = "writeset")] + WriteSet {}, + #[serde(rename = "user")] + UserTransaction { + sender: AccountAddress, + signature_scheme: String, + signature: BytesView, + public_key: BytesView, + #[serde(skip_serializing_if = "Option::is_none")] + secondary_signers: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + secondary_signature_schemes: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + secondary_signatures: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + secondary_public_keys: Option>, + sequence_number: u64, + chain_id: u8, + max_gas_amount: u64, + gas_unit_price: u64, + gas_currency: String, + expiration_timestamp_secs: u64, + script_hash: HashValue, + script_bytes: BytesView, + script: ScriptView, + }, + #[serde(rename = "unknown")] + #[serde(other)] + UnknownTransaction, +} + +#[derive(Clone, PartialEq)] +pub struct BytesView(pub Box<[u8]>); + +impl BytesView { + pub fn new>>(bytes: T) -> Self { + Self(bytes.into()) + } + + pub fn into_inner(self) -> Box<[u8]> { + self.0 + } + + pub fn inner(&self) -> &[u8] { + &self.0 + } +} + +impl std::ops::Deref for BytesView { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl std::convert::AsRef<[u8]> for BytesView { + fn as_ref(&self) -> &[u8] { + self.inner() + } +} + +impl std::fmt::Display for BytesView { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + for byte in self.inner() { + write!(f, "{:02x}", byte)?; + } + Ok(()) + } +} + +impl std::fmt::Debug for BytesView { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "BytesView(\"{}\")", self) + } +} + +impl From<&[u8]> for BytesView { + fn from(bytes: &[u8]) -> Self { + Self(bytes.into()) + } +} + +impl From> for BytesView { + fn from(bytes: Vec) -> Self { + Self(bytes.into_boxed_slice()) + } +} + +impl<'de> Deserialize<'de> for BytesView { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s = ::deserialize(deserializer)?; + >::from_hex(s) + .map_err(|e| D::Error::custom(e.to_string())) + .map(Into::into) + } +} + +impl Serialize for BytesView { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + hex::encode(self).serialize(serializer) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct EventView { + pub key: EventKey, + pub sequence_number: u64, + pub transaction_version: u64, + pub data: EventDataView, +} + +// impl TryFrom<(u64, ContractEvent)> for EventView { +// type Error = Error; + +// fn try_from((txn_version, event): (u64, ContractEvent)) -> Result { +// Ok(EventView { +// key: *event.key(), +// sequence_number: event.sequence_number(), +// transaction_version: txn_version, +// data: event.try_into()?, +// }) +// } +// } + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub struct MoveAbortExplanationView { + pub category: String, + pub category_description: String, + pub reason: String, + pub reason_description: String, +} + +// impl std::fmt::Display for MoveAbortExplanationView { +// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +// writeln!(f, "Error Category: {}", self.category)?; +// writeln!(f, "\tCategory Description: {}", self.category_description)?; +// writeln!(f, "Error Reason: {}", self.reason)?; +// writeln!(f, "\tReason Description: {}", self.reason_description) +// } +// } + +#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)] +pub struct ScriptView { + // script name / type + pub r#type: String, + + // script code bytes + #[serde(skip_serializing_if = "Option::is_none")] + pub code: Option, + // script arguments, converted into string with type information + #[serde(skip_serializing_if = "Option::is_none")] + pub arguments: Option>, + // script function arguments, converted into hex encoded BCS bytes + #[serde(skip_serializing_if = "Option::is_none")] + pub arguments_bcs: Option>, + // script type arguments, converted into string + #[serde(skip_serializing_if = "Option::is_none")] + pub type_arguments: Option>, + + // the following fields are legacy fields: maybe removed in the future + // please move to use above fields + + // peer_to_peer_transaction, other known script name or unknown + // because of a bug, we never rendered mint_transaction + // this is deprecated, please switch to use field `name` which is script name + + // peer_to_peer_transaction + #[serde(skip_serializing_if = "Option::is_none")] + pub receiver: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub amount: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub currency: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata_signature: Option, + + // Script functions + // The address that the module is published under + #[serde(skip_serializing_if = "Option::is_none")] + pub module_address: Option, + // The name of the module that the called function is defined in + #[serde(skip_serializing_if = "Option::is_none")] + pub module_name: Option, + // The (unqualified) name of the function being called. + #[serde(skip_serializing_if = "Option::is_none")] + pub function_name: Option, +} + +// impl ScriptView { +// pub fn unknown() -> Self { +// ScriptView { +// r#type: "unknown".to_string(), +// ..Default::default() +// } +// } +// } + +// impl From<&Script> for ScriptView { +// fn from(script: &Script) -> Self { +// let name = ScriptCall::decode(script) +// .map(|script_call| script_call.name().to_owned()) +// .unwrap_or_else(|| "unknown".to_owned()); +// let ty_args: Vec = script +// .ty_args() +// .iter() +// .map(|type_tag| match type_tag { +// TypeTag::Struct(StructTag { module, .. }) => module.to_string(), +// tag => format!("{}", tag), +// }) +// .collect(); +// let mut view = ScriptView { +// r#type: name.clone(), +// code: Some(script.code().into()), +// arguments: Some( +// script +// .args() +// .iter() +// .map(|arg| format!("{:?}", &arg)) +// .collect(), +// ), +// type_arguments: Some(ty_args.clone()), +// ..Default::default() +// }; + +// // handle legacy fields, backward compatible +// if name == "peer_to_peer_with_metadata" { +// if let [TransactionArgument::Address(receiver), TransactionArgument::U64(amount), TransactionArgument::U8Vector(metadata), TransactionArgument::U8Vector(metadata_signature)] = +// script.args() +// { +// view.receiver = Some(*receiver); +// view.amount = Some(*amount); +// view.currency = Some( +// ty_args +// .get(0) +// .unwrap_or(&"unknown_currency".to_string()) +// .to_string(), +// ); +// view.metadata = Some(BytesView::new(metadata.as_ref())); +// view.metadata_signature = Some(BytesView::new(metadata_signature.as_ref())); +// } +// } + +// view +// } +// } + +// impl From<&ScriptFunction> for ScriptView { +// fn from(script: &ScriptFunction) -> Self { +// let ty_args: Vec = script +// .ty_args() +// .iter() +// .map(|type_tag| match type_tag { +// TypeTag::Struct(StructTag { module, .. }) => module.to_string(), +// tag => format!("{}", tag), +// }) +// .collect(); +// ScriptView { +// r#type: "script_function".to_string(), +// module_address: Some(*script.module().address()), +// module_name: Some(script.module().name().to_string()), +// function_name: Some(script.function().to_string()), +// arguments_bcs: Some( +// script +// .args() +// .iter() +// .map(|arg| BytesView::from(arg.as_ref())) +// .collect(), +// ), +// type_arguments: Some(ty_args), +// ..Default::default() +// } +// } +// } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[serde(tag = "type")] +pub enum EventDataView { + #[serde(rename = "burn")] + Burn { + amount: AmountView, + preburn_address: AccountAddress, + }, + #[serde(rename = "cancelburn")] + CancelBurn { + amount: AmountView, + preburn_address: AccountAddress, + }, + #[serde(rename = "mint")] + Mint { amount: AmountView }, + #[serde(rename = "to_xdx_exchange_rate_update")] + ToXDXExchangeRateUpdate { + currency_code: String, + new_to_xdx_exchange_rate: f32, + }, + #[serde(rename = "preburn")] + Preburn { + amount: AmountView, + preburn_address: AccountAddress, + }, + #[serde(rename = "receivedpayment")] + ReceivedPayment { + amount: AmountView, + sender: AccountAddress, + receiver: AccountAddress, + metadata: BytesView, + }, + #[serde(rename = "sentpayment")] + SentPayment { + amount: AmountView, + receiver: AccountAddress, + sender: AccountAddress, + metadata: BytesView, + }, + #[serde(rename = "admintransaction")] + AdminTransaction { committed_timestamp_secs: u64 }, + #[serde(rename = "newepoch")] + NewEpoch { epoch: u64 }, + #[serde(rename = "newblock")] + NewBlock { + round: u64, + proposer: AccountAddress, + proposed_time: u64, + }, + #[serde(rename = "receivedmint")] + ReceivedMint { + amount: AmountView, + destination_address: AccountAddress, + }, + #[serde(rename = "compliancekeyrotation")] + ComplianceKeyRotation { + new_compliance_public_key: BytesView, + time_rotated_seconds: u64, + }, + #[serde(rename = "baseurlrotation")] + BaseUrlRotation { + new_base_url: String, + time_rotated_seconds: u64, + }, + #[serde(rename = "createaccount")] + CreateAccount { + created_address: AccountAddress, + role_id: u64, + }, + #[serde(rename = "diemiddomain")] + DiemIdDomain { + // Whether a domain was added or removed + removed: bool, + // Diem ID Domain string of the account + // TODO + domain: String, + // domain: DiemIdVaspDomainIdentifier, + // On-chain account address + address: AccountAddress, + }, + #[serde(rename = "unknown")] + Unknown { bytes: Option }, + + // used by client to deserialize server response + #[serde(other)] + UnknownToClient, +} + +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] +pub struct AmountView { + pub amount: u64, + pub currency: String, +} diff --git a/compatibility/tests/version_five_read_snapshot.rs b/compatibility/tests/version_five_read_snapshot.rs new file mode 100644 index 000000000..1c0676080 --- /dev/null +++ b/compatibility/tests/version_five_read_snapshot.rs @@ -0,0 +1,47 @@ +use std::path::PathBuf; + +use libra_backwards_compatibility::version_five::{ + balance_v5::BalanceResourceV5, + freezing_v5::FreezingBit, + state_snapshot_v5::{v5_accounts_from_snapshot_backup, v5_read_from_snapshot_manifest}, +}; + +fn fixtures_path() -> PathBuf { + let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + p.push("fixtures/v5/state_ver_119757649.17a8"); + assert!(p.exists()); + p +} + +#[test] +fn read_snapshot_manifest() { + let mut p = fixtures_path(); + p.push("state.manifest"); + assert!(p.exists()); + + let res = v5_read_from_snapshot_manifest(&p).unwrap(); + + assert!(res.version == 119757649); +} + +#[tokio::test] +async fn read_full_snapshot() -> anyhow::Result<()> { + let mut p = fixtures_path(); + p.push("state.manifest"); + + let man = v5_read_from_snapshot_manifest(&p)?; + let archive_path = fixtures_path(); + let accts = v5_accounts_from_snapshot_backup(man, &archive_path).await?; + + assert!(accts.len() == 17339); + + let first_account = accts[0].to_account_state()?; + let f = first_account.get_resource::()?; + assert!(!f.is_frozen()); + let b = first_account.get_resource::()?; + assert!(b.coin() == 100135989588); + let addr = first_account.get_address()?; + assert!(addr.len() > 0); + + Ok(()) +} diff --git a/compatibility/tests/version_five_read_transactions.rs b/compatibility/tests/version_five_read_transactions.rs new file mode 100644 index 000000000..d59e7a45d --- /dev/null +++ b/compatibility/tests/version_five_read_transactions.rs @@ -0,0 +1,37 @@ +use std::path::PathBuf; + +use libra_backwards_compatibility::version_five::{ + transaction_manifest_v5::v5_read_from_transaction_manifest, + transaction_restore_v5::read_transaction_chunk, +}; + +fn fixtures_path() -> PathBuf { + let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + p.push("fixtures/v5/transaction_141722729-.891d"); + assert!(p.exists()); + p +} + +#[test] +fn read_transaction_manifest() { + let archive = fixtures_path(); + let manifest = archive.join("transaction.manifest"); + assert!(manifest.exists()); + + let res = v5_read_from_transaction_manifest(&manifest).unwrap(); + assert!(res.first_version == 141722729); + assert!(res.last_version == 141722729); +} + +#[tokio::test] +async fn parse_tx_chunk() { + let archive = fixtures_path(); + let manifest = archive.join("transaction.manifest"); + assert!(manifest.exists()); + + let res = v5_read_from_transaction_manifest(&manifest).unwrap(); + let tx_chunk = read_transaction_chunk(&res.chunks[0].transactions, &archive) + .await + .unwrap(); + dbg!(&tx_chunk.len()); +} diff --git a/framework/libra-framework/sources/ol_sources/vouch.move b/framework/libra-framework/sources/ol_sources/vouch.move index 573278b4e..73879bc06 100644 --- a/framework/libra-framework/sources/ol_sources/vouch.move +++ b/framework/libra-framework/sources/ol_sources/vouch.move @@ -189,7 +189,7 @@ module ol_framework::vouch { } } - /// will only succesfully vouch if the two are not related by ancestry + /// will only successfully vouch if the two are not related by ancestry /// prevents spending a vouch that would not be counted. /// to add a vouch and ignore this check use insist_vouch public entry fun vouch_for(grantor: &signer, friend_account: address) acquires ReceivedVouches, GivenVouches, VouchPrice { diff --git a/tools/cli/Cargo.toml b/tools/cli/Cargo.toml index b8f2fba59..fca600d4a 100644 --- a/tools/cli/Cargo.toml +++ b/tools/cli/Cargo.toml @@ -18,7 +18,6 @@ clap = { workspace = true } diem = { workspace = true } diem-config = { workspace = true } diem-node = { workspace = true } -diem-vm = { workspace = true } libra-config = { workspace = true } libra-framework = { workspace = true } libra-genesis-tools = { workspace = true } diff --git a/tools/cli/src/node_cli.rs b/tools/cli/src/node_cli.rs index 0e43dc032..3be0f2837 100644 --- a/tools/cli/src/node_cli.rs +++ b/tools/cli/src/node_cli.rs @@ -57,7 +57,7 @@ fn find_a_config() -> anyhow::Result { let d = global_config_dir(); let val_file = d.join("validator.yaml"); - let help = "If this is not what you expected explicitly set it with --config-file "; + let help = "If this is not what you expected explicitly set it with --config-path "; // we assume if this is set up as a validator that's the preferred profile // Check if validator.yaml exists; use it if found diff --git a/tools/genesis/Cargo.toml b/tools/genesis/Cargo.toml index c8f5fbecf..c51076f66 100644 --- a/tools/genesis/Cargo.toml +++ b/tools/genesis/Cargo.toml @@ -36,6 +36,7 @@ diem-types = { workspace = true } diem-vm = { workspace = true } diem-vm-genesis = { workspace = true } indicatif = { workspace = true } +libra-backwards-compatibility = { workspace = true } libra-config = { workspace = true } libra-framework = { workspace = true } libra-types = { workspace = true } @@ -45,3 +46,6 @@ serde = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } ureq = { workspace = true } + +[dev-dependencies] +libra-backwards-compatibility = { workspace = true } diff --git a/tools/genesis/src/compare.rs b/tools/genesis/src/compare.rs index 76816e428..98634b576 100644 --- a/tools/genesis/src/compare.rs +++ b/tools/genesis/src/compare.rs @@ -9,12 +9,13 @@ use diem_state_view::account_with_state_view::AsAccountWithStateView; use diem_storage_interface::{state_view::LatestDbStateCheckpointView, DbReader}; use diem_types::{account_view::AccountView, transaction::Transaction}; use indicatif::{ProgressBar, ProgressIterator}; +use libra_backwards_compatibility::legacy_recovery_v6::{self, AccountRole, LegacyRecoveryV6}; use libra_types::{ exports::AccountAddress, - legacy_types::legacy_recovery_v6::{self, AccountRole, LegacyRecoveryV6}, move_resource::gas_coin::{GasCoinStoreResource, SlowWalletBalance}, ol_progress::OLProgress, }; + use move_core_types::{language_storage::CORE_CODE_ADDRESS, move_resource::MoveResource}; use serde::{Deserialize, Serialize}; use std::{ diff --git a/tools/genesis/src/genesis.rs b/tools/genesis/src/genesis.rs index 34ad1e480..9041d452e 100644 --- a/tools/genesis/src/genesis.rs +++ b/tools/genesis/src/genesis.rs @@ -8,7 +8,7 @@ use diem_types::{ transaction::{Transaction, WriteSetPayload}, }; use diem_vm_genesis::{GenesisConfiguration, Validator}; -use libra_types::legacy_types::legacy_recovery_v6::LegacyRecoveryV6; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; use std::{fs::File, io::Write, path::PathBuf}; #[cfg(test)] diff --git a/tools/genesis/src/genesis_builder.rs b/tools/genesis/src/genesis_builder.rs index c68dabeae..3fe1b2d68 100644 --- a/tools/genesis/src/genesis_builder.rs +++ b/tools/genesis/src/genesis_builder.rs @@ -29,13 +29,14 @@ use diem_vm_genesis::{ GenesisConfiguration as VmGenesisGenesisConfiguration, // in vendor codethere are two structs separately called the same name with nearly identical fields }; use indicatif::ProgressBar; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; use libra_framework::release; use libra_types::{ core_types::fixtures::TestPersona, exports::{ChainId, NamedChain}, - legacy_types::legacy_recovery_v6::LegacyRecoveryV6, ol_progress::OLProgress, }; + use libra_wallet::{ account_keys::get_keys_from_mnem, keys::generate_key_objects_from_legacy, diff --git a/tools/genesis/src/genesis_functions.rs b/tools/genesis/src/genesis_functions.rs index e5a3409ea..17f6dd003 100644 --- a/tools/genesis/src/genesis_functions.rs +++ b/tools/genesis/src/genesis_functions.rs @@ -7,11 +7,9 @@ use diem_types::account_config::CORE_CODE_ADDRESS; use diem_vm::move_vm_ext::SessionExt; use diem_vm_genesis::exec_function; use indicatif::ProgressIterator; -use libra_types::{ - exports::AccountAddress, - legacy_types::legacy_recovery_v6::{AccountRole, LegacyRecoveryV6}, - ol_progress::OLProgress, -}; +use libra_backwards_compatibility::legacy_recovery_v6::{AccountRole, LegacyRecoveryV6}; +use libra_types::{exports::AccountAddress, ol_progress::OLProgress}; + use move_core_types::value::{serialize_values, MoveValue}; /// Migrates all users' data during genesis including accounts, wallets, ancestry, and receipts. diff --git a/tools/genesis/src/parse_json.rs b/tools/genesis/src/parse_json.rs index 1dcbf8046..2b373e6b3 100644 --- a/tools/genesis/src/parse_json.rs +++ b/tools/genesis/src/parse_json.rs @@ -1,9 +1,8 @@ //! Module for handling recovery genesis blob creation -use libra_types::{ - exports::{AccountAddress, AuthenticationKey}, - legacy_types::legacy_recovery_v6::{self, AccountRole, LegacyRecoveryV6}, -}; +use libra_backwards_compatibility::legacy_recovery_v6::{self, AccountRole, LegacyRecoveryV6}; + +use libra_types::exports::{AccountAddress, AuthenticationKey}; use serde::{Deserialize, Serialize}; use std::{ fs, diff --git a/tools/genesis/src/process_comm_wallet.rs b/tools/genesis/src/process_comm_wallet.rs index c44c125f4..4166a4a2d 100644 --- a/tools/genesis/src/process_comm_wallet.rs +++ b/tools/genesis/src/process_comm_wallet.rs @@ -1,5 +1,5 @@ use diem_types::account_address::AccountAddress; -use libra_types::legacy_types::legacy_recovery_v6::LegacyRecoveryV6; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; use serde::Serialize; use std::collections::BTreeMap; diff --git a/tools/genesis/src/supply.rs b/tools/genesis/src/supply.rs index efe7d2a99..318ac7d47 100644 --- a/tools/genesis/src/supply.rs +++ b/tools/genesis/src/supply.rs @@ -1,5 +1,6 @@ use indicatif::ProgressBar; -use libra_types::{legacy_types::legacy_recovery_v6::LegacyRecoveryV6, ol_progress::OLProgress}; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; +use libra_types::ol_progress::OLProgress; use std::time::Duration; #[derive(Debug, Clone, Default)] diff --git a/tools/genesis/src/vm.rs b/tools/genesis/src/vm.rs index 17f5ec99b..4b76004a3 100644 --- a/tools/genesis/src/vm.rs +++ b/tools/genesis/src/vm.rs @@ -28,7 +28,8 @@ use diem_vm_genesis::{ initialize_on_chain_governance, publish_framework, set_genesis_end, validate_genesis_config, verify_genesis_write_set, GenesisConfiguration, Validator, GENESIS_KEYPAIR, }; -use libra_types::{legacy_types::legacy_recovery_v6::LegacyRecoveryV6, ol_progress::OLProgress}; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; +use libra_types::ol_progress::OLProgress; /// set the genesis parameters /// NOTE: many of the parameters are ignored in libra_framework diff --git a/tools/genesis/tests/json_to_genesis_audit_all.rs b/tools/genesis/tests/json_to_genesis_audit_all.rs index 36159c37d..51dbf4a47 100644 --- a/tools/genesis/tests/json_to_genesis_audit_all.rs +++ b/tools/genesis/tests/json_to_genesis_audit_all.rs @@ -3,6 +3,7 @@ mod support; use diem_state_view::account_with_state_view::AsAccountWithStateView; use diem_storage_interface::state_view::LatestDbStateCheckpointView; use diem_types::{account_view::AccountView, chain_id::NamedChain}; +use libra_backwards_compatibility::legacy_recovery_v6::AccountRole; use libra_framework::head_release_bundle; use libra_genesis_tools::{ compare, @@ -12,10 +13,7 @@ use libra_genesis_tools::{ supply::{self}, vm::libra_genesis_default, }; -use libra_types::{ - exports::ChainId, legacy_types::legacy_recovery_v6::AccountRole, - move_resource::gas_coin::GasCoinStoreResource, -}; +use libra_types::{exports::ChainId, move_resource::gas_coin::GasCoinStoreResource}; use support::{path_utils::json_path, test_vals}; #[test] diff --git a/tools/genesis/tests/json_to_genesis_audit_single.rs b/tools/genesis/tests/json_to_genesis_audit_single.rs index 9b5064a3c..217928512 100644 --- a/tools/genesis/tests/json_to_genesis_audit_single.rs +++ b/tools/genesis/tests/json_to_genesis_audit_single.rs @@ -3,6 +3,7 @@ mod support; use diem_state_view::account_with_state_view::AsAccountWithStateView; use diem_storage_interface::state_view::LatestDbStateCheckpointView; use diem_types::{account_view::AccountView, chain_id::NamedChain}; +use libra_backwards_compatibility::legacy_recovery_v6::LegacyRecoveryV6; use libra_framework::head_release_bundle; use libra_genesis_tools::{ compare, genesis::make_recovery_genesis_from_vec_legacy_recovery, genesis_reader, parse_json, @@ -10,9 +11,9 @@ use libra_genesis_tools::{ }; use libra_types::{ exports::{AccountAddress, ChainId}, - legacy_types::legacy_recovery_v6::LegacyRecoveryV6, move_resource::ancestry::AncestryResource, }; + use support::{path_utils::json_path, test_vals}; #[test] // test that a genesis blob created from struct, will actually contain the data diff --git a/tools/storage/Cargo.toml b/tools/storage/Cargo.toml index ccb455499..490024e4a 100644 --- a/tools/storage/Cargo.toml +++ b/tools/storage/Cargo.toml @@ -25,10 +25,11 @@ diem-logger = { workspace = true } diem-push-metrics = { workspace = true } diem-types = { workspace = true } glob = { workspace = true } -libra-types = { workspace = true } +libra-backwards-compatibility = { workspace = true } num_cpus = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true } + [dev-dependencies] diem-temppath = { workspace = true } diff --git a/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-.chunk b/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-.chunk new file mode 100644 index 000000000..97a2b1ee6 Binary files /dev/null and b/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-.chunk differ diff --git a/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-17338.proof b/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-17338.proof new file mode 100644 index 000000000..19fc6976c Binary files /dev/null and b/tools/storage/fixtures/v5/state_ver_119757649.17a8/0-17338.proof differ diff --git a/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.manifest b/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.manifest new file mode 100644 index 000000000..40c2cd220 --- /dev/null +++ b/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.manifest @@ -0,0 +1 @@ +{"version":119757649,"root_hash":"d2e6b6c474529cd3c3ea76cf211a528ee28bb13d7bcd8dcbef0ecf4c43bc3703","chunks":[{"first_idx":0,"last_idx":17338,"first_key":"000131122524ba9f4a13bd90a8b13c5d03ab621649c8100c6bbf7846fe8eaf0f","last_key":"fffed52c1dd93cc7aa5b79a8699df0c33eb4d65ab8d2a21bbe79f9d05ad62377","blobs":"state_ver_119757649.17a8/0-.chunk","proof":"state_ver_119757649.17a8/0-17338.proof"}],"proof":"state_ver_119757649.17a8/state.proof"} diff --git a/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.proof b/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.proof new file mode 100644 index 000000000..03363b8cc Binary files /dev/null and b/tools/storage/fixtures/v5/state_ver_119757649.17a8/state.proof differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk new file mode 100644 index 000000000..8f16eb938 Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk.gz b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk.gz new file mode 100644 index 000000000..e5f184a07 Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-.chunk.gz differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof new file mode 100644 index 000000000..f76dd238a Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof.gz b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof.gz new file mode 100644 index 000000000..cdbc4ca63 Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/0-121418.proof.gz differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest new file mode 100644 index 000000000..e5d8b7944 --- /dev/null +++ b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest @@ -0,0 +1 @@ +{"version":18120170,"epoch":54,"root_hash":"ad97d4fda9cce3869b1753d1b6fd850d08134d123895d3845d87fced55a00b38","chunks":[{"first_idx":0,"last_idx":121418,"first_key":"0000acadcb83f9bdcffcbb63d132be250f8018a731137db7e3aab5af2e3bc8bd","last_key":"fffff7e8a7aff9e730227f0decbef95c00ccdd60744654b8c4799a80bec23e5a","blobs":"state_epoch_54_ver_18120170.96e8/0-.chunk","proof":"state_epoch_54_ver_18120170.96e8/0-121418.proof"}],"proof":"state_epoch_54_ver_18120170.96e8/state.proof"} \ No newline at end of file diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest.gz b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest.gz new file mode 100644 index 000000000..ddbc9499d Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.manifest.gz differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof new file mode 100644 index 000000000..a8f68cf23 Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof differ diff --git a/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof.gz b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof.gz new file mode 100644 index 000000000..be9a72557 Binary files /dev/null and b/tools/storage/fixtures/v6/state_epoch_54_ver_18120170.96e8/state.proof.gz differ diff --git a/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-.chunk b/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-.chunk new file mode 100644 index 000000000..94f5762a6 Binary files /dev/null and b/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-.chunk differ diff --git a/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-10000000.proof b/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-10000000.proof new file mode 100644 index 000000000..b72f47d9c Binary files /dev/null and b/tools/storage/fixtures/v6/transaction_9900001-.e469/9900001-10000000.proof differ diff --git a/tools/storage/fixtures/v6/transaction_9900001-.e469/transaction.manifest b/tools/storage/fixtures/v6/transaction_9900001-.e469/transaction.manifest new file mode 100644 index 000000000..c406a1291 --- /dev/null +++ b/tools/storage/fixtures/v6/transaction_9900001-.e469/transaction.manifest @@ -0,0 +1 @@ +{"first_version":9900001,"last_version":10000000,"chunks":[{"first_version":9900001,"last_version":10000000,"transactions":"transaction_9900001-.e469/9900001-.chunk","proof":"transaction_9900001-.e469/9900001-10000000.proof"}]} \ No newline at end of file diff --git a/tools/storage/fixtures/v7/transaction_38100001-.541f/38100001-.chunk.gz b/tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/38100001-.chunk.gz similarity index 100% rename from tools/storage/fixtures/v7/transaction_38100001-.541f/38100001-.chunk.gz rename to tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/38100001-.chunk.gz diff --git a/tools/storage/fixtures/v7/transaction_38100001-.541f/38100001-38200000.proof.gz b/tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/38100001-38200000.proof.gz similarity index 100% rename from tools/storage/fixtures/v7/transaction_38100001-.541f/38100001-38200000.proof.gz rename to tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/38100001-38200000.proof.gz diff --git a/tools/storage/fixtures/v7/transaction_38100001-.541f/transaction.manifest.gz b/tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/transaction.manifest.gz similarity index 100% rename from tools/storage/fixtures/v7/transaction_38100001-.541f/transaction.manifest.gz rename to tools/storage/fixtures/v7/transaction_38100001-.541f_gzipped/transaction.manifest.gz diff --git a/tools/storage/src/lib.rs b/tools/storage/src/lib.rs index bdb3c06d5..b270a5e18 100644 --- a/tools/storage/src/lib.rs +++ b/tools/storage/src/lib.rs @@ -1,5 +1,6 @@ pub mod dbtool_init; pub mod read_snapshot; +pub mod read_tx_chunk; pub mod restore; pub mod restore_bundle; pub mod storage_cli; diff --git a/tools/storage/src/read_snapshot.rs b/tools/storage/src/read_snapshot.rs index 42e361f02..4b09dd2b3 100644 --- a/tools/storage/src/read_snapshot.rs +++ b/tools/storage/src/read_snapshot.rs @@ -15,7 +15,7 @@ use diem_types::{ state_value::StateValue, }, }; -use libra_types::legacy_types::legacy_recovery_v6; +use libra_backwards_compatibility::legacy_recovery_v6; use serde_json::json; use std::{ collections::HashMap, @@ -24,12 +24,9 @@ use std::{ }; use tokio::{fs::OpenOptions, io::AsyncRead}; -#[cfg(test)] -use libra_types::legacy_types::legacy_recovery_v6::{get_legacy_recovery, AccountRole}; - ////// SNAPSHOT FILE IO ////// /// read snapshot manifest file into object -pub fn load_snapshot_manifest(path: &PathBuf) -> Result { +pub fn load_snapshot_manifest(path: &Path) -> Result { let config = std::fs::read_to_string(path).map_err(|e| { format!("Error: cannot read file {:?}, error: {:?}", &path, &e); e @@ -126,11 +123,11 @@ pub async fn accounts_from_snapshot_backup( #[test] // TODO: adapt for V7. -#[ignore] + fn test_parse_manifest() { use std::str::FromStr; let mut this_path = PathBuf::from_str(env!("CARGO_MANIFEST_DIR")).unwrap(); - this_path.push("fixtures/state_epoch_79_ver_33217173.795d/state.manifest"); + this_path.push("fixtures/v7/state_epoch_116_ver_38180075.05af/state.manifest"); let _r = load_snapshot_manifest(&this_path).expect("parse manifest"); // dbg!(&r.epoch); } @@ -140,7 +137,7 @@ pub async fn manifest_to_json(manifest_path: PathBuf, out_path: Option) let archive_path = manifest_path.parent().unwrap(); let account_states = accounts_from_snapshot_backup(snapshot_manifest, archive_path) .await - .expect("could not parse snapshot"); + .expect("could not decode snapshot"); let mut legacy_recovery_vec = Vec::new(); for account_state in account_states.iter() { let legacy_recovery = legacy_recovery_v6::get_legacy_recovery(account_state) @@ -177,11 +174,11 @@ async fn test_deserialize_account() { let archive_path = this_path.parent().unwrap(); let account_states = accounts_from_snapshot_backup(snapshot_manifest, archive_path) .await - .expect("could not parse snapshot"); + .expect("could not decode snapshot"); let mut legacy_recovery_vec = Vec::new(); for account_state in account_states.iter() { - let legacy_recovery = - get_legacy_recovery(account_state).expect("could not get legacy recovery"); + let legacy_recovery = legacy_recovery_v6::get_legacy_recovery(account_state) + .expect("could not get legacy recovery"); legacy_recovery_vec.push(legacy_recovery); } @@ -202,7 +199,7 @@ async fn test_deserialize_account() { assert_eq!( legacy_recovery_vec .iter() - .filter(|l| l.role == AccountRole::System) + .filter(|l| l.role == legacy_recovery_v6::AccountRole::System) .fold(0, |count, _| count + 1), 1 ); @@ -210,7 +207,7 @@ async fn test_deserialize_account() { assert_eq!( legacy_recovery_vec .iter() - .filter(|l| l.role == AccountRole::Validator) + .filter(|l| l.role == legacy_recovery_v6::AccountRole::Validator) .fold(0, |count, _| count + 1), 74 ); @@ -219,7 +216,7 @@ async fn test_deserialize_account() { assert_eq!( legacy_recovery_vec .iter() - .filter(|l| l.role == AccountRole::Operator) + .filter(|l| l.role == legacy_recovery_v6::AccountRole::Operator) .fold(0, |count, _| count + 1), 0 ); diff --git a/tools/storage/src/read_tx_chunk.rs b/tools/storage/src/read_tx_chunk.rs new file mode 100644 index 000000000..cc321516a --- /dev/null +++ b/tools/storage/src/read_tx_chunk.rs @@ -0,0 +1,85 @@ +use std::path::Path; + +use anyhow::{anyhow, Result}; + +use diem_backup_cli::backup_types::transaction::manifest::TransactionBackup; +use diem_backup_cli::backup_types::transaction::manifest::TransactionChunk; +use diem_backup_cli::utils::read_record_bytes::ReadRecordBytes; +use diem_types::contract_event::ContractEvent; +use diem_types::transaction::Transaction; +use diem_types::transaction::TransactionInfo; +use diem_types::write_set::WriteSet; +use libra_backwards_compatibility::version_five::state_snapshot_v5::open_for_read; + +/// read snapshot manifest file into object +pub fn load_tx_chunk_manifest(path: &Path) -> anyhow::Result { + let s = std::fs::read_to_string(path).map_err(|e| { + format!("Error: cannot read file {:?}, error: {:?}", &path, &e); + e + })?; + + let map: TransactionBackup = serde_json::from_str(&s)?; + + Ok(map) +} + +// similar to Loaded Chunk +// diem/storage/backup/backup-cli/src/backup_types/transaction/restore.rs +// The vectors below are OF THE SAME LENGTH +// It is a table where for example, a tx without events will be an empty slot in the vector. +pub struct TransactionArchiveChunk { + pub manifest: TransactionChunk, + pub txns: Vec, + pub txn_infos: Vec, + pub event_vecs: Vec>, + pub write_sets: Vec, +} + +pub async fn load_chunk( + archive_path: &Path, + manifest: TransactionChunk, +) -> Result { + let full_handle = archive_path + .parent() + .expect("could not read archive path") + .join(&manifest.transactions); + let handle_str = full_handle.to_str().unwrap(); + assert!(full_handle.exists(), "file does not exist"); + + let mut file = open_for_read(handle_str) + .await + .map_err(|e| anyhow!("snapshot chunk {:?}, {:?}", &handle_str, e))?; + + let mut txns = Vec::new(); + let mut txn_infos = Vec::new(); + let mut event_vecs = Vec::new(); + let mut write_sets = Vec::new(); + + while let Some(record_bytes) = file.read_record_bytes().await? { + let (txn, txn_info, events, write_set): (_, _, _, WriteSet) = + bcs::from_bytes(&record_bytes)?; + txns.push(txn); + txn_infos.push(txn_info); + event_vecs.push(events); + write_sets.push(write_set); + } + + // the chunk is a table implements with vectors, + // they should have the same length + assert!( + txns.len() == txn_infos.len() + && txn_infos.len() == event_vecs.len() + && event_vecs.len() == write_sets.len(), + "transactions chunk have different vector length for txs, events, and writesets" + ); + + // TODO: for purposes of explorer/warehouse do we want to do the full tx restore controller verifications + + Ok(TransactionArchiveChunk { + manifest, + txns, + txn_infos, + event_vecs, + write_sets, + }) +} diff --git a/tools/wallet/src/legacy/mod.rs b/tools/wallet/src/legacy/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/tools/wallet/src/legacy/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tools/wallet/src/lib.rs b/tools/wallet/src/lib.rs index a8e037247..7e88cc306 100644 --- a/tools/wallet/src/lib.rs +++ b/tools/wallet/src/lib.rs @@ -5,7 +5,6 @@ pub mod account_keys; pub mod core; pub mod key_gen; pub mod keys; -pub mod legacy; pub mod load_keys; pub mod utils; pub mod validator_files; diff --git a/types/src/legacy_types/mod.rs b/types/src/legacy_types/mod.rs deleted file mode 100644 index 261ef0b3c..000000000 --- a/types/src/legacy_types/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! `legacy-types` - -pub mod ancestry_legacy; -pub mod legacy_recovery_v6; -pub mod tx_error; -pub mod validator_config; -pub mod wallet; diff --git a/types/src/lib.rs b/types/src/lib.rs index 98c65dbc7..040d34bc4 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -1,7 +1,6 @@ //! Exprorting some types from vendor so that they can be used in other crates pub mod core_types; pub mod exports; -pub mod legacy_types; pub mod move_resource; pub mod ol_progress; pub mod type_extensions; diff --git a/types/src/move_resource/ancestry.rs b/types/src/move_resource/ancestry.rs index a3e793d53..13c899f8b 100644 --- a/types/src/move_resource/ancestry.rs +++ b/types/src/move_resource/ancestry.rs @@ -10,7 +10,7 @@ use move_core_types::{ use serde::{Deserialize, Serialize}; /// Struct that represents a AutoPay resource -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct AncestryResource { /// A vector representing the ancestry tree of account addresses. pub tree: Vec, diff --git a/types/src/move_resource/coin_register_event.rs b/types/src/move_resource/coin_register_event.rs new file mode 100644 index 000000000..d1fdadb78 --- /dev/null +++ b/types/src/move_resource/coin_register_event.rs @@ -0,0 +1,21 @@ +use crate::move_resource::type_info::TypeInfo; +use move_core_types::{ident_str, identifier::IdentStr, move_resource::MoveStructType}; +use serde::{Deserialize, Serialize}; + +/// Struct that represents a CoinRegisterEvent. +// NOTE: this is the event that indicates that an account has been created +#[derive(Debug, Serialize, Deserialize)] +pub struct CoinRegisterEvent { + type_info: TypeInfo, +} + +impl CoinRegisterEvent { + pub fn try_from_bytes(bytes: &[u8]) -> anyhow::Result { + bcs::from_bytes(bytes).map_err(Into::into) + } +} + +impl MoveStructType for CoinRegisterEvent { + const MODULE_NAME: &'static IdentStr = ident_str!("account"); + const STRUCT_NAME: &'static IdentStr = ident_str!("CoinRegisterEvent"); +} diff --git a/types/src/move_resource/cumulative_deposits.rs b/types/src/move_resource/cumulative_deposits.rs index b82a02ff4..d5e449ca6 100644 --- a/types/src/move_resource/cumulative_deposits.rs +++ b/types/src/move_resource/cumulative_deposits.rs @@ -12,12 +12,12 @@ use serde::{Deserialize, Serialize}; // Legacy Balance resource #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct LegacyBalanceResource { +pub struct LegacyBalanceResourceV6 { pub coin: u64, } -impl LegacyBalanceResource { - /// Attempts to deserialize bytes into a `LegacyBalanceResource` instance +impl LegacyBalanceResourceV6 { + /// Attempts to deserialize bytes into a `LegacyBalanceResourceV6` instance pub fn try_from_bytes(bytes: &[u8]) -> Result { bcs::from_bytes(bytes).map_err(Into::into) } diff --git a/types/src/move_resource/mod.rs b/types/src/move_resource/mod.rs index 7ba205cc0..656878d89 100644 --- a/types/src/move_resource/mod.rs +++ b/types/src/move_resource/mod.rs @@ -3,6 +3,7 @@ pub mod ancestry; pub mod burn; pub mod coin_info; +pub mod coin_register_event; pub mod cumulative_deposits; pub mod donor_voice; pub mod donor_voice_txs; @@ -16,5 +17,7 @@ pub mod pledge_account; pub mod proof_of_fee; pub mod receipts; pub mod txschedule; +pub mod type_info; pub mod validator_universe; pub mod vouch; +pub mod wallet; diff --git a/types/src/move_resource/type_info.rs b/types/src/move_resource/type_info.rs new file mode 100644 index 000000000..0c08f9ac4 --- /dev/null +++ b/types/src/move_resource/type_info.rs @@ -0,0 +1,44 @@ +use diem_types::account_address::AccountAddress; +use serde::{Deserialize, Deserializer, Serialize}; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct TypeInfo { + pub account_address: String, + #[serde(deserialize_with = "deserialize_string_from_hexstring")] + pub module_name: String, + #[serde(deserialize_with = "deserialize_string_from_hexstring")] + pub struct_name: String, +} + +pub fn deserialize_string_from_hexstring<'de, D>( + deserializer: D, +) -> core::result::Result +where + D: Deserializer<'de>, +{ + let s = ::deserialize(deserializer)?; + Ok(convert_hex(s.clone()).unwrap_or(s)) +} + +/// Convert the bcs serialized vector to its original string format +pub fn convert_bcs_hex(typ: String, value: String) -> Option { + let decoded = hex::decode(value.strip_prefix("0x").unwrap_or(&*value)).ok()?; + + match typ.as_str() { + "0x1::string::String" => bcs::from_bytes::(decoded.as_slice()), + "u8" => bcs::from_bytes::(decoded.as_slice()).map(|e| e.to_string()), + "u64" => bcs::from_bytes::(decoded.as_slice()).map(|e| e.to_string()), + "u128" => bcs::from_bytes::(decoded.as_slice()).map(|e| e.to_string()), + "bool" => bcs::from_bytes::(decoded.as_slice()).map(|e| e.to_string()), + // 0L NOTE: using AccountAddress here + "address" => bcs::from_bytes::(decoded.as_slice()).map(|e| e.to_string()), + _ => Ok(value), + } + .ok() +} + +/// Convert the vector that is directly generated from b"xxx" +pub fn convert_hex(val: String) -> Option { + let decoded = hex::decode(val.strip_prefix("0x").unwrap_or(&*val)).ok()?; + String::from_utf8(decoded).ok() +} diff --git a/types/src/legacy_types/wallet.rs b/types/src/move_resource/wallet.rs similarity index 88% rename from types/src/legacy_types/wallet.rs rename to types/src/move_resource/wallet.rs index ce91258cb..07799ba61 100644 --- a/types/src/legacy_types/wallet.rs +++ b/types/src/move_resource/wallet.rs @@ -7,22 +7,21 @@ use move_core_types::{ move_resource::{MoveResource, MoveStructType}, }; use serde::{Deserialize, Serialize}; -// NOTE: these are legacy structs for v5 /// Struct that represents a CommunityWallet resource /// TODO: this is incorrect field structure #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct CommunityWalletsResourceLegacy { +pub struct CommunityWalletsResource { // List pub list: Vec, } -impl MoveStructType for CommunityWalletsResourceLegacy { +impl MoveStructType for CommunityWalletsResource { const MODULE_NAME: &'static IdentStr = ident_str!("community_wallet"); const STRUCT_NAME: &'static IdentStr = ident_str!("CommunityWallet"); } -impl MoveResource for CommunityWalletsResourceLegacy {} +impl MoveResource for CommunityWalletsResource {} /// Struct that represents a SlowWallet resource #[derive(Debug, Serialize, Deserialize, Clone)]