From 19a39d9669bba3459a07c275c6616c26571d4beb Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Tue, 16 Jun 2026 19:56:04 +0200 Subject: [PATCH] chore: migrate rust/candid_type_generation to icp-cli - Replace dfx.json with icp.yaml using @dfinity/rust@v3.3.0 recipe - Move src/ to backend/, add workspace Cargo.toml, rename package to backend - Update build.rs to resolve candid/ path relative to new backend/ location - Update scripts/fetch_candid.sh to use icp canister metadata instead of dfx - Add Makefile with test target for list_neurons_pretty - Add rust-toolchain.toml with wasm32-unknown-unknown target - Add CI workflow candid_type_generation.yml with icp-dev-env-rust:1.0.0 - Delete legacy rust-candid-type-generation-example.yml workflow - Regenerate Cargo.lock for new workspace structure Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/candid_type_generation.yml | 29 ++ .../rust-candid-type-generation-example.yml | 45 -- rust/candid_type_generation/.gitignore | 3 + rust/candid_type_generation/Cargo.lock | 425 ++++++++---------- rust/candid_type_generation/Cargo.toml | 21 +- rust/candid_type_generation/Makefile | 8 + rust/candid_type_generation/README.md | 40 +- .../candid_type_generation/backend/Cargo.toml | 17 + .../{ => backend}/build.rs | 2 +- .../{ => backend}/src/declarations/mod.rs | 0 .../src/declarations/nns_governance.rs | 0 .../{ => backend}/src/lib.rs | 10 +- .../candid_type_generation.did | 3 - rust/candid_type_generation/dfx.json | 10 - rust/candid_type_generation/icp.yaml | 9 + .../rust-toolchain.toml | 2 + .../scripts/fetch_candid.sh | 17 +- 17 files changed, 313 insertions(+), 328 deletions(-) create mode 100644 .github/workflows/candid_type_generation.yml delete mode 100644 .github/workflows/rust-candid-type-generation-example.yml create mode 100644 rust/candid_type_generation/.gitignore create mode 100644 rust/candid_type_generation/Makefile create mode 100644 rust/candid_type_generation/backend/Cargo.toml rename rust/candid_type_generation/{ => backend}/build.rs (92%) rename rust/candid_type_generation/{ => backend}/src/declarations/mod.rs (100%) rename rust/candid_type_generation/{ => backend}/src/declarations/nns_governance.rs (100%) rename rust/candid_type_generation/{ => backend}/src/lib.rs (85%) delete mode 100644 rust/candid_type_generation/candid_type_generation.did delete mode 100644 rust/candid_type_generation/dfx.json create mode 100644 rust/candid_type_generation/icp.yaml create mode 100644 rust/candid_type_generation/rust-toolchain.toml diff --git a/.github/workflows/candid_type_generation.yml b/.github/workflows/candid_type_generation.yml new file mode 100644 index 0000000000..f481e29e97 --- /dev/null +++ b/.github/workflows/candid_type_generation.yml @@ -0,0 +1,29 @@ +name: candid_type_generation + +on: + push: + branches: + - master + pull_request: + paths: + - rust/candid_type_generation/** + - .github/workflows/candid_type_generation.yml + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + rust-candid_type_generation: + runs-on: ubuntu-24.04 + container: ghcr.io/dfinity/icp-dev-env-rust:1.0.0 + env: + ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - name: Deploy and test + working-directory: rust/candid_type_generation + run: | + icp network start -d + icp deploy + make test diff --git a/.github/workflows/rust-candid-type-generation-example.yml b/.github/workflows/rust-candid-type-generation-example.yml deleted file mode 100644 index 8fc3d725f5..0000000000 --- a/.github/workflows/rust-candid-type-generation-example.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: rust-candid-type-generation -on: - push: - branches: - - master - pull_request: - paths: - - rust/candid_type_generation/** - - .github/workflows/provision-darwin.sh - - .github/workflows/provision-linux.sh - - .github/workflows/rust-candid-type-generation-example.yml -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - rust-candid-type-generation-example-darwin: - runs-on: macos-15 - steps: - - uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1.2.0 - - name: Provision Darwin - run: bash .github/workflows/provision-darwin.sh - - name: Candid Type Generation Darwin - run: | - pushd rust/candid_type_generation - rm -rf candid/nns_governance.did src/declarations/nns_governance.rs - ./scripts/fetch_candid.sh - cargo build - [ -s "candid/nns_governance.did" ] || exit 1 - [ -s "src/declarations/nns_governance.rs" ] || exit 1 - popd - rust-candid-type-generation-example-linux: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1.2.0 - - name: Provision Linux - run: bash .github/workflows/provision-linux.sh - - name: Candid Type Generation Linux - run: | - pushd rust/candid_type_generation - rm -rf candid/nns_governance.did src/declarations/nns_governance.rs - ./scripts/fetch_candid.sh - cargo build - [ -s "candid/nns_governance.did" ] || exit 1 - [ -s "src/declarations/nns_governance.rs" ] || exit 1 - popd diff --git a/rust/candid_type_generation/.gitignore b/rust/candid_type_generation/.gitignore new file mode 100644 index 0000000000..232c633c99 --- /dev/null +++ b/rust/candid_type_generation/.gitignore @@ -0,0 +1,3 @@ +# The backend/src/declarations/ directory contains ic-cdk-bindgen generated types +# that are committed to the repository. Override the root .gitignore rule. +!backend/src/declarations/ diff --git a/rust/candid_type_generation/Cargo.lock b/rust/candid_type_generation/Cargo.lock index 11bce4691d..aa16b0a35c 100644 --- a/rust/candid_type_generation/Cargo.lock +++ b/rust/candid_type_generation/Cargo.lock @@ -4,18 +4,27 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "ar_archive_writer" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4087686b4b0a3427190bae57a1d9a478dbb2d40c5dc1bd6e2b6d797913bdd348" +dependencies = [ + "object", +] [[package]] name = "arbitrary" @@ -40,9 +49,21 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "backend" +version = "0.1.0" +dependencies = [ + "candid", + "ic-cdk", + "ic-cdk-bindgen", + "serde", + "serde_bytes", + "serde_json", +] [[package]] name = "beef" @@ -90,9 +111,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" [[package]] name = "block-buffer" @@ -111,9 +132,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "candid" -version = "0.10.17" +version = "0.10.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaac522d18020d5fbc8320ecb12a9b13b2137ae31133da2d42fa256a825507c4" +checksum = "f8f781afa4a1303e3eab4ada0720a874942bcfa936ce01b816ac6378945c43a9" dependencies = [ "anyhow", "binread", @@ -134,14 +155,14 @@ dependencies = [ [[package]] name = "candid_derive" -version = "0.10.17" +version = "0.10.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1b4fddbd462182050989068d53604a91a3d0f117c3c8316c6818023df00add" +checksum = "ad6ae8e7944dd0035651bc0e7b3a3e4cb16f5fc43f8ae4fd76b36ff2cd52759f" dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] @@ -163,24 +184,11 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "candid_type_generation" -version = "0.1.0" -dependencies = [ - "candid", - "ic-cdk", - "ic-cdk-bindgen", - "ic-cdk-macros", - "serde", - "serde_bytes", - "serde_json", -] - [[package]] name = "cc" -version = "1.2.35" +version = "1.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590f9024a68a8c40351881787f1934dc11afd69090f5edb6831464694d836ea3" +checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f" dependencies = [ "find-msvc-tools", "shlex", @@ -188,9 +196,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "codespan-reporting" @@ -199,7 +207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -237,9 +245,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -247,9 +255,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ "darling_core", "darling_macro", @@ -257,34 +265,33 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] name = "data-encoding" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" +checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" [[package]] name = "digest" @@ -319,15 +326,15 @@ dependencies = [ [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "ena" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +checksum = "eabffdaee24bd1bf95c5ef7cec31260444317e72ea56c4c91750e8b7ee58d5f1" dependencies = [ "log", ] @@ -340,9 +347,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "find-msvc-tools" -version = "0.1.0" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fixedbitset" @@ -368,9 +375,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", @@ -379,9 +386,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "heck" @@ -397,20 +404,18 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "ic-cdk" -version = "0.18.7" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efb278f5d3ef033b3eed7f01f1096eaf67701896aa5ef69f5eddf5a84833dc0" +checksum = "6a7971f4983db147afbbc4e7f87f60b09fcd60ac707af37ff3d2468dcddbf551" dependencies = [ "candid", "ic-cdk-executor", "ic-cdk-macros", "ic-error-types", - "ic-management-canister-types", "ic0", + "pin-project-lite", "serde", - "serde_bytes", - "slotmap", - "thiserror 2.0.16", + "thiserror 2.0.18", ] [[package]] @@ -424,25 +429,26 @@ dependencies = [ [[package]] name = "ic-cdk-executor" -version = "1.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f4ee8930fd2e491177e2eb7fff53ee1c407c13b9582bdc7d6920cf83109a2d" +checksum = "33716b730ded33690b8a704bff3533fda87d229e58046823647d28816e9bcee7" dependencies = [ "ic0", "slotmap", + "smallvec", ] [[package]] name = "ic-cdk-macros" -version = "0.18.7" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb14c5d691cc9d72bb95459b4761e3a4b3444b85a63d17555d5ddd782969a1e" +checksum = "a7c20c002200c720958f321bb78b4d4987fc2c380bf9ef69ed4404730810f45f" dependencies = [ "candid", "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] @@ -456,28 +462,17 @@ dependencies = [ "strum_macros", ] -[[package]] -name = "ic-management-canister-types" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea7e5b8a0f7c3b320d9450ac950547db4f24a31601b5d398f9680b64427455d2" -dependencies = [ - "candid", - "serde", - "serde_bytes", -] - [[package]] name = "ic0" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8877193e1921b5fd16accb0305eb46016868cd1935b05c05eca0ec007b943272" +checksum = "c77c8932bff1f09502d0d8c079d5a206a06afe523e35e816162cf4d30b5bf80d" [[package]] name = "ic_principal" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1762deb6f7c8d8c2bdee4b6c5a47b60195b74e9b5280faa5ba29692f8e17429c" +checksum = "1aea751965eaf92990be8c79c64b4f3174ff22dd3604e6696a06a494afbaba2a" dependencies = [ "arbitrary", "crc32fast", @@ -495,9 +490,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "2.11.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", "hashbrown", @@ -514,9 +509,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "lalrpop" @@ -532,7 +527,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.8.6", + "regex-syntax 0.8.11", "string_cache", "term", "tiny-keccak", @@ -557,41 +552,39 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leb128" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +checksum = "c83bff1d572d6b9aeef67ddfc8448e4a3737909cb28e81f97c791b9018703e52" [[package]] name = "libc" -version = "0.2.175" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libredox" -version = "0.1.9" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" dependencies = [ - "bitflags", "libc", ] [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.28" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" [[package]] name = "logos" @@ -613,7 +606,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] @@ -627,9 +620,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "new_debug_unreachable" @@ -666,11 +659,20 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -678,15 +680,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-link", ] [[package]] @@ -720,6 +722,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + [[package]] name = "precomputed-hash" version = "0.1.1" @@ -728,47 +736,48 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "pretty" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac98773b7109bc75f475ab5a134c9b64b87e59d776d31098d8f346922396a477" +checksum = "0d22152487193190344590e4f30e219cf3fe140d9e7a3fdb683d82aa2c5f4156" dependencies = [ "arrayvec", "typed-arena", - "unicode-width", + "unicode-width 0.2.2", ] [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "psm" -version = "0.1.26" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e944464ec8536cd1beb0bbfd96987eb5e3b72f2ecdafdc5c769a37f1fa2ae1f" +checksum = "645dbe486e346d9b5de3ef16ede18c26e6c70ad97418f4874b8b1889d6e761ea" dependencies = [ + "ar_archive_writer", "cc", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags", ] @@ -786,25 +795,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.2" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.6", + "regex-syntax 0.8.11", ] [[package]] name = "regex-automata" -version = "0.4.10" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.6", + "regex-syntax 0.8.11", ] [[package]] @@ -815,9 +824,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "rustversion" @@ -825,12 +834,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - [[package]] name = "same-file" version = "1.0.6" @@ -848,43 +851,55 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ + "serde_core", "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.17" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" dependencies = [ "serde", + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] name = "serde_json" -version = "1.0.143" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", - "ryu", "serde", + "serde_core", + "zmij", ] [[package]] @@ -900,36 +915,36 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "siphasher" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" +checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" [[package]] name = "slotmap" -version = "1.0.7" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" dependencies = [ "version_check", ] [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "stacker" -version = "0.1.21" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cddb07e32ddb770749da91081d8d0ac3a16f1a569a18b20348cd371f5dead06b" +checksum = "640c8cdd92b6b12f5bcb1803ca3bbf5ab96e5e6b6b96b9ab77dabe9e880b3190" dependencies = [ "cc", "cfg-if", @@ -975,7 +990,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] @@ -991,9 +1006,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -1031,11 +1046,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.18", ] [[package]] @@ -1046,18 +1061,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.118", ] [[package]] @@ -1077,21 +1092,21 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" [[package]] name = "typenum" -version = "1.18.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" -version = "1.12.0" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-width" @@ -1099,6 +1114,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -1159,74 +1180,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.59.0" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows-targets" -version = "0.52.6" +name = "windows-sys" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-link", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" +name = "zmij" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/rust/candid_type_generation/Cargo.toml b/rust/candid_type_generation/Cargo.toml index 5c37f8252b..d1e49e317a 100644 --- a/rust/candid_type_generation/Cargo.toml +++ b/rust/candid_type_generation/Cargo.toml @@ -1,18 +1,3 @@ -[package] -name = "candid_type_generation" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -ic-cdk = "0.18.7" -ic-cdk-macros = "0.18.7" -candid = "0.10" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -serde_bytes = "0.11.17" - -[build-dependencies] -ic-cdk-bindgen = "0.1.3" \ No newline at end of file +[workspace] +members = ["backend"] +resolver = "2" diff --git a/rust/candid_type_generation/Makefile b/rust/candid_type_generation/Makefile new file mode 100644 index 0000000000..61eaffb5fc --- /dev/null +++ b/rust/candid_type_generation/Makefile @@ -0,0 +1,8 @@ +.PHONY: test + +test: + @echo "=== Test 1: list_neurons_pretty returns a text response ===" + @result=$$(icp canister call backend list_neurons_pretty '()') && \ + echo "$$result" && \ + echo "$$result" | grep -qE '(NNS Governance Neurons|Error fetching neurons)' && \ + echo "PASS" || (echo "FAIL" && exit 1) diff --git a/rust/candid_type_generation/README.md b/rust/candid_type_generation/README.md index c53da5a118..aa37dc11b2 100644 --- a/rust/candid_type_generation/README.md +++ b/rust/candid_type_generation/README.md @@ -24,7 +24,7 @@ nns_governance.binding.set_type_attributes( ); ``` -Generated types are automatically written to `src/declarations/` and can be imported like any other Rust module. +Generated types are automatically written to `backend/src/declarations/` and can be imported like any other Rust module. ## Candid Fetching Process @@ -32,27 +32,49 @@ Generated types are automatically written to `src/declarations/` and can be impo The fetch script retrieves live Candid interface definitions directly from deployed canisters: -1. **Connects to Mainnet**: Uses `dfx canister --network ic` to access deployed canisters +1. **Connects to Mainnet**: Uses `icp canister metadata --network ic` to access deployed canisters 2. **Fetches Metadata**: Retrieves the `candid:service` metadata from the target canister 3. **Saves Interface**: Writes the Candid definition to `candid/nns_governance.did` ```bash # Fetch the live Candid interface from NNS Governance -dfx canister --network ic metadata "rrkah-fqaaa-aaaaa-aaaaq-cai" candid:service > candid/nns_governance.did +icp canister metadata --network ic "rrkah-fqaaa-aaaaa-aaaaq-cai" candid:service > candid/nns_governance.did ``` This ensures your types stay synchronized with the actual deployed canister interface. +## Build and deploy from the command line + +### Prerequisites + +- [icp-cli](https://cli.internetcomputer.org): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` + +### Install + +```bash +git clone https://github.com/dfinity/examples +cd examples/rust/candid_type_generation +``` + +### Deploy and test + +```bash +icp network start -d +icp deploy +make test +icp network stop +``` + ## Usage Workflow -1. **Fetch Candid Definitions**: +1. **Fetch Candid Definitions** (the `candid/nns_governance.did` file is already checked in, but you can refresh it): ```bash ./scripts/fetch_candid.sh ``` 2. **Build Project**: The build script automatically generates types during compilation: ```bash - cargo build + icp build backend ``` 3. **Use Generated Types**: Import and use the generated types in your code: @@ -98,6 +120,10 @@ This tool automatically generates idiomatic Rust types with appropriate derives Run a bot to update the candid files from mainnet on a regular cadence, and merge these changes in if they compile. Note that you want to have the candid file checked in to ensure build reproducibility between versions, as an updated -candid file on an old version would result in different rust and then also different bytes, which would make it -impossible to reproduce historical builds. That could create problems for any sort of 3rd party verification. +candid file on an old version would result in different Rust types and then also different WASM bytes, which would make +it impossible to reproduce historical builds. That could create problems for any sort of third-party verification. + +## Security considerations and best practices +For information about security best practices when developing ICP canisters, see +https://docs.internetcomputer.org/guides/security/overview diff --git a/rust/candid_type_generation/backend/Cargo.toml b/rust/candid_type_generation/backend/Cargo.toml new file mode 100644 index 0000000000..0508a9cd4a --- /dev/null +++ b/rust/candid_type_generation/backend/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "backend" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +ic-cdk = "0.20" +candid = "0.10" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +serde_bytes = "0.11" + +[build-dependencies] +ic-cdk-bindgen = "0.1.3" diff --git a/rust/candid_type_generation/build.rs b/rust/candid_type_generation/backend/build.rs similarity index 92% rename from rust/candid_type_generation/build.rs rename to rust/candid_type_generation/backend/build.rs index d3e927827c..25ea39172c 100644 --- a/rust/candid_type_generation/build.rs +++ b/rust/candid_type_generation/backend/build.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; fn main() { let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("Cannot find manifest dir")); - let nns_candid_file = cargo_dir.join("candid").join("nns_governance.did"); + let nns_candid_file = cargo_dir.join("..").join("candid").join("nns_governance.did"); if !nns_candid_file.exists() { panic!( diff --git a/rust/candid_type_generation/src/declarations/mod.rs b/rust/candid_type_generation/backend/src/declarations/mod.rs similarity index 100% rename from rust/candid_type_generation/src/declarations/mod.rs rename to rust/candid_type_generation/backend/src/declarations/mod.rs diff --git a/rust/candid_type_generation/src/declarations/nns_governance.rs b/rust/candid_type_generation/backend/src/declarations/nns_governance.rs similarity index 100% rename from rust/candid_type_generation/src/declarations/nns_governance.rs rename to rust/candid_type_generation/backend/src/declarations/nns_governance.rs diff --git a/rust/candid_type_generation/src/lib.rs b/rust/candid_type_generation/backend/src/lib.rs similarity index 85% rename from rust/candid_type_generation/src/lib.rs rename to rust/candid_type_generation/backend/src/lib.rs index dfc896737c..c017ca4b43 100644 --- a/rust/candid_type_generation/src/lib.rs +++ b/rust/candid_type_generation/backend/src/lib.rs @@ -1,10 +1,8 @@ use candid::{CandidType, Principal}; use ic_cdk::api::call::call; -use ic_cdk_macros::*; use serde::{Deserialize, Serialize}; // Import generated types from NNS Governance canister -// This file will be generated by running ./scripts/generate_types.sh mod declarations; // Re-export the types we need @@ -15,17 +13,17 @@ const NNS_GOVERNANCE_CANISTER_ID: &str = "rrkah-fqaaa-aaaaa-aaaaq-cai"; /// Update method to fetch and pretty-print neurons from NNS Governance /// Note: This must be an update call because it makes inter-canister calls -#[update] +#[ic_cdk::update] async fn list_neurons_pretty() -> String { match fetch_neurons().await { Ok(response) => { // Pretty print the response using serde_json for better formatting match serde_json::to_string_pretty(&response) { - Ok(json) => format!("🧠 NNS Governance Neurons:\n{}", json), - Err(_) => format!("🧠 NNS Governance Neurons (Debug):\n{:#?}", response), + Ok(json) => format!("NNS Governance Neurons:\n{}", json), + Err(_) => format!("NNS Governance Neurons (Debug):\n{:#?}", response), } } - Err(err) => format!("❌ Error fetching neurons: {}", err), + Err(err) => format!("Error fetching neurons: {}", err), } } diff --git a/rust/candid_type_generation/candid_type_generation.did b/rust/candid_type_generation/candid_type_generation.did deleted file mode 100644 index def97e37d9..0000000000 --- a/rust/candid_type_generation/candid_type_generation.did +++ /dev/null @@ -1,3 +0,0 @@ -service : { - list_neurons_pretty : () -> (text); -} diff --git a/rust/candid_type_generation/dfx.json b/rust/candid_type_generation/dfx.json deleted file mode 100644 index 3f378f0288..0000000000 --- a/rust/candid_type_generation/dfx.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": 1, - "canisters": { - "candid_type_generation": { - "type": "rust", - "package": "candid_type_generation", - "candid": "candid_type_generation.did" - } - } -} diff --git a/rust/candid_type_generation/icp.yaml b/rust/candid_type_generation/icp.yaml new file mode 100644 index 0000000000..316aa4e9f2 --- /dev/null +++ b/rust/candid_type_generation/icp.yaml @@ -0,0 +1,9 @@ +networks: + - name: local + mode: managed +canisters: + - name: backend + recipe: + type: "@dfinity/rust@v3.3.0" + configuration: + package: backend diff --git a/rust/candid_type_generation/rust-toolchain.toml b/rust/candid_type_generation/rust-toolchain.toml new file mode 100644 index 0000000000..990104f055 --- /dev/null +++ b/rust/candid_type_generation/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +targets = ["wasm32-unknown-unknown"] diff --git a/rust/candid_type_generation/scripts/fetch_candid.sh b/rust/candid_type_generation/scripts/fetch_candid.sh index 120a32a67e..945a176883 100755 --- a/rust/candid_type_generation/scripts/fetch_candid.sh +++ b/rust/candid_type_generation/scripts/fetch_candid.sh @@ -18,23 +18,20 @@ mkdir -p "${FILE_DIR}/../candid" echo "Fetching Candid interface from canister: $NNS_GOVERNANCE_CANISTER_ID" echo "Output file: $OUTPUT_FILE" -# Suppress security warnings since we're only reading public metadata -export DFX_WARNING=-mainnet_plaintext_identity - # Fetch the Candid interface metadata from the deployed canister -dfx canister --network ic metadata "$NNS_GOVERNANCE_CANISTER_ID" candid:service > "$OUTPUT_FILE" +icp canister metadata --network ic "$NNS_GOVERNANCE_CANISTER_ID" candid:service > "$OUTPUT_FILE" # Check if the file was created successfully if [ -f "$OUTPUT_FILE" ]; then - echo "✅ Successfully fetched Candid interface!" - echo "📄 Candid interface saved to: $OUTPUT_FILE" - echo "📏 File size: $(wc -c < "$OUTPUT_FILE") bytes" - echo "📊 Line count: $(wc -l < "$OUTPUT_FILE") lines" + echo "Successfully fetched Candid interface!" + echo "Candid interface saved to: $OUTPUT_FILE" + echo "File size: $(wc -c < "$OUTPUT_FILE") bytes" + echo "Line count: $(wc -l < "$OUTPUT_FILE") lines" else - echo "❌ Failed to fetch Candid interface" + echo "Failed to fetch Candid interface" exit 1 fi echo "=========================================" -echo "✅ Candid interface fetch complete!" +echo "Candid interface fetch complete!" echo "========================================="