From 3c7410c68dd66a804759b04079193081292351af Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:45:31 -0400 Subject: [PATCH 1/5] fix(init): don't gitignore triple-dash (#1289) The `---` is only for the `README.md` file, not `gitignore`. I've also switched the "(ab)used link label (for use with reference style links)"-style comment (`[//] #`) for an HTML comment (``). This means it will be rendered in the HTML, which might be preferable, and is at a minimum benign. I hadn't been familiar with the `[//]: #`-style comment until I saw it here (and searched to find a description of it, along with the "(ab)use" line above, [here]), and I don't think it's worth the potential confusion for users of `soroban contract init`. [here]: https://stackoverflow.com/a/20885980/249801 --- cmd/soroban-cli/src/commands/contract/init.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/init.rs b/cmd/soroban-cli/src/commands/contract/init.rs index ca342434e7..725a9a9da3 100644 --- a/cmd/soroban-cli/src/commands/contract/init.rs +++ b/cmd/soroban-cli/src/commands/contract/init.rs @@ -422,14 +422,14 @@ fn append_contents(from: &Path, to: &Path) -> Result<(), Error> { fn get_merged_file_delimiter(file_path: &Path) -> String { let comment = if file_path.to_string_lossy().contains("README.md") { - "[//]: # \"The following is the Frontend Template's README.md\"".to_string() + "---\n".to_string() } else if file_path.to_string_lossy().contains("gitignore") { "# The following is from the Frontend Template's .gitignore".to_string() } else { String::new() }; - format!("\n\n---\n\n{comment}\n\n").to_string() + format!("\n\n{comment}\n\n").to_string() } #[cfg(test)] @@ -691,13 +691,12 @@ mod tests { let readme_path = project_dir.join("README.md"); let readme_str = read_to_string(readme_path).unwrap(); assert!(readme_str.contains("Soroban Frontend in Astro")); - let expected = "[//]: # \"The following is the Frontend Template's README.md\""; + let expected = "The following is the Frontend Template's README.md"; assert!(readme_str.contains(expected)); let readme_path = project_dir.join("README.md"); let readme_str = read_to_string(readme_path).unwrap(); - let readme_frontend_merge_delimiter = - "[//]: # \"The following is the Frontend Template's README.md\""; + let readme_frontend_merge_delimiter = "The following is the Frontend Template's README.md"; let count = readme_str.matches(readme_frontend_merge_delimiter).count(); // making sure it is in there just once so that it isn't duplicated if `contract init` is run again assert!(count == 1); From 49e053e10f99f70f227fb16b23fa40507a0ad1ec Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Mon, 29 Apr 2024 20:12:20 -0400 Subject: [PATCH 2/5] Update to protocol 21 (#1292) Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Co-authored-by: Nando Vieira --- .github/workflows/binaries.yml | 20 +++--- .github/workflows/e2e.yml | 43 +++++------ .github/workflows/rpc-tests.yml | 4 +- Cargo.lock | 123 +++++++++++++++++++------------- Cargo.toml | 20 +++--- docs/soroban-cli-full-docs.md | 2 +- 6 files changed, 120 insertions(+), 92 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 9afb1a8d65..89ad709016 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -34,21 +34,25 @@ jobs: - run: rustup target add ${{ matrix.target }} - if: matrix.target == 'aarch64-unknown-linux-gnu' run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - name: Setup Version and Name + - name: Setup vars run: | version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "soroban-cli") | .version')" echo "VERSION=${version}" >> $GITHUB_ENV echo "NAME=soroban-cli-${version}-${{ matrix.target }}" >> $GITHUB_ENV - - name: Package + - name: Package (release only) + if: github.event_name == 'release' run: cargo package --no-verify - - name: Build - env: - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + - name: Package Extract (release only) + if: github.event_name == 'release' run: | cd target/package tar xvfz soroban-cli-$VERSION.crate - cd soroban-cli-$VERSION - cargo build --target-dir=../.. --features opt --release --target ${{ matrix.target }} + echo "BUILD_WORKING_DIR=target/package/soroban-cli-$VERSION" >> $GITHUB_ENV + - name: Build + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + working-directory: ${{ env.BUILD_WORKING_DIR }} + run: cargo build --target-dir="$GITHUB_WORKSPACE/target" --features opt --release --target ${{ matrix.target }} - name: Compress run: | cd target/${{ matrix.target }}/release @@ -58,7 +62,7 @@ jobs: with: name: ${{ env.NAME }} path: 'target/${{ matrix.target }}/release/${{ env.NAME }}.tar.gz' - - name: Upload to Release + - name: Upload to Release (release only) if: github.event_name == 'release' uses: actions/github-script@v6 with: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 73e40e9133..0704d4a55a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -13,21 +13,30 @@ jobs: scenario-filter: ["^TestDappDevelop$/^.*$"] runs-on: ubuntu-latest-4-cores env: + # where git refs and images are available for the same artifact, the image + # can be set to pull a pre-compiled image from dockerhub, while the git + # refs can be used to build from source within this workflow. + # the gh tag of system-test repo version to run SYSTEM_TEST_GIT_REF: master + # the pre-compiled image to use of quickstart, or the git ref to build + # from source. + SYSTEM_TEST_QUICKSTART_IMAGE: stellar/quickstart:v423-testing + # SYSTEM_TEST_QUICKSTART_GIT_REF: "https://github.com/stellar/quickstart.git#master" + + # the version of components built in quickstart. only used if quickstart + # is configured above to build from source. + # SYSTEM_TEST_PROTOCOL_VERSION_DEFAULT: 21 + # SYSTEM_TEST_RS_XDR_GIT_REF: v21.0.1 + # SYSTEM_TEST_CORE_IMAGE: + # SYSTEM_TEST_CORE_GIT_REF: https://github.com/stellar/stellar-core.git#v21.0.0rc1 + # SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests" + # SYSTEM_TEST_SOROBAN_RPC_REF: https://github.com/stellar/soroban-rpc.git#v21.0.1 + # the soroban CLI & RPC source code to compile and run from system test # refers to checked out source of current git hub ref context SYSTEM_TEST_SOROBAN_CLI_REF: ${{ github.workspace }}/soroban-cli - SYSTEM_TEST_SOROBAN_RPC_REF: https://github.com/stellar/soroban-rpc.git#v20.3.3 - - # core git ref should be latest commit for stable soroban functionality - # the core bin can either be compiled in-line here as part of ci, - SYSTEM_TEST_CORE_GIT_REF: https://github.com/stellar/stellar-core.git#v20.2.0 - SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests" - # or set SYSTEM_TEST_CORE_GIT_REF to empty, and set SYSTEM_TEST_CORE_IMAGE - # to pull a pre-compiled image from dockerhub instead - SYSTEM_TEST_CORE_IMAGE: # sets the version of rust toolchain that will be pre-installed in the # test runtime environment, tests invoke rustc/cargo @@ -35,21 +44,13 @@ jobs: # set the version of js-stellar-sdk to use, need to choose one of either # resolution options, using npm release or a gh ref: - # # option #1, set the version of stellar-sdk based on a npm release version - SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION: 11.2.2 + SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION: 11.3.0 # option #2, set the version of stellar-sdk used as a ref to a gh repo if # a value is set on SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO, it takes # precedence over any SYSTEM_TEST_JS_STELLAR_SDK_NPM_VERSION - SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: - SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: - - # the version of rs-stellar-xdr to use for quickstart - SYSTEM_TEST_RS_XDR_GIT_REF: v20.1.0 - - # system test will build quickstart image internally to use for running - # the service stack configured in standalone network mode(core, rpc) - SYSTEM_TEST_QUICKSTART_GIT_REF: https://github.com/stellar/quickstart.git#eeb44ee99c564275654800edea2e426d73e966b8 + # SYSTEM_TEST_JS_STELLAR_SDK_GH_REPO: + # SYSTEM_TEST_JS_STELLAR_SDK_GH_REF: # triggers system test to log out details from quickstart's logs and test steps SYSTEM_TEST_VERBOSE_OUTPUT: "true" @@ -92,6 +93,7 @@ jobs: JS_STELLAR_SDK_REF="file:/home/tester/js-stellar-sdk"; \ fi make \ + PROTOCOL_VERSION_DEFAULT=$SYSTEM_TEST_PROTOCOL_VERSION_DEFAULT \ CORE_GIT_REF=$SYSTEM_TEST_CORE_GIT_REF \ CORE_COMPILE_CONFIGURE_FLAGS="$SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS" \ CORE_IMAGE=$SYSTEM_TEST_CORE_IMAGE \ @@ -99,6 +101,7 @@ jobs: SOROBAN_CLI_GIT_REF=$SYSTEM_TEST_SOROBAN_CLI_REF \ RUST_TOOLCHAIN_VERSION=$SYSTEM_TEST_RUST_TOOLCHAIN_VERSION \ RS_XDR_GIT_REF=$SYSTEM_TEST_RS_XDR_GIT_REF \ + QUICKSTART_IMAGE=$SYSTEM_TEST_QUICKSTART_IMAGE \ QUICKSTART_GIT_REF=$SYSTEM_TEST_QUICKSTART_GIT_REF \ JS_STELLAR_SDK_NPM_VERSION=$JS_STELLAR_SDK_REF \ build diff --git a/.github/workflows/rpc-tests.yml b/.github/workflows/rpc-tests.yml index a388754e9a..ad999830ae 100644 --- a/.github/workflows/rpc-tests.yml +++ b/.github/workflows/rpc-tests.yml @@ -11,13 +11,13 @@ jobs: runs-on: ubuntu-22.04 services: rpc: - image: stellar/quickstart:testing@sha256:7f074dddaf081b21d273f7346325cc1017c38bbee7b839f8b633b280a663232d + image: stellar/quickstart:v423-testing ports: - 8000:8000 env: ENABLE_LOGS: true + ENABLE_SOROBAN_DIAGNOSTIC_EVENTS: true NETWORK: local - ENABLE_SOROBAN_RPC: true options: >- --health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/soroban/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'" --health-interval 10s diff --git a/Cargo.lock b/Cargo.lock index 8f7e21907d..36be360401 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -864,16 +864,15 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "ecdsa" -version = "0.16.9" +version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ "der", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature 2.2.0", - "spki", + "signature 2.1.0", ] [[package]] @@ -892,7 +891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", - "signature 2.2.0", + "signature 2.1.0", ] [[package]] @@ -939,7 +938,6 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -2402,9 +2400,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2 0.10.8", - "signature 2.2.0", ] [[package]] @@ -2727,6 +2723,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -2904,6 +2912,15 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro2" version = "1.0.69" @@ -3311,14 +3328,13 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -3357,12 +3373,12 @@ dependencies = [ [[package]] name = "sep5" -version = "0.0.2" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afe34ccbd1fb6fa0b2fc7cccb037bd3d3f1e484c3befe1b713d7611884f336a" +checksum = "0ba64dc259185fdb8dfea7ab0418292743251efba80c9b20e88afc83c17b2593" dependencies = [ "slip10", - "stellar-strkey 0.0.7", + "stellar-strkey 0.0.8", "thiserror", "tiny-bip39", ] @@ -3549,9 +3565,9 @@ checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" [[package]] name = "signature" -version = "2.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -3595,9 +3611,9 @@ dependencies = [ [[package]] name = "soroban-builtin-sdk-macros" -version = "20.3.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc32c6e817f3ca269764ec0d7d14da6210b74a5bf14d4e745aa3ee860558900" +checksum = "e1593481b51c9a2a98b0ff60ba2256796d4dfa8005f7ce237257acee175cf48b" dependencies = [ "itertools 0.11.0", "proc-macro2", @@ -3682,9 +3698,9 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "20.3.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c14e18d879c520ff82612eaae0590acaf6a7f3b977407e1abb1c9e31f94c7814" +checksum = "4ff8c73721c0464eb8f0de7893637bd16512d3fe45143b4197b75e298988d67d" dependencies = [ "arbitrary", "crate-git-revision 0.0.6", @@ -3696,13 +3712,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-xdr", + "wasmparser 0.116.1", ] [[package]] name = "soroban-env-guest" -version = "20.3.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5122ca2abd5ebcc1e876a96b9b44f87ce0a0e06df8f7c09772ddb58b159b7454" +checksum = "94f39b60d7a8467e52ffb7863efba4b3ea3947aa028af8d88f4f5a76bb2909d8" dependencies = [ "soroban-env-common", "static_assertions", @@ -3710,13 +3727,16 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.3.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114a0fa0d0cc39d0be16b1ee35b6e5f4ee0592ddcf459bde69391c02b03cf520" +checksum = "52bd39ea66b834e6e89981affd8b8ba58e450d3964d2a589e1a6a716bca12d77" dependencies = [ "backtrace", "curve25519-dalek 4.1.1", + "ecdsa", "ed25519-dalek 2.0.0", + "elliptic-curve", + "generic-array", "getrandom", "hex-literal", "hmac 0.12.1", @@ -3724,8 +3744,10 @@ dependencies = [ "num-derive", "num-integer", "num-traits", + "p256", "rand", "rand_chacha", + "sec1", "sha2 0.10.8", "sha3", "soroban-builtin-sdk-macros", @@ -3733,13 +3755,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-strkey 0.0.8", + "wasmparser 0.116.1", ] [[package]] name = "soroban-env-macros" -version = "20.3.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13e3f8c86f812e0669e78fcb3eae40c385c6a9dd1a4886a1de733230b4fcf27" +checksum = "8fa76ebee7f29000d92792deccee1f670f4048422ad1a35e686a4654fb65f285" dependencies = [ "itertools 0.11.0", "proc-macro2", @@ -3756,9 +3779,9 @@ version = "20.3.4" [[package]] name = "soroban-ledger-snapshot" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a54708f44890e0546180db6b4f530e2a88d83b05a9b38a131caa21d005e25a" +checksum = "6b71878a8a3db38d5da6fa42d48d055b7937ef9ae608ffcb23f9589aa7989f10" dependencies = [ "serde", "serde_json", @@ -3770,9 +3793,9 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fc8be9068dd4e0212d8b13ad61089ea87e69ac212c262914503a961c8dc3a3" +checksum = "85dc6c199238c4150027034e3cfc383d9c64274292c8dc19bae598e843431356" dependencies = [ "arbitrary", "bytes-lit", @@ -3790,9 +3813,9 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db20def4ead836663633f58d817d0ed8e1af052c9650a04adf730525af85b964" +checksum = "17c503bf0d43499884aa22877e7f293b19882c2088dcd3f00b01eb21b4c65001" dependencies = [ "crate-git-revision 0.0.6", "darling", @@ -3810,14 +3833,14 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eefeb5d373b43f6828145d00f0c5cc35e96db56a6671ae9614f84beb2711cab" +checksum = "4138300450ad75817954070b1cf32422b236410f937205e9f47e44114fd82fe9" dependencies = [ "base64 0.13.1", "stellar-xdr", "thiserror", - "wasmparser 0.88.0", + "wasmparser 0.116.1", ] [[package]] @@ -3836,9 +3859,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3152bca4737ef734ac37fe47b225ee58765c9095970c481a18516a2b287c7a33" +checksum = "2b230255799160fbcf36986f96f506cca671d96541f015546e9f74e99efdedb6" dependencies = [ "prettyplease", "proc-macro2", @@ -3918,9 +3941,9 @@ dependencies = [ [[package]] name = "soroban-token-sdk" -version = "20.5.0" +version = "21.0.1-preview.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8ed0ae2e5d5e67b7939200bba3712b4c81dcf87b2ccd68bba049bec64c780f" +checksum = "a9ac1fe2457ed64e3ba18482b8375264c17340644ea485d0debce129e5cfb50f" dependencies = [ "soroban-sdk", ] @@ -3962,14 +3985,12 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-rpc-client" -version = "20.3.5" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c98cb5068faa68bb4eae0ddd492752042be3c85df145483669936fd794388e" +checksum = "fefdc91d3cda13e6e324f0c03e42126582b7ff7149da7a0ec792820bb11fb75f" dependencies = [ - "base64 0.21.7", "clap", "ed25519-dalek 2.0.0", - "ethnum", "hex", "http 1.0.0", "itertools 0.10.5", @@ -3989,7 +4010,6 @@ dependencies = [ "thiserror", "tokio", "tracing", - "wasmparser 0.90.0", ] [[package]] @@ -4015,9 +4035,9 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "20.1.0" +version = "21.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e59cdf3eb4467fb5a4b00b52e7de6dca72f67fac6f9b700f55c95a5d86f09c9d" +checksum = "88e716110d5e050e528820217f84d4667e166ced841ba48d074152d4ad4ab884" dependencies = [ "arbitrary", "base64 0.13.1", @@ -4808,20 +4828,21 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.88.0" +version = "0.90.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e" +checksum = "b62c8d843f4423efee314dc75a1049886deba3214f7e7f9ff0e4e58b4d618581" dependencies = [ "indexmap 1.9.3", ] [[package]] name = "wasmparser" -version = "0.90.0" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62c8d843f4423efee314dc75a1049886deba3214f7e7f9ff0e4e58b4d618581" +checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50" dependencies = [ - "indexmap 1.9.3", + "indexmap 2.2.3", + "semver", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7e5558c194..839dce2a28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,16 @@ version = "20.3.4" rust-version = "1.74.0" [workspace.dependencies.soroban-env-host] -version = "=20.3.0" +version = "=21.0.1" [workspace.dependencies.soroban-simulation] -version = "=20.3.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-spec] -version = "=20.5.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-spec-rust] -version = "=20.5.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-spec-json] version = "=20.3.4" @@ -38,13 +38,13 @@ version = "20.3.4" path = "./cmd/crates/soroban-spec-tools" [workspace.dependencies.soroban-sdk] -version = "=20.5.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-token-sdk] -version = "=20.5.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-ledger-snapshot] -version = "=20.5.0" +version = "=21.0.1-preview.1" [workspace.dependencies.soroban-cli] version = "=20.3.4" @@ -52,15 +52,15 @@ path = "cmd/soroban-cli" [workspace.dependencies.soroban-rpc] package = "stellar-rpc-client" -version = "=20.3.5" +version = "=21.0.1" [workspace.dependencies.stellar-xdr] -version = "=20.1.0" +version = "=21.0.1" default-features = true [workspace.dependencies] stellar-strkey = "0.0.8" -sep5 = "0.0.2" +sep5 = "0.0.3" base64 = "0.21.2" thiserror = "1.0.46" sha2 = "0.10.7" diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 9c493761be..68b9adc98f 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -1506,7 +1506,7 @@ Decode XDR Default value: `json` - Possible values: `json`, `json-formatted` + Possible values: `json`, `json-formatted`, `rust-debug`, `rust-debug-formatted` From a643000a6cc15bf4bdf1e358881e5671834806b7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:26:04 -0700 Subject: [PATCH 3/5] Bump version to 21.0.0-preview.1 (#1300) Co-authored-by: github-actions[bot] Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> --- .github/workflows/rust.yml | 2 +- Cargo.lock | 22 +++++++++---------- Cargo.toml | 10 ++++----- cmd/crates/soroban-test/Cargo.toml | 2 +- .../tests/fixtures/hello/Cargo.toml | 2 +- .../test-wasms/custom_type/Cargo.toml | 2 +- .../test-wasms/hello_world/Cargo.toml | 2 +- cmd/soroban-cli/Cargo.toml | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 65058636b4..3fcf3dfed0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -110,7 +110,7 @@ jobs: target: x86_64-pc-windows-msvc cargo-hack-feature-options: --features opt --ignore-unknown-features - uses: stellar/actions/.github/workflows/rust-publish-dry-run-v2.yml@3b400304af2619a33730493eef07fa1071aa8485 + uses: stellar/actions/.github/workflows/rust-publish-dry-run-v2.yml@main with: crates: soroban-spec-tools soroban-spec-json soroban-spec-typescript soroban-test soroban-cli runs-on: ${{ matrix.os }} diff --git a/Cargo.lock b/Cargo.lock index 36be360401..c245e03fc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3623,7 +3623,7 @@ dependencies = [ [[package]] name = "soroban-cli" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "assert_cmd", "assert_fs", @@ -3775,7 +3775,7 @@ dependencies = [ [[package]] name = "soroban-hello" -version = "20.3.4" +version = "21.0.0-preview.1" [[package]] name = "soroban-ledger-snapshot" @@ -3845,7 +3845,7 @@ dependencies = [ [[package]] name = "soroban-spec-json" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "pretty_assertions", "serde", @@ -3875,7 +3875,7 @@ dependencies = [ [[package]] name = "soroban-spec-tools" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "base64 0.21.7", "ethnum", @@ -3894,7 +3894,7 @@ dependencies = [ [[package]] name = "soroban-spec-typescript" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "base64 0.21.7", "heck 0.4.1", @@ -3915,7 +3915,7 @@ dependencies = [ [[package]] name = "soroban-test" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "assert_cmd", "assert_fs", @@ -4207,28 +4207,28 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test_custom_types" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "soroban-sdk", ] [[package]] name = "test_hello_world" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "soroban-sdk", ] [[package]] name = "test_swap" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "soroban-sdk", ] [[package]] name = "test_token" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "soroban-sdk", "soroban-token-sdk", @@ -4236,7 +4236,7 @@ dependencies = [ [[package]] name = "test_udt" -version = "20.3.4" +version = "21.0.0-preview.1" dependencies = [ "soroban-sdk", ] diff --git a/Cargo.toml b/Cargo.toml index 839dce2a28..b2ea0177b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ default-members = ["cmd/soroban-cli", "cmd/crates/soroban-spec-tools", "cmd/crat exclude = ["cmd/crates/soroban-test/tests/fixtures/hello"] [workspace.package] -version = "20.3.4" +version = "21.0.0-preview.1" rust-version = "1.74.0" [workspace.dependencies.soroban-env-host] @@ -26,15 +26,15 @@ version = "=21.0.1-preview.1" version = "=21.0.1-preview.1" [workspace.dependencies.soroban-spec-json] -version = "=20.3.4" +version = "=21.0.0-preview.1" path = "./cmd/crates/soroban-spec-json" [workspace.dependencies.soroban-spec-typescript] -version = "20.3.4" +version = "21.0.0-preview.1" path = "./cmd/crates/soroban-spec-typescript" [workspace.dependencies.soroban-spec-tools] -version = "20.3.4" +version = "21.0.0-preview.1" path = "./cmd/crates/soroban-spec-tools" [workspace.dependencies.soroban-sdk] @@ -47,7 +47,7 @@ version = "=21.0.1-preview.1" version = "=21.0.1-preview.1" [workspace.dependencies.soroban-cli] -version = "=20.3.4" +version = "=21.0.0-preview.1" path = "cmd/soroban-cli" [workspace.dependencies.soroban-rpc] diff --git a/cmd/crates/soroban-test/Cargo.toml b/cmd/crates/soroban-test/Cargo.toml index d249246cd5..cba4dae746 100644 --- a/cmd/crates/soroban-test/Cargo.toml +++ b/cmd/crates/soroban-test/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/soroban-test" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "20.3.4" +version = "21.0.0-preview.1" edition = "2021" rust-version.workspace = true autobins = false diff --git a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml index 61152e91dd..424c933418 100644 --- a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soroban-hello" -version = "20.3.4" +version = "21.0.0-preview.1" edition = "2021" publish = false diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml index 5984ee3a84..e6d095b676 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_custom_types" -version = "20.3.4" +version = "21.0.0-preview.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml index aa4acae1c8..e0937d2317 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_hello_world" -version = "20.3.4" +version = "21.0.0-preview.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index c40e3263b4..b20d223010 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/soroban-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "20.3.4" +version = "21.0.0-preview.1" edition = "2021" rust-version.workspace = true autobins = false From af78d8d086c6c509ca7b353a040b7c924d08dee9 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:08:30 -0400 Subject: [PATCH 4/5] fix(init): don't add two `dev_dependencies` (#1296) When initializing a new project with `soroban contract init`, we need to clean up the `Cargo.toml` of example projects a little. We need to make sure `soroban-sdk` is always inherited from the workspace, and we need to make sure there's no `profile` section. We had a couple issues with the old logic. 1. It was adding a `dev_dependencies` section, with an underscore, which is deprecated. If the Cargo.toml already had a `dev-dependencies` section, it would add a second `dev_dependencies`, which cargo would complain about. 2. The new setting would only set `{ workspace = true }`, even if the old one included other details like `features = ['testutils']`. This adds a new crate, `cargo_toml`, which allows us to parse and manipulate Cargo.toml files in a more sophisticated way, which allows us to make sure we get the `dev-dependencies` section even if it's called `dev_dependencies`. It also makes it straightforward to add the correct inherited dependency. --- Cargo.lock | 11 ++ cmd/soroban-cli/Cargo.toml | 14 +-- cmd/soroban-cli/src/commands/contract/init.rs | 113 ++++++++++++++---- 3 files changed, 105 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c245e03fc9..a44af436fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,6 +363,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cargo_toml" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cb1d556b8b8f36e5ca74938008be3ac102f5dcb5b68a0477e4249ae2291cd3" +dependencies = [ + "serde", + "toml 0.8.10", +] + [[package]] name = "cc" version = "1.0.95" @@ -3631,6 +3641,7 @@ dependencies = [ "base64 0.21.7", "bollard", "cargo_metadata", + "cargo_toml", "chrono", "clap", "clap-markdown", diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index b20d223010..8c0aa3e8ca 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -46,12 +46,12 @@ soroban-ledger-snapshot = { workspace = true } stellar-strkey = { workspace = true } soroban-sdk = { workspace = true } soroban-rpc = { workspace = true } - +cargo_toml = "0.20.1" clap = { workspace = true, features = [ - "derive", - "env", - "deprecated", - "string", + "derive", + "env", + "deprecated", + "string", ] } clap_complete = { workspace = true } async-trait = { workspace = true } @@ -98,8 +98,8 @@ dotenvy = "0.15.7" strum = "0.17.1" strum_macros = "0.17.1" gix = { version = "0.58.0", default-features = false, features = [ - "blocking-http-transport-reqwest-rust-tls", - "worktree-mutation", + "blocking-http-transport-reqwest-rust-tls", + "worktree-mutation", ] } ureq = { version = "2.9.1", features = ["json"] } diff --git a/cmd/soroban-cli/src/commands/contract/init.rs b/cmd/soroban-cli/src/commands/contract/init.rs index 725a9a9da3..2db495854c 100644 --- a/cmd/soroban-cli/src/commands/contract/init.rs +++ b/cmd/soroban-cli/src/commands/contract/init.rs @@ -1,3 +1,11 @@ +use cargo_toml; +use clap::{ + builder::{PossibleValue, PossibleValuesParser, ValueParser}, + Parser, ValueEnum, +}; +use gix::{clone, create, open, progress, remote}; +use rust_embed::RustEmbed; +use serde_json::{from_str, json, to_string_pretty, Error as JsonError, Value as JsonValue}; use std::{ env, ffi::OsStr, @@ -11,15 +19,6 @@ use std::{ str, sync::atomic::AtomicBool, }; - -use clap::{ - builder::{PossibleValue, PossibleValuesParser, ValueParser}, - Parser, ValueEnum, -}; -use gix::{clone, create, open, progress, remote}; -use rust_embed::RustEmbed; -use serde_json::{from_str, json, to_string_pretty, Error as JsonError, Value as JsonValue}; -use toml_edit::{Document, Formatted, InlineTable, Item, TomlError, Value as TomlValue}; use ureq::get; const SOROBAN_EXAMPLES_URL: &str = "https://github.com/stellar/soroban-examples.git"; @@ -73,7 +72,7 @@ pub enum Error { CheckoutError(#[from] clone::checkout::main_worktree::Error), #[error("Failed to parse toml file: {0}")] - TomlParseError(#[from] TomlError), + CargoTomlParseError(#[from] cargo_toml::Error), #[error("Failed to parse package.json file: {0}")] JsonParseError(#[from] JsonError), @@ -314,27 +313,49 @@ fn copy_example_contracts(from: &Path, to: &Path, contracts: &[String]) -> Resul Ok(()) } +fn inherit_sdk(mut deps: cargo_toml::DepsSet) -> cargo_toml::DepsSet { + if let Some(sdk_dep) = deps.get("soroban-sdk") { + match sdk_dep { + cargo_toml::Dependency::Simple(_) => { + deps.insert( + "soroban-sdk".to_string(), + cargo_toml::Dependency::Inherited(cargo_toml::InheritedDependencyDetail { + workspace: true, + ..Default::default() + }), + ); + } + + cargo_toml::Dependency::Detailed(details) => { + deps.insert( + "soroban-sdk".to_string(), + cargo_toml::Dependency::Inherited(cargo_toml::InheritedDependencyDetail { + features: details.features.clone(), + optional: details.optional, + workspace: true, + }), + ); + } + + // we don't need to do anything, it already has `workspace = true` + cargo_toml::Dependency::Inherited(_) => (), + } + } + deps +} + fn edit_contract_cargo_file(contract_path: &Path) -> Result<(), Error> { let cargo_path = contract_path.join("Cargo.toml"); - let cargo_toml_str = read_to_string(&cargo_path).map_err(|e| { - eprint!("Error reading Cargo.toml file in: {contract_path:?}"); - e - })?; - let mut doc = cargo_toml_str.parse::().map_err(|e| { + let mut doc = cargo_toml::Manifest::from_path(cargo_path.clone()).map_err(|e| { eprintln!("Error parsing Cargo.toml file in: {contract_path:?}"); e })?; - let mut workspace_table = InlineTable::new(); - workspace_table.insert("workspace", TomlValue::Boolean(Formatted::new(true))); - - doc["dependencies"]["soroban-sdk"] = - Item::Value(TomlValue::InlineTable(workspace_table.clone())); - doc["dev_dependencies"]["soroban-sdk"] = Item::Value(TomlValue::InlineTable(workspace_table)); - - doc.remove("profile"); + doc.dependencies = inherit_sdk(doc.dependencies); + doc.dev_dependencies = inherit_sdk(doc.dev_dependencies); + doc.profile = cargo_toml::Profiles::default(); - write(&cargo_path, doc.to_string()).map_err(|e| { + write(&cargo_path, toml::to_string(&doc).unwrap()).map_err(|e| { eprintln!("Error writing to Cargo.toml file in: {contract_path:?}"); e })?; @@ -637,8 +658,48 @@ mod tests { fn assert_contract_cargo_file_uses_workspace(project_dir: &Path, contract_name: &str) { let contract_dir = project_dir.join("contracts").join(contract_name); let cargo_toml_path = contract_dir.as_path().join("Cargo.toml"); - let cargo_toml_str = read_to_string(cargo_toml_path).unwrap(); - assert!(cargo_toml_str.contains("soroban-sdk = { workspace = true }")); + let cargo_toml_str = read_to_string(cargo_toml_path.clone()).unwrap(); + let doc = cargo_toml_str.parse::().unwrap(); + println!("{cargo_toml_path:?} contents:\n{cargo_toml_str}"); + assert!( + doc.get("dependencies") + .unwrap() + .get("soroban-sdk") + .unwrap() + .get("workspace") + .unwrap() + .as_bool() + .unwrap(), + "expected [dependencies.soroban-sdk] to be a workspace dependency" + ); + assert!( + doc.get("dev-dependencies") + .unwrap() + .get("soroban-sdk") + .unwrap() + .get("workspace") + .unwrap() + .as_bool() + .unwrap(), + "expected [dev-dependencies.soroban-sdk] to be a workspace dependency" + ); + assert_ne!( + 0, + doc.get("dev-dependencies") + .unwrap() + .get("soroban-sdk") + .unwrap() + .get("features") + .unwrap() + .as_array() + .unwrap() + .len(), + "expected [dev-dependencies.soroban-sdk] to have a features list" + ); + assert!( + doc.get("dev_dependencies").is_none(), + "erroneous 'dev_dependencies' section" + ); } fn assert_example_contract_excluded_files_do_not_exist( From ea25467ae63135877ca77efa27f240db034b8775 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 1 May 2024 07:29:08 +1000 Subject: [PATCH 5/5] Embed examples contract list into source and remove from build script (#1301) --- .github/workflows/rust.yml | 8 ++ Makefile | 5 + cmd/soroban-cli/build.rs | 121 ------------------ cmd/soroban-cli/example_contracts.list | 23 ++++ cmd/soroban-cli/src/commands/contract/init.rs | 4 +- 5 files changed, 39 insertions(+), 122 deletions(-) create mode 100644 cmd/soroban-cli/example_contracts.list diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3fcf3dfed0..8dbcb550fc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,6 +26,14 @@ jobs: - run: rustup update - run: cargo fmt --all --check + check-generated-examples-list: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: make generate-examples-list + - name: Check no diffs exist + run: git add -N . && git diff HEAD --exit-code + build-and-test: strategy: fail-fast: false diff --git a/Makefile b/Makefile index a5a051c4f1..d2faac3306 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,11 @@ build-test-wasms: build-test: build-test-wasms install +generate-examples-list: + curl -sSL https://api.github.com/repos/stellar/soroban-examples/git/trees/main \ + | jq -r '.tree[] | select(.type != "blob" and .path != "hello_world" and (.path | startswith(".") | not)) | .path' \ + > cmd/soroban-cli/example_contracts.list + test: build-test cargo test diff --git a/cmd/soroban-cli/build.rs b/cmd/soroban-cli/build.rs index 82e17a1059..b6e6dd92a0 100644 --- a/cmd/soroban-cli/build.rs +++ b/cmd/soroban-cli/build.rs @@ -1,124 +1,3 @@ fn main() { crate_git_revision::init(); - build_helper::set_example_contracts(); -} - -mod build_helper { - use std::{ - fs::{metadata, File, Metadata}, - io::{self, Write}, - path::{Path, PathBuf}, - }; - - const GITHUB_API_URL: &str = - "https://api.github.com/repos/stellar/soroban-examples/git/trees/main?recursive=1"; - - pub fn set_example_contracts() { - let example_contracts = get_example_contracts().unwrap(); - let w = &mut std::io::stdout(); - set_example_contracts_env_var(w, &example_contracts).unwrap(); - } - - #[derive(serde::Deserialize, Debug)] - struct RepoPath { - path: String, - #[serde(rename = "type")] - type_field: String, - } - - #[derive(serde::Deserialize, Debug)] - struct ReqBody { - tree: Vec, - } - - #[derive(thiserror::Error, Debug)] - pub enum Error { - #[error("Failed to complete get request")] - UreqError(#[from] Box), - - #[error("Io error: {0}")] - IoError(#[from] std::io::Error), - } - - fn get_example_contracts() -> Result { - if file_exists(&cached_example_contracts_file_path()) { - let example_contracts = std::fs::read_to_string(cached_example_contracts_file_path())?; - return Ok(example_contracts); - } - - Ok(fetch_and_cache_example_contracts()) - } - - fn fetch_and_cache_example_contracts() -> String { - let example_contracts = fetch_example_contracts().unwrap().join(","); - let cached_example_contracts = target_dir().join("example_contracts.txt"); - - if let Err(err) = write_cache(&cached_example_contracts, &example_contracts) { - eprintln!("Error writing cache: {err}"); - } - - example_contracts - } - - fn fetch_example_contracts() -> Result, Error> { - let body: ReqBody = ureq::get(GITHUB_API_URL) - .call() - .map_err(Box::new)? - .into_json()?; - let mut valid_examples = Vec::new(); - for item in body.tree { - if item.type_field == "blob" - || item.path.starts_with('.') - || item.path.contains('/') - || item.path == "hello_world" - { - continue; - } - - valid_examples.push(item.path); - } - - Ok(valid_examples) - } - - fn set_example_contracts_env_var( - w: &mut impl std::io::Write, - example_contracts: &str, - ) -> std::io::Result<()> { - writeln!(w, "cargo:rustc-env=EXAMPLE_CONTRACTS={example_contracts}")?; - Ok(()) - } - - fn cached_example_contracts_file_path() -> PathBuf { - target_dir().join("example_contracts.txt") - } - - fn target_dir() -> PathBuf { - project_root().join("target") - } - - fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")) - .ancestors() - .nth(2) - .unwrap() - .to_path_buf() - } - - fn write_cache(cache_file_path: &Path, data: &str) -> io::Result<()> { - // Create or open the cache file - let mut file = File::create(cache_file_path)?; - - // Write the data to the cache file - file.write_all(data.as_bytes())?; - - Ok(()) - } - - fn file_exists(file_path: &Path) -> bool { - metadata(file_path) - .as_ref() - .map(Metadata::is_file) - .unwrap_or(false) - } } diff --git a/cmd/soroban-cli/example_contracts.list b/cmd/soroban-cli/example_contracts.list new file mode 100644 index 0000000000..ea0fbc14f6 --- /dev/null +++ b/cmd/soroban-cli/example_contracts.list @@ -0,0 +1,23 @@ +account +alloc +atomic_multiswap +atomic_swap +auth +cross_contract +custom_types +deep_contract_auth +deployer +errors +eth_abi +events +fuzzing +increment +liquidity_pool +logging +mint-lock +simple_account +single_offer +timelock +token +upgradeable_contract +workspace diff --git a/cmd/soroban-cli/src/commands/contract/init.rs b/cmd/soroban-cli/src/commands/contract/init.rs index 2db495854c..f57caa492f 100644 --- a/cmd/soroban-cli/src/commands/contract/init.rs +++ b/cmd/soroban-cli/src/commands/contract/init.rs @@ -50,7 +50,9 @@ pub struct Cmd { } fn possible_example_values() -> ValueParser { - let example_contracts = env!("EXAMPLE_CONTRACTS").split(',').collect::>(); + let example_contracts = include_str!("../../../example_contracts.list") + .lines() + .collect::>(); let parser = PossibleValuesParser::new(example_contracts.iter().map(PossibleValue::new)); parser.into() }