diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a29913d8452..35bbf0a657a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,48 @@ concurrency: env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io - RUST_VERSION: 1.79.0 - NIGHTLY_RUST_VERSION: nightly-2024-07-16 + RUST_VERSION: 1.82.0 + NIGHTLY_RUST_VERSION: nightly-2024-10-21 jobs: - get-fuel-core-version: + verifications-complete: + needs: + - build-sway-lib-core + - build-sway-lib-std + - build-sway-examples + - build-reference-examples + - forc-fmt-check-sway-lib-core + - forc-fmt-check-sway-lib-std + - forc-fmt-check-sway-examples + - forc-fmt-check-panic + - check-sdk-harness-test-suite-compatibility + - build-mdbook + - build-forc-doc-sway-lib-std + - build-forc-test-project + - cargo-build-workspace + - cargo-clippy + - cargo-toml-fmt-check + - cargo-fmt-check + - cargo-run-e2e-test-evm + - cargo-test-lib-std + - forc-run-benchmarks + - forc-unit-tests + - forc-pkg-fuels-deps-check + - cargo-test-sway-lsp + - cargo-test-forc + - cargo-test-workspace + - cargo-unused-deps-check + - pre-publish-check + - cargo-run-e2e-test + - cargo-run-e2e-test-release + - cargo-test-forc-debug + - cargo-test-forc-client + - notify-slack-on-failure runs-on: ubuntu-latest + steps: + - run: echo "pass" + get-fuel-core-version: + runs-on: buildjet-4vcpu-ubuntu-2204 outputs: fuel_core_version: ${{steps.get_fuel_core_ver.outputs.version}} steps: @@ -40,7 +76,7 @@ jobs: echo "version=$version" >> "$GITHUB_OUTPUT" build-sway-lib-core: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -48,13 +84,15 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - name: Build sway-lib-core run: forc build --path sway-lib-core build-sway-lib-std: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -62,13 +100,15 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - name: Build sway-lib-std run: forc build --path sway-lib-std build-sway-examples: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -76,11 +116,13 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Build Sway examples workspace run: cargo run --locked -p forc -- build --locked --path ./examples/Forc.toml build-reference-examples: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -88,11 +130,13 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Build Sway examples workspace run: cargo run --locked -p forc -- build --locked --path ./docs/reference/src/code/Forc.toml forc-fmt-check-sway-lib-core: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -100,11 +144,13 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Check Sway sway-lib-core formatting run: cargo run --locked -p forc-fmt -- --check --path ./sway-lib-core forc-fmt-check-sway-lib-std: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -112,11 +158,13 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Check Sway sway-lib-std formatting run: cargo run --locked -p forc-fmt -- --check --path ./sway-lib-std forc-fmt-check-sway-examples: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -124,11 +172,13 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Check Sway examples formatting run: cargo run --locked -p forc-fmt -- --check --path ./examples forc-fmt-check-panic: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -136,13 +186,15 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install forc-fmt run: cargo install --locked --debug --path ./forc-plugins/forc-fmt - name: Run the formatter against all sway projects and fail if any of them panic run: scripts/formatter/forc-fmt-check-panic.sh check-sdk-harness-test-suite-compatibility: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - name: Checkout code uses: actions/checkout@v2 @@ -219,7 +271,7 @@ jobs: fi build-forc-doc-sway-lib-std: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -227,6 +279,8 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - name: Install Forc plugins @@ -236,7 +290,7 @@ jobs: run: forc doc --manifest-path ./sway-lib-std build-forc-test-project: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -245,6 +299,8 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - name: Initialize test project @@ -279,13 +335,15 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: "Build Workspace" run: cargo build --locked --workspace --all-features --all-targets env: RUSTFLAGS: "-D warnings" cargo-clippy: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -294,11 +352,13 @@ jobs: toolchain: ${{ env.RUST_VERSION }} components: clippy - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Check Clippy Linter run: cargo clippy --all-features --all-targets -- -D warnings cargo-toml-fmt-check: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Switching this runner to buildjet causes failure. steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -314,7 +374,7 @@ jobs: run: git ls-files | grep Cargo.toml$ | grep -v 'templates/' | xargs --verbose -n 1 cargo-toml-lint cargo-fmt-check: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -326,7 +386,7 @@ jobs: run: cargo fmt --all -- --check cargo-run-e2e-test: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 needs: get-fuel-core-version steps: - uses: actions/checkout@v3 @@ -336,6 +396,8 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown" - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install fuel-core for tests run: | curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz @@ -349,7 +411,7 @@ jobs: cargo run --locked --release --bin test -- --locked cargo-run-e2e-test-release: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 needs: get-fuel-core-version steps: - uses: actions/checkout@v3 @@ -359,6 +421,8 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown" - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install fuel-core for tests run: | curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz @@ -372,7 +436,7 @@ jobs: cargo run --locked --release --bin test -- --locked --release cargo-run-e2e-test-evm: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -381,20 +445,10 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown" - uses: Swatinem/rust-cache@v2 - - name: Cargo Run E2E Tests (EVM) - run: cargo run --locked --release --bin test -- --target evm --locked --no-encoding-v1 - - cargo-run-e2e-test-midenvm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install toolchain - uses: dtolnay/rust-toolchain@master with: - toolchain: ${{ env.RUST_VERSION }} - - uses: Swatinem/rust-cache@v2 + cache-provider: "buildjet" - name: Cargo Run E2E Tests (EVM) - run: cargo run --locked --release --bin test -- --target midenvm --locked --no-encoding-v1 + run: cargo run --locked --release --bin test -- --target evm --locked --no-experimental new_encoding # TODO: Remove this upon merging std tests with the rest of the E2E tests. cargo-test-lib-std: @@ -418,7 +472,7 @@ jobs: run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture forc-run-benchmarks: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 permissions: contents: write steps: @@ -428,6 +482,8 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - name: Run benchmarks @@ -455,7 +511,7 @@ jobs: default_author: github_actions forc-unit-tests: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -463,13 +519,19 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install Forc run: cargo install --locked --debug --path ./forc - - name: Run Unit Tests - run: forc build --path sway-lib-core && forc test --path sway-lib-core && forc build --path sway-lib-std && forc test --path sway-lib-std && forc build --path test/src/in_language_tests & forc test --path test/src/in_language_tests + - name: Run Core Unit Tests + run: forc build --path sway-lib-core && forc test --path sway-lib-core + - name: Run Std Unit Tests + run: forc build --path sway-lib-std && forc test --path sway-lib-std + - name: Run In Language Unit Tests + run: forc build --path test/src/in_language_tests && forc test --path test/src/in_language_tests forc-pkg-fuels-deps-check: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -477,15 +539,14 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 - - - name: Install cargo-deps - run: cargo install cargo-deps + with: + cache-provider: "buildjet" # We require this check to avoid cyclic dependencies between 'fuels' and 'forc-pkg'. # Detailed explanation is found in the echo below. - name: Check 'forc-pkg' dependencies for 'fuels' crates run: | - deps=$(cargo deps --manifest-path forc-pkg/Cargo.toml) + deps=$(cargo tree --manifest-path forc-pkg/Cargo.toml) case "$deps" in *fuels*) @@ -503,7 +564,7 @@ jobs: ;; esac cargo-test-forc-debug: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 needs: get-fuel-core-version steps: - uses: actions/checkout@v3 @@ -513,6 +574,8 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown" - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install fuel-core for tests run: | curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz @@ -522,7 +585,7 @@ jobs: - name: Run tests run: cargo test --locked --release -p forc-debug cargo-test-forc-client: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 needs: get-fuel-core-version steps: - uses: actions/checkout@v3 @@ -532,6 +595,8 @@ jobs: toolchain: ${{ env.RUST_VERSION }} targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown" - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install fuel-core for tests run: | curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz @@ -541,7 +606,21 @@ jobs: - name: Run tests run: cargo test --locked --release -p forc-client -- --test-threads 1 cargo-test-sway-lsp: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 + steps: + - uses: actions/checkout@v3 + - name: Setup Rust and cargo-nextest + uses: moonrepo/setup-rust@v0 + with: + channel: stable + cache-target: release + bins: cargo-nextest + - name: Run sway-lsp tests sequentially + env: + RUST_BACKTRACE: full + run: cargo nextest run --locked --release -p sway-lsp --no-capture --profile ci --config-file sway-lsp/tests/nextest.toml + cargo-test-forc: + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -549,12 +628,14 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 - - name: Run sway-lsp tests sequentially + with: + cache-provider: "buildjet" + - name: Run forc tests separately env: RUST_BACKTRACE: full - run: cargo test --locked --release -p sway-lsp -- --nocapture --test-threads=1 + run: cargo test --locked --release -p forc -- --nocapture cargo-test-workspace: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -562,10 +643,12 @@ jobs: with: toolchain: ${{ env.RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Run tests - run: cargo test --locked --release --workspace --exclude forc-debug --exclude sway-lsp --exclude forc-client + run: cargo test --locked --release --workspace --exclude forc-debug --exclude sway-lsp --exclude forc-client --exclude forc cargo-unused-deps-check: - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v3 - name: Install toolchain @@ -574,6 +657,8 @@ jobs: # `cargo-udeps` requires nightly to run toolchain: ${{ env.NIGHTLY_RUST_VERSION }} - uses: Swatinem/rust-cache@v2 + with: + cache-provider: "buildjet" - name: Install cargo-udeps run: cargo install --locked cargo-udeps - name: Check Unused Deps @@ -596,7 +681,7 @@ jobs: cargo-test-sway-lsp, cargo-unused-deps-check, ] - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - name: Notify Slack On Failure uses: ravsamhq/notify-slack-action@v2 @@ -615,7 +700,7 @@ jobs: # This is a separate job because we want this to fail fast if something is invalid here. pre-publish-check: if: github.event_name == 'release' && github.event.action == 'published' - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 steps: - name: Checkout repository uses: actions/checkout@v3 @@ -628,28 +713,7 @@ jobs: - name: Verify tag version run: | cargo install toml-cli - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-pkg/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-client/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-debug/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-doc/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-fmt/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-lsp/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-tx/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-plugins/forc-crypto/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-test/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-tracing/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} forc-util/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-ast/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-core/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-error/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-ir/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-ir/sway-ir-macros/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-lsp/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-parse/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-types/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} sway-utils/Cargo.toml - ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} swayfmt/Cargo.toml + ./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} - name: Notify if Job Fails uses: ravsamhq/notify-slack-action@v2 @@ -732,7 +796,7 @@ jobs: cargo-unused-deps-check, ] if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 permissions: contents: read packages: write @@ -794,7 +858,7 @@ jobs: build-publish-release-image: # Build & Publish Docker Image Per Sway Release needs: publish - runs-on: ubuntu-latest + runs-on: buildjet-4vcpu-ubuntu-2204 permissions: contents: read packages: write diff --git a/.github/workflows/scripts/verify_tag.sh b/.github/workflows/scripts/verify_tag.sh index e029f651988..6277011a708 100755 --- a/.github/workflows/scripts/verify_tag.sh +++ b/.github/workflows/scripts/verify_tag.sh @@ -6,30 +6,66 @@ err() { } status() { - WIDTH=12 - printf "\e[32m\e[1m%${WIDTH}s\e[0m %s\n" "$1" "$2" + local width=12 + printf "\e[32m\e[1m%${width}s\e[0m %s\n" "$1" "$2" +} + +get_toml_version () { + local toml_path="$1" + + local manifest="Cargo.toml" + echo $(toml get $manifest $toml_path | tr -d '"') +} + +check_version () { + local ref=$1 + local toml_path=$2 + + # strip preceeding 'v' if it exists on tag + ref=${ref/#v} + + local toml_version=$(get_toml_version "$toml_path") + + if [ "$toml_version" != "$ref" ]; then + err "Crate version $toml_version for $toml_path, doesn't match tag version $ref" + exit 1 + else + status "Crate version for $toml_path matches tag $toml_version" + fi } REF=$1 -MANIFEST=$2 if [ -z "$REF" ]; then err "Expected ref to be set" exit 1 fi -if [ -z "$MANIFEST" ]; then - err "Expected manifest to be set" - exit 1 -fi - -# strip preceeding 'v' if it exists on tag -REF=${REF/#v} -TOML_VERSION=$(toml get $MANIFEST package.version | tr -d '"') - -if [ "$TOML_VERSION" != "$REF" ]; then - err "Crate version $TOML_VERSION, doesn't match tag version $REF" - exit 1 -else - status "Crate version matches tag $TOML_VERSION" -fi +for toml_path in \ + "workspace.package.version" \ + "workspace.dependencies.forc.version" \ + "workspace.dependencies.forc-pkg.version" \ + "workspace.dependencies.forc-test.version" \ + "workspace.dependencies.forc-tracing.version" \ + "workspace.dependencies.forc-util.version" \ + "workspace.dependencies.forc-plugins.version" \ + "workspace.dependencies.forc-client.version" \ + "workspace.dependencies.forc-crypto.version" \ + "workspace.dependencies.forc-debug.version" \ + "workspace.dependencies.forc-doc.version" \ + "workspace.dependencies.forc-fmt.version" \ + "workspace.dependencies.forc-lsp.version" \ + "workspace.dependencies.forc-tx.version" \ + "workspace.dependencies.sway-ast.version" \ + "workspace.dependencies.sway-core.version" \ + "workspace.dependencies.sway-error.version" \ + "workspace.dependencies.sway-lsp.version" \ + "workspace.dependencies.sway-parse.version" \ + "workspace.dependencies.sway-types.version" \ + "workspace.dependencies.sway-utils.version" \ + "workspace.dependencies.swayfmt.version" \ + "workspace.dependencies.sway-ir.version" \ + "workspace.dependencies.sway-ir-macros.version" \ +; do + check_version $REF $toml_path +done diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..eb5c4aa3642 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +// Configuration for debugging the Sway Language Server (forc-lsp) +// Usage instructions: +// 1. Ensure you've built forc-lsp with debug symbols: +// cargo build -p forc-lsp +// 2. Install the debug version: +// cargo install --path ./forc-plugins/forc-lsp --debug +// 3. Open your Sway project in a separate VSCode window (this starts forc-lsp) +// 4. In the forc-lsp project window, set breakpoints in the code +// 5. Go to Run and Debug view, select "Attach to forc-lsp", and start debugging +// 6. When prompted, select the forc-lsp process +// 7. Debug forc-lsp as it responds to actions in your Sway project +{ + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "attach", + "name": "Attach to forc-lsp", + "pid": "${command:pickProcess}", + "program": "${env:HOME}/.cargo/bin/forc-lsp" + } + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b67de59cb8b..159d6d5f8cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,18 +14,18 @@ dependencies = [ [[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 0.29.0", + "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aes" @@ -44,7 +44,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.15", + "getrandom", "once_cell", "version_check", ] @@ -56,7 +56,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if 1.0.0", - "getrandom 0.2.15", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -73,9 +73,82 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" + +[[package]] +name = "alloy-eip2930" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "serde", +] + +[[package]] +name = "alloy-eip7702" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "k256", + "serde", +] + +[[package]] +name = "alloy-primitives" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd58d377699e6cfeab52c4a9d28bdc4ef37e2bd235ff2db525071fe37a2e9af5" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if 1.0.0", + "const-hex", + "derive_more 1.0.0", + "foldhash", + "hashbrown 0.15.1", + "hex-literal", + "indexmap 2.6.0", + "itoa", + "k256", + "keccak-asm", + "paste", + "proptest", + "rand", + "ruint", + "rustc-hash 2.0.0", + "serde", + "sha3", + "tiny-keccak", +] + +[[package]] +name = "alloy-rlp" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "da0822426598f95e45dd1ea32a738dac057529a709ee645fcc516ffa4cbde08f" +dependencies = [ + "alloy-rlp-derive", + "arrayvec", + "bytes", +] + +[[package]] +name = "alloy-rlp-derive" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] [[package]] name = "android-tzdata" @@ -117,11 +190,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "ansiterm" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ab587f5395da16dd2e6939adf53dede583221b320cadfb94e02b5b7b9bf24cc" +dependencies = [ + "winapi", +] + [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -134,61 +216,185 @@ 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.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] -name = "arrayref" -version = "0.3.8" +name = "arc-swap" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] -name = "arrayvec" -version = "0.5.2" +name = "ark-ff" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.1", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "ascii" @@ -220,13 +426,13 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -245,14 +451,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "atty" -version = "0.2.14" +name = "aurora-engine-modexp" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "0aef7712851e524f35fbbb74fa6599c5cd8692056a1c36f9ca0d2001b670e7e5" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "hex", + "num", ] [[package]] @@ -263,29 +468,351 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[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 = "aws-config" +version = "1.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b49afaa341e8dd8577e1a2200468f98956d6eda50bcf4a53246cc00174ba924" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-sdk-sso", + "aws-sdk-ssooidc", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "hex", + "http 0.2.12", + "ring", + "time", + "tokio", + "tracing", + "url", + "zeroize", +] + +[[package]] +name = "aws-credential-types" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] + +[[package]] +name = "aws-runtime" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a10d5c055aa540164d9561a0e2e74ad30f0dcf7393c3a92f6733ddf9c5762468" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "tracing", + "uuid 1.11.0", +] + +[[package]] +name = "aws-sdk-kms" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfd059dacda4dfd5b57f2bd453fc6555f9acb496cb77508d517da24cf5d73167" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sso" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09677244a9da92172c8dc60109b4a9658597d4d298b188dd0018b6a66b410ca4" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-ssooidc" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fea2f3a8bb3bd10932ae7ad59cc59f65f270fc9183a7e91f501dc5efbef7ee" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sts" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53dcf5e7d9bd1517b8b998e170e650047cea8a2b85fe1835abe3210713e541b7" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sigv4" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5619742a0d8f253be760bfbb8e8e8368c69e3587e4637af5754e488a611499b1" +dependencies = [ + "aws-credential-types", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "form_urlencoded", + "hex", + "hmac 0.12.1", + "http 0.2.12", + "http 1.1.0", + "once_cell", + "percent-encoding", + "sha2 0.10.8", + "time", + "tracing", +] + +[[package]] +name = "aws-smithy-async" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "aws-smithy-http" +version = "0.60.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-query" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb" +dependencies = [ + "aws-smithy-types", + "urlencoding", +] + +[[package]] +name = "aws-smithy-runtime" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be28bd063fa91fd871d131fc8b68d7cd4c5fa0869bea68daca50dcb1cbd76be2" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "http-body 1.0.1", + "httparse", + "hyper 0.14.31", + "hyper-rustls 0.24.2", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls 0.21.12", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-runtime-api" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92165296a47a812b267b4f41032ff8069ab7ff783696d217f0994a0d7ab585cd" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http 0.2.12", + "http 1.1.0", + "pin-project-lite", + "tokio", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-smithy-types" +version = "1.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbd94a32b3a7d55d3806fe27d98d3ad393050439dd05eb53ece36ec5e3d3510" +dependencies = [ + "base64-simd", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http 1.1.0", + "http-body 0.4.6", + "http-body 1.0.1", + "http-body-util", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", + "tokio", + "tokio-util", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.60.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0b0166827aa700d3dc519f72f8b3a91c35d0b8d042dc5d643a91e6f80648fc" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "rustc_version 0.4.1", + "tracing", +] [[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 1.0.0", "libc", "miniz_oxide", - "object 0.36.3", + "object", "rustc-demangle", "serde", + "windows-targets 0.52.6", ] [[package]] @@ -318,6 +845,16 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + [[package]] name = "base64ct" version = "1.6.0" @@ -362,9 +899,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" @@ -396,30 +933,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "constant_time_eq 0.1.5", -] - -[[package]] -name = "blake3" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" -dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "cc", - "cfg-if 1.0.0", - "constant_time_eq 0.3.0", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -438,11 +951,23 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blst" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + [[package]] name = "borsh" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" +checksum = "f5327f6c99920069d1fe374aa743be1af0031dea9f250852cdf1ae6a0861ee24" dependencies = [ "borsh-derive", "cfg_aliases", @@ -450,16 +975,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" +checksum = "10aedd8f1a81a8aafbfde924b0e3061cd6fedd6f6bbcfc6a76e6fd426d7bfe26" dependencies = [ "once_cell", - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.74", - "syn_derive", + "syn 2.0.87", ] [[package]] @@ -479,7 +1003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.9", "serde", ] @@ -497,9 +1021,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byte-unit" -version = "5.1.4" +version = "5.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ac19bdf0b2665407c39d82dbc937e951e7e2001609f0fb32edd0af45a2d63e" +checksum = "e1cd29c3c585209b0cbc7309bfe3ed7efd8c84c21b7af29c8bfae908f8777174" dependencies = [ "rust_decimal", "serde", @@ -529,22 +1053,57 @@ dependencies = [ ] [[package]] -name = "bytecount" -version = "0.6.8" +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" + +[[package]] +name = "bytes-utils" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" +dependencies = [ + "bytes", + "either", +] [[package]] -name = "byteorder" -version = "1.5.0" +name = "c-kzg" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", + "once_cell", + "serde", +] [[package]] -name = "bytes" -version = "1.7.1" +name = "caseless" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +dependencies = [ + "regex", + "unicode-normalization", +] [[package]] name = "cast" @@ -554,9 +1113,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.12" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68064e60dbf1f17005c2fde4d07c16d8baa506fd7ffed8ccab702d93617975c7" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ "jobserver", "libc", @@ -631,7 +1190,7 @@ checksum = "3147d8272e8fa0ccd29ce51194dd98f79ddfb8191ba9e3409884e751798acf3a" dependencies = [ "core2", "multibase", - "multihash 0.19.1", + "multihash 0.19.2", "unsigned-varint 0.8.0", ] @@ -647,24 +1206,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.2.1", - "strsim 0.8.0", - "textwrap 0.11.0", - "unicode-width", - "vec_map", -] - -[[package]] -name = "clap" -version = "4.5.16" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -672,9 +1216,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -685,11 +1229,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.16" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c677cd0126f3026d8b093fa29eae5d812fde5c05bc66dbb29d0374eea95113a" +checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595" dependencies = [ - "clap 4.5.16", + "clap", ] [[package]] @@ -698,20 +1242,20 @@ version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d494102c8ff3951810c72baf96910b980fb065ca5d3101243e6a8dc19747c86b" dependencies = [ - "clap 4.5.16", + "clap", "clap_complete", ] [[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", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -722,13 +1266,11 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clipboard-win" -version = "4.5.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" dependencies = [ "error-code", - "str-buf", - "winapi", ] [[package]] @@ -739,9 +1281,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "codspeed" -version = "2.6.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a104ac948e0188b921eb3fcbdd55dcf62e542df4c7ab7e660623f6288302089" +checksum = "450a0e9df9df1c154156f4344f99d8f6f6e69d0fc4de96ef6e2e68b2ec3bce97" dependencies = [ "colored", "libc", @@ -750,9 +1292,9 @@ dependencies = [ [[package]] name = "codspeed-criterion-compat" -version = "2.6.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722c36bdc62d9436d027256ce2627af81ac7a596dfc7d13d849d0d212448d7fe" +checksum = "8eb1a6cb9c20e177fde58cdef97c1c7c9264eb1424fe45c4fccedc2fb078a569" dependencies = [ "codspeed", "colored", @@ -813,9 +1355,9 @@ dependencies = [ [[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" @@ -870,9 +1412,9 @@ checksum = "410de1ffe61368aa040f599747584e9e3d19235cf4045be6159edb167ef45ddb" [[package]] name = "completest-pty" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3635aa91b48c47ea30fe12fe7c04efbbf17dade642d4dbaa1e9cfbf3593eed4a" +checksum = "fbd2f22a999db122bd2861c504aa363bbacaa32ebea29edf6924ee6cfe044313" dependencies = [ "completest", "ptyprocess", @@ -881,16 +1423,16 @@ dependencies = [ [[package]] name = "comrak" -version = "0.16.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784836d0812dade01579cc0cc9b1684847044e716fd7aa6bffbc172e42199500" +checksum = "c93ab3577cca16b4a1d80a88c2e0cd8b6e969e51696f0bbb0d1dcb0157109832" dependencies = [ - "clap 4.5.16", + "caseless", + "clap", + "derive_builder", "entities", "memchr", "once_cell", - "pest", - "pest_derive", "regex", "shell-words", "slug", @@ -914,22 +1456,23 @@ dependencies = [ ] [[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "const-hex" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "hex", + "proptest", + "serde", +] [[package]] -name = "constant_time_eq" -version = "0.3.0" +name = "const-oid" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "convert_case" @@ -1001,15 +1544,15 @@ dependencies = [ [[package]] name = "countme" -version = "2.0.4" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" +checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -1032,7 +1575,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.16", + "clap", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1061,9 +1604,9 @@ dependencies = [ [[package]] name = "critical-section" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-channel" @@ -1139,9 +1682,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -1178,7 +1721,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version", + "rustc_version 0.4.1", "subtle", ] @@ -1190,7 +1733,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -1289,7 +1832,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -1311,7 +1854,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -1324,7 +1867,21 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.10", + "parking_lot_core", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", ] [[package]] @@ -1395,6 +1952,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.87", +] + [[package]] name = "derive_more" version = "0.99.18" @@ -1404,8 +1992,29 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", - "syn 2.0.74", + "rustc_version 0.4.1", + "syn 2.0.87", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "unicode-xid", ] [[package]] @@ -1416,9 +2025,9 @@ checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" [[package]] name = "devault" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc1d36b1abcd53bf307972de38ed2da0a57ddeb762b141420067149d3952c9a" +checksum = "b6bd8149b97caf4a72d9dd6b09a4192fcc07c2551ef5c949ea488554a9994649" dependencies = [ "proc-macro2", "quote", @@ -1444,12 +2053,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" -[[package]] -name = "difference" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" - [[package]] name = "digest" version = "0.9.0" @@ -1479,31 +2082,20 @@ checksum = "363641827cb8d8387a69364aa2f85433db83b8b00270ed2c786235d83bf0aa0a" [[package]] name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -dependencies = [ - "libc", - "redox_users 0.3.5", - "winapi", -] - -[[package]] -name = "dirs" -version = "3.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "dirs-sys", + "dirs-sys 0.3.7", ] [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys", + "dirs-sys 0.4.1", ] [[package]] @@ -1523,10 +2115,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", - "redox_users 0.4.5", + "redox_users", "winapi", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1534,10 +2138,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", - "redox_users 0.4.5", + "redox_users", "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "dissimilar" version = "1.0.9" @@ -1562,6 +2177,24 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +[[package]] +name = "duct" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c" +dependencies = [ + "libc", + "once_cell", + "os_pipe", + "shared_child", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.16.9" @@ -1640,6 +2273,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -1654,9 +2293,9 @@ checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[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 1.0.0", ] @@ -1690,7 +2329,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -1703,7 +2342,18 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", +] + +[[package]] +name = "enumn" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -1757,13 +2407,9 @@ dependencies = [ [[package]] name = "error-code" -version = "2.3.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" [[package]] name = "escape8259" @@ -1773,9 +2419,9 @@ checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" [[package]] name = "escargot" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c000f23e9d459aef148b7267e02b03b94a0aaacf4ec64c65612f67e02f525fb6" +checksum = "05a3ac187a16b5382fef8c69fd1bad123c67b7cf3932240a2d43dcdd32cded88" dependencies = [ "log", "once_cell", @@ -1840,12 +2486,12 @@ checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "eventsource-client" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c80c6714d1a380314fcb11a22eeff022e1e1c9642f0bb54e15dc9cb29f37b29" +checksum = "43ddc25e1ad2cc0106d5e2d967397b4fb2068a66677ee9b0eea4600e5cfe8fb4" dependencies = [ "futures", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "hyper-timeout", "log", @@ -1872,7 +2518,7 @@ checksum = "dd65f1b59dd22d680c7a626cc4a000c1e03d241c51c3e034d2bc9f1e90734f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -1899,18 +2545,19 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] -name = "fd-lock" -version = "2.0.0" +name = "fastrlp" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0010f02effd88c702318c5dde0463206be67495d0b4d906ba7c0a8f166cc7f06" +checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" dependencies = [ - "libc", - "winapi", + "arrayvec", + "auto_impl", + "bytes", ] [[package]] @@ -1963,9 +2610,9 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1993,9 +2640,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -2007,55 +2654,64 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "forc" -version = "0.63.5" +version = "0.66.4" dependencies = [ "annotate-snippets", - "ansi_term", + "ansiterm", "anyhow", - "clap 4.5.16", + "clap", "clap_complete", "clap_complete_fig", "completest-pty", "forc-pkg", "forc-test", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-util", "fs_extra", "fuel-asm", "hex", + "rexpect 0.5.0", "serde", "serde_json", "sway-core", "sway-error", + "sway-features", "sway-ir", "sway-types", "sway-utils", "term-table", "tokio", - "toml 0.7.8", - "toml_edit 0.19.15", + "toml 0.8.19", + "toml_edit", "tracing", "url", - "uwuify", "walkdir", "whoami", ] [[package]] name = "forc-client" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", "async-trait", + "aws-config", + "aws-sdk-kms", "chrono", - "clap 4.5.16", + "clap", "devault", "dialoguer", "forc", "forc-pkg", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-tx", "forc-util", "forc-wallet", @@ -2070,58 +2726,66 @@ dependencies = [ "fuels-core", "futures", "hex", + "k256", "portpicker", + "pretty_assertions", "rand", + "regex", "rexpect 0.5.0", "rpassword", "serde", "serde_json", "sway-core", + "sway-features", "sway-types", "sway-utils", "tempfile", "tokio", - "toml_edit 0.21.1", + "toml_edit", "tracing", ] [[package]] name = "forc-crypto" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", "async-trait", - "atty", - "clap 4.5.16", - "forc-tracing 0.63.5", + "clap", + "criterion", + "forc-tracing 0.66.4", "forc-util", "fuel-core-types", "fuel-crypto", + "fuels-accounts", "fuels-core", "futures", "hex", "libp2p-identity", "rand", + "rayon", + "regex", "serde", "serde_json", "serde_yaml", "sha3", - "termion", + "tempfile", + "termion 4.0.3", "tokio", "tracing", ] [[package]] name = "forc-debug" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "dap", "escargot", "forc-pkg", "forc-test", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "fuel-core-client", "fuel-types", "fuel-vm", @@ -2132,6 +2796,7 @@ dependencies = [ "serde_json", "shellfish", "sway-core", + "sway-features", "sway-types", "thiserror", "tokio", @@ -2139,24 +2804,25 @@ dependencies = [ [[package]] name = "forc-doc" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "comrak", "dir_indexer", "expect-test", "forc-pkg", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-util", "horrorshow", "include_dir", "minifier", - "opener 0.5.2", + "opener", "serde", "serde_json", "sway-ast", "sway-core", + "sway-features", "sway-lsp", "sway-types", "swayfmt", @@ -2164,14 +2830,14 @@ dependencies = [ [[package]] name = "forc-fmt" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "forc-pkg", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-util", - "prettydiff 0.5.1", + "prettydiff", "sway-core", "sway-utils", "swayfmt", @@ -2181,10 +2847,10 @@ dependencies = [ [[package]] name = "forc-lsp" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "sway-lsp", "tikv-jemallocator", "tokio", @@ -2192,13 +2858,13 @@ dependencies = [ [[package]] name = "forc-pkg" -version = "0.63.5" +version = "0.66.4" dependencies = [ - "ansi_term", + "ansiterm", "anyhow", "byte-unit", "cid", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-util", "fuel-abi-types", "futures", @@ -2208,14 +2874,15 @@ dependencies = [ "ipfs-api-backend-hyper", "petgraph", "regex", - "reqwest 0.12.5", - "semver", + "reqwest 0.12.9", + "semver 1.0.23", "serde", "serde_ignored", "serde_json", "serde_with", "sway-core", "sway-error", + "sway-features", "sway-types", "sway-utils", "sysinfo", @@ -2229,7 +2896,7 @@ dependencies = [ [[package]] name = "forc-test" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", "forc-pkg", @@ -2240,6 +2907,7 @@ dependencies = [ "rand", "rayon", "sway-core", + "sway-features", "sway-types", ] @@ -2256,9 +2924,9 @@ dependencies = [ [[package]] name = "forc-tracing" -version = "0.63.5" +version = "0.66.4" dependencies = [ - "ansi_term", + "ansiterm", "tracing", "tracing-subscriber", "tracing-test", @@ -2266,10 +2934,10 @@ dependencies = [ [[package]] name = "forc-tx" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "devault", "forc-util", "fuel-tx", @@ -2281,15 +2949,15 @@ dependencies = [ [[package]] name = "forc-util" -version = "0.63.5" +version = "0.66.4" dependencies = [ "annotate-snippets", - "ansi_term", + "ansiterm", "anyhow", - "clap 4.5.16", - "dirs 3.0.2", - "fd-lock 4.0.2", - "forc-tracing 0.63.5", + "clap", + "dirs 5.0.1", + "fd-lock", + "forc-tracing 0.66.4", "fuel-tx", "hex", "paste", @@ -2308,12 +2976,12 @@ dependencies = [ [[package]] name = "forc-wallet" -version = "0.9.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fb8dd372e7141efc5a63a1e6036e4ae0789774087ec9936b6cf426ef19bb16" +checksum = "6ed94e0de4d8265fe744704544932bf1285ffa16ee5feb18062194904d299f9f" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "eth-keystore", "forc-tracing 0.47.0", "fuel-crypto", @@ -2326,7 +2994,7 @@ dependencies = [ "rand", "rpassword", "serde_json", - "termion", + "termion 2.0.3", "tiny-bip39", "tokio", "url", @@ -2384,15 +3052,15 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.74", + "syn 2.0.87", "thiserror", ] [[package]] name = "fuel-asm" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122c27ab46707017063bf1c6e0b4f3de881e22e81b4059750a0dc95033d9cc26" +checksum = "5f325971bf9047ec70004f80a989e03456316bc19cbef3ff3a39a38b192ab56e" dependencies = [ "bitflags 2.6.0", "fuel-types", @@ -2402,9 +3070,9 @@ dependencies = [ [[package]] name = "fuel-core-chain-config" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "318a5a9733255cffac64a4b5acf6a7f41e438bec3ead506fc9f74730ce956528" +checksum = "990db3029efd3766c4ae7c92a53c159ae66abf6f568ac6a3d58354f11400e6e2" dependencies = [ "anyhow", "bech32", @@ -2422,13 +3090,14 @@ dependencies = [ [[package]] name = "fuel-core-client" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ad219bde52b072a2d828f27072982047a77cc02c953ea7e83c23de586d466d" +checksum = "f09b3a35e82226d77b10653829beb508dc4bcf698fbdaa96610faf894e794444" dependencies = [ "anyhow", + "base64 0.22.1", "cynic", - "derive_more", + "derive_more 0.99.18", "eventsource-client", "fuel-core-types", "futures", @@ -2446,22 +3115,25 @@ dependencies = [ [[package]] name = "fuel-core-metrics" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88eb1bd81016b49493181b8bc29526678229350a780d4d04db137415028db179" +checksum = "94a1c3eb92040d95d27f7c658801bb5c04ad4aaf67de380cececbeed5aab6e61" dependencies = [ - "parking_lot 0.12.3", + "once_cell", + "parking_lot", "pin-project-lite", "prometheus-client", "regex", + "strum 0.25.0", + "strum_macros 0.25.3", "tracing", ] [[package]] name = "fuel-core-poa" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef478ff684ee6c2eac57070322ba05525842670576328414da7fd6c40af4e25" +checksum = "2f6f78fa31dc56b9458e3ca9a7058b4bea381e16e49fcab0db49923be8a30f9c" dependencies = [ "anyhow", "async-trait", @@ -2478,33 +3150,34 @@ dependencies = [ [[package]] name = "fuel-core-services" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064b31213ea0b56f6558a0493b264cbd79e060a56de2bd35f8a10d7e78f526fa" +checksum = "8312b598da4b9a6503c9263c1c2a7ea58d34ab1f86e7f345490e12d309fb29bb" dependencies = [ "anyhow", "async-trait", "fuel-core-metrics", "futures", - "parking_lot 0.12.3", + "parking_lot", + "pin-project-lite", "tokio", "tracing", ] [[package]] name = "fuel-core-storage" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f06320744b7d53bc7928d1a40a28fd697191a5b6938a353164231a3423ebdcd9" +checksum = "bda9242ebc9e8ef3251b9eae85f4ce5cdb376348baa30925606f3ce602db7ec5" dependencies = [ "anyhow", - "derive_more", + "derive_more 0.99.18", "enum-iterator", "fuel-core-types", "fuel-vm", "impl-tools", "itertools 0.12.1", - "num_enum 0.7.3", + "num_enum", "paste", "postcard", "primitive-types", @@ -2515,14 +3188,14 @@ dependencies = [ [[package]] name = "fuel-core-types" -version = "0.35.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fda0c6dc7b3bd24a993b3902f55862b8db0fa6de5b0f1d45f5942bc59792eb" +checksum = "6ee3a95b189bf729d21354a761862bb481298cbd883550adc3fef1bc7beb0b67" dependencies = [ "anyhow", "bs58", "derivative", - "derive_more", + "derive_more 0.99.18", "fuel-vm", "rand", "secrecy", @@ -2533,9 +3206,9 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33548590131674e8f272a3e056be4dbaa1de7cb364eab2b17987cd5c0dc31cb0" +checksum = "65e318850ca64890ff123a99b6b866954ef49da94ab9bc6827cf6ee045568585" dependencies = [ "coins-bip32", "coins-bip39", @@ -2546,7 +3219,7 @@ dependencies = [ "lazy_static", "p256", "rand", - "secp256k1 0.26.0", + "secp256k1", "serde", "sha2 0.10.8", "zeroize", @@ -2554,13 +3227,13 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f49fdbfc1615d88d2849650afc2b0ac2fecd69661ebadd31a073d8416747764" +checksum = "ab0bc46a3552964bae5169e79b383761a54bd115ea66951a1a7a229edcefa55a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", "synstructure 0.13.1", ] @@ -2613,11 +3286,11 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf17ce8ee5e8b573ea584c223635ff09f1288ad022bcf662954fdccb907602eb" +checksum = "c79eca6a452311c70978a5df796c0f99f27e474b69719e0db4c1d82e68800d07" dependencies = [ - "derive_more", + "derive_more 0.99.18", "digest 0.10.7", "fuel-storage", "hashbrown 0.13.2", @@ -2628,19 +3301,19 @@ dependencies = [ [[package]] name = "fuel-storage" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1b711f28553ddc5f3546711bd220e144ce4c1af7d9e9a1f70b2f20d9f5b791" +checksum = "2d0c46b5d76b3e11197bd31e036cd8b1cb46c4d822cacc48836638080c6d2b76" [[package]] name = "fuel-tx" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aae44611588d199dd119e4a0ebd8eb7ae4cde6bf8b4d12715610b1f5e5b731" +checksum = "6723bb8710ba2b70516ac94d34459593225870c937670fb3afaf82e0354667ac" dependencies = [ "bitflags 2.6.0", "derivative", - "derive_more", + "derive_more 0.99.18", "fuel-asm", "fuel-crypto", "fuel-merkle", @@ -2650,16 +3323,15 @@ dependencies = [ "postcard", "rand", "serde", - "serde_json", "strum 0.24.1", "strum_macros 0.24.3", ] [[package]] name = "fuel-types" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6fb26bcb408b6897e603f68cf60bbbaf6d15381c99f54a69ea743a58235ac1" +checksum = "982265415a99b5bd6277bc24194a233bb2e18764df11c937b3dbb11a02c9e545" dependencies = [ "fuel-derive", "hex", @@ -2669,16 +3341,16 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.56.0" +version = "0.58.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fc4695efac9207276f6229f2dd9811848b328a13604a698f7bce1d452bd986" +checksum = "54b5362d7d072c72eec20581f67fc5400090c356a7f3ae77c79880b3b177b667" dependencies = [ "anyhow", "async-trait", "backtrace", "bitflags 2.6.0", "derivative", - "derive_more", + "derive_more 0.99.18", "ethnum", "fuel-asm", "fuel-crypto", @@ -2703,9 +3375,9 @@ dependencies = [ [[package]] name = "fuels" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9699101cadc9ad3f1eff2a71532d755ab5526419414b99702e89c1d8b92b5938" +checksum = "25bf359dceffcbab4163bca473a03658b912686c3aa81a223f828260729dd474" dependencies = [ "fuel-core-client", "fuel-crypto", @@ -2719,12 +3391,13 @@ dependencies = [ [[package]] name = "fuels-accounts" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e97cf3bb16c8b6436dd6e3a6f9cea5c1ffda8daf7cdb335c60b74c31572f57" +checksum = "4b0b09d6ce3a12196f6944c74bdd795c39950d32ebaaf56b2943741a5e4308a1" dependencies = [ "async-trait", "chrono", + "cynic", "elliptic-curve", "eth-keystore", "fuel-core-client", @@ -2735,7 +3408,7 @@ dependencies = [ "fuels-core", "itertools 0.12.1", "rand", - "semver", + "semver 1.0.23", "tai64", "thiserror", "tokio", @@ -2744,9 +3417,9 @@ dependencies = [ [[package]] name = "fuels-code-gen" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47552a5e8b6935595131ef38b14ef4eee8db870174ea62c8db804dbfa02f57d6" +checksum = "78bf5f7b37ec598514fb3767abdae5372a9fa0919d350703f5d627ec2eb33456" dependencies = [ "Inflector", "fuel-abi-types", @@ -2755,14 +3428,14 @@ dependencies = [ "quote", "regex", "serde_json", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] name = "fuels-core" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b687c021466238851b07e2d39f974a614ffafc7e57dc9be00840d74c74c5febd" +checksum = "ab66cdf52fa6ef98dbc9cc7b4ce19c6a340b2a4710c5d5f87eae39ffb868bad7" dependencies = [ "async-trait", "bech32", @@ -2782,28 +3455,29 @@ dependencies = [ "postcard", "serde", "serde_json", + "sha2 0.10.8", "thiserror", "uint", ] [[package]] name = "fuels-macros" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9dd9359ca6c0e7ad300d487e59babe03f64c6b7b169a0743d13f5c58837b589" +checksum = "1471d221453d13d4643c9a698212781f0e8ac40f515a8566538db87409e30752" dependencies = [ "fuels-code-gen", "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] name = "fuels-programs" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3288fc4b64e8f93a39b8ffa36fcaef8753232ffda5399662d28e24c172a7d00c" +checksum = "7a854561a68ef4088972119cf31023d2d1afd58584da203bcb7dfbd1e84dd8fc" dependencies = [ "async-trait", "fuel-abi-types", @@ -2820,9 +3494,9 @@ dependencies = [ [[package]] name = "fuels-test-helpers" -version = "0.66.4" +version = "0.66.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11e18f84f11543ab29e787e2170eeed7f390b791f16ef8be363e3700ea21833d" +checksum = "5a7b428c35a54e4d667343b4051f07a7397e6039bd110411c37647db4478086e" dependencies = [ "fuel-core-chain-config", "fuel-core-client", @@ -2850,9 +3524,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -2865,9 +3539,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -2875,15 +3549,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.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -2892,38 +3566,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.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "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.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -2958,17 +3632,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.15" @@ -2977,26 +3640,20 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" dependencies = [ "fallible-iterator", - "indexmap 2.4.0", + "indexmap 2.6.0", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - [[package]] name = "git2" version = "0.19.0" @@ -3035,9 +3692,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.9" +version = "0.10.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d23d5bbda31344d8abc8de7c075b3cf26e5873feba7c4a15d916bce67382bd9" +checksum = "c04e5a94fdb56b1e91eb7df2658ad16832428b8eeda24ff1a0f0288de2bce554" dependencies = [ "bstr", "gix-trace", @@ -3048,15 +3705,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" +checksum = "04bdde120c29f1fc23a24d3e115aeeea3d60d8e65bab92cc5f9d90d9302eb952" [[package]] name = "gix-url" -version = "0.27.4" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2eb9b35bba92ea8f0b5ab406fad3cf6b87f7929aa677ff10aa042c6da621156" +checksum = "fd280c5e84fb22e128ed2a053a0daeacb6379469be6a85e3d518a0636e160c89" dependencies = [ "bstr", "gix-features", @@ -3073,6 +3730,19 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + [[package]] name = "graph-cycles" version = "0.1.0" @@ -3117,7 +3787,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.4.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3126,9 +3796,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -3136,7 +3806,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.4.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3155,11 +3825,12 @@ dependencies = [ [[package]] name = "handlebars" -version = "5.1.2" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315" dependencies = [ "log", + "num-order", "pest", "pest_derive", "serde", @@ -3176,12 +3847,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - [[package]] name = "hashbrown" version = "0.12.3" @@ -3211,6 +3876,15 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +dependencies = [ + "foldhash", +] + [[package]] name = "heapless" version = "0.7.17" @@ -3219,21 +3893,12 @@ checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", - "rustc_version", + "rustc_version 0.4.1", "serde", "spin", "stable_deref_trait", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.1" @@ -3246,15 +3911,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -3276,6 +3932,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hkdf" version = "0.12.4" @@ -3388,9 +4050,9 @@ dependencies = [ [[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" @@ -3406,9 +4068,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[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", @@ -3430,14 +4092,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -3458,7 +4120,7 @@ dependencies = [ "common-multipart-rfc7578", "futures-core", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", ] [[package]] @@ -3469,7 +4131,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs", @@ -3480,15 +4142,15 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", - "rustls 0.23.12", + "rustls 0.23.16", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -3501,7 +4163,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.30", + "hyper 0.14.31", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -3515,7 +4177,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "native-tls", "tokio", @@ -3525,29 +4187,28 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", - "tower", "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", @@ -3566,6 +4227,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -3584,12 +4363,23 @@ dependencies = [ [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -3635,26 +4425,26 @@ dependencies = [ [[package]] name = "impl-tools" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82c305b1081f1a99fda262883c788e50ab57d36c00830bdd7e0a82894ad965c" +checksum = "8a84bc8d2baf8da56e93b4247067d918e1a44829bbbe3e4b875aaf8d7d3c7bc9" dependencies = [ "autocfg", "impl-tools-lib", - "proc-macro-error", - "syn 2.0.74", + "proc-macro-error2", + "syn 2.0.87", ] [[package]] name = "impl-tools-lib" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85d3946d886eaab0702fa0c6585adcced581513223fa9df7ccfabbd9fa331a88" +checksum = "a795a1e201125947a063b967c79de6ae152143ab522f481d4f493c44835ba37a" dependencies = [ - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -3706,12 +4496,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.1", "rayon", "serde", ] @@ -3728,7 +4518,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "inotify-sys", "libc", ] @@ -3753,9 +4543,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.39.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5" +checksum = "7e9ffc4d4892617c50a928c52b2961cb5174b6fc6ebf252b2fac9d21955c48b8" dependencies = [ "console", "lazy_static", @@ -3765,15 +4555,6 @@ dependencies = [ "similar", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "ipfs-api-backend-hyper" version = "0.6.0" @@ -3785,7 +4566,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-multipart-rfc7578", "ipfs-api-prelude", "thiserror", @@ -3819,9 +4600,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 = "is-terminal" @@ -3867,6 +4648,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -3884,18 +4674,18 @@ 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 = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if 1.0.0", "ecdsa", @@ -3914,6 +4704,16 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak-asm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + [[package]] name = "kqueue" version = "1.0.8" @@ -3930,7 +4730,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "libc", ] @@ -3945,9 +4745,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.156" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libdbus-sys" @@ -3975,9 +4775,9 @@ 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 = "libp2p-identity" @@ -3989,7 +4789,7 @@ dependencies = [ "bs58", "hkdf", "libsecp256k1", - "multihash 0.19.1", + "multihash 0.19.2", "quick-protobuf", "sha2 0.10.8", "thiserror", @@ -4016,7 +4816,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", ] [[package]] @@ -4087,7 +4887,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc0bda45ed5b3a2904262c1bb91e526127aa70e7ef3758aba2ef93cf896b9b58" dependencies = [ - "clap 4.5.16", + "clap", "escape8259", "termcolor", "threadpool", @@ -4095,9 +4895,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.19" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc53a7799a7496ebc9fd29f31f7df80e83c9bda5299768af5f9e59eeea74647" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "libc", @@ -4117,6 +4917,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -4162,7 +4968,7 @@ version = "0.94.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c66bfd44a06ae10647fe3f8214762e9369fd4248df1350924b4ef9e770a85ea1" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "serde", "serde_json", "serde_repr", @@ -4180,20 +4986,20 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5" +checksum = "7624879735513024d323e7267a0b3a7176aceb0db537939beb4ee31d9e8945e3" dependencies = [ "anyhow", "chrono", - "clap 4.5.16", + "clap", "clap_complete", "env_logger", "handlebars", "log", "memchr", "once_cell", - "opener 0.7.2", + "opener", "pulldown-cmark", "regex", "serde", @@ -4209,9 +5015,9 @@ name = "mdbook-forc-documenter" version = "0.0.0" dependencies = [ "anyhow", - "clap 4.5.16", + "clap", "mdbook", - "semver", + "semver 1.0.23", "serde", "serde_json", ] @@ -4240,100 +5046,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "miden" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d8a25e092075f58af207e2a42bad5fbbf40c5200f13d2432a806db751a52b5" -dependencies = [ - "log", - "miden-air", - "miden-assembly", - "miden-core", - "miden-processor", - "miden-prover", - "miden-stdlib", - "miden-verifier", -] - -[[package]] -name = "miden-air" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5046ab97d8c2b7136601e9430fd0a14e7d6c6cdd648c90c1e6b39186a38b9a8b" -dependencies = [ - "miden-core", - "winter-air", -] - -[[package]] -name = "miden-assembly" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04eec160cbd5cf3051ad16a244c3d83e648eddbd3349120dc069f6e309259dc" -dependencies = [ - "miden-core", - "num_enum 0.5.11", - "winter-crypto", -] - -[[package]] -name = "miden-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75a2446684f44e61afb27bbdbf2458e8ec58c5c55d9bd202981d7cd265f7cf4" -dependencies = [ - "winter-crypto", - "winter-math", - "winter-utils", -] - -[[package]] -name = "miden-processor" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7a467447a7d6236f3971f91f8c47c8880a01a43c29b0b08285ec50454f02ed" -dependencies = [ - "log", - "miden-core", - "winter-prover", -] - -[[package]] -name = "miden-prover" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2343eaf338770b78fe421f36a3445bb491123e0787006dfa2b98788cd6440ec6" -dependencies = [ - "log", - "miden-air", - "miden-core", - "miden-processor", - "winter-prover", -] - -[[package]] -name = "miden-stdlib" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2a52fd1a44b136dbce7a513ebe5a407dfebc17160af8a2707383df731fc098" -dependencies = [ - "miden-assembly", - "miden-core", -] - -[[package]] -name = "miden-verifier" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d942d5b0bdcad47359d52534ef6fbccebffc0c713d2c7ca65ab603c7965c0a8b" -dependencies = [ - "miden-air", - "miden-assembly", - "miden-core", - "winter-verifier", -] - [[package]] name = "mime" version = "0.3.17" @@ -4352,17 +5064,20 @@ dependencies = [ [[package]] name = "minifier" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95bbbf96b9ac3482c2a25450b67a15ed851319bc5fabf3b40742ea9066e84282" +checksum = "bd559bbf5d350ac7f2c1cf92ed71a869b847a92bce0c1318b47932a5b5f65cdd" +dependencies = [ + "clap", +] [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -4373,7 +5088,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -4385,7 +5100,7 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.52.0", ] @@ -4432,12 +5147,12 @@ dependencies = [ [[package]] name = "multihash" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" +checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" dependencies = [ "core2", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", ] [[package]] @@ -4486,7 +5201,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", "cc", "cfg-if 0.1.10", "libc", @@ -4495,44 +5210,48 @@ dependencies = [ [[package]] name = "nix" -version = "0.20.2" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e06129fb611568ef4e868c14b326274959aa70ff7776e9d55323531c374945" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ - "bitflags 1.2.1", - "cc", + "autocfg", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", "memoffset 0.6.5", + "pin-utils", ] [[package]] name = "nix" -version = "0.25.1" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ - "autocfg", - "bitflags 1.2.1", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", - "memoffset 0.6.5", + "memoffset 0.7.1", "pin-utils", ] [[package]] name = "nix" -version = "0.26.4" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.2.1", + "bitflags 2.6.0", "cfg-if 1.0.0", "libc", - "memoffset 0.7.1", - "pin-utils", ] +[[package]] +name = "normalize-path" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5438dd2b2ff4c6df6e1ce22d825ed2fa93ee2922235cc45186991717f0a892d" + [[package]] name = "normpath" version = "1.3.0" @@ -4544,29 +5263,31 @@ dependencies = [ [[package]] name = "notify" -version = "5.2.0" +version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 1.2.1", + "bitflags 2.6.0", "crossbeam-channel", "filetime", "fsevent-sys", "inotify", "kqueue", "libc", + "log", "mio 0.8.11", "walkdir", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "notify-debouncer-mini" -version = "0.2.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23e9fa24f094b143c1eb61f90ac6457de87be6987bc70746e0179f7dbc9007b" +checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" dependencies = [ "crossbeam-channel", + "log", "notify", ] @@ -4649,6 +5370,21 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-modular" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + [[package]] name = "num-rational" version = "0.4.2" @@ -4667,25 +5403,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] name = "num_cpus" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "num_enum_derive 0.5.11", + "hermit-abi 0.3.9", + "libc", ] [[package]] @@ -4694,19 +5422,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ - "num_enum_derive 0.7.3", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn 1.0.109", + "num_enum_derive", ] [[package]] @@ -4715,10 +5431,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -4728,43 +5444,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] -name = "object" -version = "0.32.2" +name = "numtoa" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "crc32fast", - "flate2", - "hashbrown 0.14.5", - "indexmap 2.4.0", - "memchr", - "ruzstd", -] +checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" [[package]] name = "object" -version = "0.36.3" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ + "crc32fast", + "flate2", + "hashbrown 0.15.1", + "indexmap 2.6.0", "memchr", + "ruzstd", ] [[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 = "onig" -version = "6.3.1" +version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ddfe2c93bb389eea6e6d713306880c7f6dcc99a75b659ce145d962c861b225" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" dependencies = [ - "bitflags 1.2.1", - "lazy_static", + "bitflags 1.3.2", "libc", + "once_cell", "onig_sys", ] @@ -4790,16 +5503,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "opener" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "293c15678e37254c15bd2f092314abb4e51d7fdde05c2021279c12631b54f005" -dependencies = [ - "bstr", - "winapi", -] - [[package]] name = "opener" version = "0.7.2" @@ -4814,9 +5517,9 @@ dependencies = [ [[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 1.0.0", @@ -4835,7 +5538,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -4846,18 +5549,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.1+3.3.1" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] [[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", @@ -4866,6 +5569,28 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "os_pipe" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + [[package]] name = "overload" version = "0.1.1" @@ -4874,9 +5599,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "1.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "p256" @@ -4905,7 +5630,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", @@ -4919,23 +5644,12 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.3" @@ -4943,21 +5657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", - "parking_lot_core 0.9.10", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -4968,7 +5668,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -5000,9 +5700,9 @@ dependencies = [ [[package]] name = "peg" -version = "0.7.0" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" +checksum = "295283b02df346d1ef66052a757869b2876ac29a6bb0ac3f5f7cd44aebe40e8f" dependencies = [ "peg-macros", "peg-runtime", @@ -5010,9 +5710,9 @@ dependencies = [ [[package]] name = "peg-macros" -version = "0.7.0" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" +checksum = "bdad6a1d9cf116a059582ce415d5f5566aabcd4008646779dab7fdc2a9a9d426" dependencies = [ "peg-runtime", "proc-macro2", @@ -5021,9 +5721,9 @@ dependencies = [ [[package]] name = "peg-runtime" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" +checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a" [[package]] name = "percent-encoding" @@ -5033,9 +5733,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", @@ -5044,9 +5744,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", @@ -5054,22 +5754,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", "quote", - "syn 2.0.74", + "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", @@ -5083,27 +5783,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.4.0", + "indexmap 2.6.0", "serde", "serde_derive", ] [[package]] name = "phf" -version = "0.10.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_macros", "phf_shared", - "proc-macro-hack", ] [[package]] name = "phf_generator" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared", "rand", @@ -5111,52 +5810,51 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ "phf_generator", "phf_shared", - "proc-macro-hack", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] name = "phf_shared" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", ] [[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", "quote", - "syn 2.0.74", + "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" @@ -5176,9 +5874,9 @@ dependencies = [ [[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 = "plist" @@ -5187,7 +5885,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64 0.22.1", - "indexmap 2.4.0", + "indexmap 2.6.0", "quick-xml", "serde", "time", @@ -5195,9 +5893,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -5208,15 +5906,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -5232,12 +5930,13 @@ dependencies = [ [[package]] name = "postcard" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" dependencies = [ "cobs", - "embedded-io", + "embedded-io 0.4.0", + "embedded-io 0.6.1", "heapless", "serde", ] @@ -5259,49 +5958,23 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" dependencies = [ "diff", - "yansi", -] - -[[package]] -name = "prettydiff" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5671a83709b2755fe5b776d4915701bf36ed2cd9575035502ec12818141d71" -dependencies = [ - "ansi_term", - "prettytable-rs 0.8.0", - "structopt", + "yansi 1.0.1", ] [[package]] name = "prettydiff" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff1fec61082821f8236cf6c0c14e8172b62ce8a72a0eedc30d3b247bb68dc11" +checksum = "abec3fb083c10660b3854367697da94c674e9e82aa7511014dc958beeb7215e9" dependencies = [ - "ansi_term", + "owo-colors", "pad", - "prettytable-rs 0.10.0", - "structopt", -] - -[[package]] -name = "prettytable-rs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" -dependencies = [ - "atty", - "csv", - "encode_unicode 0.3.6", - "lazy_static", - "term 0.5.2", - "unicode-width", + "prettytable-rs", ] [[package]] @@ -5314,7 +5987,7 @@ dependencies = [ "encode_unicode 1.0.0", "is-terminal", "lazy_static", - "term 0.7.0", + "term", "unicode-width", ] @@ -5352,11 +6025,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -5384,16 +6057,31 @@ dependencies = [ ] [[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", +] [[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", ] @@ -5406,7 +6094,7 @@ checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" dependencies = [ "dtoa", "itoa", - "parking_lot 0.12.3", + "parking_lot", "prometheus-client-derive-encode", ] @@ -5418,7 +6106,27 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", +] + +[[package]] +name = "proptest" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags 2.6.0", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax 0.8.5", + "rusty-fork", + "tempfile", + "unarray", ] [[package]] @@ -5484,6 +6192,12 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-protobuf" version = "0.8.1" @@ -5504,9 +6218,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -5554,7 +6268,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", ] [[package]] @@ -5597,35 +6320,20 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.2.1", -] - [[package]] name = "redox_syscall" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", ] [[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", ] @@ -5638,36 +6346,25 @@ checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb" [[package]] name = "redox_users" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" -dependencies = [ - "getrandom 0.1.16", - "redox_syscall 0.1.57", - "rust-argon2", -] - -[[package]] -name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox 0.1.3", "thiserror", ] [[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.9", + "regex-syntax 0.8.5", ] [[package]] @@ -5681,15 +6378,21 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -5698,9 +6401,9 @@ 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 = "rend" @@ -5727,7 +6430,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -5742,7 +6445,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", - "system-configuration", + "system-configuration 0.5.1", "tokio", "tokio-rustls 0.24.1", "tower-service", @@ -5751,26 +6454,26 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots", - "winreg 0.50.0", + "winreg", ] [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper 1.5.0", + "hyper-rustls 0.27.3", "hyper-tls", "hyper-util", "ipnet", @@ -5781,12 +6484,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.3", + "rustls-pemfile 2.2.0", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", - "system-configuration", + "system-configuration 0.6.1", "tokio", "tokio-native-tls", "tower-service", @@ -5794,44 +6497,73 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.52.0", + "windows-registry", ] [[package]] name = "revm" -version = "2.3.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d84c8f9836efb0f5f5f8de4700a953c4e1f3119e5cfcb0aad8e5be73daf991" +checksum = "641702b12847f9ed418d552f4fcabe536d867a2c980e96b6e7e25d7b992f929f" dependencies = [ - "arrayref", "auto_impl", - "bytes", - "hashbrown 0.13.2", - "num_enum 0.5.11", - "primitive-types", - "revm_precompiles", - "rlp", - "sha3", + "cfg-if 1.0.0", + "dyn-clone", + "revm-interpreter", + "revm-precompile", + "serde", + "serde_json", ] [[package]] -name = "revm_precompiles" -version = "1.1.2" +name = "revm-interpreter" +version = "10.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0353d456ef3e989dc9190f42c6020f09bc2025930c37895826029304413204b5" +checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2" dependencies = [ - "bytes", - "hashbrown 0.13.2", - "num", + "revm-primitives", + "serde", +] + +[[package]] +name = "revm-precompile" +version = "11.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b" +dependencies = [ + "aurora-engine-modexp", + "blst", + "c-kzg", + "cfg-if 1.0.0", + "k256", "once_cell", - "primitive-types", + "revm-primitives", "ripemd", - "secp256k1 0.24.3", + "secp256k1", "sha2 0.10.8", - "sha3", "substrate-bn", ] +[[package]] +name = "revm-primitives" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101" +dependencies = [ + "alloy-eip2930", + "alloy-eip7702", + "alloy-primitives", + "auto_impl", + "bitflags 2.6.0", + "bitvec", + "c-kzg", + "cfg-if 1.0.0", + "dyn-clone", + "enumn", + "hex", + "serde", +] + [[package]] name = "rexpect" version = "0.4.0" @@ -5875,7 +6607,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if 1.0.0", - "getrandom 0.2.15", + "getrandom", "libc", "spin", "untrusted", @@ -5893,9 +6625,9 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.44" +version = "0.7.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" dependencies = [ "bitvec", "bytecheck", @@ -5906,14 +6638,14 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] name = "rkyv_derive" -version = "0.7.44" +version = "0.7.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" dependencies = [ "proc-macro2", "quote", @@ -5937,7 +6669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ "base64 0.13.1", - "bitflags 1.2.1", + "bitflags 1.3.2", "serde", ] @@ -5953,14 +6685,13 @@ dependencies = [ [[package]] name = "rowan" -version = "0.14.1" +version = "0.15.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f77412a3d1f26af0c0783c23b3555a301b1a49805cba7bf9a7827a9e9e285f0" +checksum = "0a542b0253fa46e632d27a1dc5cf7b930de4df8659dc6e720b647fc72147ae3d" dependencies = [ "countme", - "hashbrown 0.11.2", - "memoffset 0.6.5", - "rustc-hash", + "hashbrown 0.14.5", + "rustc-hash 1.1.0", "text-size", ] @@ -5986,24 +6717,42 @@ dependencies = [ ] [[package]] -name = "rust-argon2" -version = "0.8.3" +name = "ruint" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ - "base64 0.13.1", - "blake2b_simd", - "constant_time_eq 0.1.5", - "crossbeam-utils", + "alloy-rlp", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint", + "num-traits", + "parity-scale-codec", + "primitive-types", + "proptest", + "rand", + "rlp", + "ruint-macro", + "serde", + "valuable", + "zeroize", ] +[[package]] +name = "ruint-macro" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" + [[package]] name = "rust_decimal" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "borsh", "bytes", "num-traits", @@ -6025,6 +6774,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -6033,18 +6788,27 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver", + "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -6067,13 +6831,13 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "once_cell", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -6101,19 +6865,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -6127,9 +6890,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -6138,28 +6901,38 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "rusty-fork" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] [[package]] name = "rustyline" -version = "8.2.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd4eaf7a7738f76c98e4f0395253ae853be3eb018f7b0bb57fe1b6c17e31874" +checksum = "02a2d683a4ac90aeef5b1013933f6d977bd37d51ff3f4dad829d4931a7e6be86" dependencies = [ - "bitflags 1.2.1", + "bitflags 2.6.0", "cfg-if 1.0.0", "clipboard-win", - "dirs-next", - "fd-lock 2.0.0", + "fd-lock", + "home", "libc", "log", "memchr", - "nix 0.20.2", + "nix 0.27.1", "radix_trie", - "scopeguard", - "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", @@ -6168,12 +6941,10 @@ dependencies = [ [[package]] name = "ruzstd" -version = "0.5.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" +checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21" dependencies = [ - "byteorder", - "derive_more", "twox-hash", ] @@ -6203,20 +6974,20 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.15" +version = "2.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478f373151538826ed50feaceeef7095ad435065a48153af789005fd5e44c0d" +checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" dependencies = [ "sdd", ] [[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]] @@ -6275,9 +7046,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" +checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" [[package]] name = "seahash" @@ -6301,37 +7072,19 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" -dependencies = [ - "secp256k1-sys 0.6.1", -] - -[[package]] -name = "secp256k1" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "rand", - "secp256k1-sys 0.8.1", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" -dependencies = [ - "cc", + "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" dependencies = [ "cc", ] @@ -6360,14 +7113,23 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.23" @@ -6377,24 +7139,33 @@ dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" -version = "1.0.208" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -6408,10 +7179,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ + "indexmap 2.6.0", "itoa", "memchr", "ryu", @@ -6426,14 +7198,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[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", ] @@ -6452,15 +7224,15 @@ dependencies = [ [[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.4.0", + "indexmap 2.6.0", "serde", "serde_derive", "serde_json", @@ -6470,14 +7242,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", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -6486,7 +7258,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.6.0", "itoa", "ryu", "serde", @@ -6495,27 +7267,27 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" dependencies = [ "futures", "log", "once_cell", - "parking_lot 0.12.3", + "parking_lot", "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -6552,6 +7324,16 @@ dependencies = [ "keccak", ] +[[package]] +name = "sha3-asm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" +dependencies = [ + "cc", + "cfg-if 1.0.0", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -6561,6 +7343,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shared_child" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fa9338aed9a1df411814a5b2252f7cd206c55ae9bf2fa763f8de84603aa60c" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "shell-words" version = "1.1.0" @@ -6569,15 +7361,17 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shellfish" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c66e6fc7a668d89939ee241fb342f401f8c11a80da8fb72fd14681f8d47440b" +checksum = "fef42fa3356b28a29aee098d1656681670da7eb15be0e89bba6f05aea540df3d" dependencies = [ "async-trait", "cfg-if 1.0.0", "rustyline", + "thiserror", "tokio", - "yansi", + "version_check", + "yansi 0.5.1", ] [[package]] @@ -6607,9 +7401,9 @@ dependencies = [ [[package]] name = "simdutf8" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "similar" @@ -6737,23 +7531,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - [[package]] name = "str_indices" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9557cb6521e8d009c51a8666f09356f4b817ba9ba0981a305bd86aee47bd35c" - -[[package]] -name = "strsim" -version = "0.8.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "d08889ec5408683408db66ad89e0e1f93dff55c73a4ccc71c427d5b277ee47e6" [[package]] name = "strsim" @@ -6767,30 +7549,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "strum" version = "0.24.1" @@ -6806,6 +7564,15 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros 0.26.4", +] + [[package]] name = "strum_macros" version = "0.24.3" @@ -6829,7 +7596,20 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.74", + "syn 2.0.87", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.87", ] [[package]] @@ -6853,7 +7633,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sway-ast" -version = "0.63.5" +version = "0.66.4" dependencies = [ "extension-trait", "num-bigint", @@ -6865,38 +7645,39 @@ dependencies = [ [[package]] name = "sway-core" -version = "0.63.5" +version = "0.66.4" dependencies = [ - "clap 4.5.16", + "clap", "derivative", - "dirs 3.0.2", + "dirs 5.0.1", "either", "fuel-abi-types", "fuel-ethabi", "fuel-etk-asm", "fuel-etk-ops", "fuel-vm", - "gimli 0.28.1", + "gimli", "graph-cycles", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "hex", "im", - "indexmap 2.4.0", - "itertools 0.10.5", + "indexmap 2.6.0", + "itertools 0.13.0", "lazy_static", - "miden-core", - "object 0.32.2", - "parking_lot 0.12.3", + "object", + "parking_lot", + "paste", "pest", "pest_derive", "petgraph", - "rustc-hash", + "rustc-hash 1.1.0", "serde", "serde_json", - "sha2 0.9.9", - "strum 0.24.1", + "sha2 0.10.8", + "strum 0.26.3", "sway-ast", "sway-error", + "sway-features", "sway-ir", "sway-parse", "sway-types", @@ -6910,7 +7691,7 @@ dependencies = [ [[package]] name = "sway-error" -version = "0.63.5" +version = "0.66.4" dependencies = [ "either", "in_definite", @@ -6919,23 +7700,32 @@ dependencies = [ "strsim 0.11.1", "sway-types", "thiserror", - "uwuify", +] + +[[package]] +name = "sway-features" +version = "0.66.4" +dependencies = [ + "clap", + "paste", ] [[package]] name = "sway-ir" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", "downcast-rs", "filecheck", - "indexmap 2.4.0", - "itertools 0.10.5", + "indexmap 2.6.0", + "itertools 0.13.0", "once_cell", "peg", - "prettydiff 0.6.4", - "rustc-hash", + "prettydiff", + "rustc-hash 1.1.0", + "serde", "slotmap", + "sway-features", "sway-ir-macros", "sway-types", "sway-utils", @@ -6943,35 +7733,35 @@ dependencies = [ [[package]] name = "sway-ir-macros" -version = "0.63.5" +version = "0.66.4" dependencies = [ - "itertools 0.10.5", + "itertools 0.13.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] name = "sway-lsp" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", "assert-json-diff", "codspeed-criterion-compat", "criterion", "crossbeam-channel", - "dashmap", + "dashmap 6.1.0", "dirs 4.0.0", - "fd-lock 4.0.2", + "fd-lock", "forc-pkg", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "forc-util", "futures", - "indexmap 2.4.0", + "indexmap 2.6.0", "lsp-types", "notify", "notify-debouncer-mini", - "parking_lot 0.12.3", + "parking_lot", "pretty_assertions", "proc-macro2", "quote", @@ -6984,18 +7774,19 @@ dependencies = [ "sway-ast", "sway-core", "sway-error", + "sway-features", "sway-lsp-test-utils", "sway-parse", "sway-types", "sway-utils", "swayfmt", - "syn 1.0.109", + "syn 2.0.87", "tempfile", "thiserror", "tikv-jemallocator", "tokio", - "toml_edit 0.19.15", - "tower", + "toml_edit", + "tower 0.4.13", "tower-lsp", "tracing", "urlencoding", @@ -7003,7 +7794,7 @@ dependencies = [ [[package]] name = "sway-lsp-test-utils" -version = "0.1.0" +version = "0.66.4" dependencies = [ "assert-json-diff", "futures", @@ -7012,13 +7803,13 @@ dependencies = [ "serde", "serde_json", "tokio", - "tower", + "tower 0.5.1", "tower-lsp", ] [[package]] name = "sway-parse" -version = "0.63.5" +version = "0.66.4" dependencies = [ "assert_matches", "extension-trait", @@ -7036,18 +7827,18 @@ dependencies = [ [[package]] name = "sway-types" -version = "0.63.5" +version = "0.66.4" dependencies = [ "bytecount", "fuel-asm", "fuel-crypto", "fuel-tx", - "indexmap 2.4.0", + "indexmap 2.6.0", "lazy_static", "num-bigint", "num-traits", - "parking_lot 0.12.3", - "rustc-hash", + "parking_lot", + "rustc-hash 1.1.0", "serde", "sway-utils", "thiserror", @@ -7055,7 +7846,7 @@ dependencies = [ [[package]] name = "sway-utils" -version = "0.63.5" +version = "0.66.4" dependencies = [ "serde", "walkdir", @@ -7063,17 +7854,17 @@ dependencies = [ [[package]] name = "swayfmt" -version = "0.63.5" +version = "0.66.4" dependencies = [ "anyhow", - "difference", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "indoc", "paste", - "prettydiff 0.6.4", + "prettydiff", "ropey", "serde", "serde_ignored", + "similar", "sway-ast", "sway-core", "sway-error", @@ -7082,7 +7873,7 @@ dependencies = [ "sway-utils", "test-macros", "thiserror", - "toml 0.7.8", + "toml 0.8.19", ] [[package]] @@ -7098,27 +7889,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.74" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syn_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.74", -] - [[package]] name = "sync_wrapper" version = "0.1.2" @@ -7130,6 +7909,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -7151,7 +7933,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7161,14 +7943,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" dependencies = [ "bincode", - "bitflags 1.2.1", + "bitflags 1.3.2", "fancy-regex", "flate2", "fnv", "once_cell", "onig", "plist", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "serde", "serde_derive", "serde_json", @@ -7198,9 +7980,20 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 1.2.1", + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys 0.5.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.6.0", ] [[package]] @@ -7213,11 +8006,21 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tai64" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7401421025f4132e6c1f7af5e7f8287383969f36e6628016cd509b8d3da9dc" +checksum = "014639506e4f425c78e823eabf56e71c093f940ae55b43e58f682e7bc2f5887a" dependencies = [ "serde", ] @@ -7230,26 +8033,30 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "taplo" -version = "0.7.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d17cb5ff4095af064048f25a0a8df815384f63ce21c7410e96b93016757259" +checksum = "010941ac4171eaf12f1e26dfc11dadaf78619ea2330940fef01fe6bb0442d14d" dependencies = [ - "glob", - "indexmap 1.9.3", + "ahash 0.8.11", + "arc-swap", + "either", + "globset", + "itertools 0.10.5", "logos", - "regex", + "once_cell", "rowan", - "semver", - "smallvec", - "toml 0.5.11", - "wasm-bindgen", + "serde", + "serde_json", + "thiserror", + "time", + "tracing", ] [[package]] name = "tar" -version = "0.4.41" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" dependencies = [ "filetime", "libc", @@ -7258,9 +8065,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if 1.0.0", "fastrand", @@ -7269,17 +8076,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "term" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" -dependencies = [ - "byteorder", - "dirs 1.0.5", - "winapi", -] - [[package]] name = "term" version = "0.7.0" @@ -7313,12 +8109,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -7329,7 +8125,19 @@ checksum = "c4648c7def6f2043b2568617b9f9b75eae88ca185dbc1f1fda30e95a85d49d7d" dependencies = [ "libc", "libredox 0.0.2", - "numtoa", + "numtoa 0.1.0", + "redox_termios", +] + +[[package]] +name = "termion" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eaa98560e51a2cf4f0bb884d8b2098a9ea11ecf3b7078e9c68242c74cc923a7" +dependencies = [ + "libc", + "libredox 0.1.3", + "numtoa 0.2.4", "redox_termios", ] @@ -7339,14 +8147,15 @@ version = "0.0.0" dependencies = [ "anyhow", "bytes", - "clap 4.5.16", + "clap", "colored", + "duct", "filecheck", "forc", "forc-client", "forc-pkg", "forc-test", - "forc-tracing 0.63.5", + "forc-tracing 0.66.4", "fuel-vm", "futures", "gag", @@ -7354,20 +8163,21 @@ dependencies = [ "hex", "insta", "libtest-mimic", - "miden", - "prettydiff 0.6.4", + "normalize-path", + "prettydiff", "rand", "regex", "revm", "serde_json", "sway-core", "sway-error", + "sway-features", "sway-ir", "sway-types", "sway-utils", - "textwrap 0.16.1", + "textwrap", "tokio", - "toml 0.7.8", + "toml 0.8.19", "tracing", "vte 0.13.0", ] @@ -7377,7 +8187,7 @@ name = "test-macros" version = "0.0.0" dependencies = [ "paste", - "prettydiff 0.6.4", + "prettydiff", ] [[package]] @@ -7386,15 +8196,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "textwrap" version = "0.16.1" @@ -7408,22 +8209,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7447,9 +8248,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" dependencies = [ "cc", "libc", @@ -7457,9 +8258,9 @@ dependencies = [ [[package]] name = "tikv-jemallocator" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865" dependencies = [ "libc", "tikv-jemalloc-sys", @@ -7507,7 +8308,7 @@ dependencies = [ "once_cell", "pbkdf2 0.11.0", "rand", - "rustc-hash", + "rustc-hash 1.1.0", "sha2 0.10.8", "thiserror", "unicode-normalization", @@ -7524,6 +8325,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -7551,15 +8362,15 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", "libc", "mio 1.0.2", - "parking_lot 0.12.3", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -7585,7 +8396,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7614,16 +8425,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.12", + "rustls 0.23.16", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -7632,36 +8443,24 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", + "futures-sink", + "pin-project-lite", + "tokio", ] [[package]] name = "toml" -version = "0.7.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", ] [[package]] @@ -7673,7 +8472,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -7687,39 +8486,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.4.0", - "serde", - "serde_spanned", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.4.0", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -7738,7 +8513,20 @@ dependencies = [ "futures-util", "pin-project", "pin-project-lite", - "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -7758,7 +8546,7 @@ dependencies = [ "async-trait", "auto_impl", "bytes", - "dashmap", + "dashmap 5.5.3", "futures", "httparse", "lsp-types", @@ -7767,7 +8555,7 @@ dependencies = [ "serde_json", "tokio", "tokio-util", - "tower", + "tower 0.4.13", "tower-lsp-macros", "tracing", ] @@ -7780,7 +8568,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7808,7 +8596,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7881,7 +8669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.74", + "syn 2.0.87", ] [[package]] @@ -7925,9 +8713,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[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" @@ -7941,26 +8729,29 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[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" @@ -7970,30 +8761,30 @@ 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" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unicode_categories" @@ -8036,12 +8827,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.3", "percent-encoding", "serde", ] @@ -8052,12 +8843,24 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + [[package]] name = "utf8-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -8070,27 +8873,15 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.15", + "getrandom", "serde", ] [[package]] name = "uuid" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" - -[[package]] -name = "uwuify" -version = "0.2.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db6840b7adcfd2e866c79157cc890ecdbbc1f739607134039ae64eaa6c07e24" -dependencies = [ - "clap 2.34.0", - "owo-colors", - "parking_lot 0.11.2", - "thiserror", -] +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" @@ -8110,12 +8901,6 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab68b56840f69efb0fefbe3ab6661499217ffdc58e2eef7c3f6f69835386322" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.5" @@ -8128,6 +8913,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + [[package]] name = "vt100" version = "0.15.2" @@ -8146,7 +8937,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "utf8parse", "vte_generate_state_changes", ] @@ -8157,7 +8948,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40eb22ae96f050e0c0d6f7ce43feeae26c348fc4dea56928ca81537cfaa6188b" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "utf8parse", "vte_generate_state_changes", ] @@ -8172,6 +8963,15 @@ dependencies = [ "quote", ] +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -8191,12 +8991,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -8211,37 +9005,35 @@ 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 1.0.0", "once_cell", - "serde", - "serde_json", "wasm-bindgen-macro", ] [[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", "quote", - "syn 2.0.74", + "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 1.0.0", "js-sys", @@ -8251,9 +9043,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", "wasm-bindgen-macro-support", @@ -8261,28 +9053,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", "quote", - "syn 2.0.74", + "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 = "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", @@ -8296,9 +9088,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "which" -version = "6.0.2" +version = "6.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d9c5ed668ee1f17edb3b627225343d210006a90bb1e3745ce1f30b1fb115075" +checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" dependencies = [ "either", "home", @@ -8308,11 +9100,11 @@ dependencies = [ [[package]] name = "whoami" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall 0.5.7", "wasite", "web-sys", ] @@ -8358,12 +9150,33 @@ dependencies = [ ] [[package]] -name = "windows-sys" -version = "0.45.0" +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", ] [[package]] @@ -8393,21 +9206,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -8439,12 +9237,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -8457,12 +9249,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -8475,12 +9261,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -8499,12 +9279,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -8517,12 +9291,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -8535,12 +9303,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -8553,12 +9315,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -8573,18 +9329,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -8599,16 +9346,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - [[package]] name = "winsafe" version = "0.0.19" @@ -8616,81 +9353,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" [[package]] -name = "winter-air" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef91b335c5fefa4e6d3c6274de75a7744b4eecae2d7ee3778c23570f35f83396" -dependencies = [ - "winter-crypto", - "winter-fri", - "winter-math", - "winter-utils", -] - -[[package]] -name = "winter-crypto" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd17ea728ff42185c54dfbabaafd0b442207df6b2cc60f74c607d8c01e9c4db" -dependencies = [ - "blake3", - "sha3", - "winter-math", - "winter-utils", -] - -[[package]] -name = "winter-fri" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2473f8b2c5c553e9f9d4d94b3b7a1e75806b4cdc964004f9bde4b5fc07c10c87" -dependencies = [ - "winter-crypto", - "winter-math", - "winter-utils", -] - -[[package]] -name = "winter-math" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b459961e5d679a1eb62ec1a71c85ac25c5d3bfd126874fcd32b591202d896" -dependencies = [ - "winter-utils", -] - -[[package]] -name = "winter-prover" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831583fd662f49f23ea39427aba20a9b5ab6326230f7994e843d2bd34524411" -dependencies = [ - "log", - "winter-air", - "winter-crypto", - "winter-fri", - "winter-math", - "winter-utils", -] - -[[package]] -name = "winter-utils" -version = "0.4.2" +name = "write16" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f0dbf7ca6aa5893b59928718bf1e7dbe7279bb277b5aa4c4898ddf5004f9417" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" [[package]] -name = "winter-verifier" -version = "0.4.2" +name = "writeable" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922be4651b76aa80e132386a97d23788e2bc542d37b3c187a39998876a8094b6" -dependencies = [ - "winter-air", - "winter-crypto", - "winter-fri", - "winter-math", - "winter-utils", -] +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "wyz" @@ -8718,6 +9390,12 @@ version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" +[[package]] +name = "xmlparser" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" + [[package]] name = "yaml-rust" version = "0.4.5" @@ -8733,6 +9411,36 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure 0.13.1", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -8751,7 +9459,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure 0.13.1", ] [[package]] @@ -8771,5 +9500,27 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.87", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] diff --git a/Cargo.toml b/Cargo.toml index b9fe0d0c4ea..31bc6386951 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ members = [ "sway-ast", "sway-core", "sway-error", + "sway-features", "sway-ir", "sway-ir/sway-ir-macros", "sway-lsp", @@ -26,38 +27,208 @@ members = [ "swayfmt", "test", ] -exclude = [ - "examples/*", - "swayfmt/test_macros", - "forc-test/test_data" -] +exclude = ["examples/*", "swayfmt/test_macros", "forc-test/test_data"] + +[workspace.package] +edition = "2021" +version = "0.66.4" +authors = ["Fuel Labs "] +homepage = "https://fuel.network/" +license = "Apache-2.0" +repository = "https://github.com/FuelLabs/sway" [workspace.dependencies] -# Dependencies from the `fuel-core` repository: -fuel-core-client = { version = "0.35.0", default-features = false } -fuel-core-types = { version = "0.35.0", default-features = false } +# +# Internal dependencies in order to propagate `workspace.version` +# -# Dependencies from the `fuel-vm` repository: -fuel-asm = "0.56.0" -fuel-crypto = "0.56.0" -fuel-types = "0.56.0" -fuel-tx = "0.56.0" -fuel-vm = "0.56.0" +forc = { path = "forc/", version = "0.66.4" } +forc-pkg = { path = "forc-pkg/", version = "0.66.4" } +forc-test = { path = "forc-test/", version = "0.66.4" } +forc-tracing = { path = "forc-tracing/", version = "0.66.4" } +forc-util = { path = "forc-util/", version = "0.66.4" } + +# Forc plugins +forc-plugins = { path = "forc-plugins/", version = "0.66.4" } +forc-client = { path = "forc-plugins/forc-client/", version = "0.66.4" } +forc-crypto = { path = "forc-plugins/forc-crypto/", version = "0.66.4" } +forc-debug = { path = "forc-plugins/forc-debug/", version = "0.66.4" } +forc-doc = { path = "forc-plugins/forc-doc/", version = "0.66.4" } +forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.66.4" } +forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.66.4" } +forc-tx = { path = "forc-plugins/forc-tx/", version = "0.66.4" } + +sway-ast = { path = "sway-ast/", version = "0.66.4" } +sway-core = { path = "sway-core/", version = "0.66.4" } +sway-error = { path = "sway-error/", version = "0.66.4" } +sway-features = { path = "sway-features/", version = "0.66.4" } +sway-lsp = { path = "sway-lsp/", version = "0.66.4" } +sway-parse = { path = "sway-parse/", version = "0.66.4" } +sway-types = { path = "sway-types/", version = "0.66.4" } +sway-utils = { path = "sway-utils/", version = "0.66.4" } +swayfmt = { path = "swayfmt/", version = "0.66.4" } + +# Sway IR +sway-ir = { path = "sway-ir/", version = "0.66.4" } +sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.66.4" } + +# +# External Fuel dependencies +# + +# Dependencies from the `fuel-abi-types` repository: +fuel-abi-types = "0.7" + +# Dependencies from the `fuel-core` repository: +# +# Although ALL verions are "X.Y", we need the complete semver for +# fuel-core-client as the GitHub Actions workflow parses this value to pull down +# the correct tarball +fuel-core-client = { version = "0.40.0", default-features = false } +fuel-core-types = { version = "0.40", default-features = false } # Dependencies from the `fuels-rs` repository: -fuels-core = "0.66.4" -fuels-accounts = "0.66.4" -fuels = "0.66.4" + +fuels = "0.66.10" +fuels-core = "0.66.10" +fuels-accounts = "0.66.10" + +# Dependencies from the `fuel-vm` repository: +fuel-asm = "0.58" +fuel-crypto = "0.58" +fuel-types = "0.58" +fuel-tx = "0.58" +fuel-vm = "0.58" # Dependencies from the `forc-wallet` repository: -forc-wallet = "0.9.0" +forc-wallet = "0.11" -# Dependencies from the `fuel-abi-types` repository: -fuel-abi-types = "0.7.0" +# +# External dependencies +# -[workspace.package] -edition = "2021" -authors = ["Fuel Labs "] -homepage = "https://fuel.network/" -license = "Apache-2.0" -repository = "https://github.com/FuelLabs/sway" +annotate-snippets = "0.10" +ansiterm = "0.12" +anyhow = "1.0" +assert-json-diff = "2.0" +async-trait = "0.1" +aws-config = "1.5" +aws-sdk-kms = "1.44" +byte-unit = "5.1" +bytecount = "0.6" +bytes = "1.7" +chrono = { version = "0.4", default-features = false } +cid = "0.11" +clap = "4.5" +clap_complete = "4.5" +clap_complete_fig = "4.5" +colored = "2.0" +comrak = "0.28" +crossbeam-channel = "0.5" +dap = "0.4.1-alpha" +dashmap = "6.1" +derivative = "2.2" +devault = "0.2" +dialoguer = "0.11" +dirs = "5.0" +downcast-rs = "1.2" +either = "1.9" +ethabi = { package = "fuel-ethabi", version = "18.0" } +etk-asm = { package = "fuel-etk-asm", version = "0.3.1-dev" } +etk-ops = { package = "fuel-etk-ops", version = "0.3.1-dev" } +extension-trait = "1.0" +fd-lock = "4.0" +filecheck = "0.5" +fs_extra = "1.2" +futures = { version = "0.3", default-features = false } +gag = "1.0" +gimli = "0.31" +git2 = "0.19" +gix-url = "0.27" +glob = "0.3" +graph-cycles = "0.1" +hashbrown = "0.14" +hex = "0.4" +horrorshow = "0.8" +im = "15.0" +in_definite = "1.0" +include_dir = "0.7" +indexmap = "2.5" +indoc = "2.0" +insta = "1.40" +ipfs-api-backend-hyper = "0.6" +itertools = "0.13" +k256 = "0.13" +lazy_static = "1.4" +libp2p-identity = "0.2" +libtest-mimic = "0.7" +lsp-types = "0.94" +mdbook = { version = "0.4", default-features = false } +minifier = "0.3" +normalize-path = "0.2" +notify = "6.1" +notify-debouncer-mini = "0.4" +num-bigint = "0.4" +num-traits = "0.2" +object = "0.36" +once_cell = "1.18" +opener = "0.7" +parking_lot = "0.12" +paste = "1.0" +peg = "0.8" +pest = "2.7" +pest_derive = "2.7" +petgraph = "0.6" +phf = "0.11" +pretty_assertions = "1.4" +prettydiff = "0.7" +proc-macro2 = "1.0" +quote = "1.0" +rand = "0.8" +rayon = "1.7" +rayon-cond = "0.3" +regex = "1.10" +reqwest = "0.12" +revm = "14.0" +ropey = "1.5" +rpassword = "7.2" +rustc-hash = "1.1" +semver = "1.0" +serde = "1.0" +serde_ignored = "0.1" +serde_json = "1.0" +serde_with = "3.3" +serde_yaml = "0.9" +serial_test = "3.0" +sha2 = "0.10" +sha3 = "0.10" +shellfish = "0.9" +slotmap = "1.0" +smallvec = "1.7" +strsim = "0.11" +strum = "0.26" +syn = "2.0" +taplo = "0.13" +tar = "0.4" +tempfile = "3" +term-table = "1.3" +termion = "4.0" +textwrap = "0.16" +thiserror = "1.0" +tikv-jemallocator = "0.6" +tokio = "1.12" +toml = "0.8" +toml_edit = "0.22" +tower = { version = "0.5", default-features = false } +tower-lsp = "0.20" +tracing = "0.1" +tracing-subscriber = "0.3" +uint = "0.9" +unicode-bidi = "0.3" +unicode-xid = "0.2" +url = "2.2" +urlencoding = "2.1" +vec1 = "1.8" +vte = "0.13" +walkdir = "2.3" +whoami = "1.5" diff --git a/README.md b/README.md index 14eb838f01f..737fb61ebc7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![docs](https://docs.rs/forc/badge.svg)](https://docs.rs/forc/) [![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe) -Sway is a language developed for the Fuel blockchain. It is heavily inspired by Rust and aims to bring modern language development and performance to the blockchain ecosystem. +Sway is a language developed for the [Fuel](https://docs.fuel.network/docs/intro/what-is-fuel/) blockchain. It is heavily inspired by Rust and aims to bring modern language development and performance to the blockchain ecosystem. ## Documentation diff --git a/docs/book/src/blockchain-development/native_assets.md b/docs/book/src/blockchain-development/native_assets.md index 49b1b0bef79..7f1298326f9 100644 --- a/docs/book/src/blockchain-development/native_assets.md +++ b/docs/book/src/blockchain-development/native_assets.md @@ -199,21 +199,31 @@ It implements the [SRC-20; Native Asset](https://github.com/FuelLabs/sway-standa // ERC20 equivalent in Sway. contract; -use src3::SRC3; -use src5::{SRC5, State, AccessError}; -use src20::SRC20; +use standards::{ + src3::SRC3, + src5::{ + SRC5, + State, + AccessError, + }, + src20::{ + SetDecimalsEvent, + SetNameEvent, + SetSymbolEvent, + SRC20, + TotalSupplyEvent, + }, +}; use std::{ asset::{ burn, mint_to, }, - call_frames::{ - contract_id, - msg_asset_id, - }, + call_frames::msg_asset_id, constants::DEFAULT_SUB_ID, context::msg_amount, string::String, + contract_id::ContractId }; configurable { @@ -282,14 +292,21 @@ impl SRC5 for Contract { // Mint and Burn Standard impl SRC3 for Contract { #[storage(read, write)] - fn mint(recipient: Identity, sub_id: SubId, amount: u64) { - require(sub_id == DEFAULT_SUB_ID, "incorrect-sub-id"); + fn mint(recipient: Identity, sub_id: Option, amount: u64) { + require(sub_id.is_some() && sub_id.unwrap() == DEFAULT_SUB_ID, "incorrect-sub-id"); require_access_owner(); + let new_supply = storage.total_supply.read() + amount; storage .total_supply - .write(amount + storage.total_supply.read()); + .write(new_supply); mint_to(recipient, DEFAULT_SUB_ID, amount); + + TotalSupplyEvent::new( + AssetId::default(), + new_supply, + msg_sender().unwrap() + ).log(); } #[storage(read, write)] @@ -302,10 +319,17 @@ impl SRC3 for Contract { ); require_access_owner(); + let new_supply = storage.total_supply.read() - amount; storage .total_supply - .write(storage.total_supply.read() - amount); + .write(new_supply); burn(DEFAULT_SUB_ID, amount); + + TotalSupplyEvent::new( + AssetId::default(), + new_supply, + msg_sender().unwrap() + ).log(); } } @@ -329,6 +353,24 @@ fn require_access_owner() { AccessError::NotOwner, ); } + +abi EmitSRC20Events { + fn emit_src20_events(); +} + +impl EmitSRC20Events for Contract { + fn emit_src20_events() { + // Metadata that is stored as a configurable should only be emitted once. + let asset = AssetId::default(); + let sender = msg_sender().unwrap(); + let name = Some(String::from_ascii_str(from_str_array(NAME))); + let symbol = Some(String::from_ascii_str(from_str_array(SYMBOL))); + + SetNameEvent::new(asset, name, sender).log(); + SetSymbolEvent::new(asset, symbol, sender).log(); + SetDecimalsEvent::new(asset, DECIMALS, sender).log(); + } +} ``` ## Multi Native Asset Example @@ -341,24 +383,34 @@ It implements the [SRC-20; Native Asset](https://github.com/FuelLabs/sway-standa // ERC1155 equivalent in Sway. contract; -use src5::{SRC5, State, AccessError}; -use src20::SRC20; -use src3::SRC3; +use standards::{ + src5::{ + SRC5, + State, + AccessError + }, + src20::{ + SetDecimalsEvent, + SetNameEvent, + SetSymbolEvent, + SRC20, + TotalSupplyEvent, + } + src3::SRC3, +}; use std::{ asset::{ burn, mint_to, }, - call_frames::{ - contract_id, - msg_asset_id, - }, + call_frames::msg_asset_id, hash::{ Hash, }, context::this_balance, storage::storage_string::*, - string::String + string::String, + contract_id::ContractId }; storage { @@ -401,28 +453,42 @@ impl SRC20 for Contract { // Mint and Burn Standard impl SRC3 for Contract { #[storage(read, write)] - fn mint(recipient: Identity, sub_id: SubId, amount: u64) { + fn mint(recipient: Identity, sub_id: Option, amount: u64) { + require(sub_id.is_some(), "Error: SubId is None"); require_access_owner(); - let asset_id = AssetId::new(contract_id(), sub_id); + + let asset_id = AssetId::new(ContractId::this(), sub_id.unwrap()); let supply = storage.total_supply.get(asset_id).try_read(); if supply.is_none() { storage.total_assets.write(storage.total_assets.try_read().unwrap_or(0) + 1); } - let current_supply = supply.unwrap_or(0); - storage.total_supply.insert(asset_id, current_supply + amount); + let new_supply = supply.unwrap_or(0) + amount; + storage.total_supply.insert(asset_id, new_supply); mint_to(recipient, sub_id, amount); + + TotalSupplyEvent::new( + asset_id, + new_supply, + msg_sender().unwrap() + ).log(); } #[storage(read, write)] fn burn(sub_id: SubId, amount: u64) { require_access_owner(); - let asset_id = AssetId::new(contract_id(), sub_id); + let asset_id = AssetId::new(ContractId::this(), sub_id); require(this_balance(asset_id) >= amount, "not-enough-coins"); let supply = storage.total_supply.get(asset_id).try_read(); - let current_supply = supply.unwrap_or(0); - storage.total_supply.insert(asset_id, current_supply - amount); + let new_supply = supply.unwrap_or(0) - amount; + storage.total_supply.insert(asset_id, new_supply); burn(sub_id, amount); + + TotalSupplyEvent::new( + asset_id, + new_supply, + msg_sender().unwrap() + ).log(); } } @@ -431,10 +497,10 @@ abi MultiAsset { fn constructor(owner_: Identity); #[storage(read, write)] - fn set_name(asset: AssetId, name: String); + fn set_name(asset: AssetId, name: Option); #[storage(read, write)] - fn set_symbol(asset: AssetId, symbol: String); + fn set_symbol(asset: AssetId, symbol: Option); #[storage(read, write)] fn set_decimals(asset: AssetId, decimals: u8); @@ -448,23 +514,29 @@ impl MultiAsset for Contract { } #[storage(read, write)] - fn set_name(asset: AssetId, name: String) { + fn set_name(asset: AssetId, name: Option) { require_access_owner(); storage.name.insert(asset, StorageString {}); storage.name.get(asset).write_slice(name); + + SetNameEvent::new(asset, name, msg_sender().unwrap()).log(); } #[storage(read, write)] - fn set_symbol(asset: AssetId, symbol: String) { + fn set_symbol(asset: AssetId, symbol: Option) { require_access_owner(); storage.symbol.insert(asset, StorageString {}); storage.symbol.get(asset).write_slice(symbol); + + SetSymbolEvent::new(asset, symbol, msg_sender().unwrap()).log(); } #[storage(read, write)] fn set_decimals(asset: AssetId, decimals: u8) { require_access_owner(); storage.decimals.insert(asset, decimals); + + SetDecimalsEvent::new(asset, decimals, msg_sender().unwrap()).log(); } } diff --git a/docs/book/src/forc/plugins/forc_client/index.md b/docs/book/src/forc/plugins/forc_client/index.md index 23c668b18d4..feb436af788 100644 --- a/docs/book/src/forc/plugins/forc_client/index.md +++ b/docs/book/src/forc/plugins/forc_client/index.md @@ -92,24 +92,30 @@ By default `--default-signer` flag would sign your transactions with the followi 0xde97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c ``` -## Interacting with the testnet +## Selecting a target network -To interact with the latest testnet, use the `--testnet` flag. When this flag is passed, transactions created by `forc-deploy` will be sent to the latest `testnet`. +By default, `local` is used for the target network. To interact with the latest testnet, use the `--testnet` flag. When this flag is passed, transactions created by `forc-deploy` will be sent to the latest `testnet`: ```sh forc-deploy --testnet ``` -It is also possible to pass the exact node URL while using `forc-deploy` or `forc-run` which can be done using `--node-url` flag. +The same can be done to target mainnet: ```sh -forc-deploy --node-url https://beta-3.fuel.network +forc-deploy --mainnet ``` -Another alternative is the `--target` option, which provides useful aliases to all targets. For example if you want to deploy to `beta-5` you can use: +It is also possible to pass the exact node URL while using `forc-deploy` or `forc-run` which can be done using `--node-url` flag: ```sh -forc-deploy --target beta-5 +forc-deploy --node-url https://mainnet.fuel.network +``` + +Another alternative is the `--target` option, which provides useful aliases to all targets. For example if you want to deploy to `testnet` you can use: + +```sh +forc-deploy --target testnet ``` Since deploying and running projects on the testnet cost gas, you will need coins to pay for them. You can get some using the [testnet faucet](https://faucet-testnet.fuel.network/). @@ -179,4 +185,25 @@ If an `address` is present, `forc` calls into that contract to update its `targe ## Large Contracts -For contracts over 100KB, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments. +For contracts over the maximum contract size limit (currently `100kB`) defined by the network, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments. + +## Deploying Scripts and Predicates + +`forc deploy` now supports deploying scripts and predicates in addition to contracts. These are deployed as blobs with generated loaders for efficiency. + +Scripts and predicates are deployed automatically when you run `forc deploy` on a project that contains them. The deployment process differs slightly from contract deployment: + +1. For scripts and predicates, the bytecode is uploaded as a blob. +2. A loader is generated that can load and execute the blob. +3. The loader bytecode is saved in the project's output directory. + +After deployment, you'll find new files in your project's output directory: + +- For scripts: `-loader.bin` +- For predicates: `-loader.bin` and `-loader-root` + +The loader files contain the bytecode necessary to load and execute your script or predicate from the deployed blob. + +This new deployment method allows for more efficient storage and execution of scripts and predicates on the Fuel network. + +Note: Contracts are still deployed directly, not as blobs given that the contract size is under the maximum contract size limit defined by network (currently `100kB`). diff --git a/docs/book/src/lsp/troubleshooting.md b/docs/book/src/lsp/troubleshooting.md index 2f17bf8c028..954e1a668e3 100644 --- a/docs/book/src/lsp/troubleshooting.md +++ b/docs/book/src/lsp/troubleshooting.md @@ -34,7 +34,7 @@ In the meantime, if it's too slow, you can disable the LSP server entirely with ## Server Logs -You can you enable verbose logging of the LSP server. +You can enable verbose logging of the LSP server. In VSCode, this is under the setting: diff --git a/docs/book/src/reference/sway_libs.md b/docs/book/src/reference/sway_libs.md index 8e5d237fe07..15be990c56d 100644 --- a/docs/book/src/reference/sway_libs.md +++ b/docs/book/src/reference/sway_libs.md @@ -32,7 +32,6 @@ Cryptography Libraries are any libraries that provided cryptographic functionali Math Libraries are libraries which provide mathematic functions or number types that are outside of the std-lib's scope. -- [Fixed Point Number Library](https://fuellabs.github.io/sway-libs/book/fixed_point/index.html); an interface to implement fixed-point numbers. - [Signed Integers Library](https://fuellabs.github.io/sway-libs/book/signed_integers/index.html); an interface to implement signed integers. ## Data Structures Libraries diff --git a/docs/book/src/sway-program-types/libraries.md b/docs/book/src/sway-program-types/libraries.md index 60d820a7b01..4247c9873ca 100644 --- a/docs/book/src/sway-program-types/libraries.md +++ b/docs/book/src/sway-program-types/libraries.md @@ -192,7 +192,6 @@ Some Sway Libraries to try out: - [Binary Merkle Proof](https://github.com/FuelLabs/sway-libs/tree/master/libs/src/merkle) - [Signed Integers](https://github.com/FuelLabs/sway-libs/tree/master/libs/src/signed_integers) -- [Unsigned Fixed Point Number](https://github.com/FuelLabs/sway-libs/tree/master/libs/src/fixed_point) - [Ownership](https://github.com/FuelLabs/sway-libs/tree/master/libs/src/ownership) ### Example diff --git a/examples/enums/src/main.sw b/examples/enums/src/main.sw index b6804891143..87dbdf428cb 100644 --- a/examples/enums/src/main.sw +++ b/examples/enums/src/main.sw @@ -2,6 +2,6 @@ library; mod basic_enum; mod enum_of_structs; -mod enum_of_enums; +pub mod enum_of_enums; mod enums_avoid; mod enums_preferred; diff --git a/forc-pkg/Cargo.toml b/forc-pkg/Cargo.toml index e9004882fe6..6e0e6431fac 100644 --- a/forc-pkg/Cargo.toml +++ b/forc-pkg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-pkg" -version = "0.63.5" +version.workspace = true description = "Building, locking, fetching and updating Sway projects as Forc packages." authors.workspace = true edition.workspace = true @@ -9,41 +9,40 @@ license.workspace = true repository.workspace = true [dependencies] -ansi_term = "0.12" -anyhow = "1" -byte-unit = "5.1.4" -cid = "0.11" -forc-tracing = { version = "0.63.5", path = "../forc-tracing" } -forc-util = { version = "0.63.5", path = "../forc-util" } -fuel-abi-types = { workspace = true } -futures = "0.3" -git2 = { version = "0.19", features = [ - "vendored-libgit2", - "vendored-openssl", -] } -gix-url = { version = "0.27", features = ["serde"] } -hex = "0.4.3" -ipfs-api-backend-hyper = { version = "0.6", features = ["with-builder"] } -petgraph = { version = "0.6", features = ["serde-1"] } -reqwest = "0.12" -semver = { version = "1.0", features = ["serde"] } -serde = { version = "1.0", features = ["derive"] } -serde_ignored = "0.1.9" -serde_json = "1.0" -serde_with = "3.3.0" -sway-core = { version = "0.63.5", path = "../sway-core" } -sway-error = { version = "0.63.5", path = "../sway-error" } -sway-types = { version = "0.63.5", path = "../sway-types" } -sway-utils = { version = "0.63.5", path = "../sway-utils" } -tar = "0.4.38" -toml = { version = "0.8", features = ["parse"] } -tracing = "0.1" -url = { version = "2.2", features = ["serde"] } -vec1 = "1.8.0" -walkdir = "2" +ansiterm.workspace = true +anyhow.workspace = true +byte-unit.workspace = true +cid.workspace = true +forc-tracing.workspace = true +forc-util.workspace = true +fuel-abi-types.workspace = true +futures.workspace = true +git2 = { workspace = true, features = ["vendored-libgit2", "vendored-openssl"] } +gix-url = { workspace = true, features = ["serde"] } +hex.workspace = true +ipfs-api-backend-hyper = { workspace = true, features = ["with-builder"] } +petgraph = { workspace = true, features = ["serde-1"] } +reqwest.workspace = true +semver = { workspace = true, features = ["serde"] } +serde = { workspace = true, features = ["derive"] } +serde_ignored.workspace = true +serde_json.workspace = true +serde_with.workspace = true +sway-core.workspace = true +sway-error.workspace = true +sway-features.workspace = true +sway-types.workspace = true +sway-utils.workspace = true +tar.workspace = true +toml = { workspace = true, features = ["parse"] } +tracing.workspace = true +url = { workspace = true, features = ["serde"] } +vec1.workspace = true +walkdir.workspace = true [dev-dependencies] regex = "^1.10.2" [target.'cfg(not(target_os = "macos"))'.dependencies] sysinfo = "0.29" + diff --git a/forc-pkg/src/lock.rs b/forc-pkg/src/lock.rs index 594c107bc09..f5db529cc7b 100644 --- a/forc-pkg/src/lock.rs +++ b/forc-pkg/src/lock.rs @@ -354,7 +354,7 @@ where }; println_action_red( "Removing", - &format!("{}{src}", ansi_term::Style::new().bold().paint(&pkg.name)), + &format!("{}{src}", ansiterm::Style::new().bold().paint(&pkg.name)), ); } } @@ -372,7 +372,7 @@ where }; println_action_green( "Adding", - &format!("{}{src}", ansi_term::Style::new().bold().paint(&pkg.name)), + &format!("{}{src}", ansiterm::Style::new().bold().paint(&pkg.name)), ); } } diff --git a/forc-pkg/src/manifest/build_profile.rs b/forc-pkg/src/manifest/build_profile.rs index 59610ee8bf9..a196cd51068 100644 --- a/forc-pkg/src/manifest/build_profile.rs +++ b/forc-pkg/src/manifest/build_profile.rs @@ -1,12 +1,6 @@ use serde::{Deserialize, Serialize}; use sway_core::{OptLevel, PrintAsm, PrintIr}; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)] -#[serde(rename_all = "kebab-case")] -pub struct ExperimentalFlags { - pub new_encoding: bool, -} - /// Parameters to pass through to the `sway_core::BuildConfig` during compilation. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[serde(rename_all = "kebab-case")] @@ -30,6 +24,8 @@ pub struct BuildProfile { #[serde(default)] pub time_phases: bool, #[serde(default)] + pub profile: bool, + #[serde(default)] pub metrics_outfile: Option, #[serde(default)] pub include_tests: bool, @@ -39,8 +35,6 @@ pub struct BuildProfile { pub reverse_results: bool, #[serde(default)] pub optimization_level: OptLevel, - #[serde(default)] - pub experimental: ExperimentalFlags, } impl BuildProfile { @@ -60,14 +54,12 @@ impl BuildProfile { print_bytecode_spans: false, terse: false, time_phases: false, + profile: false, metrics_outfile: None, include_tests: false, error_on_warnings: false, reverse_results: false, optimization_level: OptLevel::Opt0, - experimental: ExperimentalFlags { - new_encoding: false, - }, } } @@ -83,14 +75,12 @@ impl BuildProfile { print_bytecode_spans: false, terse: false, time_phases: false, + profile: false, metrics_outfile: None, include_tests: false, error_on_warnings: false, reverse_results: false, optimization_level: OptLevel::Opt1, - experimental: ExperimentalFlags { - new_encoding: false, - }, } } } @@ -103,10 +93,9 @@ impl Default for BuildProfile { #[cfg(test)] mod tests { + use crate::{BuildProfile, PackageManifest}; use sway_core::{OptLevel, PrintAsm, PrintIr}; - use crate::{manifest::build_profile::ExperimentalFlags, BuildProfile, PackageManifest}; - #[test] fn test_build_profiles() { let manifest = PackageManifest::from_dir("./tests/sections").expect("manifest"); @@ -155,12 +144,12 @@ mod tests { print_bytecode_spans: false, terse: true, time_phases: true, + profile: false, metrics_outfile: Some("metrics_outfile".into()), include_tests: true, error_on_warnings: true, reverse_results: true, optimization_level: OptLevel::Opt0, - experimental: ExperimentalFlags { new_encoding: true }, }; let profile = build_profiles.get("release").expect("release profile"); assert_eq!(*profile, expected); diff --git a/forc-pkg/src/manifest/mod.rs b/forc-pkg/src/manifest/mod.rs index 28729aff757..5ce50d65804 100644 --- a/forc-pkg/src/manifest/mod.rs +++ b/forc-pkg/src/manifest/mod.rs @@ -200,6 +200,8 @@ pub struct Project { pub entry: String, pub implicit_std: Option, pub forc_version: Option, + #[serde(default)] + pub experimental: HashMap, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] @@ -771,7 +773,7 @@ impl std::ops::Deref for PackageManifestFile { /// This can be configured using environment variables: /// - use `FORC_IMPLICIT_STD_PATH` for the path for the std-lib; /// - use `FORC_IMPLICIT_STD_GIT`, `FORC_IMPLICIT_STD_GIT_TAG` and/or `FORC_IMPLICIT_STD_GIT_BRANCH` to configure -/// the git repo of the std-lib. +/// the git repo of the std-lib. fn implicit_std_dep() -> Dependency { if let Ok(path) = std::env::var("FORC_IMPLICIT_STD_PATH") { return Dependency::Detailed(DependencyDetails { diff --git a/forc-pkg/src/pkg.rs b/forc-pkg/src/pkg.rs index 2dbbc45f20d..ab4733949b8 100644 --- a/forc-pkg/src/pkg.rs +++ b/forc-pkg/src/pkg.rs @@ -1,10 +1,7 @@ use crate::manifest::GenericManifestFile; use crate::{ lock::Lock, - manifest::{ - build_profile::ExperimentalFlags, Dependency, ManifestFile, MemberManifestFiles, - PackageManifestFile, - }, + manifest::{Dependency, ManifestFile, MemberManifestFiles, PackageManifestFile}, source::{self, IPFSNode, Source}, BuildProfile, }; @@ -51,6 +48,7 @@ use sway_core::{ }; use sway_core::{PrintAsm, PrintIr}; use sway_error::{error::CompileError, handler::Handler, warning::CompileWarning}; +use sway_features::ExperimentalFeatures; use sway_types::constants::{CORE, PRELUDE, STD}; use sway_types::{Ident, Span, Spanned}; use sway_utils::{constants, time_expr, PerformanceData, PerformanceMetric}; @@ -302,6 +300,8 @@ pub struct BuildOpts { pub release: bool, /// Output the time elapsed over each part of the compilation process. pub time_phases: bool, + /// Profile the build process. + pub profile: bool, /// If set, outputs compilation metrics info in JSON format. pub metrics_outfile: Option, /// Warnings must be treated as compiler errors. @@ -310,8 +310,10 @@ pub struct BuildOpts { pub tests: bool, /// The set of options to filter by member project kind. pub member_filter: MemberFilter, - /// Set of experimental flags - pub experimental: ExperimentalFlags, + /// Set of enabled experimental flags + pub experimental: Vec, + /// Set of disabled experimental flags + pub no_experimental: Vec, } /// The set of options to filter type of projects to build in a workspace. @@ -893,22 +895,19 @@ fn validate_version(member_manifests: &MemberManifestFiles) -> Result<()> { /// If required minimum forc version is higher than current forc version return an error with /// upgrade instructions fn validate_pkg_version(pkg_manifest: &PackageManifestFile) -> Result<()> { - match &pkg_manifest.project.forc_version { - Some(min_forc_version) => { - // Get the current version of the toolchain - let crate_version = env!("CARGO_PKG_VERSION"); - let toolchain_version = semver::Version::parse(crate_version)?; - if toolchain_version < *min_forc_version { - bail!( - "{:?} requires forc version {} but current forc version is {}\nUpdate the toolchain by following: https://fuellabs.github.io/sway/v{}/introduction/installation.html", - pkg_manifest.project.name, - min_forc_version, - crate_version, - crate_version - ); - } + if let Some(min_forc_version) = &pkg_manifest.project.forc_version { + // Get the current version of the toolchain + let crate_version = env!("CARGO_PKG_VERSION"); + let toolchain_version = semver::Version::parse(crate_version)?; + if toolchain_version < *min_forc_version { + bail!( + "{:?} requires forc version {} but current forc version is {}\nUpdate the toolchain by following: https://fuellabs.github.io/sway/v{}/introduction/installation.html", + pkg_manifest.project.name, + min_forc_version, + crate_version, + crate_version + ); } - None => {} }; Ok(()) } @@ -1564,11 +1563,9 @@ pub fn sway_build_config( .with_print_ir(build_profile.print_ir.clone()) .with_include_tests(build_profile.include_tests) .with_time_phases(build_profile.time_phases) + .with_profile(build_profile.profile) .with_metrics(build_profile.metrics_outfile.clone()) - .with_optimization_level(build_profile.optimization_level) - .with_experimental(sway_core::ExperimentalFlags { - new_encoding: build_profile.experimental.new_encoding, - }); + .with_optimization_level(build_profile.optimization_level); Ok(build_config) } @@ -1594,7 +1591,7 @@ pub fn dependency_namespace( node: NodeIx, engines: &Engines, contract_id_value: Option, - experimental: sway_core::ExperimentalFlags, + experimental: ExperimentalFeatures, ) -> Result> { // TODO: Clean this up when config-time constants v1 are removed. let node_idx = &graph[node]; @@ -1760,6 +1757,7 @@ pub fn compile( engines: &Engines, namespace: &mut namespace::Root, source_map: &mut SourceMap, + experimental: ExperimentalFeatures, ) -> Result { let mut metrics = PerformanceData::default(); @@ -1785,6 +1783,7 @@ pub fn compile( // First, compile to an AST. We'll update the namespace and check for JSON ABI output. let ast_res = time_expr!( + pkg.name, "compile to ast", "compile_to_ast", sway_core::compile_to_ast( @@ -1795,6 +1794,7 @@ pub fn compile( Some(&sway_build_config), &pkg.name, None, + experimental ), Some(sway_build_config.clone()), metrics @@ -1823,20 +1823,28 @@ pub fn compile( } let asm_res = time_expr!( + pkg.name, "compile ast to asm", "compile_ast_to_asm", - sway_core::ast_to_asm(&handler, engines, &programs, &sway_build_config), + sway_core::ast_to_asm( + &handler, + engines, + &programs, + &sway_build_config, + experimental + ), Some(sway_build_config.clone()), metrics ); - const OLD_ENCODING_VERSION: &str = "0"; - const NEW_ENCODING_VERSION: &str = "1"; + const ENCODING_V0: &str = "0"; + const ENCODING_V1: &str = "1"; const SPEC_VERSION: &str = "1"; let mut program_abi = match pkg.target { BuildTarget::Fuel => { let program_abi_res = time_expr!( + pkg.name, "generate JSON ABI program", "generate_json_abi", fuel_abi::generate_program_abi( @@ -1847,11 +1855,11 @@ pub fn compile( type_ids_to_full_type_str: HashMap::::new(), }, engines, - profile - .experimental - .new_encoding - .then(|| NEW_ENCODING_VERSION.into()) - .unwrap_or(OLD_ENCODING_VERSION.into()), + if experimental.new_encoding { + ENCODING_V1.into() + } else { + ENCODING_V0.into() + }, SPEC_VERSION.into(), ), Some(sway_build_config.clone()), @@ -1875,6 +1883,7 @@ pub fn compile( }; let abi = time_expr!( + pkg.name, "generate JSON ABI program", "generate_json_abi", evm_abi::generate_abi_program(typed_program, engines), @@ -1886,8 +1895,6 @@ pub fn compile( ProgramABI::Evm(ops) } - - BuildTarget::MidenVM => ProgramABI::MidenVM(()), }; let entries = asm_res @@ -1899,15 +1906,22 @@ pub fn compile( .map(|finalized_entry| PkgEntry::from_finalized_entry(finalized_entry, engines)) .collect::>()?; - let asm = match asm_res { + let mut asm = match asm_res { Err(_) => return fail(handler), Ok(asm) => asm, }; let bc_res = time_expr!( + pkg.name, "compile asm to bytecode", "compile_asm_to_bytecode", - sway_core::asm_to_bytecode(&handler, asm, source_map, engines.se(), &sway_build_config), + sway_core::asm_to_bytecode( + &handler, + &mut asm, + source_map, + engines.se(), + &sway_build_config + ), Some(sway_build_config.clone()), metrics ); @@ -1957,9 +1971,84 @@ pub fn compile( warnings, metrics, }; + if sway_build_config.profile { + report_assembly_information(&asm, &compiled_package); + } + Ok(compiled_package) } +/// Reports assembly information for a compiled package to an external `dyno` process through `stdout`. +fn report_assembly_information( + compiled_asm: &sway_core::CompiledAsm, + compiled_package: &CompiledPackage, +) { + // Get the bytes of the compiled package. + let mut bytes = compiled_package.bytecode.bytes.clone(); + + // Attempt to get the data section offset out of the compiled package bytes. + let data_offset = u64::from_be_bytes( + bytes + .iter() + .skip(8) + .take(8) + .cloned() + .collect::>() + .try_into() + .unwrap(), + ); + let data_section_size = bytes.len() as u64 - data_offset; + + // Remove the data section from the compiled package bytes. + bytes.truncate(data_offset as usize); + + // Calculate the unpadded size of each data section section. + // Implementation based directly on `sway_core::asm_generation::Entry::to_bytes`, referenced here: + // https://github.com/FuelLabs/sway/blob/afd6a6709e7cb11c676059a5004012cc466e653b/sway-core/src/asm_generation/fuel/data_section.rs#L147 + fn calculate_entry_size(entry: &sway_core::asm_generation::Entry) -> u64 { + match &entry.value { + sway_core::asm_generation::Datum::Byte(value) => std::mem::size_of_val(value) as u64, + + sway_core::asm_generation::Datum::Word(value) => std::mem::size_of_val(value) as u64, + + sway_core::asm_generation::Datum::ByteArray(bytes) + | sway_core::asm_generation::Datum::Slice(bytes) => { + if bytes.len() % 8 == 0 { + bytes.len() as u64 + } else { + ((bytes.len() + 7) & 0xfffffff8_usize) as u64 + } + } + + sway_core::asm_generation::Datum::Collection(items) => { + items.iter().map(calculate_entry_size).sum() + } + } + } + + // Compute the assembly information to be reported. + let asm_information = sway_core::asm_generation::AsmInformation { + bytecode_size: bytes.len() as _, + data_section: sway_core::asm_generation::DataSectionInformation { + size: data_section_size, + used: compiled_asm + .0 + .data_section + .value_pairs + .iter() + .map(calculate_entry_size) + .sum(), + value_pairs: compiled_asm.0.data_section.value_pairs.clone(), + }, + }; + + // Report the assembly information to the `dyno` process through `stdout`. + println!( + "/dyno info {}", + serde_json::to_string(&asm_information).unwrap() + ); +} + impl PkgEntry { /// Returns whether this `PkgEntry` corresponds to a test. pub fn is_test(&self) -> bool { @@ -2062,12 +2151,12 @@ fn build_profile_from_opts( pkg, print, time_phases, + profile: profile_opt, build_profile, release, metrics_outfile, tests, error_on_warnings, - experimental, .. } = build_options; @@ -2103,14 +2192,13 @@ fn build_profile_from_opts( profile.print_bytecode_spans |= print.bytecode_spans; profile.terse |= pkg.terse; profile.time_phases |= time_phases; + profile.profile |= profile_opt; if profile.metrics_outfile.is_none() { profile.metrics_outfile.clone_from(metrics_outfile); } profile.include_tests |= tests; profile.error_on_warnings |= error_on_warnings; - profile.experimental = ExperimentalFlags { - new_encoding: experimental.new_encoding, - }; + // profile.experimental = *experimental; Ok(profile) } @@ -2149,6 +2237,7 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result { build_target, member_filter, experimental, + no_experimental, .. } = &build_options; @@ -2194,9 +2283,8 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result { *build_target, &build_profile, &outputs, - sway_core::ExperimentalFlags { - new_encoding: experimental.new_encoding, - }, + experimental, + no_experimental, )?; let output_dir = pkg.output_directory.as_ref().map(PathBuf::from); let total_size = built_packages @@ -2247,13 +2335,13 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result { fn print_pkg_summary_header(built_pkg: &BuiltPackage) { let prog_ty_str = forc_util::program_type_str(&built_pkg.tree_type); - // The ansi_term formatters ignore the `std::fmt` right-align + // The ansiterm formatters ignore the `std::fmt` right-align // formatter, so we manually calculate the padding to align the program // type and name around the 10th column ourselves. let padded_ty_str = format!("{prog_ty_str:>10}"); let padding = &padded_ty_str[..padded_ty_str.len() - prog_ty_str.len()]; - let ty_ansi = ansi_term::Colour::Green.bold().paint(prog_ty_str); - let name_ansi = ansi_term::Style::new() + let ty_ansi = ansiterm::Colour::Green.bold().paint(prog_ty_str); + let name_ansi = ansiterm::Style::new() .bold() .paint(&built_pkg.descriptor.name); debug!("{padding}{ty_ansi} {name_ansi}"); @@ -2307,7 +2395,8 @@ pub fn build( target: BuildTarget, profile: &BuildProfile, outputs: &HashSet, - experimental: sway_core::ExperimentalFlags, + experimental: &[sway_features::Feature], + no_experimental: &[sway_features::Feature], ) -> anyhow::Result> { let mut built_packages = Vec::new(); @@ -2342,6 +2431,13 @@ pub fn build( &pkg.source.display_compiling(manifest.dir()), ); + let experimental = ExperimentalFeatures::new( + &manifest.project.experimental, + experimental, + no_experimental, + ) + .map_err(|err| anyhow!("{err}"))?; + let descriptor = PackageDescriptor { name: pkg.name.clone(), target, @@ -2399,6 +2495,7 @@ pub fn build( &engines, &mut dep_namespace, &mut source_map, + experimental, )?; if let Some(outfile) = profile.metrics_outfile { @@ -2472,6 +2569,7 @@ pub fn build( &engines, &mut dep_namespace, &mut source_map, + experimental, )?; if let Some(outfile) = profile.metrics_outfile { @@ -2517,7 +2615,8 @@ pub fn check( include_tests: bool, engines: &Engines, retrigger_compilation: Option>, - experimental: sway_core::ExperimentalFlags, + experimental: &[sway_features::Feature], + no_experimental: &[sway_features::Feature], ) -> anyhow::Result, Handler)>> { let mut lib_namespace_map = HashMap::default(); let mut source_map = SourceMap::new(); @@ -2529,6 +2628,13 @@ pub fn check( let pkg = &plan.graph[node]; let manifest = &plan.manifest_map()[&pkg.id()]; + let experimental = ExperimentalFeatures::new( + &manifest.project.experimental, + experimental, + no_experimental, + ) + .map_err(|err| anyhow!("{err}"))?; + // This is necessary because `CONTRACT_ID` is a special constant that's injected into the // compiler's namespace. Although we only know the contract id during building, we are // inserting a dummy value here to avoid false error signals being reported in LSP. @@ -2576,6 +2682,7 @@ pub fn check( Some(&build_config), &pkg.name, retrigger_compilation.clone(), + experimental, ); if retrigger_compilation diff --git a/forc-pkg/src/source/git/mod.rs b/forc-pkg/src/source/git/mod.rs index a89e77f3128..d1a74c13f34 100644 --- a/forc-pkg/src/source/git/mod.rs +++ b/forc-pkg/src/source/git/mod.rs @@ -206,11 +206,7 @@ impl source::Fetch for Pinned { if !repo_path.exists() { println_action_green( "Fetching", - &format!( - "{} {}", - ansi_term::Style::new().bold().paint(ctx.name), - self - ), + &format!("{} {}", ansiterm::Style::new().bold().paint(ctx.name), self), ); fetch(ctx.fetch_id(), ctx.name(), self)?; } diff --git a/forc-pkg/src/source/ipfs.rs b/forc-pkg/src/source/ipfs.rs index 1391348834c..4d465ff23f6 100644 --- a/forc-pkg/src/source/ipfs.rs +++ b/forc-pkg/src/source/ipfs.rs @@ -69,11 +69,7 @@ impl source::Fetch for Pinned { if !repo_path.exists() { println_action_green( "Fetching", - &format!( - "{} {}", - ansi_term::Style::new().bold().paint(ctx.name), - self - ), + &format!("{} {}", ansiterm::Style::new().bold().paint(ctx.name), self), ); let cid = &self.0; let ipfs_client = ipfs_client(); diff --git a/forc-pkg/tests/sections/Forc.toml b/forc-pkg/tests/sections/Forc.toml index 88b012cd138..4c65994f702 100644 --- a/forc-pkg/tests/sections/Forc.toml +++ b/forc-pkg/tests/sections/Forc.toml @@ -10,7 +10,7 @@ name = "sections" print-ast = true print-dca-graph = "dca_graph" print-dca-graph-url-format = "print_dca_graph_url_format" -print-ir = { initial = false, final = true, modified = true, passes = []} +print-ir = { initial = false, final = true, modified = true, passes = [] } print-asm = { virtual = true, allocated = true, final = true } print-bytecode = true terse = true @@ -20,10 +20,13 @@ include-tests = true error-on-warnings = true reverse-results = true optimization-level = 0 -experimental = { new-encoding = true } +experimental = { encoding-v1 = true } [build-profile.custom_asm] print-asm = { virtual = false, allocated = false, final = true } [build-profile.custom_ir] -print-ir = { initial = true, final = false, modified = true, passes = ["dce", "sroa"]} +print-ir = { initial = true, final = false, modified = true, passes = [ + "dce", + "sroa", +] } diff --git a/forc-plugins/forc-client/Cargo.toml b/forc-plugins/forc-client/Cargo.toml index 44b5713fd1e..c3c5d5d57da 100644 --- a/forc-plugins/forc-client/Cargo.toml +++ b/forc-plugins/forc-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-client" -version = "0.63.5" +version.workspace = true description = "A `forc` plugin for interacting with a Fuel node." authors.workspace = true edition.workspace = true @@ -9,45 +9,56 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1" -async-trait = "0.1.58" -chrono = { version = "0.4", default-features = false, features = ["std"] } -clap = { version = "4.5.4", features = ["derive", "env"] } -devault = "0.1" -dialoguer = "0.11" -forc = { version = "0.63.5", path = "../../forc" } -forc-pkg = { version = "0.63.5", path = "../../forc-pkg" } -forc-tracing = { version = "0.63.5", path = "../../forc-tracing" } -forc-tx = { version = "0.63.5", path = "../forc-tx" } -forc-util = { version = "0.63.5", path = "../../forc-util" } -forc-wallet = { workspace = true } -fuel-abi-types = { workspace = true } +anyhow.workspace = true +async-trait.workspace = true +aws-config.workspace = true +aws-sdk-kms.workspace = true +chrono = { workspace = true, features = ["std"] } +clap = { workspace = true, features = ["derive", "env"] } +devault.workspace = true +dialoguer.workspace = true +forc.workspace = true +forc-pkg.workspace = true +forc-tracing.workspace = true +forc-tx.workspace = true +forc-util.workspace = true +forc-wallet.workspace = true +fuel-abi-types.workspace = true fuel-core-client = { workspace = true, features = ["subscriptions"] } -fuel-core-types = { workspace = true } -fuel-crypto = { workspace = true } +fuel-core-types.workspace = true +fuel-crypto.workspace = true fuel-tx = { workspace = true, features = ["test-helpers"] } -fuel-vm = { workspace = true } -fuels = { workspace = true } -fuels-accounts = { workspace = true } -fuels-core = { workspace = true } -futures = "0.3" -hex = "0.4.3" -rand = "0.8" -rpassword = "7.2" -serde = "1.0" -serde_json = "1" -sway-core = { version = "0.63.5", path = "../../sway-core" } -sway-types = { version = "0.63.5", path = "../../sway-types" } -sway-utils = { version = "0.63.5", path = "../../sway-utils" } -tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "process"] } -toml_edit = "0.21.1" -tracing = "0.1" +fuel-vm.workspace = true +fuels.workspace = true +fuels-accounts.workspace = true +fuels-core.workspace = true +futures.workspace = true +hex.workspace = true +k256.workspace = true +rand.workspace = true +rpassword.workspace = true +serde.workspace = true +serde_json.workspace = true +sway-core.workspace = true +sway-features.workspace = true +sway-types.workspace = true +sway-utils.workspace = true +tokio = { workspace = true, features = [ + "macros", + "process", + "rt-multi-thread", +] } +toml_edit.workspace = true +tracing.workspace = true [dev-dependencies] portpicker = "0.1.1" +pretty_assertions = "1.4.1" rexpect = "0.5" tempfile = "3" -toml_edit = "0.21.1" + +[build-dependencies] +regex = "1.5.4" [[bin]] name = "forc-deploy" diff --git a/forc-plugins/forc-client/build.rs b/forc-plugins/forc-client/build.rs new file mode 100644 index 00000000000..00e28aaef3a --- /dev/null +++ b/forc-plugins/forc-client/build.rs @@ -0,0 +1,79 @@ +use std::fs; +use std::path::{Path, PathBuf}; + +fn minify_json(json: &str) -> String { + let mut result = String::with_capacity(json.len()); + let mut in_string = false; + let mut previous_char: Option = None; + + for c in json.chars() { + if in_string { + result.push(c); + if c == '"' && previous_char != Some('\\') { + in_string = false; + } + } else { + match c { + '"' => { + result.push(c); + in_string = true; + } + ' ' | '\n' | '\r' | '\t' => continue, // Skip whitespace + _ => result.push(c), + } + } + previous_char = Some(c); + } + result +} + +fn update_proxy_abi_decl_with_file(source_file_path: &Path, minified_json: &str) { + // Read the contents of the source file + let mut source_code = fs::read_to_string(source_file_path).expect("Unable to read source file"); + + // Prepare the replacement string for the `abigen!` macro + let escaped_json = minified_json.replace('\\', "\\\\").replace('"', "\\\""); + let new_abigen = format!( + "abigen!(Contract(name = \"ProxyContract\", abi = \"{}\",));", + escaped_json + ); + + // Use a regular expression to find and replace the `abigen!` macro + let re = regex::Regex::new(r#"abigen!\(Contract\(name = "ProxyContract", abi = ".*?",\)\);"#) + .expect("Invalid regex pattern"); + + // Replace the existing `abigen!` macro with the new one containing the updated ABI + if re.is_match(&source_code) { + source_code = re.replace(&source_code, new_abigen.as_str()).to_string(); + } else { + panic!("abigen! macro not found in the source file"); + } + + // Write the modified source code back to the source file + fs::write(source_file_path, source_code).expect("Unable to write back to the source file"); +} + +fn main() { + // Path to the JSON file in the root directory next to the `src` folder + let json_path = PathBuf::from("proxy_abi/proxy_contract-abi.json"); + // Read the contents of the JSON file + let json_content = + fs::read_to_string(json_path).expect("Unable to read proxy_contract-abi.json"); + + // Minify the JSON content + let minified_json = minify_json(&json_content); + + // If proxy_contract-abi.json is changed, re-run this script + println!("cargo:rerun-if-changed=proxy_abi/proxy_contract-abi.json"); + + // Path to the Rust source file that contains the `abigen!` macro that + // creates a `ProxyContract`. + let util_tx_path = PathBuf::from("src/util/tx.rs"); + update_proxy_abi_decl_with_file(&util_tx_path, &minified_json); + + let test_path = PathBuf::from("tests/deploy.rs"); + update_proxy_abi_decl_with_file(&test_path, &minified_json); + + let deploy_path = PathBuf::from("src/op/deploy.rs"); + update_proxy_abi_decl_with_file(&deploy_path, &minified_json); +} diff --git a/forc-plugins/forc-client/proxy_abi/README.md b/forc-plugins/forc-client/proxy_abi/README.md index eee3d6b1c2a..684e8ceff17 100644 --- a/forc-plugins/forc-client/proxy_abi/README.md +++ b/forc-plugins/forc-client/proxy_abi/README.md @@ -2,7 +2,7 @@ This folder contains pre-built version of the owned proxy contract, its abi and `storage-slots.json` file. -*contract url*: [sway-standard-implementation/src-14/owned_proxy](https://github.com/FuelLabs/sway-standard-implementations/tree/61fd4ad8f69d21cec0d5cd8135bdc4495e0c125c). -*commit hash*: `61fd4ad8f69d21cec0d5cd8135bdc4495e0c125c` -*forc version*: `v0.63.3` +*contract url*: [sway-standard-implementation/src-14/owned_proxy](https://github.com/FuelLabs/sway-standard-implementations/tree/174f5ed9c79c23a6aaf5db906fe27ecdb29c22eb). +*commit hash*: `174f5ed9c79c23a6aaf5db906fe27ecdb29c22eb` +*forc version*: `v0.63.6` *build command*: `forc build --release` diff --git a/forc-plugins/forc-client/proxy_abi/proxy_contract-abi.json b/forc-plugins/forc-client/proxy_abi/proxy_contract-abi.json index f19a27bdf39..9fa09e507ba 100644 --- a/forc-plugins/forc-client/proxy_abi/proxy_contract-abi.json +++ b/forc-plugins/forc-client/proxy_abi/proxy_contract-abi.json @@ -713,12 +713,12 @@ { "name": "INITIAL_TARGET", "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "offset": 13616 + "offset": 13368 }, { "name": "INITIAL_OWNER", "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "offset": 13568 + "offset": 13320 } ] } \ No newline at end of file diff --git a/forc-plugins/forc-client/proxy_abi/proxy_contract-storage_slots.json b/forc-plugins/forc-client/proxy_abi/proxy_contract-storage_slots.json index 7401f63e638..72849c97055 100644 --- a/forc-plugins/forc-client/proxy_abi/proxy_contract-storage_slots.json +++ b/forc-plugins/forc-client/proxy_abi/proxy_contract-storage_slots.json @@ -1,18 +1,18 @@ [ { - "key": "35fa5b7532d53cf687e13e3db014eaf208c5b8c534ab693dd7090d5e02675f3e", + "key": "7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55", "value": "0000000000000000000000000000000000000000000000000000000000000000" }, { - "key": "35fa5b7532d53cf687e13e3db014eaf208c5b8c534ab693dd7090d5e02675f3f", + "key": "7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd56", "value": "0000000000000000000000000000000000000000000000000000000000000000" }, { - "key": "7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55", + "key": "bb79927b15d9259ea316f2ecb2297d6cc8851888a98278c0a2e03e1a091ea754", "value": "0000000000000000000000000000000000000000000000000000000000000000" }, { - "key": "7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd56", + "key": "bb79927b15d9259ea316f2ecb2297d6cc8851888a98278c0a2e03e1a091ea755", "value": "0000000000000000000000000000000000000000000000000000000000000000" } -] +] \ No newline at end of file diff --git a/forc-plugins/forc-client/proxy_abi/proxy_contract.bin b/forc-plugins/forc-client/proxy_abi/proxy_contract.bin index ca4f22d1332..9ce27196250 100644 Binary files a/forc-plugins/forc-client/proxy_abi/proxy_contract.bin and b/forc-plugins/forc-client/proxy_abi/proxy_contract.bin differ diff --git a/forc-plugins/forc-client/src/cmd/deploy.rs b/forc-plugins/forc-client/src/cmd/deploy.rs index edb9e76d7f0..a30a40b3b0b 100644 --- a/forc-plugins/forc-client/src/cmd/deploy.rs +++ b/forc-plugins/forc-client/src/cmd/deploy.rs @@ -10,7 +10,7 @@ forc_util::cli_examples! { super::Command { [ Deploy a single contract => "forc deploy bc09bfa7a11a04ce42b0a5abf04fd437387ee49bf4561d575177e2946468b408" ] [ Deploy a single contract from a different path => "forc deploy bc09bfa7a11a04ce42b0a5abf04fd437387ee49bf4561d575177e2946468b408 --path {path}" ] - [ Deploy to a custom network => "forc deploy --node-url https://beta-5.fuel.network/graphql" ] + [ Deploy to a custom network => "forc deploy --node-url https://testnet.fuel.network/graphql" ] } } @@ -84,7 +84,10 @@ pub struct Command { #[clap(long, verbatim_doc_comment, name = "JSON_FILE_PATH")] pub override_storage_slots: Option, - /// Disable the "new encoding" feature + #[clap(flatten)] + pub experimental: sway_features::CliFields, + + /// AWS KMS signer arn. If present forc-deploy will automatically use AWS KMS signer instead of forc-wallet. #[clap(long)] - pub no_encoding_v1: bool, + pub aws_kms_signer: Option, } diff --git a/forc-plugins/forc-client/src/cmd/run.rs b/forc-plugins/forc-client/src/cmd/run.rs index 5875b270adc..85b5ec31fe9 100644 --- a/forc-plugins/forc-client/src/cmd/run.rs +++ b/forc-plugins/forc-client/src/cmd/run.rs @@ -56,7 +56,6 @@ pub struct Command { #[clap(long)] pub args: Option>, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } diff --git a/forc-plugins/forc-client/src/constants.rs b/forc-plugins/forc-client/src/constants.rs index f6e1faa4201..1b195f733e6 100644 --- a/forc-plugins/forc-client/src/constants.rs +++ b/forc-plugins/forc-client/src/constants.rs @@ -1,20 +1,12 @@ /// Default to localhost to favour the common case of testing. pub const NODE_URL: &str = sway_utils::constants::DEFAULT_NODE_URL; -pub const BETA_2_ENDPOINT_URL: &str = "https://node-beta-2.fuel.network"; -pub const BETA_3_ENDPOINT_URL: &str = "https://beta-3.fuel.network"; -pub const BETA_4_ENDPOINT_URL: &str = "https://beta-4.fuel.network"; -pub const BETA_5_ENDPOINT_URL: &str = "https://beta-5.fuel.network"; -pub const DEVNET_ENDPOINT_URL: &str = "https://devnet.fuel.network"; pub const TESTNET_ENDPOINT_URL: &str = "https://testnet.fuel.network"; +pub const MAINNET_ENDPOINT_URL: &str = "https://mainnet.fuel.network"; -pub const BETA_2_FAUCET_URL: &str = "https://faucet-beta-2.fuel.network"; -pub const BETA_3_FAUCET_URL: &str = "https://faucet-beta-3.fuel.network"; -pub const BETA_4_FAUCET_URL: &str = "https://faucet-beta-4.fuel.network"; -pub const BETA_5_FAUCET_URL: &str = "https://faucet-beta-5.fuel.network"; -pub const DEVNET_FAUCET_URL: &str = "https://faucet-devnet.fuel.network"; pub const TESTNET_FAUCET_URL: &str = "https://faucet-testnet.fuel.network"; -pub const TESTNET_EXPLORER_URL: &str = "https://app.fuel.network"; +pub const TESTNET_EXPLORER_URL: &str = "https://app-testnet.fuel.network"; +pub const MAINNET_EXPLORER_URL: &str = "https://app.fuel.network"; /// Default PrivateKey to sign transactions submitted to local node. pub const DEFAULT_PRIVATE_KEY: &str = diff --git a/forc-plugins/forc-client/src/lib.rs b/forc-plugins/forc-client/src/lib.rs index cce5e5ab95e..a4db6b262a1 100644 --- a/forc-plugins/forc-client/src/lib.rs +++ b/forc-plugins/forc-client/src/lib.rs @@ -14,19 +14,27 @@ pub struct NodeTarget { /// If unspecified, checks the manifest's `network` table, then falls back /// to `http://127.0.0.1:4000` /// - /// You can also use `--target` or `--testnet` to specify the Fuel node. + /// You can also use `--target`, `--testnet`, or `--mainnet` to specify the Fuel node. #[clap(long, env = "FUEL_NODE_URL")] pub node_url: Option, + /// Use preset configurations for deploying to a specific target. /// - /// You can also use `--node-url` or `--testnet` to specify the Fuel node. + /// You can also use `--node-url`, `--testnet`, or `--mainnet` to specify the Fuel node. /// - /// Possible values are: [beta-1, beta-2, beta-3, beta-4, local] + /// Possible values are: [local, testnet, mainnet] #[clap(long)] pub target: Option, - /// Use preset configuration for the latest testnet. + + /// Use preset configuration for testnet. /// - /// You can also use `--node-url` or `--target` to specify the Fuel node. + /// You can also use `--node-url`, `--target`, or `--mainnet` to specify the Fuel node. #[clap(long)] pub testnet: bool, + + /// Use preset configuration for mainnet. + /// + /// You can also use `--node-url`, `--target`, or `--testnet` to specify the Fuel node. + #[clap(long)] + pub mainnet: bool, } diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index ff18dde51f4..44eb8eb5442 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -2,34 +2,43 @@ use crate::{ cmd, constants::TX_SUBMIT_TIMEOUT_MS, util::{ + account::ForcClientAccount, node_url::get_node_url, pkg::{built_pkgs, create_proxy_contract, update_proxy_address_in_manifest}, target::Target, tx::{ - bech32_from_secret, prompt_forc_wallet_password, select_secret_key, - update_proxy_contract_target, WalletSelectionMode, + check_and_create_wallet_at_default_path, prompt_forc_wallet_password, select_account, + update_proxy_contract_target, SignerSelectionMode, }, }, }; use anyhow::{bail, Context, Result}; -use forc_pkg::manifest::GenericManifestFile; use forc_pkg::{self as pkg, PackageManifestFile}; +use forc_pkg::{manifest::GenericManifestFile, MemberFilter}; use forc_tracing::{println_action_green, println_warning}; use forc_util::default_output_directory; use forc_wallet::utils::default_wallet_path; +use fuel_abi_types::abi::program::Configurable; use fuel_core_client::client::types::{ChainInfo, TransactionStatus}; use fuel_core_client::client::FuelClient; use fuel_crypto::fuel_types::ChainId; use fuel_tx::{Salt, Transaction}; -use fuel_vm::prelude::*; +use fuel_vm::{consts::WORD_SIZE, fuel_asm::op, prelude::*}; use fuels::{ - programs::contract::{LoadConfiguration, StorageConfiguration}, - types::{bech32::Bech32ContractId, transaction_builders::Blob}, + macros::abigen, + programs::{ + contract::{LoadConfiguration, StorageConfiguration}, + executable::Executable, + }, + types::{ + bech32::Bech32ContractId, + transaction_builders::{Blob, BlobId}, + }, }; -use fuels_accounts::{provider::Provider, wallet::WalletUnlocked, Account}; +use fuels_accounts::{provider::Provider, Account, ViewOnlyAccount}; use fuels_core::types::{transaction::TxPolicies, transaction_builders::CreateTransactionBuilder}; use futures::FutureExt; -use pkg::{manifest::build_profile::ExperimentalFlags, BuildProfile, BuiltPackage}; +use pkg::{BuildProfile, BuiltPackage}; use serde::{Deserialize, Serialize}; use std::{ collections::BTreeMap, @@ -38,15 +47,24 @@ use std::{ sync::Arc, time::Duration, }; -use sway_core::language::parsed::TreeType; -use sway_core::BuildTarget; +use sway_core::{asm_generation::ProgramABI, language::parsed::TreeType, BuildTarget}; -/// Maximum contract size allowed for a single contract. If the target +/// Default maximum contract size allowed for a single contract. If the target /// contract size is bigger than this amount, forc-deploy will automatically /// starts dividing the contract and deploy them in chunks automatically. -/// The value is in bytes. +/// The value is in bytes const MAX_CONTRACT_SIZE: usize = 100_000; +/// Represents a deployed instance of a forc package. +/// Packages other than libraries are deployable through different mechanisms. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum DeployedPackage { + Contract(DeployedContract), + Script(DeployedExecutable), + Predicate(DeployedExecutable), +} + +/// Represents a deployed contract on the Fuel network. #[derive(Debug, PartialEq, Eq, Clone, PartialOrd, Ord)] pub struct DeployedContract { pub id: fuel_tx::ContractId, @@ -54,6 +72,13 @@ pub struct DeployedContract { pub chunked: bool, } +/// Represents a deployed executable (script or predicate) on the Fuel network. +/// Executables are deployed as blobs with generated loaders for efficiency. +#[derive(Debug, PartialEq, Eq, Clone, PartialOrd, Ord)] +pub struct DeployedExecutable { + pub bytecode: Vec, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DeploymentArtifact { transaction_id: String, @@ -151,14 +176,14 @@ fn resolve_storage_slots( } /// Creates blobs from the contract to deploy contracts that are larger than -/// `MAX_CONTRACT_SIZE`. Created blobs are deployed, and a loader contract is +/// maximum contract size. Created blobs are deployed, and a loader contract is /// generated such that it loads all the deployed blobs, and provides the user /// a single contract (loader contract that loads the blobs) to call into. async fn deploy_chunked( command: &cmd::Deploy, compiled: &BuiltPackage, salt: Salt, - signing_key: &SecretKey, + account: &ForcClientAccount, provider: &Provider, pkg_name: &str, ) -> anyhow::Result { @@ -166,13 +191,12 @@ async fn deploy_chunked( let storage_slots = resolve_storage_slots(command, compiled)?; let chain_info = provider.chain_info().await?; - let target = Target::from_str(&chain_info.name).unwrap_or(Target::testnet()); + let target = Target::from_str(&chain_info.name).unwrap_or_default(); let contract_url = match target.explorer_url() { Some(explorer_url) => format!("{explorer_url}/contract/0x"), None => "".to_string(), }; - let wallet = WalletUnlocked::new_from_private_key(*signing_key, Some(provider.clone())); let blobs = compiled .bytecode .bytes @@ -183,7 +207,7 @@ async fn deploy_chunked( let tx_policies = tx_policies_from_cmd(command); let contract_id = fuels::programs::contract::Contract::loader_from_blobs(blobs, salt, storage_slots)? - .deploy(&wallet, tx_policies) + .deploy(account, tx_policies) .await? .into(); @@ -199,745 +223,20 @@ async fn deploy_chunked( async fn deploy_new_proxy( command: &cmd::Deploy, pkg_name: &str, + pkg_storage_slots: &[StorageSlot], impl_contract: &fuel_tx::ContractId, provider: &Provider, - signing_key: &SecretKey, + account: &ForcClientAccount, ) -> Result { - fuels::macros::abigen!(Contract( - name = "ProxyContract", - abi = r#" -{ - "programType": "contract", - "specVersion": "1", - "encodingVersion": "1", - "concreteTypes": [ - { - "type": "()", - "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "type": "enum standards::src5::AccessError", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d", - "metadataTypeId": 1 - }, - { - "type": "enum standards::src5::State", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "metadataTypeId": 2 - }, - { - "type": "enum std::option::Option", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "metadataTypeId": 4, - "typeArguments": [ - "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893", - "metadataTypeId": 5 - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74", - "metadataTypeId": 6 - }, - { - "type": "str", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - }, - { - "type": "struct std::contract_id::ContractId", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54", - "metadataTypeId": 9 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247", - "metadataTypeId": 10 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8", - "metadataTypeId": 11 - } - ], - "metadataTypes": [ - { - "type": "b256", - "metadataTypeId": 0 - }, - { - "type": "enum standards::src5::AccessError", - "metadataTypeId": 1, - "components": [ - { - "name": "NotOwner", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum standards::src5::State", - "metadataTypeId": 2, - "components": [ - { - "name": "Uninitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Initialized", - "typeId": 3 - }, - { - "name": "Revoked", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum std::identity::Identity", - "metadataTypeId": 3, - "components": [ - { - "name": "Address", - "typeId": 8 - }, - { - "name": "ContractId", - "typeId": 9 - } - ] - }, - { - "type": "enum std::option::Option", - "metadataTypeId": 4, - "components": [ - { - "name": "None", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Some", - "typeId": 7 - } - ], - "typeParameters": [ - 7 - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "metadataTypeId": 5, - "components": [ - { - "name": "CannotReinitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "metadataTypeId": 6, - "components": [ - { - "name": "CannotUninitialize", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "generic T", - "metadataTypeId": 7 - }, - { - "type": "struct std::address::Address", - "metadataTypeId": 8, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct std::contract_id::ContractId", - "metadataTypeId": 9, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "metadataTypeId": 10, - "components": [ - { - "name": "new_proxy_owner", - "typeId": 2 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "metadataTypeId": 11, - "components": [ - { - "name": "new_target", - "typeId": 9 - } - ] - } - ], - "functions": [ - { - "inputs": [], - "name": "proxy_target", - "output": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [Option] - The new proxy contract to which all fallback calls will be passed or `None`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_target", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - } - ], - "name": "set_proxy_target", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Change the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called by the `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When not called by `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Write: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read", - "write" - ] - } - ] - }, - { - "inputs": [], - "name": "proxy_owner", - "output": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the owner of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [State] - Represents the state of ownership for this contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [], - "name": "initialize_proxy", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Initializes the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This then allows methods that write to storage to be called." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called once." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When `storage::SRC14.proxy_owner` is not [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `2`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_proxy_owner", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c" - } - ], - "name": "set_proxy_owner", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Changes proxy ownership to the passed State." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can be used to transfer ownership between Identities or to revoke ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_proxy_owner`: [State] - The new state of the proxy ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the sender is not the current proxy owner." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the new state of the proxy ownership is [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - } - ], - "loggedTypes": [ - { - "logId": "4571204900286667806", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d" - }, - { - "logId": "2151606668983994881", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8" - }, - { - "logId": "2161305517876418151", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893" - }, - { - "logId": "4354576968059844266", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74" - }, - { - "logId": "10870989709723147660", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247" - }, - { - "logId": "10098701174489624218", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - } - ], - "messagesTypes": [], - "configurables": [ - { - "name": "INITIAL_TARGET", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "offset": 13616 - }, - { - "name": "INITIAL_OWNER", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "offset": 13568 - } - ] -}"#, - )); + abigen!(Contract(name = "ProxyContract", abi = "{\"programType\":\"contract\",\"specVersion\":\"1\",\"encodingVersion\":\"1\",\"concreteTypes\":[{\"type\":\"()\",\"concreteTypeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"type\":\"enum standards::src5::AccessError\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\",\"metadataTypeId\":1},{\"type\":\"enum standards::src5::State\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"metadataTypeId\":2},{\"type\":\"enum std::option::Option\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"metadataTypeId\":4,\"typeArguments\":[\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\",\"metadataTypeId\":5},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\",\"metadataTypeId\":6},{\"type\":\"str\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"},{\"type\":\"struct std::contract_id::ContractId\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\",\"metadataTypeId\":9},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\",\"metadataTypeId\":10},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\",\"metadataTypeId\":11}],\"metadataTypes\":[{\"type\":\"b256\",\"metadataTypeId\":0},{\"type\":\"enum standards::src5::AccessError\",\"metadataTypeId\":1,\"components\":[{\"name\":\"NotOwner\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum standards::src5::State\",\"metadataTypeId\":2,\"components\":[{\"name\":\"Uninitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Initialized\",\"typeId\":3},{\"name\":\"Revoked\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum std::identity::Identity\",\"metadataTypeId\":3,\"components\":[{\"name\":\"Address\",\"typeId\":8},{\"name\":\"ContractId\",\"typeId\":9}]},{\"type\":\"enum std::option::Option\",\"metadataTypeId\":4,\"components\":[{\"name\":\"None\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Some\",\"typeId\":7}],\"typeParameters\":[7]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"metadataTypeId\":5,\"components\":[{\"name\":\"CannotReinitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"metadataTypeId\":6,\"components\":[{\"name\":\"CannotUninitialize\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"generic T\",\"metadataTypeId\":7},{\"type\":\"struct std::address::Address\",\"metadataTypeId\":8,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct std::contract_id::ContractId\",\"metadataTypeId\":9,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"metadataTypeId\":10,\"components\":[{\"name\":\"new_proxy_owner\",\"typeId\":2}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"metadataTypeId\":11,\"components\":[{\"name\":\"new_target\",\"typeId\":9}]}],\"functions\":[{\"inputs\":[],\"name\":\"proxy_target\",\"output\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [Option] - The new proxy contract to which all fallback calls will be passed or `None`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[{\"name\":\"new_target\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"}],\"name\":\"set_proxy_target\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Change the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called by the `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When not called by `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Write: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\",\"write\"]}]},{\"inputs\":[],\"name\":\"proxy_owner\",\"output\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the owner of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [State] - Represents the state of ownership for this contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[],\"name\":\"initialize_proxy\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Initializes the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This then allows methods that write to storage to be called.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called once.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When `storage::SRC14.proxy_owner` is not [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `2`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]},{\"inputs\":[{\"name\":\"new_proxy_owner\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\"}],\"name\":\"set_proxy_owner\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Changes proxy ownership to the passed State.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can be used to transfer ownership between Identities or to revoke ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_proxy_owner`: [State] - The new state of the proxy ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the sender is not the current proxy owner.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the new state of the proxy ownership is [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]}],\"loggedTypes\":[{\"logId\":\"4571204900286667806\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\"},{\"logId\":\"2151606668983994881\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\"},{\"logId\":\"2161305517876418151\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\"},{\"logId\":\"4354576968059844266\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\"},{\"logId\":\"10870989709723147660\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\"},{\"logId\":\"10098701174489624218\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"}],\"messagesTypes\":[],\"configurables\":[{\"name\":\"INITIAL_TARGET\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"offset\":13368},{\"name\":\"INITIAL_OWNER\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"offset\":13320}]}",)); let proxy_dir_output = create_proxy_contract(pkg_name)?; - let address = bech32_from_secret(signing_key)?; - let wallet = WalletUnlocked::new_from_private_key(*signing_key, Some(provider.clone())); + let address = account.address(); - let storage_path = proxy_dir_output.join("proxy-storage_slots.json"); - let storage_configuration = - StorageConfiguration::default().add_slot_overrides_from_file(storage_path)?; + // Add the combined storage slots from the original contract and the proxy contract. + let proxy_storage_path = proxy_dir_output.join("proxy-storage_slots.json"); + let storage_configuration = StorageConfiguration::default() + .add_slot_overrides(pkg_storage_slots.iter().cloned()) + .add_slot_overrides_from_file(proxy_storage_path)?; let configurables = ProxyContractConfigurables::default() .with_INITIAL_TARGET(Some(*impl_contract))? @@ -952,12 +251,12 @@ async fn deploy_new_proxy( proxy_dir_output.join("proxy.bin"), configuration, )? - .deploy(&wallet, tx_policies) + .deploy(account, tx_policies) .await? .into(); let chain_info = provider.chain_info().await?; - let target = Target::from_str(&chain_info.name).unwrap_or(Target::testnet()); + let target = Target::from_str(&chain_info.name).unwrap_or_default(); let contract_url = match target.explorer_url() { Some(explorer_url) => format!("{explorer_url}/contract/0x"), None => "".to_string(), @@ -969,33 +268,31 @@ async fn deploy_new_proxy( ); let proxy_contract_bech_id: Bech32ContractId = proxy_contract_id.into(); - let instance = ProxyContract::new(&proxy_contract_bech_id, wallet); + let instance = ProxyContract::new(&proxy_contract_bech_id, account.clone()); instance.methods().initialize_proxy().call().await?; println_action_green("Initialized", &format!("proxy contract for {pkg_name}")); Ok(proxy_contract_id) } -/// Builds and deploys contract(s). If the given path corresponds to a workspace, all deployable members -/// will be built and deployed. +/// Builds and deploys contracts, scripts, and predicates from the given path or workspace. /// -/// Upon success, returns the ID of each deployed contract in order of deployment. +/// Contracts are deployed directly, while scripts and predicates are deployed as blobs with generated loaders. /// -/// When deploying a single contract, only that contract's ID is returned. -pub async fn deploy(command: cmd::Deploy) -> Result> { +/// Returns a vector of `DeployedPackage` representing all successful deployments. +pub async fn deploy(command: cmd::Deploy) -> Result> { if command.unsigned { println_warning("--unsigned flag is deprecated, please prefer using --default-signer. Assuming `--default-signer` is passed. This means your transaction will be signed by an account that is funded by fuel-core by default for testing purposes."); } - - let mut deployed_contracts = Vec::new(); let curr_dir = if let Some(ref path) = command.pkg.path { PathBuf::from(path) } else { std::env::current_dir()? }; - - let build_opts = build_opts_from_cmd(&command); + let build_opts = build_opts_from_cmd(&command, MemberFilter::default()); let built_pkgs = built_pkgs(&curr_dir, &build_opts)?; - let pkgs_to_deploy = built_pkgs + let mut deployed_packages = Vec::new(); + + let contracts_to_deploy = built_pkgs .iter() .filter(|pkg| { pkg.descriptor @@ -1003,20 +300,281 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { .check_program_type(&[TreeType::Contract]) .is_ok() }) + .cloned() + .collect::>(); + + let scripts_to_deploy = built_pkgs + .iter() + .filter(|pkg| { + pkg.descriptor + .manifest_file + .check_program_type(&[TreeType::Script]) + .is_ok() + }) + .cloned() + .collect::>(); + + let predicates_to_deploy = built_pkgs + .iter() + .filter(|pkg| { + pkg.descriptor + .manifest_file + .check_program_type(&[TreeType::Predicate]) + .is_ok() + }) + .cloned() .collect::>(); - if pkgs_to_deploy.is_empty() { - println_warning("No deployable contracts found in the current directory."); + if contracts_to_deploy.is_empty() + && scripts_to_deploy.is_empty() + && predicates_to_deploy.is_empty() + { + println_warning("No deployable package was found in the current directory."); + } else { + deployed_packages.extend( + deploy_contracts(&command, &contracts_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Contract), + ); + deployed_packages.extend( + deploy_executables(&command, &scripts_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Script), + ); + deployed_packages.extend( + deploy_executables(&command, &predicates_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Predicate), + ); + } + + Ok(deployed_packages) +} + +/// Calculates the loader data offset. Returns a `None` if the original `binary` +/// does not have a data section (no configurables and no args). Otherwise +/// returns the new offset of the data section. +fn loader_data_offset(binary: &[u8], blob_id: &BlobId) -> Result> { + // The following code is taken from SDK, and once they expose the offsets + // we will no longer need to maintain this duplicate version here. + + // The final code is going to have this structure (if the data section is non-empty): + // 1. loader instructions + // 2. blob id + // 3. length_of_data_section + // 4. the data_section (updated with configurables as needed) + const BLOB_ID_SIZE: u16 = 32; + const REG_ADDRESS_OF_DATA_AFTER_CODE: u8 = 0x10; + const REG_START_OF_LOADED_CODE: u8 = 0x11; + const REG_GENERAL_USE: u8 = 0x12; + let get_instructions = |num_of_instructions| { + // There are 3 main steps: + // 1. Load the blob content into memory + // 2. Load the data section right after the blob + // 3. Jump to the beginning of the memory where the blob was loaded + [ + // 1. Load the blob content into memory + // Find the start of the hardcoded blob ID, which is located after the loader code ends. + op::move_(REG_ADDRESS_OF_DATA_AFTER_CODE, RegId::PC), + // hold the address of the blob ID. + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + num_of_instructions * Instruction::SIZE as u16, + ), + // The code is going to be loaded from the current value of SP onwards, save + // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end. + op::move_(REG_START_OF_LOADED_CODE, RegId::SP), + // REG_GENERAL_USE to hold the size of the blob. + op::bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE), + // Push the blob contents onto the stack. + op::ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1), + // Move on to the data section length + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + BLOB_ID_SIZE, + ), + // load the size of the data section into REG_GENERAL_USE + op::lw(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE, 0), + // after we have read the length of the data section, we move the pointer to the actual + // data by skipping WORD_SIZE B. + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + WORD_SIZE as u16, + ), + // load the data section of the executable + op::ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 2), + // Jump into the memory where the contract is loaded. + // What follows is called _jmp_mem by the sway compiler. + // Subtract the address contained in IS because jmp will add it back. + op::sub( + REG_START_OF_LOADED_CODE, + REG_START_OF_LOADED_CODE, + RegId::IS, + ), + // jmp will multiply by 4, so we need to divide to cancel that out. + op::divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4), + // Jump to the start of the contract we loaded. + op::jmp(REG_START_OF_LOADED_CODE), + ] + }; + + let offset = extract_data_offset(binary)?; + + if binary.len() < offset { + anyhow::bail!("data sectio offset is out of bounds"); + } + + let data_section = binary[offset..].to_vec(); + + if !data_section.is_empty() { + let num_of_instructions = u16::try_from(get_instructions(0).len()) + .expect("to never have more than u16::MAX instructions"); + + let instruction_bytes = get_instructions(num_of_instructions) + .into_iter() + .flat_map(|instruction| instruction.to_bytes()); + + let blob_bytes = blob_id.iter().copied(); + + let loader_offset = + instruction_bytes.count() + blob_bytes.count() + data_section.len().to_be_bytes().len(); + + Ok(Some(loader_offset)) + } else { + Ok(None) + } +} + +/// Builds and deploys executable (script and predicate) package(s) as blobs, +/// and generates a loader for each of them. +pub async fn deploy_executables( + command: &cmd::Deploy, + executables_to_deploy: &[Arc], +) -> Result> { + let mut deployed_executable = vec![]; + if executables_to_deploy.is_empty() { + return Ok(deployed_executable); + } + + let node_url = validate_and_get_node_url(command, executables_to_deploy).await?; + // We will have 1 transaction per executable as each deployment uses a single blob. + let tx_count = executables_to_deploy.len(); + let account = setup_deployment_account(command, &node_url, tx_count).await?; + + for pkg in executables_to_deploy { + let script = Executable::from_bytes(pkg.bytecode.bytes.clone()); + let loader = script.convert_to_loader()?; + println_action_green("Uploading", "blob containing executable bytecode."); + loader.upload_blob(account.clone()).await?; + println_action_green("Generating", "loader bytecode for the uploaded executable."); + let loader_bytecode = loader.code(); + let pkg_name = &pkg.descriptor.name; + let out_dir = pkg.descriptor.manifest_file.dir().join("out"); + let bin_path = out_dir.join(format!("{pkg_name}-loader.bin")); + std::fs::write(&bin_path, &loader_bytecode)?; + println_action_green( + "Saved", + &format!("loader bytecode at {}", bin_path.display()), + ); + if let Some(loader_data_section_offset) = + loader_data_offset(&pkg.bytecode.bytes, &BlobId::default())? + { + if let ProgramABI::Fuel(mut fuel_abi) = pkg.program_abi.clone() { + println_action_green("Generating", "loader abi for the uploaded executable."); + let json_abi_path = out_dir.join(format!("{pkg_name}-loader-abi.json")); + let original_data_section = extract_data_offset(&pkg.bytecode.bytes).unwrap(); + let offset_shift = original_data_section - loader_data_section_offset; + // if there are configurables in the abi we need to shift them by `offset_shift`. + let configurables = fuel_abi.configurables.clone().map(|configs| { + configs + .into_iter() + .map(|config| Configurable { + offset: config.offset - offset_shift as u64, + ..config.clone() + }) + .collect() + }); + fuel_abi.configurables = configurables; + let json_string = serde_json::to_string_pretty(&fuel_abi)?; + std::fs::write(json_abi_path, json_string)?; + } + } + // If the executable is a predicate, we also want to display and save the predicate root. + if pkg + .descriptor + .manifest_file + .program_type() + .with_context(|| { + "error while trying to retrieve program type for executable deployment." + })? + == TreeType::Predicate + { + // Calculate the root. + let root = format!("0x{}", fuel_tx::Input::predicate_owner(&loader_bytecode)); + // Root files are named in `pkg-name-root` format, since this is a + // loader we are also adding an identifier to differentiate it from + // the root of the "original" predicate. + let root_file_name = format!("{}-loader-root", &pkg_name); + let root_path = out_dir.join(root_file_name); + std::fs::write(&root_path, &root)?; + println_action_green( + "Saved", + &format!("loader root ({}) at {}", root, root_path.display()), + ); + } + let deployed = DeployedExecutable { + bytecode: loader_bytecode, + }; + deployed_executable.push(deployed); + println_action_green("Finished", &format!("deploying executable {pkg_name}")); + } + Ok(deployed_executable) +} + +fn extract_data_offset(binary: &[u8]) -> Result { + if binary.len() < 16 { + anyhow::bail!( + "given binary is too short to contain a data offset, len: {}", + binary.len() + ); + } + + let data_offset: [u8; 8] = binary[8..16].try_into().expect("checked above"); + + Ok(u64::from_be_bytes(data_offset) as usize) +} + +/// Builds and deploys contract(s). If the given path corresponds to a workspace, all deployable members +/// will be built and deployed. +/// +/// Upon success, returns the ID of each deployed contract in order of deployment. +/// +/// When deploying a single contract, only that contract's ID is returned. +pub async fn deploy_contracts( + command: &cmd::Deploy, + contracts_to_deploy: &[Arc], +) -> Result> { + let mut deployed_contracts = Vec::new(); + + if contracts_to_deploy.is_empty() { return Ok(deployed_contracts); } let contract_salt_map = if let Some(salt_input) = &command.salt { // If we're building 1 package, we just parse the salt as a string, ie. 0x00... // If we're building >1 package, we must parse the salt as a pair of strings, ie. contract_name:0x00... - if built_pkgs.len() > 1 { + if contracts_to_deploy.len() > 1 { let map = validate_and_parse_salts( salt_input, - built_pkgs.iter().map(|b| &b.descriptor.manifest_file), + contracts_to_deploy + .iter() + .map(|b| &b.descriptor.manifest_file), )?; Some(map) @@ -1034,7 +592,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { .unwrap(); let mut contract_salt_map = ContractSaltMap::default(); contract_salt_map.insert( - built_pkgs[0] + contracts_to_deploy[0] .descriptor .manifest_file .project_name() @@ -1047,23 +605,19 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { None }; - // Ensure that all packages are being deployed to the same node. - let node_url = get_node_url( - &command.node, - &pkgs_to_deploy[0].descriptor.manifest_file.network, - )?; - if !pkgs_to_deploy.iter().all(|pkg| { - get_node_url(&command.node, &pkg.descriptor.manifest_file.network).ok() - == Some(node_url.clone()) - }) { - bail!("All contracts in a deployment should be deployed to the same node. Please ensure that the network specified in the Forc.toml files of all contracts is the same."); - } + let node_url = validate_and_get_node_url(command, contracts_to_deploy).await?; + let provider = Provider::connect(node_url.clone()).await?; // Confirmation step. Summarize the transaction(s) for the deployment. - let (provider, signing_key) = - confirm_transaction_details(&pkgs_to_deploy, &command, node_url.clone()).await?; + let account = confirm_transaction_details( + contracts_to_deploy, + command, + node_url.clone(), + MAX_CONTRACT_SIZE, + ) + .await?; - for pkg in pkgs_to_deploy { + for pkg in contracts_to_deploy { let salt = match (&contract_salt_map, command.default_salt) { (Some(map), false) => { if let Some(salt) = map.get(pkg.descriptor.manifest_file.project_name()) { @@ -1085,16 +639,16 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { let provider = Provider::connect(node_url).await?; deploy_chunked( - &command, + command, pkg, salt, - &signing_key, + &account, &provider, &pkg.descriptor.name, ) .await? } else { - deploy_pkg(&command, pkg, salt, &provider, &signing_key).await? + deploy_pkg(command, pkg, salt, &provider, &account).await? }; let proxy_id = match &pkg.descriptor.manifest_file.proxy { @@ -1109,13 +663,8 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { let proxy_contract = ContractId::from_str(proxy_addr).map_err(|e| anyhow::anyhow!(e))?; - update_proxy_contract_target( - &provider, - signing_key, - proxy_contract, - deployed_contract_id, - ) - .await?; + update_proxy_contract_target(&account, proxy_contract, deployed_contract_id) + .await?; Some(proxy_contract) } Some(forc_pkg::manifest::Proxy { @@ -1123,13 +672,15 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { address: None, }) => { let pkg_name = &pkg.descriptor.name; + let pkg_storage_slots = &pkg.storage_slots; // Deploy a new proxy contract. let deployed_proxy_contract = deploy_new_proxy( - &command, + command, pkg_name, + pkg_storage_slots, &deployed_contract_id, &provider, - &signing_key, + &account, ) .await?; @@ -1156,10 +707,11 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { /// Prompt the user to confirm the transactions required for deployment, as well as the signing key. async fn confirm_transaction_details( - pkgs_to_deploy: &[&Arc], + pkgs_to_deploy: &[Arc], command: &cmd::Deploy, node_url: String, -) -> Result<(Provider, SecretKey)> { + max_contract_size: usize, +) -> Result { // Confirmation step. Summarize the transaction(s) for the deployment. let mut tx_count = 0; let tx_summary = pkgs_to_deploy @@ -1182,8 +734,8 @@ async fn confirm_transaction_details( }; let pkg_bytecode_len = pkg.bytecode.bytes.len(); - let blob_text = if pkg_bytecode_len > MAX_CONTRACT_SIZE { - let number_of_blobs = pkg_bytecode_len.div_ceil(MAX_CONTRACT_SIZE); + let blob_text = if pkg_bytecode_len > max_contract_size { + let number_of_blobs = pkg_bytecode_len.div_ceil(max_contract_size); tx_count += number_of_blobs; &format!(" + {number_of_blobs} blobs") } else { @@ -1201,30 +753,12 @@ async fn confirm_transaction_details( println_action_green("Confirming", &format!("transactions [{tx_summary}]")); println_action_green("", &format!("Network: {node_url}")); - let provider = Provider::connect(node_url.clone()).await?; - - let wallet_mode = if command.default_signer || command.signing_key.is_some() { - WalletSelectionMode::Manual - } else { - println_action_green("", &format!("Wallet: {}", default_wallet_path().display())); - let password = prompt_forc_wallet_password()?; - WalletSelectionMode::ForcWallet(password) - }; + let account = setup_deployment_account(command, &node_url, tx_count).await?; // TODO: Display the estimated gas cost of the transaction(s). // https://github.com/FuelLabs/sway/issues/6277 - let signing_key = select_secret_key( - &wallet_mode, - command.default_signer || command.unsigned, - command.signing_key, - &provider, - tx_count, - ) - .await? - .ok_or_else(|| anyhow::anyhow!("failed to select a signer for the transaction"))?; - - Ok((provider.clone(), signing_key)) + Ok(account) } /// Deploy a single pkg given deploy command and the manifest file @@ -1233,7 +767,7 @@ pub async fn deploy_pkg( compiled: &BuiltPackage, salt: Salt, provider: &Provider, - signing_key: &SecretKey, + account: &ForcClientAccount, ) -> Result { let manifest = &compiled.descriptor.manifest_file; let node_url = provider.url(); @@ -1256,10 +790,10 @@ pub async fn deploy_pkg( storage_slots.clone(), tx_policies, ); - let wallet = WalletUnlocked::new_from_private_key(*signing_key, Some(provider.clone())); - wallet.add_witnesses(&mut tb)?; - wallet.adjust_for_fee(&mut tb, 0).await?; + account.add_witnesses(&mut tb)?; + account.adjust_for_fee(&mut tb, 0).await?; + let tx = tb.build(provider).await?; let tx = Transaction::from(tx); @@ -1358,7 +892,7 @@ fn tx_policies_from_cmd(cmd: &cmd::Deploy) -> TxPolicies { tx_policies } -fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { +fn build_opts_from_cmd(cmd: &cmd::Deploy, member_filter: pkg::MemberFilter) -> pkg::BuildOpts { pkg::BuildOpts { pkg: pkg::PkgOpts { path: cmd.pkg.path.clone(), @@ -1379,6 +913,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { reverse_order: cmd.print.reverse_order, }, time_phases: cmd.print.time_phases, + profile: cmd.print.profile, metrics_outfile: cmd.print.metrics_outfile.clone(), minify: pkg::MinifyOpts { json_abi: cmd.minify.json_abi, @@ -1391,10 +926,9 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { debug_outfile: cmd.build_output.debug_file.clone(), build_target: BuildTarget::default(), tests: false, - member_filter: pkg::MemberFilter::only_contracts(), - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + member_filter, + experimental: cmd.experimental.experimental.clone(), + no_experimental: cmd.experimental.no_experimental.clone(), } } @@ -1413,7 +947,7 @@ fn create_deployment_artifact( let contract_id = ContractId::from_str(&deployment_artifact.contract_id).unwrap(); let pkg_name = manifest.project_name(); - let target = Target::from_str(&chain_info.name).unwrap_or(Target::testnet()); + let target = Target::from_str(&chain_info.name).unwrap_or_default(); let (contract_url, block_url) = match target.explorer_url() { Some(explorer_url) => ( format!("{explorer_url}/contract/0x"), @@ -1427,14 +961,8 @@ fn create_deployment_artifact( ); let block_height = deployment_artifact.deployed_block_height; - if block_height.is_some() { - let block_height_formatted = - match u32::from_str_radix(&block_height.unwrap().to_string(), 16) { - Ok(decimal) => format!("{block_url}{decimal}"), - Err(_) => block_height.unwrap().to_string(), - }; - - println_action_green("Deployed", &format!("in block {block_height_formatted}")); + if let Some(block_height) = block_height { + println_action_green("Deployed", &format!("in block {block_url}{block_height}")); } let output_dir = cmd @@ -1447,6 +975,55 @@ fn create_deployment_artifact( deployment_artifact.to_file(&output_dir, pkg_name, contract_id) } +/// Validates that all packages are being deployed to the same node and returns the node URL. +async fn validate_and_get_node_url( + command: &cmd::Deploy, + packages: &[Arc], +) -> Result { + let node_url = get_node_url(&command.node, &packages[0].descriptor.manifest_file.network)?; + if !packages.iter().all(|pkg| { + get_node_url(&command.node, &pkg.descriptor.manifest_file.network).ok() + == Some(node_url.clone()) + }) { + bail!("All packages in a deployment should be deployed to the same node. Please ensure that the network specified in the Forc.toml files of all packages is the same."); + } + Ok(node_url) +} + +/// Sets up and returns the account for deployment. +async fn setup_deployment_account( + command: &cmd::Deploy, + node_url: &str, + tx_count: usize, +) -> Result { + let provider = Provider::connect(node_url).await?; + + let wallet_mode = if command.default_signer || command.signing_key.is_some() { + SignerSelectionMode::Manual + } else if let Some(arn) = &command.aws_kms_signer { + SignerSelectionMode::AwsSigner(arn.clone()) + } else { + // Check if we have a wallet in the default path + // If there is one we will ask for the password + // If not we will ask the user to either create a new one or import one + let wallet_path = default_wallet_path(); + check_and_create_wallet_at_default_path(&wallet_path)?; + println_action_green("", &format!("Wallet: {}", default_wallet_path().display())); + let password = prompt_forc_wallet_password()?; + SignerSelectionMode::ForcWallet(password) + }; + + let account = select_account( + &wallet_mode, + command.default_signer || command.unsigned, + command.signing_key, + &provider, + tx_count, + ) + .await?; + + Ok(account) +} #[cfg(test)] mod test { use super::*; diff --git a/forc-plugins/forc-client/src/op/mod.rs b/forc-plugins/forc-client/src/op/mod.rs index 44a1b055551..f11f8c63b7c 100644 --- a/forc-plugins/forc-client/src/op/mod.rs +++ b/forc-plugins/forc-client/src/op/mod.rs @@ -2,6 +2,6 @@ mod deploy; mod run; mod submit; -pub use deploy::{deploy, DeployedContract}; +pub use deploy::{deploy, DeployedContract, DeployedExecutable, DeployedPackage}; pub use run::run; pub use submit::submit; diff --git a/forc-plugins/forc-client/src/op/run/mod.rs b/forc-plugins/forc-client/src/op/run/mod.rs index cda23fb14cf..7d21d439e8c 100644 --- a/forc-plugins/forc-client/src/op/run/mod.rs +++ b/forc-plugins/forc-client/src/op/run/mod.rs @@ -3,10 +3,9 @@ use crate::{ cmd, constants::TX_SUBMIT_TIMEOUT_MS, util::{ - gas::get_script_gas_used, node_url::get_node_url, pkg::built_pkgs, - tx::{prompt_forc_wallet_password, TransactionBuilderExt, WalletSelectionMode}, + tx::{prompt_forc_wallet_password, select_account, SignerSelectionMode}, }, }; use anyhow::{anyhow, bail, Context, Result}; @@ -14,9 +13,17 @@ use forc_pkg::{self as pkg, fuel_core_not_running, PackageManifestFile}; use forc_tracing::println_warning; use forc_util::tx_utils::format_log_receipts; use fuel_core_client::client::FuelClient; -use fuel_tx::{ContractId, Transaction, TransactionBuilder}; -use fuels_accounts::provider::Provider; -use pkg::{manifest::build_profile::ExperimentalFlags, BuiltPackage}; +use fuel_tx::{ContractId, Transaction}; +use fuels::{ + programs::calls::{traits::TransactionTuner, ScriptCall}, + types::{ + bech32::Bech32ContractId, + transaction::TxPolicies, + transaction_builders::{BuildableTransaction, VariableOutputPolicy}, + }, +}; +use fuels_accounts::{provider::Provider, Account}; +use pkg::BuiltPackage; use std::time::Duration; use std::{path::PathBuf, str::FromStr}; use sway_core::language::parsed::TreeType; @@ -51,10 +58,10 @@ pub async fn run(command: cmd::Run) -> Result> { let build_opts = build_opts_from_cmd(&command); let built_pkgs_with_manifest = built_pkgs(&curr_dir, &build_opts)?; let wallet_mode = if command.default_signer || command.signing_key.is_some() { - WalletSelectionMode::Manual + SignerSelectionMode::Manual } else { let password = prompt_forc_wallet_password()?; - WalletSelectionMode::ForcWallet(password) + SignerSelectionMode::ForcWallet(password) }; for built in built_pkgs_with_manifest { if built @@ -77,13 +84,34 @@ pub async fn run(command: cmd::Run) -> Result> { Ok(receipts) } +fn tx_policies_from_cmd(cmd: &cmd::Run) -> TxPolicies { + let mut tx_policies = TxPolicies::default(); + if let Some(max_fee) = cmd.gas.max_fee { + tx_policies = tx_policies.with_max_fee(max_fee); + } + if let Some(script_gas_limit) = cmd.gas.script_gas_limit { + tx_policies = tx_policies.with_script_gas_limit(script_gas_limit); + } + tx_policies +} + pub async fn run_pkg( command: &cmd::Run, manifest: &PackageManifestFile, compiled: &BuiltPackage, - wallet_mode: &WalletSelectionMode, + signer_mode: &SignerSelectionMode, ) -> Result { let node_url = get_node_url(&command.node, &manifest.network)?; + let provider = Provider::connect(node_url.clone()).await?; + let tx_count = 1; + let account = select_account( + signer_mode, + command.default_signer || command.unsigned, + command.signing_key, + &provider, + tx_count, + ) + .await?; let script_data = match (&command.data, &command.args) { (None, Some(args)) => { @@ -116,31 +144,28 @@ pub async fn run_pkg( }) .collect::>>()?; - let mut tb = TransactionBuilder::script(compiled.bytecode.bytes.clone(), script_data); - tb.maturity(command.maturity.maturity.into()) - .add_contracts(contract_ids); - - let provider = Provider::connect(node_url.clone()).await?; - - let script_gas_limit = if compiled.bytecode.bytes.is_empty() { - 0 - } else if let Some(script_gas_limit) = command.gas.script_gas_limit { - script_gas_limit - // Dry run tx and get `gas_used` - } else { - get_script_gas_used(tb.clone().finalize_without_signature_inner(), &provider).await? + let script_binary = compiled.bytecode.bytes.clone(); + let external_contracts = contract_ids + .into_iter() + .map(Bech32ContractId::from) + .collect::>(); + let call = ScriptCall { + script_binary, + encoded_args: Ok(script_data), + inputs: vec![], + outputs: vec![], + external_contracts, }; - tb.script_gas_limit(script_gas_limit); - - let tx = tb - .finalize_signed( - Provider::connect(node_url.clone()).await?, - command.default_signer, - command.signing_key, - wallet_mode, - ) + let tx_policies = tx_policies_from_cmd(command); + let mut tb = call + .transaction_builder(tx_policies, VariableOutputPolicy::EstimateMinimum, &account) .await?; + account.add_witnesses(&mut tb)?; + account.adjust_for_fee(&mut tb, 0).await?; + + let tx = tb.build(provider).await?; + if command.dry_run { info!("{:?}", tx); Ok(RanScript { receipts: vec![] }) @@ -242,13 +267,13 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts { release: cmd.build_profile.release, error_on_warnings: cmd.build_profile.error_on_warnings, time_phases: cmd.print.time_phases, + profile: cmd.print.profile, metrics_outfile: cmd.print.metrics_outfile.clone(), binary_outfile: cmd.build_output.bin_file.clone(), debug_outfile: cmd.build_output.debug_file.clone(), tests: false, member_filter: pkg::MemberFilter::only_scripts(), - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + experimental: cmd.experimental.experimental.clone(), + no_experimental: cmd.experimental.no_experimental.clone(), } } diff --git a/forc-plugins/forc-client/src/util/account.rs b/forc-plugins/forc-client/src/util/account.rs new file mode 100644 index 00000000000..17ecc6781b8 --- /dev/null +++ b/forc-plugins/forc-client/src/util/account.rs @@ -0,0 +1,87 @@ +use async_trait::async_trait; +use fuel_crypto::{Message, Signature}; +use fuels::{ + prelude::*, + types::{coin_type_id::CoinTypeId, input::Input}, +}; +use fuels_accounts::{wallet::WalletUnlocked, Account}; + +use super::aws::AwsSigner; + +#[derive(Clone, Debug)] +/// Set of different signers available to be used with `forc-client` operations. +pub enum ForcClientAccount { + /// Local signer where the private key owned locally. This can be + /// generated through `forc-wallet` integration or manually by providing + /// a private-key. + Wallet(WalletUnlocked), + /// A KMS Signer specifically using AWS KMS service. The signing key + /// is managed by another entity for KMS signers. Messages are + /// signed by the KMS entity. Signed transactions are retrieved + /// and submitted to the node by `forc-client`. + KmsSigner(AwsSigner), +} + +#[async_trait] +impl Account for ForcClientAccount { + async fn get_asset_inputs_for_amount( + &self, + asset_id: AssetId, + amount: u64, + excluded_coins: Option>, + ) -> Result> { + match self { + ForcClientAccount::Wallet(wallet) => { + wallet + .get_asset_inputs_for_amount(asset_id, amount, excluded_coins) + .await + } + ForcClientAccount::KmsSigner(account) => { + account + .get_asset_inputs_for_amount(asset_id, amount, excluded_coins) + .await + } + } + } + + fn add_witnesses(&self, tb: &mut Tb) -> Result<()> { + tb.add_signer(self.clone())?; + + Ok(()) + } +} + +impl ViewOnlyAccount for ForcClientAccount { + fn address(&self) -> &Bech32Address { + match self { + ForcClientAccount::Wallet(wallet) => wallet.address(), + ForcClientAccount::KmsSigner(account) => { + fuels_accounts::ViewOnlyAccount::address(account) + } + } + } + + fn try_provider(&self) -> Result<&Provider> { + match self { + ForcClientAccount::Wallet(wallet) => wallet.try_provider(), + ForcClientAccount::KmsSigner(account) => Ok(account.provider()), + } + } +} + +#[async_trait] +impl Signer for ForcClientAccount { + async fn sign(&self, message: Message) -> Result { + match self { + ForcClientAccount::Wallet(wallet) => wallet.sign(message).await, + ForcClientAccount::KmsSigner(account) => account.sign(message).await, + } + } + + fn address(&self) -> &Bech32Address { + match self { + ForcClientAccount::Wallet(wallet) => wallet.address(), + ForcClientAccount::KmsSigner(account) => fuels_core::traits::Signer::address(account), + } + } +} diff --git a/forc-plugins/forc-client/src/util/aws.rs b/forc-plugins/forc-client/src/util/aws.rs new file mode 100644 index 00000000000..90da533815c --- /dev/null +++ b/forc-plugins/forc-client/src/util/aws.rs @@ -0,0 +1,269 @@ +use async_trait::async_trait; +use aws_config::{default_provider::credentials::DefaultCredentialsChain, Region, SdkConfig}; +use aws_sdk_kms::config::Credentials; +use aws_sdk_kms::operation::get_public_key::GetPublicKeyOutput; +use aws_sdk_kms::primitives::Blob; +use aws_sdk_kms::types::{MessageType, SigningAlgorithmSpec}; +use aws_sdk_kms::{config::BehaviorVersion, Client}; +use fuel_crypto::Message; +use fuels::prelude::*; +use fuels::types::bech32::{Bech32Address, FUEL_BECH32_HRP}; +use fuels::types::coin_type_id::CoinTypeId; +use fuels::types::input::Input; +use fuels_accounts::provider::Provider; +use fuels_accounts::{Account, ViewOnlyAccount}; +use fuels_core::traits::Signer; + +/// AWS configuration for the `AwsSigner` to be created. +/// De-facto way of creating the configuration is to load it from env. +#[derive(Debug, Clone)] +pub struct AwsConfig { + sdk_config: SdkConfig, +} + +impl AwsConfig { + /// Load configuration from environment variables. + /// For more details see: https://docs.rs/aws-config/latest/aws_config/ + pub async fn from_env() -> Self { + let loader = aws_config::defaults(BehaviorVersion::latest()) + .credentials_provider(DefaultCredentialsChain::builder().build().await); + + let loader = match std::env::var("E2E_TEST_AWS_ENDPOINT") { + Ok(url) => loader.endpoint_url(url), + _ => loader, + }; + + Self { + sdk_config: loader.load().await, + } + } + + pub async fn for_testing(url: String) -> Self { + let sdk_config = aws_config::defaults(BehaviorVersion::latest()) + .credentials_provider(Credentials::new( + "test", + "test", + None, + None, + "Static Credentials", + )) + .endpoint_url(url) + .region(Region::new("us-east-1")) // placeholder region for test + .load() + .await; + + Self { sdk_config } + } + + pub fn url(&self) -> Option<&str> { + self.sdk_config.endpoint_url() + } + + pub fn region(&self) -> Option<&Region> { + self.sdk_config.region() + } +} + +/// A configured `AwsClient` which allows using the AWS KMS SDK. +#[derive(Clone, Debug)] +pub struct AwsClient { + client: Client, +} + +impl AwsClient { + pub fn new(config: AwsConfig) -> Self { + let config = config.sdk_config; + let client = Client::new(&config); + + Self { client } + } + + pub fn inner(&self) -> &Client { + &self.client + } +} + +/// A signer which is capable of signing `fuel_crypto::Message`s using AWS KMS. +/// This is both a `Signer` and `Account`, which means it is directly usable +/// with most of the fuels-* calls, without any additional operations on the +/// representation. +#[derive(Clone, Debug)] +pub struct AwsSigner { + kms: AwsClient, + key_id: String, + bech: Bech32Address, + public_key_bytes: Vec, + provider: Provider, +} + +async fn request_get_pubkey( + kms: &Client, + key_id: String, +) -> std::result::Result { + kms.get_public_key() + .key_id(key_id) + .send() + .await + .map_err(Into::into) +} + +/// Decode an AWS KMS Pubkey response. +fn decode_pubkey(resp: &GetPublicKeyOutput) -> std::result::Result, anyhow::Error> { + let raw = resp + .public_key + .as_ref() + .ok_or(anyhow::anyhow!("public key not found"))?; + Ok(raw.clone().into_inner()) +} + +async fn sign_with_kms( + client: &aws_sdk_kms::Client, + key_id: &str, + public_key_bytes: &[u8], + message: Message, +) -> anyhow::Result { + use k256::{ + ecdsa::{RecoveryId, VerifyingKey}, + pkcs8::DecodePublicKey, + }; + + let reply = client + .sign() + .key_id(key_id) + .signing_algorithm(SigningAlgorithmSpec::EcdsaSha256) + .message_type(MessageType::Digest) + .message(Blob::new(*message)) + .send() + .await + .inspect_err(|err| tracing::error!("Failed to sign with AWS KMS: {err:?}"))?; + let signature_der = reply + .signature + .ok_or_else(|| anyhow::anyhow!("no signature returned from AWS KMS"))? + .into_inner(); + // https://stackoverflow.com/a/71475108 + let sig = k256::ecdsa::Signature::from_der(&signature_der) + .map_err(|_| anyhow::anyhow!("invalid DER signature from AWS KMS"))?; + let sig = sig.normalize_s().unwrap_or(sig); + + // This is a hack to get the recovery id. The signature should be normalized + // before computing the recovery id, but aws kms doesn't support this, and + // instead always computes the recovery id from non-normalized signature. + // So instead the recovery id is determined by checking which variant matches + // the original public key. + + let recid1 = RecoveryId::new(false, false); + let recid2 = RecoveryId::new(true, false); + + let rec1 = VerifyingKey::recover_from_prehash(&*message, &sig, recid1); + let rec2 = VerifyingKey::recover_from_prehash(&*message, &sig, recid2); + + let correct_public_key = k256::PublicKey::from_public_key_der(public_key_bytes) + .map_err(|_| anyhow::anyhow!("invalid DER public key from AWS KMS"))? + .into(); + + let recovery_id = if rec1.map(|r| r == correct_public_key).unwrap_or(false) { + recid1 + } else if rec2.map(|r| r == correct_public_key).unwrap_or(false) { + recid2 + } else { + anyhow::bail!("Invalid signature generated (reduced-x form coordinate)"); + }; + + // Insert the recovery id into the signature + debug_assert!( + !recovery_id.is_x_reduced(), + "reduced-x form coordinates are caught by the if-else chain above" + ); + let v = recovery_id.is_y_odd() as u8; + let mut signature = <[u8; 64]>::from(sig.to_bytes()); + signature[32] = (v << 7) | (signature[32] & 0x7f); + Ok(fuel_crypto::Signature::from_bytes(signature)) +} + +impl AwsSigner { + pub async fn new( + kms: AwsClient, + key_id: String, + provider: Provider, + ) -> std::result::Result { + use k256::pkcs8::DecodePublicKey; + + let resp = request_get_pubkey(kms.inner(), key_id.clone()).await?; + let public_key_bytes = decode_pubkey(&resp)?; + let k256_public_key = k256::PublicKey::from_public_key_der(&public_key_bytes)?; + + let public_key = fuel_crypto::PublicKey::from(k256_public_key); + let hashed = public_key.hash(); + let bech = Bech32Address::new(FUEL_BECH32_HRP, hashed); + Ok(Self { + kms, + key_id, + bech, + public_key_bytes, + provider, + }) + } + + /// Sign a digest with the key associated with a key ID. + pub async fn sign_message_with_key( + &self, + key_id: String, + message: Message, + ) -> std::result::Result { + sign_with_kms(self.kms.inner(), &key_id, &self.public_key_bytes, message).await + } + + /// Sign a digest with this signer's key. + pub async fn sign_message( + &self, + message: Message, + ) -> std::result::Result { + self.sign_message_with_key(self.key_id.clone(), message) + .await + } + + pub fn provider(&self) -> &Provider { + &self.provider + } +} + +#[async_trait] +impl Signer for AwsSigner { + async fn sign(&self, message: Message) -> Result { + let sig = self.sign_message(message).await.map_err(|_| { + fuels_core::types::errors::Error::Other("aws signer failed".to_string()) + })?; + Ok(sig) + } + + fn address(&self) -> &Bech32Address { + &self.bech + } +} + +impl ViewOnlyAccount for AwsSigner { + fn address(&self) -> &Bech32Address { + &self.bech + } + + fn try_provider(&self) -> Result<&Provider> { + Ok(&self.provider) + } +} + +#[async_trait] +impl Account for AwsSigner { + async fn get_asset_inputs_for_amount( + &self, + asset_id: AssetId, + amount: u64, + excluded_coins: Option>, + ) -> Result> { + Ok(self + .get_spendable_resources(asset_id, amount, excluded_coins) + .await? + .into_iter() + .map(Input::resource_signed) + .collect::>()) + } +} diff --git a/forc-plugins/forc-client/src/util/gas.rs b/forc-plugins/forc-client/src/util/gas.rs deleted file mode 100644 index 9667bee8674..00000000000 --- a/forc-plugins/forc-client/src/util/gas.rs +++ /dev/null @@ -1,53 +0,0 @@ -use anyhow::Result; - -use fuel_tx::{ - field::{Inputs, Witnesses}, - Buildable, Chargeable, Input, Script, TxPointer, -}; -use fuels_accounts::provider::Provider; -use fuels_core::types::transaction::ScriptTransaction; - -fn no_spendable_input<'a, I: IntoIterator>(inputs: I) -> bool { - !inputs.into_iter().any(|i| { - matches!( - i, - Input::CoinSigned(_) - | Input::CoinPredicate(_) - | Input::MessageCoinSigned(_) - | Input::MessageCoinPredicate(_) - ) - }) -} - -pub(crate) async fn get_script_gas_used(mut tx: Script, provider: &Provider) -> Result { - let no_spendable_input = no_spendable_input(tx.inputs()); - let base_asset_id = provider.base_asset_id(); - if no_spendable_input { - tx.inputs_mut().push(Input::coin_signed( - Default::default(), - Default::default(), - 1_000_000_000, - *base_asset_id, - TxPointer::default(), - 0, - )); - - // Add an empty `Witness` for the `coin_signed` we just added - // and increase the witness limit - tx.witnesses_mut().push(Default::default()); - } - let consensus_params = provider.consensus_parameters(); - - // Get `max_gas` used by everything except the script execution. Add `1` because of rounding. - let max_gas_per_tx = consensus_params.tx_params().max_gas_per_tx(); - let max_gas = tx.max_gas(consensus_params.gas_costs(), consensus_params.fee_params()) + 1; - // Increase `script_gas_limit` to the maximum allowed value. - tx.set_script_gas_limit(max_gas_per_tx - max_gas); - let script_tx = ScriptTransaction::from(tx); - - let tolerance = 0.1; - let estimated_tx_cost = provider - .estimate_transaction_cost(script_tx, Some(tolerance), None) - .await?; - Ok(estimated_tx_cost.gas_used) -} diff --git a/forc-plugins/forc-client/src/util/mod.rs b/forc-plugins/forc-client/src/util/mod.rs index d8024081b28..2e58fc41c79 100644 --- a/forc-plugins/forc-client/src/util/mod.rs +++ b/forc-plugins/forc-client/src/util/mod.rs @@ -1,5 +1,6 @@ +pub mod account; +pub mod aws; pub(crate) mod encode; -pub(crate) mod gas; pub(crate) mod node_url; pub(crate) mod pkg; pub(crate) mod target; diff --git a/forc-plugins/forc-client/src/util/node_url.rs b/forc-plugins/forc-client/src/util/node_url.rs index b7fe3f8bf39..58e9dcd87e1 100644 --- a/forc-plugins/forc-client/src/util/node_url.rs +++ b/forc-plugins/forc-client/src/util/node_url.rs @@ -12,18 +12,22 @@ pub fn get_node_url( ) -> Result { let node_url = match ( node_target.testnet, + node_target.mainnet, node_target.target.clone(), node_target.node_url.clone(), ) { - (true, None, None) => Target::testnet().target_url(), - (false, Some(target), None) => target.target_url(), - (false, None, Some(node_url)) => node_url, - (false, None, None) => manifest_network + (true, false, None, None) => Target::testnet().target_url(), + (false, true, None, None) => Target::mainnet().target_url(), + (false, false, Some(target), None) => target.target_url(), + (false, false, None, Some(node_url)) => node_url, + (false, false, None, None) => manifest_network .as_ref() .map(|nw| &nw.url[..]) .unwrap_or(crate::constants::NODE_URL) .to_string(), - _ => bail!("Only one of `--testnet`, `--target`, or `--node-url` should be specified"), + _ => bail!( + "Only one of `--testnet`, `--mainnet`, `--target`, or `--node-url` should be specified" + ), }; Ok(node_url) @@ -35,6 +39,7 @@ fn test_get_node_url_testnet() { target: None, node_url: None, testnet: true, + mainnet: false, }; let actual = get_node_url(&input, &None).unwrap(); @@ -42,63 +47,41 @@ fn test_get_node_url_testnet() { } #[test] -fn test_get_node_url_target_devnet() { +fn test_get_node_url_mainnet() { let input = NodeTarget { - target: Some(Target::Devnet), - node_url: None, - testnet: false, - }; - let actual = get_node_url(&input, &None).unwrap(); - assert_eq!("https://devnet.fuel.network", actual); -} - -#[test] -fn test_get_node_url_target_testnet() { - let input = NodeTarget { - target: Some(Target::Testnet), + target: None, node_url: None, testnet: false, + mainnet: true, }; let actual = get_node_url(&input, &None).unwrap(); - assert_eq!("https://testnet.fuel.network", actual); + assert_eq!("https://mainnet.fuel.network", actual); } #[test] -fn test_get_node_url_beta5() { +fn test_get_node_url_target_mainnet() { let input = NodeTarget { - target: Some(Target::Beta5), + target: Some(Target::Mainnet), node_url: None, testnet: false, + mainnet: false, }; let actual = get_node_url(&input, &None).unwrap(); - assert_eq!("https://beta-5.fuel.network", actual); + assert_eq!("https://mainnet.fuel.network", actual); } #[test] -fn test_get_node_url_beta4() { - let input = NodeTarget { - target: None, - node_url: Some("https://beta-4.fuel.network".to_string()), - testnet: false, - }; - let actual = get_node_url(&input, &None).unwrap(); - assert_eq!("https://beta-4.fuel.network", actual); -} - -#[test] -fn test_get_node_url_url_beta4_manifest() { - let network = Network { - url: "https://beta-4.fuel.network".to_string(), - }; +fn test_get_node_url_target_testnet() { let input = NodeTarget { - target: None, + target: Some(Target::Testnet), node_url: None, testnet: false, + mainnet: false, }; - let actual = get_node_url(&input, &Some(network)).unwrap(); - assert_eq!("https://beta-4.fuel.network", actual); + let actual = get_node_url(&input, &None).unwrap(); + assert_eq!("https://testnet.fuel.network", actual); } #[test] @@ -107,29 +90,20 @@ fn test_get_node_url_default() { target: None, node_url: None, testnet: false, + mainnet: false, }; let actual = get_node_url(&input, &None).unwrap(); assert_eq!("http://127.0.0.1:4000", actual); } -#[test] -fn test_get_node_url_beta3() { - let input = NodeTarget { - target: Some(Target::Beta3), - node_url: None, - testnet: false, - }; - let actual = get_node_url(&input, &None).unwrap(); - assert_eq!("https://beta-3.fuel.network", actual); -} - #[test] fn test_get_node_url_local() { let input = NodeTarget { target: Some(Target::Local), node_url: None, testnet: false, + mainnet: false, }; let actual = get_node_url(&input, &None).unwrap(); assert_eq!("http://127.0.0.1:4000", actual); @@ -137,26 +111,28 @@ fn test_get_node_url_local() { #[test] #[should_panic( - expected = "Only one of `--testnet`, `--target`, or `--node-url` should be specified" + expected = "Only one of `--testnet`, `--mainnet`, `--target`, or `--node-url` should be specified" )] fn test_get_node_url_local_testnet() { let input = NodeTarget { target: Some(Target::Local), node_url: None, testnet: true, + mainnet: false, }; get_node_url(&input, &None).unwrap(); } #[test] #[should_panic( - expected = "Only one of `--testnet`, `--target`, or `--node-url` should be specified" + expected = "Only one of `--testnet`, `--mainnet`, `--target`, or `--node-url` should be specified" )] fn test_get_node_url_same_url() { let input = NodeTarget { - target: Some(Target::Beta3), - node_url: Some("beta-3.fuel.network".to_string()), + target: Some(Target::Testnet), + node_url: Some("testnet.fuel.network".to_string()), testnet: false, + mainnet: false, }; get_node_url(&input, &None).unwrap(); } diff --git a/forc-plugins/forc-client/src/util/pkg.rs b/forc-plugins/forc-client/src/util/pkg.rs index 3aa8f6b2236..c93df24bacc 100644 --- a/forc-plugins/forc-client/src/util/pkg.rs +++ b/forc-plugins/forc-client/src/util/pkg.rs @@ -26,7 +26,7 @@ pub(crate) fn update_proxy_address_in_manifest( let mut toml = String::new(); let mut file = File::open(manifest.path())?; file.read_to_string(&mut toml)?; - let mut manifest_toml = toml.parse::()?; + let mut manifest_toml = toml.parse::()?; if manifest.proxy().is_some() { manifest_toml["proxy"]["address"] = toml_edit::value(address); let mut file = std::fs::OpenOptions::new() diff --git a/forc-plugins/forc-client/src/util/target.rs b/forc-plugins/forc-client/src/util/target.rs index 86b9b947666..bbc5679e844 100644 --- a/forc-plugins/forc-client/src/util/target.rs +++ b/forc-plugins/forc-client/src/util/target.rs @@ -1,8 +1,6 @@ use crate::constants::{ - BETA_2_ENDPOINT_URL, BETA_2_FAUCET_URL, BETA_3_ENDPOINT_URL, BETA_3_FAUCET_URL, - BETA_4_ENDPOINT_URL, BETA_4_FAUCET_URL, BETA_5_ENDPOINT_URL, BETA_5_FAUCET_URL, - DEVNET_ENDPOINT_URL, DEVNET_FAUCET_URL, NODE_URL, TESTNET_ENDPOINT_URL, TESTNET_EXPLORER_URL, - TESTNET_FAUCET_URL, + MAINNET_ENDPOINT_URL, MAINNET_EXPLORER_URL, NODE_URL, TESTNET_ENDPOINT_URL, + TESTNET_EXPLORER_URL, TESTNET_FAUCET_URL, }; use anyhow::{bail, Result}; use serde::{Deserialize, Serialize}; @@ -11,12 +9,8 @@ use std::str::FromStr; #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] /// Possible target values that forc-client can interact with. pub enum Target { - Beta2, - Beta3, - Beta4, - Beta5, - Devnet, Testnet, + Mainnet, Local, } @@ -29,12 +23,8 @@ impl Default for Target { impl Target { pub fn target_url(&self) -> String { let url = match self { - Target::Beta2 => BETA_2_ENDPOINT_URL, - Target::Beta3 => BETA_3_ENDPOINT_URL, - Target::Beta4 => BETA_4_ENDPOINT_URL, - Target::Beta5 => BETA_5_ENDPOINT_URL, - Target::Devnet => DEVNET_ENDPOINT_URL, Target::Testnet => TESTNET_ENDPOINT_URL, + Target::Mainnet => MAINNET_ENDPOINT_URL, Target::Local => NODE_URL, }; url.to_string() @@ -42,36 +32,37 @@ impl Target { pub fn from_target_url(target_url: &str) -> Option { match target_url { - BETA_2_ENDPOINT_URL => Some(Target::Beta2), - BETA_3_ENDPOINT_URL => Some(Target::Beta3), - BETA_4_ENDPOINT_URL => Some(Target::Beta4), - BETA_5_ENDPOINT_URL => Some(Target::Beta5), - DEVNET_ENDPOINT_URL => Some(Target::Devnet), TESTNET_ENDPOINT_URL => Some(Target::Testnet), + MAINNET_ENDPOINT_URL => Some(Target::Mainnet), NODE_URL => Some(Target::Local), _ => None, } } + pub fn local() -> Self { + Target::Local + } + pub fn testnet() -> Self { Target::Testnet } - pub fn faucet_url(&self) -> String { + pub fn mainnet() -> Self { + Target::Mainnet + } + + pub fn faucet_url(&self) -> Option { match self { - Target::Beta2 => BETA_2_FAUCET_URL.to_string(), - Target::Beta3 => BETA_3_FAUCET_URL.to_string(), - Target::Beta4 => BETA_4_FAUCET_URL.to_string(), - Target::Beta5 => BETA_5_FAUCET_URL.to_string(), - Target::Devnet => DEVNET_FAUCET_URL.to_string(), - Target::Testnet => TESTNET_FAUCET_URL.to_string(), - Target::Local => "http://localhost:3000".to_string(), + Target::Testnet => Some(TESTNET_FAUCET_URL.to_string()), + Target::Mainnet => None, + Target::Local => Some("http://localhost:3000".to_string()), } } pub fn explorer_url(&self) -> Option { match self { - Target::Testnet | Target::Devnet => Some(TESTNET_EXPLORER_URL.to_string()), + Target::Testnet => Some(TESTNET_EXPLORER_URL.to_string()), + Target::Mainnet => Some(MAINNET_EXPLORER_URL.to_string()), _ => None, } } @@ -82,21 +73,13 @@ impl FromStr for Target { fn from_str(s: &str) -> Result { match s { - "beta-2" => Ok(Target::Beta2), - "beta-3" => Ok(Target::Beta3), - "beta-4" => Ok(Target::Beta4), - "beta-5" => Ok(Target::Beta5), - "devnet" => Ok(Target::Devnet), - "testnet" => Ok(Target::Testnet), + "Fuel Sepolia Testnet" => Ok(Target::Testnet), + "Ignition" => Ok(Target::Mainnet), "local" => Ok(Target::Local), _ => bail!( - "'{s}' is not a valid target name. Possible values: '{}', '{}', '{}', '{}', '{}', '{}', '{}'", - Target::Beta2, - Target::Beta3, - Target::Beta4, - Target::Beta5, - Target::Devnet, + "'{s}' is not a valid target name. Possible values: '{}', '{}', '{}'", Target::Testnet, + Target::Mainnet, Target::Local ), } @@ -106,12 +89,8 @@ impl FromStr for Target { impl std::fmt::Display for Target { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let s = match self { - Target::Beta2 => "beta-2", - Target::Beta3 => "beta-3", - Target::Beta4 => "beta-4", - Target::Beta5 => "beta-5", - Target::Devnet => "devnet", - Target::Testnet => "testnet", + Target::Testnet => "Fuel Sepolia Testnet", + Target::Mainnet => "Ignition", Target::Local => "local", }; write!(f, "{}", s) diff --git a/forc-plugins/forc-client/src/util/tx.rs b/forc-plugins/forc-client/src/util/tx.rs index bd9ab0dc9cf..a1dad6a3fcd 100644 --- a/forc-plugins/forc-client/src/util/tx.rs +++ b/forc-plugins/forc-client/src/util/tx.rs @@ -1,6 +1,8 @@ -use crate::{constants::DEFAULT_PRIVATE_KEY, util::target::Target}; -use anyhow::{Error, Result}; -use async_trait::async_trait; +use crate::{ + constants::DEFAULT_PRIVATE_KEY, + util::{account::ForcClientAccount, aws::AwsSigner, target::Target}, +}; +use anyhow::Result; use dialoguer::{theme::ColorfulTheme, Confirm, Password, Select}; use forc_tracing::{println_action_green, println_warning}; use forc_wallet::{ @@ -8,50 +10,33 @@ use forc_wallet::{ balance::{ collect_accounts_with_verification, AccountBalances, AccountVerification, AccountsMap, }, + import::{import_wallet_cli, Import}, new::{new_wallet_cli, New}, utils::default_wallet_path, }; -use fuel_crypto::{Message, PublicKey, SecretKey, Signature}; -use fuel_tx::{ - field, Address, AssetId, Buildable, ContractId, Input, Output, TransactionBuilder, Witness, +use fuel_crypto::SecretKey; +use fuel_tx::{AssetId, ContractId}; +use fuels::{ + macros::abigen, programs::responses::CallResponse, types::checksum_address::checksum_encode, }; -use fuels::{macros::abigen, programs::responses::CallResponse}; use fuels_accounts::{ provider::Provider, wallet::{Wallet, WalletUnlocked}, ViewOnlyAccount, }; -use fuels_core::types::{ - bech32::{Bech32Address, FUEL_BECH32_HRP}, - coin_type::CoinType, - transaction_builders::{create_coin_input, create_coin_message_input}, -}; -use std::{collections::BTreeMap, io::Write, path::Path, str::FromStr}; +use std::{collections::BTreeMap, path::Path, str::FromStr}; + +use super::aws::{AwsClient, AwsConfig}; #[derive(PartialEq, Eq)] -pub enum WalletSelectionMode { +pub enum SignerSelectionMode { /// Holds the password of forc-wallet instance. ForcWallet(String), + /// Holds ARN of the AWS signer. + AwsSigner(String), Manual, } -fn prompt_address() -> Result { - print!("Please provide the address of the wallet you are going to sign this transaction with:"); - std::io::stdout().flush()?; - let mut buf = String::new(); - std::io::stdin().read_line(&mut buf)?; - Bech32Address::from_str(buf.trim()).map_err(Error::msg) -} - -fn prompt_signature(tx_id: fuel_tx::Bytes32) -> Result { - println!("Transaction id to sign: {tx_id}"); - print!("Please provide the signature:"); - std::io::stdout().flush()?; - let mut buf = String::new(); - std::io::stdin().read_line(&mut buf)?; - Signature::from_str(buf.trim()).map_err(Error::msg) -} - fn ask_user_yes_no_question(question: &str) -> Result { let answer = Confirm::with_theme(&ColorfulTheme::default()) .with_prompt(question) @@ -61,10 +46,19 @@ fn ask_user_yes_no_question(question: &str) -> Result { Ok(answer) } +fn ask_user_with_options(question: &str, options: &[&str], default: usize) -> Result { + let selection = Select::with_theme(&ColorfulTheme::default()) + .with_prompt(question) + .items(options) + .default(default) + .interact()?; + Ok(selection) +} + fn collect_user_accounts( wallet_path: &Path, password: &str, -) -> Result> { +) -> Result> { let verification = AccountVerification::Yes(password.to_string()); let accounts = collect_accounts_with_verification(wallet_path, verification).map_err(|e| { if e.to_string().contains("Mac Mismatch") { @@ -87,21 +81,27 @@ pub(crate) fn prompt_forc_wallet_password() -> Result { pub(crate) fn check_and_create_wallet_at_default_path(wallet_path: &Path) -> Result<()> { if !wallet_path.exists() { - let question = format!("Could not find a wallet at {wallet_path:?}, would you like to create a new one? [y/N]: "); - let accepted = ask_user_yes_no_question(&question)?; - let new_options = New { - force: false, - cache_accounts: None, - }; - if accepted { - new_wallet_cli(wallet_path, new_options)?; - println!("Wallet created successfully."); - // Derive first account for the fresh wallet we created. - new_at_index_cli(wallet_path, 0)?; - println!("Account derived successfully."); - } else { - anyhow::bail!("Refused to create a new wallet. If you don't want to use forc-wallet, you can sign this transaction manually with --manual-signing flag.") + let question = + format!("Could not find a wallet at {wallet_path:?}, please select an option: "); + let wallet_options = ask_user_with_options( + &question, + &["Create new wallet", "Import existing wallet"], + 0, + )?; + match wallet_options { + 0 => { + new_wallet_cli(wallet_path, New { force: false, cache_accounts: None })?; + println!("Wallet created successfully."); + } + 1 => { + import_wallet_cli(wallet_path, Import { force: false, cache_accounts: None })?; + println!("Wallet imported successfully."); + }, + _ => anyhow::bail!("Refused to create or import a new wallet. If you don't want to use forc-wallet, you can sign this transaction manually with --manual-signing flag."), } + // Derive first account for the fresh wallet we created. + new_at_index_cli(wallet_path, 0)?; + println!("Account derived successfully."); } Ok(()) } @@ -121,13 +121,6 @@ pub(crate) fn secret_key_from_forc_wallet( Ok(secret_key) } -pub(crate) fn bech32_from_secret(secret_key: &SecretKey) -> Result { - let public_key = PublicKey::from(secret_key); - let hashed = public_key.hash(); - let bech32 = Bech32Address::new(FUEL_BECH32_HRP, hashed); - Ok(bech32) -} - pub(crate) fn select_manual_secret_key( default_signer: bool, signing_key: Option, @@ -151,7 +144,7 @@ async fn collect_account_balances( ) -> Result { let accounts: Vec<_> = accounts_map .values() - .map(|addr| Wallet::from_address(addr.clone(), Some(provider.clone()))) + .map(|addr| Wallet::from_address((*addr).into(), Some(provider.clone()))) .collect(); futures::future::try_join_all(accounts.iter().map(|acc| acc.get_balances())) @@ -164,7 +157,7 @@ pub fn format_base_asset_account_balances( accounts_map: &AccountsMap, account_balances: &AccountBalances, base_asset_id: &AssetId, -) -> Vec { +) -> Result> { accounts_map .iter() .zip(account_balances) @@ -173,27 +166,26 @@ pub fn format_base_asset_account_balances( .get(&base_asset_id.to_string()) .copied() .unwrap_or(0); + let raw_addr = format!("0x{address}"); + let checksum_addr = checksum_encode(&raw_addr)?; let eth_amount = base_asset_amount as f64 / 1_000_000_000.0; - format!("[{ix}] {address} - {eth_amount} ETH") + Ok(format!("[{ix}] {checksum_addr} - {eth_amount} ETH")) }) - .collect() + .collect::>>() } // TODO: Simplify the function signature once https://github.com/FuelLabs/sway/issues/6071 is closed. -pub(crate) async fn select_secret_key( - wallet_mode: &WalletSelectionMode, +pub(crate) async fn select_account( + wallet_mode: &SignerSelectionMode, default_sign: bool, signing_key: Option, provider: &Provider, tx_count: usize, -) -> Result> { +) -> Result { let chain_info = provider.chain_info().await?; - let signing_key = match wallet_mode { - WalletSelectionMode::ForcWallet(password) => { + match wallet_mode { + SignerSelectionMode::ForcWallet(password) => { let wallet_path = default_wallet_path(); - check_and_create_wallet_at_default_path(&wallet_path)?; - // TODO: This is a very simple TUI, we should consider adding a nice TUI - // capabilities for selections and answer collection. let accounts = collect_user_accounts(&wallet_path, password)?; let account_balances = collect_account_balances(&accounts, provider).await?; let base_asset_id = provider.base_asset_id(); @@ -206,15 +198,22 @@ pub(crate) async fn select_secret_key( let first_account = accounts .get(&0) .ok_or_else(|| anyhow::anyhow!("No account derived for this wallet"))?; - let target = Target::from_str(&chain_info.name).unwrap_or(Target::testnet()); - let faucet_link = format!("{}/?address={first_account}", target.faucet_url()); - anyhow::bail!("Your wallet does not have any funds to pay for the transaction.\ - \n\nIf you are interacting with a testnet consider using the faucet.\ - \n-> {target} network faucet: {faucet_link}\ - \nIf you are interacting with a local node, consider providing a chainConfig which funds your account.") + let target = Target::from_str(&chain_info.name).unwrap_or_default(); + let message = if let Some(faucet_url) = target.faucet_url() { + format!( + "Your wallet does not have any funds to pay for the transaction.\ + \n\nIf you are interacting with a testnet, consider using the faucet.\ + \n-> {target} network faucet: {}/?address={first_account}\ + \nIf you are interacting with a local node, consider providing a chainConfig which funds your account.", + faucet_url + ) + } else { + "Your wallet does not have any funds to pay for the transaction.".to_string() + }; + anyhow::bail!(message) } let selections = - format_base_asset_account_balances(&accounts, &account_balances, base_asset_id); + format_base_asset_account_balances(&accounts, &account_balances, base_asset_id)?; let mut account_index; loop { @@ -228,7 +227,14 @@ pub(crate) async fn select_secret_key( if accounts.contains_key(&account_index) { break; } - let options: Vec = accounts.keys().map(|key| key.to_string()).collect(); + let options: Vec = accounts + .keys() + .map(|key| { + let raw_addr = format!("0x{key}"); + let checksum_addr = checksum_encode(&raw_addr)?; + Ok(checksum_addr) + }) + .collect::>>()?; println_warning(&format!( "\"{}\" is not a valid account.\nPlease choose a valid option from {}", account_index, @@ -249,751 +255,34 @@ pub(crate) async fn select_secret_key( anyhow::bail!("User refused to sign"); } - Some(secret_key) + let wallet = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + Ok(ForcClientAccount::Wallet(wallet)) + } + SignerSelectionMode::Manual => { + let secret_key = select_manual_secret_key(default_sign, signing_key) + .ok_or_else(|| anyhow::anyhow!("missing manual secret key"))?; + let wallet = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + Ok(ForcClientAccount::Wallet(wallet)) } - WalletSelectionMode::Manual => select_manual_secret_key(default_sign, signing_key), - }; - Ok(signing_key) + SignerSelectionMode::AwsSigner(arn) => { + let aws_config = AwsConfig::from_env().await; + let aws_client = AwsClient::new(aws_config); + let aws_signer = AwsSigner::new(aws_client, arn.clone(), provider.clone()).await?; + + let account = ForcClientAccount::KmsSigner(aws_signer); + Ok(account) + } + } } pub async fn update_proxy_contract_target( - provider: &Provider, - secret_key: SecretKey, + account: &ForcClientAccount, proxy_contract_id: ContractId, new_target: ContractId, ) -> Result> { - abigen!(Contract( - name = "ProxyContract", - abi = r#" - { - "programType": "contract", - "specVersion": "1", - "encodingVersion": "1", - "concreteTypes": [ - { - "type": "()", - "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "type": "enum standards::src5::AccessError", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d", - "metadataTypeId": 1 - }, - { - "type": "enum standards::src5::State", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "metadataTypeId": 2 - }, - { - "type": "enum std::option::Option", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "metadataTypeId": 4, - "typeArguments": [ - "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893", - "metadataTypeId": 5 - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74", - "metadataTypeId": 6 - }, - { - "type": "str", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - }, - { - "type": "struct std::contract_id::ContractId", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54", - "metadataTypeId": 9 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247", - "metadataTypeId": 10 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8", - "metadataTypeId": 11 - } - ], - "metadataTypes": [ - { - "type": "b256", - "metadataTypeId": 0 - }, - { - "type": "enum standards::src5::AccessError", - "metadataTypeId": 1, - "components": [ - { - "name": "NotOwner", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum standards::src5::State", - "metadataTypeId": 2, - "components": [ - { - "name": "Uninitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Initialized", - "typeId": 3 - }, - { - "name": "Revoked", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum std::identity::Identity", - "metadataTypeId": 3, - "components": [ - { - "name": "Address", - "typeId": 8 - }, - { - "name": "ContractId", - "typeId": 9 - } - ] - }, - { - "type": "enum std::option::Option", - "metadataTypeId": 4, - "components": [ - { - "name": "None", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Some", - "typeId": 7 - } - ], - "typeParameters": [ - 7 - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "metadataTypeId": 5, - "components": [ - { - "name": "CannotReinitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "metadataTypeId": 6, - "components": [ - { - "name": "CannotUninitialize", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "generic T", - "metadataTypeId": 7 - }, - { - "type": "struct std::address::Address", - "metadataTypeId": 8, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct std::contract_id::ContractId", - "metadataTypeId": 9, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "metadataTypeId": 10, - "components": [ - { - "name": "new_proxy_owner", - "typeId": 2 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "metadataTypeId": 11, - "components": [ - { - "name": "new_target", - "typeId": 9 - } - ] - } - ], - "functions": [ - { - "inputs": [], - "name": "proxy_target", - "output": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [Option] - The new proxy contract to which all fallback calls will be passed or `None`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_target", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - } - ], - "name": "set_proxy_target", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Change the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called by the `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When not called by `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Write: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read", - "write" - ] - } - ] - }, - { - "inputs": [], - "name": "proxy_owner", - "output": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the owner of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [State] - Represents the state of ownership for this contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [], - "name": "initialize_proxy", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Initializes the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This then allows methods that write to storage to be called." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called once." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When `storage::SRC14.proxy_owner` is not [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `2`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_proxy_owner", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c" - } - ], - "name": "set_proxy_owner", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Changes proxy ownership to the passed State." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can be used to transfer ownership between Identities or to revoke ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_proxy_owner`: [State] - The new state of the proxy ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the sender is not the current proxy owner." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the new state of the proxy ownership is [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - } - ], - "loggedTypes": [ - { - "logId": "4571204900286667806", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d" - }, - { - "logId": "2151606668983994881", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8" - }, - { - "logId": "2161305517876418151", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893" - }, - { - "logId": "4354576968059844266", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74" - }, - { - "logId": "10870989709723147660", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247" - }, - { - "logId": "10098701174489624218", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - } - ], - "messagesTypes": [], - "configurables": [ - { - "name": "INITIAL_TARGET", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "offset": 13616 - }, - { - "name": "INITIAL_OWNER", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "offset": 13568 - } - ] -}"#, - )); - - let wallet = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + abigen!(Contract(name = "ProxyContract", abi = "{\"programType\":\"contract\",\"specVersion\":\"1\",\"encodingVersion\":\"1\",\"concreteTypes\":[{\"type\":\"()\",\"concreteTypeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"type\":\"enum standards::src5::AccessError\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\",\"metadataTypeId\":1},{\"type\":\"enum standards::src5::State\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"metadataTypeId\":2},{\"type\":\"enum std::option::Option\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"metadataTypeId\":4,\"typeArguments\":[\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\",\"metadataTypeId\":5},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\",\"metadataTypeId\":6},{\"type\":\"str\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"},{\"type\":\"struct std::contract_id::ContractId\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\",\"metadataTypeId\":9},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\",\"metadataTypeId\":10},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\",\"metadataTypeId\":11}],\"metadataTypes\":[{\"type\":\"b256\",\"metadataTypeId\":0},{\"type\":\"enum standards::src5::AccessError\",\"metadataTypeId\":1,\"components\":[{\"name\":\"NotOwner\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum standards::src5::State\",\"metadataTypeId\":2,\"components\":[{\"name\":\"Uninitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Initialized\",\"typeId\":3},{\"name\":\"Revoked\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum std::identity::Identity\",\"metadataTypeId\":3,\"components\":[{\"name\":\"Address\",\"typeId\":8},{\"name\":\"ContractId\",\"typeId\":9}]},{\"type\":\"enum std::option::Option\",\"metadataTypeId\":4,\"components\":[{\"name\":\"None\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Some\",\"typeId\":7}],\"typeParameters\":[7]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"metadataTypeId\":5,\"components\":[{\"name\":\"CannotReinitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"metadataTypeId\":6,\"components\":[{\"name\":\"CannotUninitialize\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"generic T\",\"metadataTypeId\":7},{\"type\":\"struct std::address::Address\",\"metadataTypeId\":8,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct std::contract_id::ContractId\",\"metadataTypeId\":9,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"metadataTypeId\":10,\"components\":[{\"name\":\"new_proxy_owner\",\"typeId\":2}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"metadataTypeId\":11,\"components\":[{\"name\":\"new_target\",\"typeId\":9}]}],\"functions\":[{\"inputs\":[],\"name\":\"proxy_target\",\"output\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [Option] - The new proxy contract to which all fallback calls will be passed or `None`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[{\"name\":\"new_target\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"}],\"name\":\"set_proxy_target\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Change the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called by the `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When not called by `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Write: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\",\"write\"]}]},{\"inputs\":[],\"name\":\"proxy_owner\",\"output\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the owner of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [State] - Represents the state of ownership for this contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[],\"name\":\"initialize_proxy\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Initializes the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This then allows methods that write to storage to be called.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called once.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When `storage::SRC14.proxy_owner` is not [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `2`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]},{\"inputs\":[{\"name\":\"new_proxy_owner\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\"}],\"name\":\"set_proxy_owner\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Changes proxy ownership to the passed State.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can be used to transfer ownership between Identities or to revoke ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_proxy_owner`: [State] - The new state of the proxy ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the sender is not the current proxy owner.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the new state of the proxy ownership is [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]}],\"loggedTypes\":[{\"logId\":\"4571204900286667806\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\"},{\"logId\":\"2151606668983994881\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\"},{\"logId\":\"2161305517876418151\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\"},{\"logId\":\"4354576968059844266\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\"},{\"logId\":\"10870989709723147660\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\"},{\"logId\":\"10098701174489624218\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"}],\"messagesTypes\":[],\"configurables\":[{\"name\":\"INITIAL_TARGET\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"offset\":13368},{\"name\":\"INITIAL_OWNER\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"offset\":13320}]}",)); - let proxy_contract = ProxyContract::new(proxy_contract_id, wallet); + let proxy_contract = ProxyContract::new(proxy_contract_id, account.clone()); let result = proxy_contract .methods() @@ -1007,176 +296,32 @@ pub async fn update_proxy_contract_target( Ok(result) } -#[async_trait] -pub trait TransactionBuilderExt { - fn add_contract(&mut self, contract_id: ContractId) -> &mut Self; - fn add_contracts(&mut self, contract_ids: Vec) -> &mut Self; - fn add_inputs(&mut self, inputs: Vec) -> &mut Self; - async fn fund( - &mut self, - address: Address, - provider: Provider, - signature_witness_index: u16, - ) -> Result<&mut Self>; - async fn finalize_signed( - &mut self, - client: Provider, - default_signature: bool, - signing_key: Option, - wallet_mode: &WalletSelectionMode, - ) -> Result; -} - -#[async_trait] -impl TransactionBuilderExt for TransactionBuilder { - fn add_contract(&mut self, contract_id: ContractId) -> &mut Self { - let input_index = self - .inputs() - .len() - .try_into() - .expect("limit of 256 inputs exceeded"); - self.add_input(fuel_tx::Input::contract( - fuel_tx::UtxoId::new(fuel_tx::Bytes32::zeroed(), 0), - fuel_tx::Bytes32::zeroed(), - fuel_tx::Bytes32::zeroed(), - fuel_tx::TxPointer::new(0u32.into(), 0), - contract_id, - )) - .add_output(fuel_tx::Output::Contract( - fuel_tx::output::contract::Contract { - input_index, - balance_root: fuel_tx::Bytes32::zeroed(), - state_root: fuel_tx::Bytes32::zeroed(), - }, - )) - } - fn add_contracts(&mut self, contract_ids: Vec) -> &mut Self { - for contract_id in contract_ids { - self.add_contract(contract_id); - } - self - } - fn add_inputs(&mut self, inputs: Vec) -> &mut Self { - for input in inputs { - self.add_input(input); - } - self - } - async fn fund( - &mut self, - address: Address, - provider: Provider, - signature_witness_index: u16, - ) -> Result<&mut Self> { - let asset_id = *provider.base_asset_id(); - let wallet = Wallet::from_address(Bech32Address::from(address), Some(provider)); - - let amount = 1_000_000; - let filter = None; - let inputs: Vec<_> = wallet - .get_spendable_resources(asset_id, amount, filter) - .await? - .into_iter() - .map(|coin_type| match coin_type { - CoinType::Coin(coin) => create_coin_input(coin, signature_witness_index), - CoinType::Message(message) => { - create_coin_message_input(message, signature_witness_index) - } - }) - .collect(); - let output = Output::change(wallet.address().into(), 0, asset_id); - - self.add_inputs(inputs).add_output(output); - - Ok(self) - } - async fn finalize_signed( - &mut self, - provider: Provider, - default_sign: bool, - signing_key: Option, - wallet_mode: &WalletSelectionMode, - ) -> Result { - let chain_info = provider.chain_info().await?; - let params = chain_info.consensus_parameters; - let signing_key = - select_secret_key(wallet_mode, default_sign, signing_key, &provider, 1).await?; - // Get the address - let address = if let Some(key) = signing_key { - Address::from(*key.public_key().hash()) - } else { - // TODO: Remove this path https://github.com/FuelLabs/sway/issues/6071 - Address::from(prompt_address()?) - }; - - // Insert dummy witness for signature - let signature_witness_index = self.witnesses().len().try_into()?; - self.add_witness(Witness::default()); - - // Add input coin and output change - self.fund( - address, - provider, - signature_witness_index, - ) - .await.map_err(|e| if e.to_string().contains("not enough coins to fit the target") { - anyhow::anyhow!("Deployment failed due to insufficient funds. Please be sure to have enough coins to pay for deployment transaction.") - } else { - e - })?; - - let mut tx = self.finalize_without_signature_inner(); - - let signature = if let Some(signing_key) = signing_key { - let message = Message::from_bytes(*tx.id(¶ms.chain_id())); - Signature::sign(&signing_key, &message) - } else { - prompt_signature(tx.id(¶ms.chain_id()))? - }; - - let witness = Witness::from(signature.as_ref()); - tx.replace_witness(signature_witness_index, witness); - tx.precompute(¶ms.chain_id()) - .map_err(anyhow::Error::msg)?; - - Ok(tx) - } -} - -pub trait TransactionExt { - fn replace_witness(&mut self, witness_index: u16, witness: Witness) -> &mut Self; -} - -impl TransactionExt for T { - fn replace_witness(&mut self, index: u16, witness: Witness) -> &mut Self { - self.witnesses_mut()[index as usize] = witness; - self - } -} - #[cfg(test)] mod tests { use super::*; - use std::collections::BTreeMap; - use std::collections::HashMap; + use fuels::types::bech32::Bech32Address; + use std::collections::{BTreeMap, HashMap}; #[test] fn test_format_base_asset_account_balances() { let mut accounts_map: AccountsMap = BTreeMap::new(); - let address1 = Bech32Address::from_str( + let address1: fuel_tx::Address = Bech32Address::from_str( "fuel1dved7k25uxadatl7l5kql309jnw07dcn4t3a6x9hm9nxyjcpqqns50p7n2", ) - .expect("address1"); - let address2 = Bech32Address::from_str( + .expect("address1") + .into(); + + let address2: fuel_tx::Address = Bech32Address::from_str( "fuel1x9f3ysyk7fmey5ac23s2p4rwg4gjye2kke3nu3pvrs5p4qc4m4qqwx56k3", ) - .expect("address2"); + .expect("address2") + .into(); let base_asset_id = AssetId::zeroed(); - accounts_map.insert(0, address1.clone()); - accounts_map.insert(1, address2.clone()); + accounts_map.insert(0, address1); + accounts_map.insert(1, address2); let mut account_balances: AccountBalances = Vec::new(); let mut balance1 = HashMap::new(); @@ -1188,13 +333,18 @@ mod tests { balance2.insert("other_asset".to_string(), 3_000_000_000); account_balances.push(balance2); + let address1_expected = + "0x6B32DF5954e1BaDEAFFEFD2c0fc5E594dcff3713aaE3Dd18B7d966624B010027"; + let address2_expected = + "0x3153124096f2779253B85460a0D46e4551226556b6633E442c1C281a8315dd40"; let expected = vec![ - format!("[0] {address1} - 1.5 ETH"), - format!("[1] {address2} - 0 ETH"), + format!("[0] {address1_expected} - 1.5 ETH"), + format!("[1] {address2_expected} - 0 ETH"), ]; let result = - format_base_asset_account_balances(&accounts_map, &account_balances, &base_asset_id); + format_base_asset_account_balances(&accounts_map, &account_balances, &base_asset_id) + .unwrap(); assert_eq!(result, expected); } } diff --git a/forc-plugins/forc-client/test/data/standalone_contract_b/.gitignore b/forc-plugins/forc-client/test/data/deployed_predicate/.gitignore similarity index 100% rename from forc-plugins/forc-client/test/data/standalone_contract_b/.gitignore rename to forc-plugins/forc-client/test/data/deployed_predicate/.gitignore diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock new file mode 100644 index 00000000000..2be3d70a3ca --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-661979F06117CBCE" + +[[package]] +name = "deployed_predicate" +source = "member" +dependencies = ["std"] + +[[package]] +name = "std" +source = "path+from-root-661979F06117CBCE" +dependencies = ["core"] diff --git a/forc-plugins/forc-client/test/data/standalone_contract_b/Forc.toml b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml similarity index 75% rename from forc-plugins/forc-client/test/data/standalone_contract_b/Forc.toml rename to forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml index e61b046039b..68b7cb9dff1 100644 --- a/forc-plugins/forc-client/test/data/standalone_contract_b/Forc.toml +++ b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml @@ -1,9 +1,8 @@ [project] authors = ["Fuel Labs "] entry = "main.sw" -implicit-std = false license = "Apache-2.0" -name = "standalone_contract_b" +name = "deployed_predicate" [dependencies] std = { path = "../../../../../sway-lib-std/" } diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json b/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json new file mode 100644 index 00000000000..f38d1dbedd6 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json @@ -0,0 +1,128 @@ +{ + "programType": "predicate", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 1, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 3, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 1, + "components": [ + { + "name": "VariantOne", + "typeId": 2 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 2 + ] + }, + { + "type": "generic D", + "metadataTypeId": 2 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 3, + "components": [ + { + "name": "field_1", + "typeId": 2 + }, + { + "name": "field_2", + "typeId": 4 + } + ], + "typeParameters": [ + 2 + ] + }, + { + "type": "u64", + "metadataTypeId": 4 + } + ], + "functions": [ + { + "inputs": [ + { + "name": "switch", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "u_8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "some_struct", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075" + }, + { + "name": "some_enum", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272" + } + ], + "name": "main", + "output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "attributes": null + } + ], + "loggedTypes": [], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 1896 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 1936 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 1920 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 1904 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw b/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw new file mode 100644 index 00000000000..f33b61faf40 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw @@ -0,0 +1,53 @@ +predicate; + +#[allow(dead_code)] +enum EnumWithGeneric { + VariantOne: D, + VariantTwo: (), +} + +struct StructWithGeneric { + field_1: D, + field_2: u64, +} + +impl Eq for EnumWithGeneric +where + D: Eq, +{ + fn eq(self, other: Self) -> bool { + match (self, other) { + (EnumWithGeneric::VariantOne(d1), EnumWithGeneric::VariantOne(d2)) => d1 == d2, + (EnumWithGeneric::VariantTwo, EnumWithGeneric::VariantTwo) => true, + _ => false, + } + } +} + +impl Eq for StructWithGeneric +where + D: Eq, +{ + fn eq(self, other: Self) -> bool { + self.field_1 == other.field_1 && self.field_2 == other.field_2 + } +} + +configurable { + BOOL: bool = true, + U8: u8 = 8, + STRUCT: StructWithGeneric = StructWithGeneric { + field_1: 8, + field_2: 16, + }, + ENUM: EnumWithGeneric = EnumWithGeneric::VariantOne(true), +} + +fn main( + switch: bool, + u_8: u8, + some_struct: StructWithGeneric, + some_enum: EnumWithGeneric, +) -> bool { + switch == BOOL && u_8 == U8 && some_struct == STRUCT && some_enum == ENUM +} diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/log_decode/.gitignore b/forc-plugins/forc-client/test/data/deployed_script/.gitignore similarity index 100% rename from test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/log_decode/.gitignore rename to forc-plugins/forc-client/test/data/deployed_script/.gitignore diff --git a/forc-plugins/forc-client/test/data/deployed_script/Forc.toml b/forc-plugins/forc-client/test/data/deployed_script/Forc.toml new file mode 100644 index 00000000000..3eb3cdf653b --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/Forc.toml @@ -0,0 +1,8 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "deployed_script" + +[dependencies] +std = { path = "../../../../../sway-lib-std/" } diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json new file mode 100644 index 00000000000..7689a658d2a --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json @@ -0,0 +1,312 @@ +{ + "programType": "script", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], struct StructWithGeneric, enum EnumWithGeneric), bool, u64, u8)", + "concreteTypeId": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "metadataTypeId": 2 + }, + { + "type": "(u8, bool)", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "metadataTypeId": 1 + }, + { + "type": "[u32; 3]", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "metadataTypeId": 4 + }, + { + "type": "b256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 5, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "str[4]", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 7, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "type": "u256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "type": "u32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "type": "u64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "(_, _)", + "metadataTypeId": 1, + "components": [ + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + }, + { + "type": "(_, _, _, _)", + "metadataTypeId": 2, + "components": [ + { + "name": "__tuple_element", + "typeId": 3 + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "type": "(_, _, _, _, _, _, _, _, _, _, _, _)", + "metadataTypeId": 3, + "components": [ + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "name": "__tuple_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "name": "__tuple_element", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "__tuple_element", + "typeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "name": "__tuple_element", + "typeId": 1 + }, + { + "name": "__tuple_element", + "typeId": 4 + }, + { + "name": "__tuple_element", + "typeId": 7, + "typeArguments": [ + { + "name": "", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "name": "__tuple_element", + "typeId": 5, + "typeArguments": [ + { + "name": "", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + } + ] + }, + { + "type": "[_; 3]", + "metadataTypeId": 4, + "components": [ + { + "name": "__array_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + } + ] + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 5, + "components": [ + { + "name": "VariantOne", + "typeId": 6 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 6 + ] + }, + { + "type": "generic D", + "metadataTypeId": 6 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 7, + "components": [ + { + "name": "field_1", + "typeId": 6 + }, + { + "name": "field_2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "typeParameters": [ + 6 + ] + } + ], + "functions": [ + { + "inputs": [ + { + "name": "a", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "contract_addr", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + } + ], + "name": "main", + "output": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": "14454674236531057292", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 8560 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 8672 + }, + { + "name": "U16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "offset": 8616 + }, + { + "name": "U32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "offset": 8656 + }, + { + "name": "U64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "offset": 8664 + }, + { + "name": "U256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "offset": 8624 + }, + { + "name": "B256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "offset": 8528 + }, + { + "name": "STR_4", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a", + "offset": 8600 + }, + { + "name": "TUPLE", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "offset": 8608 + }, + { + "name": "ARRAY", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "offset": 8512 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 8584 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 8568 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json new file mode 100644 index 00000000000..81b65c43cd7 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json @@ -0,0 +1,312 @@ +{ + "programType": "script", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], struct StructWithGeneric, enum EnumWithGeneric), bool, u64, u8)", + "concreteTypeId": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "metadataTypeId": 2 + }, + { + "type": "(u8, bool)", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "metadataTypeId": 1 + }, + { + "type": "[u32; 3]", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "metadataTypeId": 4 + }, + { + "type": "b256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 5, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "str[4]", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 7, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "type": "u256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "type": "u32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "type": "u64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "(_, _)", + "metadataTypeId": 1, + "components": [ + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + }, + { + "type": "(_, _, _, _)", + "metadataTypeId": 2, + "components": [ + { + "name": "__tuple_element", + "typeId": 3 + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "type": "(_, _, _, _, _, _, _, _, _, _, _, _)", + "metadataTypeId": 3, + "components": [ + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "name": "__tuple_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "name": "__tuple_element", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "__tuple_element", + "typeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "name": "__tuple_element", + "typeId": 1 + }, + { + "name": "__tuple_element", + "typeId": 4 + }, + { + "name": "__tuple_element", + "typeId": 7, + "typeArguments": [ + { + "name": "", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "name": "__tuple_element", + "typeId": 5, + "typeArguments": [ + { + "name": "", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + } + ] + }, + { + "type": "[_; 3]", + "metadataTypeId": 4, + "components": [ + { + "name": "__array_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + } + ] + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 5, + "components": [ + { + "name": "VariantOne", + "typeId": 6 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 6 + ] + }, + { + "type": "generic D", + "metadataTypeId": 6 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 7, + "components": [ + { + "name": "field_1", + "typeId": 6 + }, + { + "name": "field_2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "typeParameters": [ + 6 + ] + } + ], + "functions": [ + { + "inputs": [ + { + "name": "a", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "contract_addr", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + } + ], + "name": "main", + "output": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": "14454674236531057292", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 136 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 248 + }, + { + "name": "U16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "offset": 192 + }, + { + "name": "U32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "offset": 232 + }, + { + "name": "U64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "offset": 240 + }, + { + "name": "U256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "offset": 200 + }, + { + "name": "B256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "offset": 104 + }, + { + "name": "STR_4", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a", + "offset": 176 + }, + { + "name": "TUPLE", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "offset": 184 + }, + { + "name": "ARRAY", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "offset": 88 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 160 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 144 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin b/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin new file mode 100644 index 00000000000..0daa7de8f3e Binary files /dev/null and b/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin differ diff --git a/forc-plugins/forc-client/test/data/deployed_script/src/main.sw b/forc-plugins/forc-client/test/data/deployed_script/src/main.sw new file mode 100644 index 00000000000..c47105d4d74 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/src/main.sw @@ -0,0 +1,72 @@ +script; + +use std::logging::log; + +#[allow(dead_code)] +enum EnumWithGeneric { + VariantOne: D, + VariantTwo: (), +} + +struct StructWithGeneric { + field_1: D, + field_2: u64, +} + +abi MyContract { + fn test_function() -> bool; + + #[storage(read)] + fn test_function_read() -> u8; + + #[storage(read, write)] + fn test_function_write(value: u8) -> u8; +} + +configurable { + BOOL: bool = true, + U8: u8 = 8, + U16: u16 = 16, + U32: u32 = 32, + U64: u64 = 63, + U256: u256 = 0x0000000000000000000000000000000000000000000000000000000000000008u256, + B256: b256 = 0x0101010101010101010101010101010101010101010101010101010101010101, + STR_4: str[4] = __to_str_array("fuel"), + TUPLE: (u8, bool) = (8, true), + ARRAY: [u32; 3] = [253, 254, 255], + STRUCT: StructWithGeneric = StructWithGeneric { + field_1: 8, + field_2: 16, + }, + ENUM: EnumWithGeneric = EnumWithGeneric::VariantOne(true), +} + +fn get_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric, EnumWithGeneric) { + (BOOL, U8, U16, U32, U64, U256, B256, STR_4, TUPLE, ARRAY, STRUCT, ENUM) +} + +fn basic_function_with_input(a: u32) -> bool { + if a % 2 == 0 { + true + }else { + false + } +} + +fn basic_function_without_input() -> u64 { + let a = 100; + let b = 25; + a*b +} + +fn main(a: u32, contract_addr: b256) -> ((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric, EnumWithGeneric), bool, u64, u8) { + log(U8); + let configs = get_configurables(); + let with_in = basic_function_with_input(a); + let without_in = basic_function_without_input(); + + let contract_instance = abi(MyContract, contract_addr); + let from_contract = contract_instance.test_function_read(); + + return (configs, with_in, without_in, from_contract); +} diff --git a/forc-plugins/forc-client/test/data/standalone_contract/src/main.sw b/forc-plugins/forc-client/test/data/standalone_contract/src/main.sw index 7d4a75493c6..49e0ac20ae2 100644 --- a/forc-plugins/forc-client/test/data/standalone_contract/src/main.sw +++ b/forc-plugins/forc-client/test/data/standalone_contract/src/main.sw @@ -1,11 +1,32 @@ contract; +storage { + value: u8 = 5, +} + abi MyContract { fn test_function() -> bool; + + #[storage(read)] + fn test_function_read() -> u8; + + #[storage(read, write)] + fn test_function_write(value: u8) -> u8; } impl MyContract for Contract { fn test_function() -> bool { true } + + #[storage(read)] + fn test_function_read() -> u8 { + storage.value.read() + } + + #[storage(read, write)] + fn test_function_write(value: u8) -> u8 { + storage.value.write(value); + storage.value.read() + } } diff --git a/forc-plugins/forc-client/test/data/standalone_contract/standalone_contract-abi.json b/forc-plugins/forc-client/test/data/standalone_contract/standalone_contract-abi.json index a2d797817fc..0dfb6f2fad7 100644 --- a/forc-plugins/forc-client/test/data/standalone_contract/standalone_contract-abi.json +++ b/forc-plugins/forc-client/test/data/standalone_contract/standalone_contract-abi.json @@ -6,6 +6,10 @@ { "type": "bool", "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" } ], "metadataTypes": [], @@ -15,6 +19,38 @@ "name": "test_function", "output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", "attributes": null + }, + { + "inputs": [], + "name": "test_function_read", + "output": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "value", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "name": "test_function_write", + "output": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] } ], "loggedTypes": [], diff --git a/forc-plugins/forc-client/tests/deploy.rs b/forc-plugins/forc-client/tests/deploy.rs index 93faa96d40e..b06d6aa96ed 100644 --- a/forc-plugins/forc-client/tests/deploy.rs +++ b/forc-plugins/forc-client/tests/deploy.rs @@ -1,8 +1,8 @@ use forc::cli::shared::Pkg; use forc_client::{ cmd, - op::{deploy, DeployedContract}, - util::tx::update_proxy_contract_target, + op::{deploy, DeployedContract, DeployedExecutable, DeployedPackage}, + util::{account::ForcClientAccount, tx::update_proxy_contract_target}, NodeTarget, }; use forc_pkg::manifest::Proxy; @@ -10,9 +10,9 @@ use fuel_crypto::SecretKey; use fuel_tx::{ContractId, Salt}; use fuels::{ macros::abigen, - types::{transaction::TxPolicies, AsciiString, Bits256}, + types::{transaction::TxPolicies, AsciiString, Bits256, SizedAsciiString}, }; -use fuels_accounts::{provider::Provider, wallet::WalletUnlocked, Account}; +use fuels_accounts::{provider::Provider, wallet::WalletUnlocked, Account, ViewOnlyAccount}; use portpicker::Port; use rand::thread_rng; use rexpect::spawn; @@ -23,7 +23,7 @@ use std::{ str::FromStr, }; use tempfile::tempdir; -use toml_edit::{value, Document, InlineTable, Item, Table, Value}; +use toml_edit::{value, DocumentMut, InlineTable, Item, Table, Value}; fn get_workspace_root() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")) @@ -71,11 +71,42 @@ fn copy_dir(source: &Path, dest: &Path) -> anyhow::Result<()> { Ok(()) } +/// Tries to get an `DeployedContract` out of the given `DeployedPackage`. +/// Panics otherwise. +fn expect_deployed_contract(deployed_package: DeployedPackage) -> DeployedContract { + if let DeployedPackage::Contract(contract) = deployed_package { + contract + } else { + println!("{deployed_package:?}"); + panic!("expected deployed package to be a contract") + } +} + +/// Tries to get a script (`DeployedExecutable`) out of given deployed package. +/// Panics otherwise. +fn expect_deployed_script(deployed_package: DeployedPackage) -> DeployedExecutable { + if let DeployedPackage::Script(script) = deployed_package { + script + } else { + panic!("expected deployed package to be a script") + } +} + +/// Tries to get a predicate (`DeployedExecutable`) out of given deployed package. +/// Panics otherwise. +fn expect_deployed_predicate(deployed_package: DeployedPackage) -> DeployedExecutable { + if let DeployedPackage::Predicate(predicate) = deployed_package { + predicate + } else { + panic!("expected deployed package to be a predicate") + } +} + fn patch_manifest_file_with_path_std(manifest_dir: &Path) -> anyhow::Result<()> { let toml_path = manifest_dir.join(sway_utils::constants::MANIFEST_FILE_NAME); let toml_content = fs::read_to_string(&toml_path).unwrap(); - let mut doc = toml_content.parse::().unwrap(); + let mut doc = toml_content.parse::().unwrap(); let new_std_path = get_workspace_root().join("sway-lib-std"); let mut std_dependency = InlineTable::new(); @@ -89,7 +120,7 @@ fn patch_manifest_file_with_path_std(manifest_dir: &Path) -> anyhow::Result<()> fn patch_manifest_file_with_proxy_table(manifest_dir: &Path, proxy: Proxy) -> anyhow::Result<()> { let toml_path = manifest_dir.join(sway_utils::constants::MANIFEST_FILE_NAME); let toml_content = fs::read_to_string(&toml_path)?; - let mut doc = toml_content.parse::()?; + let mut doc = toml_content.parse::()?; let proxy_table = doc.entry("proxy").or_insert(Item::Table(Table::new())); let proxy_table = proxy_table.as_table_mut().unwrap(); @@ -329,6 +360,7 @@ async fn test_simple_deploy() { node_url: Some(node_url), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -339,14 +371,14 @@ async fn test_simple_deploy() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let expected = vec![DeployedContract { + let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae", + "5a4d19b92e784817f3e4f7d7c9961c5cba3069e53dcee2a93e8cd723e555c5f3", ) .unwrap(), proxy: None, chunked: false, - }]; + })]; assert_eq!(contract_ids, expected) } @@ -370,6 +402,7 @@ async fn test_deploy_submit_only() { node_url: Some(node_url), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -381,14 +414,14 @@ async fn test_deploy_submit_only() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let expected = vec![DeployedContract { + let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae", + "5a4d19b92e784817f3e4f7d7c9961c5cba3069e53dcee2a93e8cd723e555c5f3", ) .unwrap(), proxy: None, chunked: false, - }]; + })]; assert_eq!(contract_ids, expected) } @@ -416,6 +449,7 @@ async fn test_deploy_fresh_proxy() { node_url: Some(node_url), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -426,19 +460,19 @@ async fn test_deploy_fresh_proxy() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let impl_contract = DeployedContract { + let impl_contract = DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae", + "5a4d19b92e784817f3e4f7d7c9961c5cba3069e53dcee2a93e8cd723e555c5f3", ) .unwrap(), proxy: Some( ContractId::from_str( - "9c50c6837ba29508ad1b0fb01953892031218b5a08be73925ca5c0148e00a186", + "f0641246d72044059de56248becf345bd8553c7892df8c12d7df23f461a7f95b", ) .unwrap(), ), chunked: false, - }; + }); let expected = vec![impl_contract]; assert_eq!(contract_ids, expected) @@ -467,6 +501,7 @@ async fn test_proxy_contract_re_routes_call() { node_url: Some(node_url.clone()), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -475,10 +510,10 @@ async fn test_proxy_contract_re_routes_call() { default_signer: true, ..Default::default() }; - let contract_ids = deploy(cmd).await.unwrap(); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // At this point we deployed a contract with proxy. - let proxy_contract_id = contract_ids[0].proxy.unwrap(); - let impl_contract_id = contract_ids[0].id; + let proxy_contract_id = deployed_contract.proxy.unwrap(); + let impl_contract_id = deployed_contract.id; // Make a contract call into proxy contract, and check if the initial // contract returns a true. let provider = Provider::connect(&node_url).await.unwrap(); @@ -491,6 +526,25 @@ async fn test_proxy_contract_re_routes_call() { )); let impl_contract_a = ImplementationContract::new(proxy_contract_id, wallet_unlocked.clone()); + + // Test storage functions + let res = impl_contract_a + .methods() + .test_function_read() + .with_contract_ids(&[impl_contract_id.into()]) + .call() + .await + .unwrap(); + assert_eq!(res.value, 5); + let res = impl_contract_a + .methods() + .test_function_write(8) + .with_contract_ids(&[impl_contract_id.into()]) + .call() + .await + .unwrap(); + assert_eq!(res.value, 8); + let res = impl_contract_a .methods() .test_function() @@ -505,6 +559,7 @@ async fn test_proxy_contract_re_routes_call() { node_url: Some(node_url.clone()), target: None, testnet: false, + mainnet: false, }; let pkg = Pkg { path: Some(tmp_dir.path().display().to_string()), @@ -518,13 +573,33 @@ async fn test_proxy_contract_re_routes_call() { default_signer: true, ..Default::default() }; - let contract_ids = deploy(cmd).await.unwrap(); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // proxy contract id should be the same. - let proxy_contract_after_update = contract_ids[0].proxy.unwrap(); + let proxy_contract_after_update = deployed_contract.proxy.unwrap(); assert_eq!(proxy_contract_id, proxy_contract_after_update); - let impl_contract_id_after_update = contract_ids[0].id; + let impl_contract_id_after_update = deployed_contract.id; assert!(impl_contract_id != impl_contract_id_after_update); let impl_contract_a = ImplementationContract::new(proxy_contract_after_update, wallet_unlocked); + + // Test storage functions + let res = impl_contract_a + .methods() + .test_function_read() + .with_contract_ids(&[impl_contract_id_after_update.into()]) + .call() + .await + .unwrap(); + // Storage should be preserved from the previous target contract. + assert_eq!(res.value, 8); + let res = impl_contract_a + .methods() + .test_function_write(9) + .with_contract_ids(&[impl_contract_id_after_update.into()]) + .call() + .await + .unwrap(); + assert_eq!(res.value, 9); + let res = impl_contract_a .methods() .test_function() @@ -559,6 +634,7 @@ async fn test_non_owner_fails_to_set_target() { node_url: Some(node_url.clone()), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -567,9 +643,9 @@ async fn test_non_owner_fails_to_set_target() { default_signer: true, ..Default::default() }; - let contract_id = deploy(cmd).await.unwrap(); + let contract_id = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // Proxy contract's id. - let proxy_id = contract_id.first().and_then(|f| f.proxy).unwrap(); + let proxy_id = contract_id.proxy.unwrap(); // Create and fund an owner account and an attacker account. let provider = Provider::connect(&node_url).await.unwrap(); @@ -595,745 +671,15 @@ async fn test_non_owner_fails_to_set_target() { .unwrap(); let dummy_contract_id_target = ContractId::default(); - abigen!(Contract( - name = "ProxyContract", - abi = r#" -{ - "programType": "contract", - "specVersion": "1", - "encodingVersion": "1", - "concreteTypes": [ - { - "type": "()", - "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "type": "enum standards::src5::AccessError", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d", - "metadataTypeId": 1 - }, - { - "type": "enum standards::src5::State", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "metadataTypeId": 2 - }, - { - "type": "enum std::option::Option", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "metadataTypeId": 4, - "typeArguments": [ - "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893", - "metadataTypeId": 5 - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74", - "metadataTypeId": 6 - }, - { - "type": "str", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - }, - { - "type": "struct std::contract_id::ContractId", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54", - "metadataTypeId": 9 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247", - "metadataTypeId": 10 - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8", - "metadataTypeId": 11 - } - ], - "metadataTypes": [ - { - "type": "b256", - "metadataTypeId": 0 - }, - { - "type": "enum standards::src5::AccessError", - "metadataTypeId": 1, - "components": [ - { - "name": "NotOwner", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum standards::src5::State", - "metadataTypeId": 2, - "components": [ - { - "name": "Uninitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Initialized", - "typeId": 3 - }, - { - "name": "Revoked", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum std::identity::Identity", - "metadataTypeId": 3, - "components": [ - { - "name": "Address", - "typeId": 8 - }, - { - "name": "ContractId", - "typeId": 9 - } - ] - }, - { - "type": "enum std::option::Option", - "metadataTypeId": 4, - "components": [ - { - "name": "None", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "name": "Some", - "typeId": 7 - } - ], - "typeParameters": [ - 7 - ] - }, - { - "type": "enum sway_libs::ownership::errors::InitializationError", - "metadataTypeId": 5, - "components": [ - { - "name": "CannotReinitialized", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "enum sway_libs::upgradability::errors::SetProxyOwnerError", - "metadataTypeId": 6, - "components": [ - { - "name": "CannotUninitialize", - "typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - } - ] - }, - { - "type": "generic T", - "metadataTypeId": 7 - }, - { - "type": "struct std::address::Address", - "metadataTypeId": 8, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct std::contract_id::ContractId", - "metadataTypeId": 9, - "components": [ - { - "name": "bits", - "typeId": 0 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyOwnerSet", - "metadataTypeId": 10, - "components": [ - { - "name": "new_proxy_owner", - "typeId": 2 - } - ] - }, - { - "type": "struct sway_libs::upgradability::events::ProxyTargetSet", - "metadataTypeId": 11, - "components": [ - { - "name": "new_target", - "typeId": 9 - } - ] - } - ], - "functions": [ - { - "inputs": [], - "name": "proxy_target", - "output": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [Option] - The new proxy contract to which all fallback calls will be passed or `None`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_target", - "concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54" - } - ], - "name": "set_proxy_target", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Change the target contract of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called by the `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When not called by `proxy_owner`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Write: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read", - "write" - ] - } - ] - }, - { - "inputs": [], - "name": "proxy_owner", - "output": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Returns the owner of the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Returns" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * [State] - Represents the state of ownership for this contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "read" - ] - } - ] - }, - { - "inputs": [], - "name": "initialize_proxy", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Initializes the proxy contract." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This then allows methods that write to storage to be called." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can only be called once." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When `storage::SRC14.proxy_owner` is not [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `2`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - }, - { - "inputs": [ - { - "name": "new_proxy_owner", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c" - } - ], - "name": "set_proxy_owner", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "doc-comment", - "arguments": [ - " Changes proxy ownership to the passed State." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Additional Information" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " This method can be used to transfer ownership between Identities or to revoke ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Arguments" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * `new_proxy_owner`: [State] - The new state of the proxy ownership." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Reverts" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the sender is not the current proxy owner." - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * When the new state of the proxy ownership is [State::Uninitialized]." - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " # Number of Storage Accesses" - ] - }, - { - "name": "doc-comment", - "arguments": [ - "" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Reads: `1`" - ] - }, - { - "name": "doc-comment", - "arguments": [ - " * Writes: `1`" - ] - }, - { - "name": "storage", - "arguments": [ - "write" - ] - } - ] - } - ], - "loggedTypes": [ - { - "logId": "4571204900286667806", - "concreteTypeId": "3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d" - }, - { - "logId": "2151606668983994881", - "concreteTypeId": "1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8" - }, - { - "logId": "2161305517876418151", - "concreteTypeId": "1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893" - }, - { - "logId": "4354576968059844266", - "concreteTypeId": "3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74" - }, - { - "logId": "10870989709723147660", - "concreteTypeId": "96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247" - }, - { - "logId": "10098701174489624218", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - } - ], - "messagesTypes": [], - "configurables": [ - { - "name": "INITIAL_TARGET", - "concreteTypeId": "0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8", - "offset": 13616 - }, - { - "name": "INITIAL_OWNER", - "concreteTypeId": "192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c", - "offset": 13568 - } - ] -}"#, - )); + abigen!(Contract(name = "ProxyContract", abi = "{\"programType\":\"contract\",\"specVersion\":\"1\",\"encodingVersion\":\"1\",\"concreteTypes\":[{\"type\":\"()\",\"concreteTypeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"type\":\"enum standards::src5::AccessError\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\",\"metadataTypeId\":1},{\"type\":\"enum standards::src5::State\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"metadataTypeId\":2},{\"type\":\"enum std::option::Option\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"metadataTypeId\":4,\"typeArguments\":[\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\",\"metadataTypeId\":5},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\",\"metadataTypeId\":6},{\"type\":\"str\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"},{\"type\":\"struct std::contract_id::ContractId\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\",\"metadataTypeId\":9},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\",\"metadataTypeId\":10},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\",\"metadataTypeId\":11}],\"metadataTypes\":[{\"type\":\"b256\",\"metadataTypeId\":0},{\"type\":\"enum standards::src5::AccessError\",\"metadataTypeId\":1,\"components\":[{\"name\":\"NotOwner\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum standards::src5::State\",\"metadataTypeId\":2,\"components\":[{\"name\":\"Uninitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Initialized\",\"typeId\":3},{\"name\":\"Revoked\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum std::identity::Identity\",\"metadataTypeId\":3,\"components\":[{\"name\":\"Address\",\"typeId\":8},{\"name\":\"ContractId\",\"typeId\":9}]},{\"type\":\"enum std::option::Option\",\"metadataTypeId\":4,\"components\":[{\"name\":\"None\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"},{\"name\":\"Some\",\"typeId\":7}],\"typeParameters\":[7]},{\"type\":\"enum sway_libs::ownership::errors::InitializationError\",\"metadataTypeId\":5,\"components\":[{\"name\":\"CannotReinitialized\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"enum sway_libs::upgradability::errors::SetProxyOwnerError\",\"metadataTypeId\":6,\"components\":[{\"name\":\"CannotUninitialize\",\"typeId\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\"}]},{\"type\":\"generic T\",\"metadataTypeId\":7},{\"type\":\"struct std::address::Address\",\"metadataTypeId\":8,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct std::contract_id::ContractId\",\"metadataTypeId\":9,\"components\":[{\"name\":\"bits\",\"typeId\":0}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyOwnerSet\",\"metadataTypeId\":10,\"components\":[{\"name\":\"new_proxy_owner\",\"typeId\":2}]},{\"type\":\"struct sway_libs::upgradability::events::ProxyTargetSet\",\"metadataTypeId\":11,\"components\":[{\"name\":\"new_target\",\"typeId\":9}]}],\"functions\":[{\"inputs\":[],\"name\":\"proxy_target\",\"output\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [Option] - The new proxy contract to which all fallback calls will be passed or `None`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[{\"name\":\"new_target\",\"concreteTypeId\":\"29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54\"}],\"name\":\"set_proxy_target\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Change the target contract of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called by the `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_target`: [ContractId] - The new proxy contract to which all fallback calls will be passed.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When not called by `proxy_owner`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Write: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\",\"write\"]}]},{\"inputs\":[],\"name\":\"proxy_owner\",\"output\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Returns the owner of the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Returns\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * [State] - Represents the state of ownership for this contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"read\"]}]},{\"inputs\":[],\"name\":\"initialize_proxy\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Initializes the proxy contract.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method sets the storage values using the values of the configurable constants `INITIAL_TARGET` and `INITIAL_OWNER`.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This then allows methods that write to storage to be called.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can only be called once.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When `storage::SRC14.proxy_owner` is not [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `2`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]},{\"inputs\":[{\"name\":\"new_proxy_owner\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\"}],\"name\":\"set_proxy_owner\",\"output\":\"2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d\",\"attributes\":[{\"name\":\"doc-comment\",\"arguments\":[\" Changes proxy ownership to the passed State.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Additional Information\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" This method can be used to transfer ownership between Identities or to revoke ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Arguments\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * `new_proxy_owner`: [State] - The new state of the proxy ownership.\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Reverts\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the sender is not the current proxy owner.\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * When the new state of the proxy ownership is [State::Uninitialized].\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" # Number of Storage Accesses\"]},{\"name\":\"doc-comment\",\"arguments\":[\"\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Reads: `1`\"]},{\"name\":\"doc-comment\",\"arguments\":[\" * Writes: `1`\"]},{\"name\":\"storage\",\"arguments\":[\"write\"]}]}],\"loggedTypes\":[{\"logId\":\"4571204900286667806\",\"concreteTypeId\":\"3f702ea3351c9c1ece2b84048006c8034a24cbc2bad2e740d0412b4172951d3d\"},{\"logId\":\"2151606668983994881\",\"concreteTypeId\":\"1ddc0adda1270a016c08ffd614f29f599b4725407c8954c8b960bdf651a9a6c8\"},{\"logId\":\"2161305517876418151\",\"concreteTypeId\":\"1dfe7feadc1d9667a4351761230f948744068a090fe91b1bc6763a90ed5d3893\"},{\"logId\":\"4354576968059844266\",\"concreteTypeId\":\"3c6e90ae504df6aad8b34a93ba77dc62623e00b777eecacfa034a8ac6e890c74\"},{\"logId\":\"10870989709723147660\",\"concreteTypeId\":\"96dd838b44f99d8ccae2a7948137ab6256c48ca4abc6168abc880de07fba7247\"},{\"logId\":\"10098701174489624218\",\"concreteTypeId\":\"8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a\"}],\"messagesTypes\":[],\"configurables\":[{\"name\":\"INITIAL_TARGET\",\"concreteTypeId\":\"0d79387ad3bacdc3b7aad9da3a96f4ce60d9a1b6002df254069ad95a3931d5c8\",\"offset\":13368},{\"name\":\"INITIAL_OWNER\",\"concreteTypeId\":\"192bc7098e2fe60635a9918afb563e4e5419d386da2bdbf0d716b4bc8549802c\",\"offset\":13320}]}",)); + let wallet = WalletUnlocked::new_from_private_key(attacker_secret_key, Some(provider.clone())); + let attacker_account = ForcClientAccount::Wallet(wallet); // Try to change target of the proxy with a random wallet which is not the owner of the proxy. - let res = update_proxy_contract_target( - &provider, - attacker_secret_key, - proxy_id, - dummy_contract_id_target, - ) - .await - .err() - .unwrap(); + let res = update_proxy_contract_target(&attacker_account, proxy_id, dummy_contract_id_target) + .await + .err() + .unwrap(); node.kill().unwrap(); assert!(res @@ -1347,7 +693,7 @@ async fn test_non_owner_fails_to_set_target() { // It would also require overriding `default_wallet_path` function for tests, so as not to interfere with the user's wallet. #[test] -fn test_deploy_interactive_wrong_password() -> Result<(), rexpect::error::Error> { +fn test_deploy_interactive_missing_wallet() -> Result<(), rexpect::error::Error> { let (mut node, port) = run_node(); let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); @@ -1365,9 +711,8 @@ fn test_deploy_interactive_wrong_password() -> Result<(), rexpect::error::Error> process .exp_string("\u{1b}[1;32mConfirming\u{1b}[0m transactions [deploy standalone_contract]")?; process.exp_string(&format!("Network: {node_url}"))?; - process.exp_string("Wallet: ")?; - process.exp_string("Wallet password")?; - process.send_line("mock_password")?; + process.exp_regex("Could not find a wallet at")?; + process.send_line("n")?; process.process.exit()?; node.kill().unwrap(); @@ -1392,6 +737,7 @@ async fn chunked_deploy() { node_url: Some(node_url), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -1400,7 +746,7 @@ async fn chunked_deploy() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); node.kill().unwrap(); assert!(deployed_contract.chunked); @@ -1424,6 +770,7 @@ async fn chunked_deploy_re_routes_calls() { node_url: Some(node_url.clone()), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -1432,7 +779,7 @@ async fn chunked_deploy_re_routes_calls() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); let provider = Provider::connect(&node_url).await.unwrap(); let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); @@ -1466,6 +813,7 @@ async fn chunked_deploy_with_proxy_re_routes_call() { node_url: Some(node_url.clone()), target: None, testnet: false, + mainnet: false, }; let cmd = cmd::Deploy { pkg, @@ -1474,7 +822,7 @@ async fn chunked_deploy_with_proxy_re_routes_call() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); let provider = Provider::connect(&node_url).await.unwrap(); let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); @@ -1484,3 +832,481 @@ async fn chunked_deploy_with_proxy_re_routes_call() { node.kill().unwrap(); } + +#[tokio::test] +async fn can_deploy_script() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + node.kill().unwrap(); +} + +#[tokio::test] +async fn deploy_script_calls() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + + // Deploy the contract the script is going to be calling. + let contract_tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("standalone_contract"); + copy_dir(&project_dir, contract_tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(contract_tmp_dir.path()).unwrap(); + + let pkg = Pkg { + path: Some(contract_tmp_dir.path().display().to_string()), + ..Default::default() + }; + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + let deployed_packages = deploy(cmd).await.unwrap().remove(0); + let contract = expect_deployed_contract(deployed_packages); + let contract_id = contract.id; + + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json" + )); + + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider)); + + let loader_path = tmp_dir.path().join("out/deployed_script-loader.bin"); + let instance = MyScript::new(wallet_unlocked, &loader_path.display().to_string()); + + let contract_id_bits256 = Bits256(contract.id.into()); + let call_handler = instance + .main(10, contract_id_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap(); + let (configs, with_input, without_input, from_contract) = call_handler.value; + let receipts = call_handler.receipts; + + assert!(configs.0); // bool + assert_eq!(configs.1, 8); // u8 + assert_eq!(configs.2, 16); // u16 + assert_eq!(configs.3, 32); // u32 + assert_eq!(configs.4, 63); // u64 + assert_eq!(configs.5, 8.into()); // u256 + assert_eq!( + configs.6, + Bits256::from_hex_str("0x0101010101010101010101010101010101010101010101010101010101010101") + .unwrap() + ); // b256 + assert_eq!( + configs.7, + SizedAsciiString::new("fuel".to_string()).unwrap() + ); // str[4] + assert_eq!(configs.8, (8, true)); // tuple + assert_eq!(configs.9, [253, 254, 255]); // array + + let expected_struct = StructWithGeneric { + field_1: 8, + field_2: 16, + }; + assert_eq!(configs.10, expected_struct); // struct + + let expected_enum = EnumWithGeneric::VariantOne(true); + assert_eq!(configs.11, expected_enum); // enum + + assert!(with_input); // 10 % 2 == 0 + assert_eq!(without_input, 2500); // 25 * 100 = 2500 + + assert_eq!(from_contract, 5); + + receipts.iter().find(|receipt| { + if let fuel_tx::Receipt::LogData { data, .. } = receipt { + *data == Some(vec![0x08]) + } else { + false + } + }); + + node.kill().unwrap(); +} + +#[tokio::test] +async fn can_deploy_predicates() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_predicate"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_predicate(deploy(cmd).await.unwrap().remove(0)); + node.kill().unwrap(); +} + +#[tokio::test] +async fn deployed_predicate_call() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_predicate"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + expect_deployed_predicate(deploy(cmd).await.unwrap().remove(0)); + + abigen!(Predicate( + name = "MyPredicate", + abi = "forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json" + )); + + let provider = Provider::connect(&node_url).await.unwrap(); + let base_asset_id = *provider.base_asset_id(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let loader_path = tmp_dir.path().join("out/deployed_predicate-loader.bin"); + let strct = StructWithGeneric { + field_1: 8, + field_2: 16, + }; + let enm = EnumWithGeneric::VariantOne(true); + let encoded_data = MyPredicateEncoder::default() + .encode_data(true, 8, strct, enm) + .unwrap(); + let predicate: fuels::prelude::Predicate = + fuels::prelude::Predicate::load_from(&loader_path.display().to_string()) + .unwrap() + .with_data(encoded_data) + .with_provider(provider); + + // lock some amount under the predicate + wallet_unlocked + .transfer( + predicate.address(), + 500, + base_asset_id, + TxPolicies::default(), + ) + .await + .unwrap(); + + // Check predicate balance. + let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap(); + assert_eq!(balance, 500); + + // Try to spend it + let amount_to_unlock = 300; + predicate + .transfer( + wallet_unlocked.address(), + amount_to_unlock, + base_asset_id, + TxPolicies::default(), + ) + .await + .unwrap(); + + // Check predicate balance again. + let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap(); + assert_eq!(balance, 200); + + node.kill().unwrap(); +} + +/// Generates a script instance using SDK, and returns the result as a string. +async fn call_with_sdk_generated_overrides(node_url: &str, contract_id: ContractId) -> String { + let project_dir = test_data_path().join("deployed_script"); + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json" + )); + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let bin_dir = project_dir.join("deployed_script.bin"); + let script_instance = MyScript::new(wallet_unlocked, bin_dir.display().to_string().as_str()); + + let strc = StructWithGeneric { + field_1: 1u8, + field_2: 2, + }; + let encoded = MyScriptConfigurables::default() + .with_BOOL(false) + .unwrap() + .with_U8(1) + .unwrap() + .with_U16(2) + .unwrap() + .with_U32(3) + .unwrap() + .with_U64(4) + .unwrap() + .with_U256(5.into()) + .unwrap() + .with_B256(Bits256::zeroed()) + .unwrap() + .with_ARRAY([1, 2, 3]) + .unwrap() + .with_STRUCT(strc) + .unwrap() + .with_ENUM(EnumWithGeneric::VariantTwo) + .unwrap(); + + let mut script_instance_with_configs = script_instance.with_configurables(encoded); + + let loader_from_sdk = script_instance_with_configs + .convert_into_loader() + .await + .unwrap(); + + let contract_ids_bits256 = Bits256(contract_id.into()); + format!( + "{:?}", + loader_from_sdk + .main(10, contract_ids_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap() + .value + ) +} + +/// Generates a script instance using the shifted abi, and returns the result as a string. +async fn call_with_forc_generated_overrides(node_url: &str, contract_id: ContractId) -> String { + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let target = NodeTarget { + node_url: Some(node_url.to_string()), + target: None, + testnet: false, + mainnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + + // Since `abigen!` macro does not allow for dynamic paths, we need to + // pre-generate the loader bin and abi and read them from project dir. Here + // we are ensuring forc-deploy indeed generated the files we are basing our + // tests below. + let generated_loader_abi_path = tmp_dir.path().join("out/deployed_script-loader-abi.json"); + let generated_loader_abi = fs::read_to_string(generated_loader_abi_path).unwrap(); + + // this path is basically, `forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json`. + let used_loader_abi_path = project_dir.join("deployed_script-loader-abi.json"); + let used_loader_abi = fs::read_to_string(used_loader_abi_path).unwrap(); + + assert_eq!(generated_loader_abi, used_loader_abi); + + let generated_loader_bin = tmp_dir.path().join("out/deployed_script-loader.bin"); + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json" + )); + let forc_generated_script_instance = MyScript::new( + wallet_unlocked, + generated_loader_bin.display().to_string().as_str(), + ); + let strc = StructWithGeneric { + field_1: 1u8, + field_2: 2, + }; + let encoded = MyScriptConfigurables::default() + .with_BOOL(false) + .unwrap() + .with_U8(1) + .unwrap() + .with_U16(2) + .unwrap() + .with_U32(3) + .unwrap() + .with_U64(4) + .unwrap() + .with_U256(5.into()) + .unwrap() + .with_B256(Bits256::zeroed()) + .unwrap() + .with_ARRAY([1, 2, 3]) + .unwrap() + .with_STRUCT(strc) + .unwrap() + .with_ENUM(EnumWithGeneric::VariantTwo) + .unwrap(); + + let forc_generated_script_with_configs = + forc_generated_script_instance.with_configurables(encoded); + let contract_ids_bits256 = Bits256(contract_id.into()); + format!( + "{:?}", + forc_generated_script_with_configs + .main(10, contract_ids_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap() + .value + ) +} + +#[tokio::test] +async fn offset_shifted_abi_works() { + // To test if offset shifted abi works or not, we generate a loader + // contract using sdk and give a configurable override, and call the + // main function. + + // We also create the shited abi using forc-deploy and create a script + // instance using this new shifted abi, and generate a normal script out of + // the loader binary generated again by forc-deploy. + + // We then override the configurables with the same values as sdk flow on + // this script, generated with loader abi and bin coming from forc-deploy. + + // If returned value is equal, than the configurables work correctly. + let (mut node, port) = run_node(); + // Deploy the contract the script is going to be calling. + let contract_tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("standalone_contract"); + copy_dir(&project_dir, contract_tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(contract_tmp_dir.path()).unwrap(); + + let pkg = Pkg { + path: Some(contract_tmp_dir.path().display().to_string()), + ..Default::default() + }; + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + mainnet: false, + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + let deployed_packages = deploy(cmd).await.unwrap().remove(0); + let contract = expect_deployed_contract(deployed_packages); + let contract_id = contract.id; + // Generating the sdk loader bytecode with configurables. + let loader_with_configs_from_sdk = + call_with_sdk_generated_overrides(&node_url, contract_id).await; + + // Genearating the forc-deploy loader bytecode and loader abi. + let loader_with_configs_from_forc = + call_with_forc_generated_overrides(&node_url, contract_id).await; + pretty_assertions::assert_eq!(loader_with_configs_from_forc, loader_with_configs_from_sdk); + + node.kill().unwrap() +} diff --git a/forc-plugins/forc-crypto/Cargo.toml b/forc-plugins/forc-crypto/Cargo.toml index 8423e1e7f3b..e0e631e937d 100644 --- a/forc-plugins/forc-crypto/Cargo.toml +++ b/forc-plugins/forc-crypto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-crypto" -version = "0.63.5" +version.workspace = true description = "A `forc` plugin for handling various cryptographic operations and conversions." authors.workspace = true edition.workspace = true @@ -9,23 +9,33 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1.0.75" -async-trait = "0.1.58" -atty = "0.2.14" -clap = { version = "4.5.4", features = ["derive", "env"] } -forc-tracing = { version = "0.63.5", path = "../../forc-tracing" } -forc-util = { version = "0.63.5", path = "../../forc-util" } -fuel-core-types = { workspace = true } +anyhow.workspace = true +async-trait.workspace = true +clap = { workspace = true, features = ["derive", "env"] } +forc-tracing.workspace = true +forc-util.workspace = true +fuel-core-types.workspace = true fuel-crypto = { workspace = true, features = ["random"] } -fuels-core = { workspace = true } -futures = "0.3" -hex = "0.4.3" -libp2p-identity = { version = "0.2.4", features = ["secp256k1", "peerid"] } -rand = "0.8" -serde = "1.0" -serde_json = "1" -serde_yaml = "0.9.27" -sha3 = "0.10.8" -termion = "2.0.1" -tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "process"] } -tracing = "0.1" +fuels-accounts.workspace = true +fuels-core.workspace = true +futures.workspace = true +hex.workspace = true +libp2p-identity = { workspace = true, features = ["peerid", "secp256k1"] } +rand.workspace = true +rayon.workspace = true +regex.workspace = true +serde.workspace = true +serde_json.workspace = true +serde_yaml.workspace = true +sha3.workspace = true +termion.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread", "process"] } +tracing.workspace = true + +[dev-dependencies] +criterion = "0.5" +tempfile.workspace = true + +[[bench]] +name = "bench_main" +harness = false diff --git a/forc-plugins/forc-crypto/benches/bench_main.rs b/forc-plugins/forc-crypto/benches/bench_main.rs new file mode 100644 index 00000000000..675923911cb --- /dev/null +++ b/forc-plugins/forc-crypto/benches/bench_main.rs @@ -0,0 +1,73 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use forc_crypto::keys::vanity::{find_vanity_address_with_timeout, HexMatcher, RegexMatcher}; +use rayon::iter::Either; + +fn benchmark_vanity_address(c: &mut Criterion) { + let mut group = c.benchmark_group("Vanity Address Generation"); + + // Benchmark HexMatcher with prefix + group.bench_function("HexMatcher (starts with 'a')", |b| { + b.iter(|| { + let matcher = Either::Right(HexMatcher::new("a", "").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), false, None) + }) + }); + + // Benchmark HexMatcher with suffix + group.bench_function("HexMatcher (ends with 'f')", |b| { + b.iter(|| { + let matcher = Either::Right(HexMatcher::new("", "f").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), false, None) + }) + }); + + // Benchmark HexMatcher with both prefix and suffix + group.bench_function("HexMatcher (starts with 'a' ends with 'f')", |b| { + b.iter(|| { + let matcher = Either::Right(HexMatcher::new("a", "f").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), false, None) + }) + }); + + // Benchmark RegexMatcher with simple pattern + group.bench_function("RegexMatcher (starts with 'a')", |b| { + b.iter(|| { + let matcher = Either::Left(RegexMatcher::new("^a.*").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), false, None) + }) + }); + + // Benchmark RegexMatcher with complex pattern + group.bench_function("RegexMatcher (contains two consecutive digits)", |b| { + b.iter(|| { + let matcher = Either::Left(RegexMatcher::new(r"[0-9]{2}").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), false, None) + }) + }); + + // Benchmark with mnemonic generation + group.bench_function("HexMatcher with Mnemonic (starts with 'a')", |b| { + b.iter(|| { + let matcher = Either::Right(HexMatcher::new("a", "").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), true, None) + }) + }); + + group.bench_function("RegexMatcher with Mnemonic (starts with 'a')", |b| { + b.iter(|| { + let matcher = Either::Left(RegexMatcher::new("^a.*").unwrap()); + find_vanity_address_with_timeout(black_box(matcher), true, None) + }) + }); + + group.finish(); +} + +criterion_group! { + name = benches; + config = Criterion::default() + .sample_size(10) // Reduced sample size due to potentially long-running benchmarks + .measurement_time(std::time::Duration::from_secs(20)); + targets = benchmark_vanity_address +} +criterion_main!(benches); diff --git a/forc-plugins/forc-crypto/src/args.rs b/forc-plugins/forc-crypto/src/args.rs index 8e4bcee25fd..4201894632c 100644 --- a/forc-plugins/forc-crypto/src/args.rs +++ b/forc-plugins/forc-crypto/src/args.rs @@ -24,17 +24,17 @@ forc_util::cli_examples! { pub struct HashArgs { /// This argument is optional, it can be either: /// - /// 1. A path to a file. If that is the case, the content of the file is - /// loaded. + /// 1. A path to a file. If that is the case, the content of the file is + /// loaded /// - /// 2. A binary string encoded as a hex string. If that is the case, the - /// hex is decoded and passed as a Vec + /// 2. A binary string encoded as a hex string. If that is the case, the + /// hex is decoded and passed as a Vec /// - /// 3. A string. This is the last option, if the string is "-", `stdin` - /// is read instead. Otherwise the raw string is converted to a Vec - /// and passed + /// 3. A string. This is the last option, if the string is "-", "stdin" + /// is read instead. Otherwise the raw string is converted to a Vec + /// and passed /// - /// 4. If it nos not provided, `stdin` is read + /// 4. If it is not provided, "stdin" is read content_or_filepath: Option, } diff --git a/forc-plugins/forc-crypto/src/keys/mod.rs b/forc-plugins/forc-crypto/src/keys/mod.rs index 9741e32623c..8935b5f366e 100644 --- a/forc-plugins/forc-crypto/src/keys/mod.rs +++ b/forc-plugins/forc-crypto/src/keys/mod.rs @@ -3,6 +3,7 @@ use clap::ValueEnum; pub mod get_public_key; pub mod new_key; pub mod parse_secret; +pub mod vanity; #[derive(Clone, Debug, Default, ValueEnum)] pub enum KeyType { diff --git a/forc-plugins/forc-crypto/src/keys/vanity.rs b/forc-plugins/forc-crypto/src/keys/vanity.rs new file mode 100644 index 00000000000..640165dc818 --- /dev/null +++ b/forc-plugins/forc-crypto/src/keys/vanity.rs @@ -0,0 +1,457 @@ +use fuel_crypto::{fuel_types::Address, PublicKey, SecretKey}; +use fuels_accounts::wallet::{generate_mnemonic_phrase, DEFAULT_DERIVATION_PATH_PREFIX}; +use fuels_core::types::{ + bech32::{Bech32Address, FUEL_BECH32_HRP}, + checksum_address::checksum_encode, +}; +use rayon::iter::{self, Either, ParallelIterator}; +use regex::Regex; +use serde_json::json; +use std::{ + path::PathBuf, + time::{Duration, Instant}, +}; +use tokio::runtime::Runtime; + +forc_util::cli_examples! { + crate::Command { + [ Generate a checksummed vanity address with a given prefix => "forc crypto vanity --starts-with \"aaa\"" ] + [ Generate a checksummed vanity address with a given suffix => "forc crypto vanity --ends-with \"aaa\"" ] + [ Generate a checksummed vanity address with a given prefix and suffix => "forc crypto vanity --starts-with \"00\" --ends-with \"ff\"" ] + [ Generate a checksummed vanity address with a given regex pattern => "forc crypto vanity --regex \"^00.*ff$\"" ] + } +} + +fn validate_hex_string(s: &str) -> Result { + if !s.chars().all(|c| c.is_ascii_hexdigit()) { + return Err("Pattern must contain only hex characters (0-9, a-f)".to_string()); + } + Ok(s.to_string()) +} + +fn validate_regex_pattern(s: &str) -> Result { + if s.len() > 128 { + return Err("Regex pattern too long: max 128 characters".to_string()); + } + + if let Err(e) = Regex::new(&format!("(?i){}", s)) { + return Err(format!("Invalid regex pattern: {}", e)); + } + + Ok(s.to_string()) +} + +#[derive(Debug, clap::Parser)] +#[clap( + version, + about = "Generate a vanity address", + after_help = "Generate vanity addresses for the Fuel blockchain" +)] +pub struct Arg { + /// Desired hex string prefix for the address + #[arg( + long, + value_name = "HEX_STRING", + required_unless_present = "ends_with", + required_unless_present = "regex", + conflicts_with = "regex", + value_parser = validate_hex_string, + )] + pub starts_with: Option, + + /// Desired hex string suffix for the address + #[arg(long, value_name = "HEX_STRING", conflicts_with = "regex", value_parser = validate_hex_string)] + pub ends_with: Option, + + /// Desired regex pattern to match the entire address (case-insensitive) + #[arg(long, value_name = "PATTERN", conflicts_with = "starts_with", value_parser = validate_regex_pattern)] + pub regex: Option, + + /// Timeout in seconds for address generation + #[arg(long, value_name = "SECONDS")] + pub timeout: Option, + + /// Return mnemonic with address (default false) + #[arg(long)] + pub mnemonic: bool, + + /// Path to save the generated vanity address to. + #[arg(long, value_hint = clap::ValueHint::FilePath, value_name = "PATH")] + pub save_path: Option, +} + +impl Arg { + pub fn validate(&self) -> anyhow::Result<()> { + let total_length = self.starts_with.as_ref().map_or(0, |s| s.len()) + + self.ends_with.as_ref().map_or(0, |s| s.len()); + if total_length > 64 { + return Err(anyhow::anyhow!( + "Combined pattern length exceeds 64 characters" + )); + } + Ok(()) + } +} + +pub fn handler(args: Arg) -> anyhow::Result { + args.validate()?; + + let Arg { + starts_with, + ends_with, + regex, + mnemonic, + timeout, + save_path, + } = args; + + let matcher = if let Some(pattern) = regex { + Either::Left(RegexMatcher::new(&pattern)?) + } else { + let starts_with = starts_with.as_deref().unwrap_or(""); + let ends_with = ends_with.as_deref().unwrap_or(""); + Either::Right(HexMatcher::new(starts_with, ends_with)?) + }; + + println!("Starting to generate vanity address..."); + let start_time = Instant::now(); + + let result = find_vanity_address_with_timeout(matcher, mnemonic, timeout)?; + let (address, secret_key, mnemonic) = result; + + let duration = start_time.elapsed(); + println!( + "Successfully found vanity address in {:.3} seconds.\n", + duration.as_secs_f64() + ); + + let checksum_address = checksum_encode(&address.to_string())?; + let result = if let Some(mnemonic) = mnemonic { + json!({ + "Address": checksum_address, + "PrivateKey": hex::encode(secret_key.as_ref()), + "Mnemonic": mnemonic, + }) + } else { + json!({ + "Address": checksum_address, + "PrivateKey": hex::encode(secret_key.as_ref()), + }) + }; + + if let Some(path) = save_path { + std::fs::write(path, serde_json::to_string_pretty(&result)?)?; + } + + Ok(result) +} + +pub trait VanityMatcher: Send + Sync + 'static { + fn is_match(&self, addr: &Address) -> bool; +} + +pub struct HexMatcher { + prefix: String, + suffix: String, +} + +impl HexMatcher { + pub fn new(prefix: &str, suffix: &str) -> anyhow::Result { + Ok(Self { + prefix: prefix.to_lowercase(), + suffix: suffix.to_lowercase(), + }) + } +} + +impl VanityMatcher for HexMatcher { + fn is_match(&self, addr: &Address) -> bool { + let hex_addr = hex::encode(addr.as_ref()).to_lowercase(); + hex_addr.starts_with(&self.prefix) && hex_addr.ends_with(&self.suffix) + } +} + +pub struct RegexMatcher { + re: Regex, +} + +impl RegexMatcher { + pub fn new(pattern: &str) -> anyhow::Result { + let re = Regex::new(&format!("(?i){}", pattern))?; + Ok(Self { re }) + } +} + +impl VanityMatcher for RegexMatcher { + fn is_match(&self, addr: &Address) -> bool { + let addr = hex::encode(addr.as_ref()); + self.re.is_match(&addr) + } +} + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +pub fn find_vanity_address_with_timeout( + matcher: Either, + use_mnemonic: bool, + timeout_secs: Option, +) -> anyhow::Result<(Address, SecretKey, Option)> { + let should_stop = Arc::new(AtomicBool::new(false)); + let should_stop_clone = should_stop.clone(); + + let generate_wallet = move || { + let breakpoint = if use_mnemonic { 1_000 } else { 100_000 }; + let start = Instant::now(); + let attempts = std::sync::atomic::AtomicUsize::new(0); + + wallet_generator(use_mnemonic) + .find_any(|result| { + // Check if we should stop due to timeout + if should_stop.load(Ordering::Relaxed) { + return true; // This will cause find_any to return the current result + } + + let current = attempts.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + if current != 0 && current % breakpoint == 0 { + let elapsed = start.elapsed().as_secs_f64(); + let rate = current as f64 / elapsed; + println!( + "└─ tried {} addresses ({:.2} addresses/sec)...", + current, rate + ); + } + + if let Ok((addr, _, _)) = result { + match &matcher { + Either::Left(regex_matcher) => regex_matcher.is_match(addr), + Either::Right(hex_matcher) => hex_matcher.is_match(addr), + } + } else { + false + } + }) + .ok_or_else(|| anyhow::anyhow!("No matching address found"))? + }; + + let Some(secs) = timeout_secs else { + return generate_wallet(); + }; + + Runtime::new()?.block_on(async { + let generation_task = tokio::task::spawn_blocking(generate_wallet); + + tokio::select! { + result = generation_task => { + match result { + Ok(wallet_result) => wallet_result, + Err(_) => Err(anyhow::anyhow!("No matching address found")), + } + } + _ = tokio::time::sleep(Duration::from_secs(secs)) => { + // Signal all threads to stop + should_stop_clone.store(true, Ordering::Relaxed); + // Wait a short time for threads to notice the stop signal + tokio::time::sleep(Duration::from_millis(100)).await; + Err(anyhow::anyhow!("Vanity address generation timed out after {} seconds", secs)) + } + } + }) +} + +#[inline] +fn wallet_generator( + use_mnemonic: bool, +) -> impl ParallelIterator)>> { + iter::repeat(()).map(move |()| generate_wallet(use_mnemonic)) +} + +fn generate_wallet(use_mnemonic: bool) -> anyhow::Result<(Address, SecretKey, Option)> { + let mut rng = rand::thread_rng(); + + let (private_key, mnemonic) = if use_mnemonic { + let mnemonic = generate_mnemonic_phrase(&mut rng, 24)?; + let account_ix = 0; + let derivation_path = format!("{DEFAULT_DERIVATION_PATH_PREFIX}/{account_ix}'/0/0"); + let private_key = + SecretKey::new_from_mnemonic_phrase_with_path(&mnemonic, &derivation_path)?; + (private_key, Some(mnemonic)) + } else { + (SecretKey::random(&mut rng), None) + }; + + let public = PublicKey::from(&private_key); + let hashed = public.hash(); + let address = Bech32Address::new(FUEL_BECH32_HRP, hashed); + + Ok((address.into(), private_key, mnemonic)) +} + +#[cfg(test)] +mod tests { + use super::*; + use clap::Parser; + + // Helper function to parse args and get validation errors + fn parse_args(args: Vec<&str>) -> Result { + let args = + Arg::try_parse_from(std::iter::once("test").chain(args)).map_err(|e| e.to_string())?; + args.validate().map_err(|e| e.to_string())?; + Ok(args) + } + + #[test] + fn test_invalid_hex_characters() { + let result = parse_args(vec!["--starts-with", "xyz"]); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), "error: invalid value 'xyz' for '--starts-with ': Pattern must contain only hex characters (0-9, a-f)\n\nFor more information, try '--help'.\n"); + } + + #[test] + fn test_pattern_too_long() { + let result = parse_args(vec![ + "--starts-with", + &"a".repeat(32), + "--ends-with", + &"b".repeat(33), + ]); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err(), + "Combined pattern length exceeds 64 characters" + ); + } + + #[test] + fn test_invalid_regex_syntax() { + let result = parse_args(vec!["--regex", "["]); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), "error: invalid value '[' for '--regex ': Invalid regex pattern: regex parse error:\n (?i)[\n ^\nerror: unclosed character class\n\nFor more information, try '--help'.\n"); + } + + #[test] + fn test_regex_too_long() { + let result = parse_args(vec!["--regex", &"a".repeat(129)]); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), "error: invalid value 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' for '--regex ': Regex pattern too long: max 128 characters\n\nFor more information, try '--help'.\n"); + } + + #[test] + fn test_conflicting_args() { + let result = parse_args(vec!["--starts-with", "aa", "--regex", "^aa"]); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), "error: the argument '--starts-with ' cannot be used with '--regex '\n\nUsage: test --starts-with \n\nFor more information, try '--help'.\n"); + } + + #[test] + fn test_timeout_respected() { + // This pattern should take a long time to generate + let args = parse_args(vec!["--starts-with", "fffffffffffff", "--timeout", "1"]).unwrap(); + + let result = handler(args); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + "Vanity address generation timed out after 1 seconds" + ); + } + + // Test actual functionality with minimal patterns + #[test] + fn test_valid_short_prefix() { + let args = parse_args(vec!["--starts-with", "a"]).unwrap(); + let result = handler(args).unwrap(); + let address = result["Address"].as_str().unwrap(); + assert!( + address.to_lowercase().starts_with("0xa"), + "Address should start with 'a'" + ); + } + + #[test] + fn test_valid_short_suffix() { + let args = parse_args(vec!["--ends-with", "a"]).unwrap(); + let result = handler(args).unwrap(); + let address = result["Address"].as_str().unwrap(); + assert!( + address.to_lowercase().ends_with('a'), + "Address should end with 'a'" + ); + } + + #[test] + fn test_both_prefix_and_suffix() { + let args = parse_args(vec!["--starts-with", "a", "--ends-with", "b"]).unwrap(); + let result = handler(args).unwrap(); + let address = result["Address"].as_str().unwrap().to_lowercase(); + assert!(address.starts_with("0xa"), "Address should start with 'a'"); + assert!(address.ends_with('b'), "Address should end with 'b'"); + } + + #[test] + fn test_simple_regex() { + let args = parse_args(vec!["--regex", "^a.*b$"]).unwrap(); + let result = handler(args).unwrap(); + let address = result["Address"].as_str().unwrap().to_lowercase(); + assert!(address.starts_with("0xa"), "Address should start with 'a'"); + assert!(address.ends_with('b'), "Address should end with 'b'"); + } + + #[test] + fn test_simple_regex_uppercase() { + let args = parse_args(vec!["--regex", "^A.*B$"]).unwrap(); + let result = handler(args).unwrap(); + let address = result["Address"].as_str().unwrap().to_lowercase(); + assert!(address.starts_with("0xa"), "Address should start with 'a'"); + assert!(address.ends_with('b'), "Address should end with 'b'"); + } + + #[test] + fn test_mnemonic_generation() { + let args = parse_args(vec!["--starts-with", "a", "--mnemonic"]).unwrap(); + let result = handler(args).unwrap(); + + assert!(result["Mnemonic"].is_string(), "Mnemonic should be present"); + assert_eq!( + result["Mnemonic"] + .as_str() + .unwrap() + .split_whitespace() + .count(), + 24, + "Mnemonic should have 24 words" + ); + + let address = result["Address"].as_str().unwrap(); + assert!( + address.to_lowercase().starts_with("0xa"), + "Address should start with 'a'" + ); + } + + #[test] + fn test_save_path() { + let tmp = tempfile::NamedTempFile::new().unwrap(); + let args = parse_args(vec![ + "--starts-with", + "a", + "--save-path", + tmp.path().to_str().unwrap(), + ]) + .unwrap(); + + handler(args).unwrap(); + + assert!(tmp.path().exists(), "File should exist"); + let content = std::fs::read_to_string(tmp.path()).unwrap(); + let saved_result: serde_json::Value = serde_json::from_str(&content).unwrap(); + assert!( + saved_result["Address"].is_string(), + "Saved result should contain an Address" + ); + assert!( + saved_result["PrivateKey"].is_string(), + "Saved result should contain a PrivateKey" + ); + } +} diff --git a/forc-plugins/forc-crypto/src/lib.rs b/forc-plugins/forc-crypto/src/lib.rs new file mode 100644 index 00000000000..7c89d848120 --- /dev/null +++ b/forc-plugins/forc-crypto/src/lib.rs @@ -0,0 +1,37 @@ +pub mod address; +pub mod args; +pub mod keccak256; +pub mod keys; +pub mod sha256; + +pub(crate) fn help() -> &'static str { + Box::leak( + format!( + "EXAMPLES:\n{}{}{}{}{}{}", + args::examples(), + address::examples(), + keys::new_key::examples(), + keys::parse_secret::examples(), + keys::get_public_key::examples(), + keys::vanity::examples(), + ) + .into_boxed_str(), + ) +} + +/// Forc plugin for hashing arbitrary data +#[derive(Debug, clap::Parser)] +#[clap( + name = "forc-crypto", + after_help = help(), + version +)] +pub enum Command { + Keccak256(args::HashArgs), + Sha256(args::HashArgs), + Address(address::Args), + GetPublicKey(keys::get_public_key::Arg), + NewKey(keys::new_key::Arg), + ParseSecret(keys::parse_secret::Arg), + Vanity(keys::vanity::Arg), +} diff --git a/forc-plugins/forc-crypto/src/main.rs b/forc-plugins/forc-crypto/src/main.rs index fba619b2b59..575b3e9d1ec 100644 --- a/forc-plugins/forc-crypto/src/main.rs +++ b/forc-plugins/forc-crypto/src/main.rs @@ -1,51 +1,15 @@ //! A `forc` plugin for converting a given string or path to their hash. use anyhow::Result; -use atty::Stream; use clap::Parser; +use forc_crypto::{address, keccak256, keys, sha256, Command}; use forc_tracing::{init_tracing_subscriber, println_error}; use std::{ default::Default, - io::{stdin, stdout, Read, Write}, + io::{stdin, stdout, IsTerminal, Read, Write}, }; use termion::screen::IntoAlternateScreen; -mod address; -mod args; -mod keccak256; -mod keys; -mod sha256; - -fn help() -> &'static str { - Box::leak( - format!( - "EXAMPLES:\n{}{}{}{}{}", - args::examples(), - address::examples(), - keys::new_key::examples(), - keys::parse_secret::examples(), - keys::get_public_key::examples(), - ) - .into_boxed_str(), - ) -} - -/// Forc plugin for hashing arbitrary data -#[derive(Debug, Parser)] -#[clap( - name = "forc-crypto", - after_help = help(), - version -)] -pub enum Command { - Keccak256(args::HashArgs), - Sha256(args::HashArgs), - Address(address::Args), - GetPublicKey(keys::get_public_key::Arg), - NewKey(keys::new_key::Arg), - ParseSecret(keys::parse_secret::Arg), -} - fn main() { init_tracing_subscriber(Default::default()); if let Err(err) = run() { @@ -59,6 +23,7 @@ fn run() -> Result<()> { let content = match app { Command::Keccak256(arg) => keccak256::hash(arg)?, Command::GetPublicKey(arg) => keys::get_public_key::handler(arg)?, + Command::Vanity(arg) => keys::vanity::handler(arg)?, Command::Sha256(arg) => sha256::hash(arg)?, Command::Address(arg) => address::dump_address(arg.address)?, Command::NewKey(arg) => keys::new_key::handler(arg)?, @@ -83,11 +48,11 @@ where } } -pub(crate) fn display_output(message: T) -> anyhow::Result<()> +pub fn display_output(message: T) -> anyhow::Result<()> where T: serde::Serialize, { - if atty::is(Stream::Stdout) { + if stdout().is_terminal() { let text = serde_yaml::to_string(&message).expect("valid string"); if has_sensible_info(&message) { let mut screen = stdout().into_alternate_screen()?; diff --git a/forc-plugins/forc-debug/Cargo.toml b/forc-plugins/forc-debug/Cargo.toml index 6246a1f279d..84c3d05797d 100644 --- a/forc-plugins/forc-debug/Cargo.toml +++ b/forc-plugins/forc-debug/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-debug" -version = "0.63.5" +version.workspace = true description = "Supports debugging Sway code via CLI and DAP server." authors.workspace = true edition.workspace = true @@ -9,26 +9,27 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1.0" # Used by the examples and for conversion only -clap = { version = "4.5.4", features = ["derive", "env"] } -dap = "0.4.1-alpha1" -forc-pkg = { version = "0.63.5", path = "../../forc-pkg" } -forc-test = { version = "0.63.5", path = "../../forc-test" } -forc-tracing = { version = "0.63.5", path = "../../forc-tracing" } -fuel-core-client = { workspace = true } +anyhow.workspace = true +clap = { workspace = true, features = ["derive", "env"] } +dap.workspace = true +forc-pkg.workspace = true +forc-test.workspace = true +forc-tracing.workspace = true +fuel-core-client.workspace = true fuel-types = { workspace = true, features = ["serde"] } fuel-vm = { workspace = true, features = ["serde"] } -rayon = "1.7.0" -serde = "1.0" -serde_json = "1.0" -shellfish = { version = "0.6.0", features = ["rustyline", "async", "tokio"] } -sway-core = { version = "0.63.5", path = "../../sway-core" } -sway-types = { version = "0.63.5", path = "../../sway-types" } -thiserror = "1.0" -tokio = { version = "1.8", features = [ - "net", +rayon.workspace = true +serde.workspace = true +serde_json.workspace = true +shellfish = { workspace = true, features = ["async", "rustyline", "tokio"] } +sway-core.workspace = true +sway-features.workspace = true +sway-types.workspace = true +thiserror.workspace = true +tokio = { workspace = true, features = [ "io-util", "macros", + "net", "rt-multi-thread", ] } diff --git a/forc-plugins/forc-debug/src/server/handlers/handle_launch.rs b/forc-plugins/forc-debug/src/server/handlers/handle_launch.rs index fd281261347..3ae3c2f3539 100644 --- a/forc-plugins/forc-debug/src/server/handlers/handle_launch.rs +++ b/forc-plugins/forc-debug/src/server/handlers/handle_launch.rs @@ -54,10 +54,6 @@ impl DapServer { } } - let experimental = sway_core::ExperimentalFlags { - new_encoding: false, - }; - // 1. Build the packages let manifest_file = forc_pkg::manifest::ManifestFile::from_dir(&self.state.program_path) .map_err(|err| AdapterError::BuildFailed { @@ -110,7 +106,8 @@ impl DapServer { ..Default::default() }, &outputs, - experimental, + &[], + &[], ) .map_err(|err| AdapterError::BuildFailed { reason: format!("build packages: {:?}", err), diff --git a/forc-plugins/forc-doc/Cargo.toml b/forc-plugins/forc-doc/Cargo.toml index 4c92f0e495b..ebfd2bc7197 100644 --- a/forc-plugins/forc-doc/Cargo.toml +++ b/forc-plugins/forc-doc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-doc" -version = "0.63.5" +version.workspace = true description = "Build the documentation for the local package and all dependencies. The output is placed in `out/doc` in the same format as the project." authors.workspace = true edition.workspace = true @@ -9,23 +9,24 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1.0.65" -clap = { version = "4.5.4", features = ["derive"] } -comrak = "0.16" -forc-pkg = { version = "0.63.5", path = "../../forc-pkg" } -forc-tracing = { version = "0.63.5", path = "../../forc-tracing" } -forc-util = { version = "0.63.5", path = "../../forc-util" } -horrorshow = "0.8.4" -include_dir = "0.7.3" -minifier = "0.3.0" -opener = "0.5.0" -serde = "1.0" -serde_json = "1.0" -sway-ast = { version = "0.63.5", path = "../../sway-ast" } -sway-core = { version = "0.63.5", path = "../../sway-core" } -sway-lsp = { version = "0.63.5", path = "../../sway-lsp" } -sway-types = { version = "0.63.5", path = "../../sway-types" } -swayfmt = { version = "0.63.5", path = "../../swayfmt" } +anyhow.workspace = true +clap = { workspace = true, features = ["derive"] } +comrak.workspace = true +forc-pkg.workspace = true +forc-tracing.workspace = true +forc-util.workspace = true +horrorshow.workspace = true +include_dir.workspace = true +minifier.workspace = true +opener.workspace = true +serde.workspace = true +serde_json.workspace = true +sway-ast.workspace = true +sway-core.workspace = true +sway-features.workspace = true +sway-lsp.workspace = true +sway-types.workspace = true +swayfmt.workspace = true [dev-dependencies] dir_indexer = "0.0.2" diff --git a/forc-plugins/forc-doc/src/cli.rs b/forc-plugins/forc-doc/src/cli.rs index 8ba9906203f..309bfb880d6 100644 --- a/forc-plugins/forc-doc/src/cli.rs +++ b/forc-plugins/forc-doc/src/cli.rs @@ -53,7 +53,6 @@ pub struct Command { #[cfg(test)] pub(crate) doc_path: Option, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } diff --git a/forc-plugins/forc-doc/src/lib.rs b/forc-plugins/forc-doc/src/lib.rs index d629b606563..4043cfde1f2 100644 --- a/forc-plugins/forc-doc/src/lib.rs +++ b/forc-plugins/forc-doc/src/lib.rs @@ -55,7 +55,6 @@ pub struct ProgramInfo<'a> { pub fn compile_html( build_instructions: &Command, get_doc_dir: &dyn Fn(&Command) -> String, - experimental: sway_core::ExperimentalFlags, ) -> Result<(PathBuf, Box)> { // get manifest directory let dir = if let Some(ref path) = build_instructions.manifest_path { @@ -108,7 +107,8 @@ pub fn compile_html( tests_enabled, &engines, None, - experimental, + &build_instructions.experimental.experimental, + &build_instructions.experimental.no_experimental, )?; let raw_docs = if build_instructions.no_deps { diff --git a/forc-plugins/forc-doc/src/main.rs b/forc-plugins/forc-doc/src/main.rs index ab990727d7f..5b3082fd1a7 100644 --- a/forc-plugins/forc-doc/src/main.rs +++ b/forc-plugins/forc-doc/src/main.rs @@ -12,13 +12,7 @@ use std::{ pub fn main() -> Result<()> { let build_instructions = Command::parse(); - let (doc_path, pkg_manifest) = compile_html( - &build_instructions, - &get_doc_dir, - sway_core::ExperimentalFlags { - new_encoding: !build_instructions.no_encoding_v1, - }, - )?; + let (doc_path, pkg_manifest) = compile_html(&build_instructions, &get_doc_dir)?; // CSS, icons and logos static ASSETS_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/static.files"); diff --git a/forc-plugins/forc-doc/src/render/search.rs b/forc-plugins/forc-doc/src/render/search.rs index 9213c17210d..584256189e6 100644 --- a/forc-plugins/forc-doc/src/render/search.rs +++ b/forc-plugins/forc-doc/src/render/search.rs @@ -47,7 +47,9 @@ pub(crate) fn generate_searchbar(module_info: &ModuleInfo) -> Box if (results.length > 0) {{ const resultList = results.map(item => {{ const formattedName = `${{item.name}}`; - const name = [...item.module_info, formattedName].join("::"); + const name = item.type_name === "module" + ? [...item.module_info.slice(0, -1), formattedName].join("::") + : [...item.module_info, formattedName].join("::"); const path = ["{}", ...item.module_info, item.html_filename].join("/"); const left = `${{name}}`; const right = `

${{item.preview}}

`; diff --git a/forc-plugins/forc-doc/src/search.rs b/forc-plugins/forc-doc/src/search.rs index 2506292a21e..2073fc750a6 100644 --- a/forc-plugins/forc-doc/src/search.rs +++ b/forc-plugins/forc-doc/src/search.rs @@ -1,13 +1,17 @@ -use crate::doc::{Document, Documentation}; +use crate::doc::{module::ModuleInfo, Document, Documentation}; use anyhow::Result; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, fs, path::Path}; +use std::{ + collections::{BTreeMap, HashMap}, + fs, + path::Path, +}; const JS_SEARCH_FILE_NAME: &str = "search.js"; /// Creates the search index javascript file for the search bar. pub fn write_search_index(doc_path: &Path, docs: &Documentation) -> Result<()> { - let json_data = docs.to_json_value()?; + let json_data = docs.to_search_index_json_value()?; let module_export = "\"object\"==typeof exports&&\"undefined\"!=typeof module&&(module.exports=SEARCH_INDEX);"; let js_data = format!("var SEARCH_INDEX={json_data};\n{module_export}"); @@ -17,14 +21,28 @@ pub fn write_search_index(doc_path: &Path, docs: &Documentation) -> Result<()> { impl Documentation { /// Generates a mapping of program name to a vector of documentable items within the program /// and returns the map as a `serde_json::Value`. - fn to_json_value(&self) -> Result { + fn to_search_index_json_value(&self) -> Result { let mut map = HashMap::with_capacity(self.len()); + let mut modules = BTreeMap::new(); for doc in self.iter() { let project_name = doc.module_info.project_name().to_string(); map.entry(project_name) .or_insert_with(Vec::new) .push(JsonSearchItem::from(doc)); + modules.insert( + doc.module_info.module_prefixes.join("::"), + doc.module_info.clone(), + ); } + + // Insert the modules themselves into the map. + for (_, module) in modules.iter() { + let project_name = module.project_name().to_string(); + map.entry(project_name) + .or_insert_with(Vec::new) + .push(JsonSearchItem::from(module)); + } + serde_json::to_value(map) } } @@ -57,3 +75,24 @@ impl<'a> From<&'a Document> for JsonSearchItem { } } } + +impl<'a> From<&'a ModuleInfo> for JsonSearchItem { + fn from(value: &'a ModuleInfo) -> Self { + Self { + name: value + .module_prefixes + .last() + .unwrap_or(&String::new()) + .to_string(), + html_filename: "index.html".into(), + module_info: value.module_prefixes.clone(), + preview: value + .preview_opt() + .unwrap_or_default() + .replace("
", "") + .replace("

", "") + .replace("

", ""), + type_name: "module".into(), + } + } +} diff --git a/forc-plugins/forc-doc/src/static.files/swaydoc.css b/forc-plugins/forc-doc/src/static.files/swaydoc.css index 9ed50926ad1..193f3e77586 100644 --- a/forc-plugins/forc-doc/src/static.files/swaydoc.css +++ b/forc-plugins/forc-doc/src/static.files/swaydoc.css @@ -952,6 +952,7 @@ table, .search-results .type.trait { color: #B78CF2; } +.search-results .type.module, .search-results .type.constant { color: #D2991D; } diff --git a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs index 4699c55a6a9..602b66f49d7 100644 --- a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs +++ b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs @@ -10,7 +10,6 @@ use std::{ collections::HashSet, path::{Path, PathBuf}, }; -use sway_core::ExperimentalFlags; /// The path to the generated HTML of the type the traits are implemented on. const IMPL_FOR: &str = "bar/struct.Bar.html"; @@ -26,148 +25,143 @@ fn test_impl_traits_default() { doc_path: Some(doc_dir_name.into()), ..Default::default() }; - let (doc_path, _) = compile_html( - &command, - &get_doc_dir, - ExperimentalFlags { - new_encoding: false, - }, - ) - .unwrap(); + let (doc_path, _) = compile_html(&command, &get_doc_dir).unwrap(); assert_index_html( &doc_path, project_name, &expect![[r##" - Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

+ Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn abi_encode(self, buffer: Buffer) -> Buffer

fn abi_decode(refmut _buffer: BufferReader) -> Self

fn foo()

something more about foo();

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"##]], ); assert_search_js( &doc_path, &expect![[r#" - var SEARCH_INDEX={"core":[{"html_filename":"trait.AsRawSlice.html","module_info":["core","raw_slice"],"name":"AsRawSlice","preview":"Trait to return a type as a raw_slice.\n","type_name":"trait"},{"html_filename":"fn.from_str_array.html","module_info":["core","str"],"name":"from_str_array","preview":"","type_name":"function"},{"html_filename":"trait.Add.html","module_info":["core","ops"],"name":"Add","preview":"Trait for the addition of two values.\n","type_name":"trait"},{"html_filename":"trait.Subtract.html","module_info":["core","ops"],"name":"Subtract","preview":"Trait for the subtraction of two values.\n","type_name":"trait"},{"html_filename":"trait.Multiply.html","module_info":["core","ops"],"name":"Multiply","preview":"Trait for the multiplication of two values.\n","type_name":"trait"},{"html_filename":"trait.Divide.html","module_info":["core","ops"],"name":"Divide","preview":"Trait for the division of two values.\n","type_name":"trait"},{"html_filename":"trait.Mod.html","module_info":["core","ops"],"name":"Mod","preview":"Trait for the modulo of two values.\n","type_name":"trait"},{"html_filename":"trait.Not.html","module_info":["core","ops"],"name":"Not","preview":"Trait to invert a type.\n","type_name":"trait"},{"html_filename":"trait.Eq.html","module_info":["core","ops"],"name":"Eq","preview":"Trait to evaluate if two types are equal.\n","type_name":"trait"},{"html_filename":"trait.Ord.html","module_info":["core","ops"],"name":"Ord","preview":"Trait to evaluate if one value is greater or less than another of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseAnd.html","module_info":["core","ops"],"name":"BitwiseAnd","preview":"Trait to bitwise AND two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseOr.html","module_info":["core","ops"],"name":"BitwiseOr","preview":"Trait to bitwise OR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseXor.html","module_info":["core","ops"],"name":"BitwiseXor","preview":"Trait to bitwise XOR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.Shift.html","module_info":["core","ops"],"name":"Shift","preview":"Trait to bit shift a value.\n","type_name":"trait"},{"html_filename":"fn.ok_str_eq.html","module_info":["core","ops"],"name":"ok_str_eq","preview":"","type_name":"function"},{"html_filename":"struct.StorageKey.html","module_info":["core","storage"],"name":"StorageKey","preview":"Describes a location in storage.\n","type_name":"struct"},{"html_filename":"struct.Buffer.html","module_info":["core","codec"],"name":"Buffer","preview":"","type_name":"struct"},{"html_filename":"struct.BufferReader.html","module_info":["core","codec"],"name":"BufferReader","preview":"","type_name":"struct"},{"html_filename":"trait.AbiDecode.html","module_info":["core","codec"],"name":"AbiDecode","preview":"","type_name":"trait"},{"html_filename":"trait.AbiEncode.html","module_info":["core","codec"],"name":"AbiEncode","preview":"","type_name":"trait"},{"html_filename":"fn.encode.html","module_info":["core","codec"],"name":"encode","preview":"","type_name":"function"},{"html_filename":"fn.abi_decode.html","module_info":["core","codec"],"name":"abi_decode","preview":"","type_name":"function"},{"html_filename":"fn.abi_decode_in_place.html","module_info":["core","codec"],"name":"abi_decode_in_place","preview":"","type_name":"function"},{"html_filename":"fn.contract_call.html","module_info":["core","codec"],"name":"contract_call","preview":"","type_name":"function"},{"html_filename":"fn.decode_script_data.html","module_info":["core","codec"],"name":"decode_script_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_predicate_data.html","module_info":["core","codec"],"name":"decode_predicate_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_predicate_data_by_index.html","module_info":["core","codec"],"name":"decode_predicate_data_by_index","preview":"","type_name":"function"},{"html_filename":"fn.decode_first_param.html","module_info":["core","codec"],"name":"decode_first_param","preview":"","type_name":"function"},{"html_filename":"fn.decode_second_param.html","module_info":["core","codec"],"name":"decode_second_param","preview":"","type_name":"function"},{"html_filename":"primitive.u256.html","module_info":["core"],"name":"u256","preview":"256-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u64.html","module_info":["core"],"name":"u64","preview":"64-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u32.html","module_info":["core"],"name":"u32","preview":"32-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u16.html","module_info":["core"],"name":"u16","preview":"16-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u8.html","module_info":["core"],"name":"u8","preview":"8-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.b256.html","module_info":["core"],"name":"b256","preview":"256 bits (32 bytes), i.e. a hash","type_name":"primitive"},{"html_filename":"primitive.str.html","module_info":["core"],"name":"str","preview":"string slice","type_name":"primitive"},{"html_filename":"primitive.bool.html","module_info":["core"],"name":"bool","preview":"Boolean true or false","type_name":"primitive"},{"html_filename":"primitive.str[0].html","module_info":["core"],"name":"str[0]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[1].html","module_info":["core"],"name":"str[1]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[2].html","module_info":["core"],"name":"str[2]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[3].html","module_info":["core"],"name":"str[3]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[4].html","module_info":["core"],"name":"str[4]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[5].html","module_info":["core"],"name":"str[5]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[6].html","module_info":["core"],"name":"str[6]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[7].html","module_info":["core"],"name":"str[7]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[8].html","module_info":["core"],"name":"str[8]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[9].html","module_info":["core"],"name":"str[9]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[10].html","module_info":["core"],"name":"str[10]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[11].html","module_info":["core"],"name":"str[11]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[12].html","module_info":["core"],"name":"str[12]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[13].html","module_info":["core"],"name":"str[13]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[14].html","module_info":["core"],"name":"str[14]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[15].html","module_info":["core"],"name":"str[15]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[16].html","module_info":["core"],"name":"str[16]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[17].html","module_info":["core"],"name":"str[17]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[18].html","module_info":["core"],"name":"str[18]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[19].html","module_info":["core"],"name":"str[19]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[20].html","module_info":["core"],"name":"str[20]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[21].html","module_info":["core"],"name":"str[21]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[22].html","module_info":["core"],"name":"str[22]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[23].html","module_info":["core"],"name":"str[23]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[24].html","module_info":["core"],"name":"str[24]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[25].html","module_info":["core"],"name":"str[25]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[26].html","module_info":["core"],"name":"str[26]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[27].html","module_info":["core"],"name":"str[27]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[28].html","module_info":["core"],"name":"str[28]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[29].html","module_info":["core"],"name":"str[29]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[30].html","module_info":["core"],"name":"str[30]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[31].html","module_info":["core"],"name":"str[31]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[32].html","module_info":["core"],"name":"str[32]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[33].html","module_info":["core"],"name":"str[33]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[34].html","module_info":["core"],"name":"str[34]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[35].html","module_info":["core"],"name":"str[35]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[36].html","module_info":["core"],"name":"str[36]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[37].html","module_info":["core"],"name":"str[37]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[38].html","module_info":["core"],"name":"str[38]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[39].html","module_info":["core"],"name":"str[39]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[40].html","module_info":["core"],"name":"str[40]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[41].html","module_info":["core"],"name":"str[41]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[42].html","module_info":["core"],"name":"str[42]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[43].html","module_info":["core"],"name":"str[43]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[44].html","module_info":["core"],"name":"str[44]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[45].html","module_info":["core"],"name":"str[45]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[46].html","module_info":["core"],"name":"str[46]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[47].html","module_info":["core"],"name":"str[47]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[48].html","module_info":["core"],"name":"str[48]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[49].html","module_info":["core"],"name":"str[49]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[50].html","module_info":["core"],"name":"str[50]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[51].html","module_info":["core"],"name":"str[51]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[52].html","module_info":["core"],"name":"str[52]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[53].html","module_info":["core"],"name":"str[53]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[54].html","module_info":["core"],"name":"str[54]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[55].html","module_info":["core"],"name":"str[55]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[56].html","module_info":["core"],"name":"str[56]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[57].html","module_info":["core"],"name":"str[57]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[58].html","module_info":["core"],"name":"str[58]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[59].html","module_info":["core"],"name":"str[59]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[60].html","module_info":["core"],"name":"str[60]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[61].html","module_info":["core"],"name":"str[61]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[62].html","module_info":["core"],"name":"str[62]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[63].html","module_info":["core"],"name":"str[63]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[64].html","module_info":["core"],"name":"str[64]","preview":"fixed-length string","type_name":"primitive"}],"impl_traits":[{"html_filename":"trait.Foo.html","module_info":["impl_traits","foo"],"name":"Foo","preview":"","type_name":"trait"},{"html_filename":"trait.Baz.html","module_info":["impl_traits","foo"],"name":"Baz","preview":"","type_name":"trait"},{"html_filename":"struct.Bar.html","module_info":["impl_traits","bar"],"name":"Bar","preview":"","type_name":"struct"}]}; + var SEARCH_INDEX={"core":[{"html_filename":"trait.AsRawSlice.html","module_info":["core","raw_slice"],"name":"AsRawSlice","preview":"Trait to return a type as a raw_slice.\n","type_name":"trait"},{"html_filename":"fn.from_str_array.html","module_info":["core","str"],"name":"from_str_array","preview":"","type_name":"function"},{"html_filename":"trait.Add.html","module_info":["core","ops"],"name":"Add","preview":"Trait for the addition of two values.\n","type_name":"trait"},{"html_filename":"trait.Subtract.html","module_info":["core","ops"],"name":"Subtract","preview":"Trait for the subtraction of two values.\n","type_name":"trait"},{"html_filename":"trait.Multiply.html","module_info":["core","ops"],"name":"Multiply","preview":"Trait for the multiplication of two values.\n","type_name":"trait"},{"html_filename":"trait.Divide.html","module_info":["core","ops"],"name":"Divide","preview":"Trait for the division of two values.\n","type_name":"trait"},{"html_filename":"trait.Mod.html","module_info":["core","ops"],"name":"Mod","preview":"Trait for the modulo of two values.\n","type_name":"trait"},{"html_filename":"trait.Not.html","module_info":["core","ops"],"name":"Not","preview":"Trait to invert a type.\n","type_name":"trait"},{"html_filename":"trait.Eq.html","module_info":["core","ops"],"name":"Eq","preview":"Trait to evaluate if two types are equal.\n","type_name":"trait"},{"html_filename":"trait.Ord.html","module_info":["core","ops"],"name":"Ord","preview":"Trait to evaluate if one value is greater or less than another of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseAnd.html","module_info":["core","ops"],"name":"BitwiseAnd","preview":"Trait to bitwise AND two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseOr.html","module_info":["core","ops"],"name":"BitwiseOr","preview":"Trait to bitwise OR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseXor.html","module_info":["core","ops"],"name":"BitwiseXor","preview":"Trait to bitwise XOR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.OrdEq.html","module_info":["core","ops"],"name":"OrdEq","preview":"Trait to evaluate if one value is greater than or equal, or less than or equal to another of the same type.","type_name":"trait"},{"html_filename":"trait.Shift.html","module_info":["core","ops"],"name":"Shift","preview":"Trait to bit shift a value.\n","type_name":"trait"},{"html_filename":"trait.TotalOrd.html","module_info":["core","ops"],"name":"TotalOrd","preview":"Trait to compare values of the same type.\n","type_name":"trait"},{"html_filename":"fn.ok_str_eq.html","module_info":["core","ops"],"name":"ok_str_eq","preview":"","type_name":"function"},{"html_filename":"struct.StorageKey.html","module_info":["core","storage"],"name":"StorageKey","preview":"Describes a location in storage.\n","type_name":"struct"},{"html_filename":"struct.Buffer.html","module_info":["core","codec"],"name":"Buffer","preview":"","type_name":"struct"},{"html_filename":"struct.BufferReader.html","module_info":["core","codec"],"name":"BufferReader","preview":"","type_name":"struct"},{"html_filename":"trait.AbiDecode.html","module_info":["core","codec"],"name":"AbiDecode","preview":"","type_name":"trait"},{"html_filename":"trait.AbiEncode.html","module_info":["core","codec"],"name":"AbiEncode","preview":"","type_name":"trait"},{"html_filename":"fn.encode.html","module_info":["core","codec"],"name":"encode","preview":"","type_name":"function"},{"html_filename":"fn.abi_decode.html","module_info":["core","codec"],"name":"abi_decode","preview":"","type_name":"function"},{"html_filename":"fn.abi_decode_in_place.html","module_info":["core","codec"],"name":"abi_decode_in_place","preview":"","type_name":"function"},{"html_filename":"fn.contract_call.html","module_info":["core","codec"],"name":"contract_call","preview":"","type_name":"function"},{"html_filename":"fn.decode_script_data.html","module_info":["core","codec"],"name":"decode_script_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_predicate_data.html","module_info":["core","codec"],"name":"decode_predicate_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_predicate_data_by_index.html","module_info":["core","codec"],"name":"decode_predicate_data_by_index","preview":"","type_name":"function"},{"html_filename":"fn.decode_first_param.html","module_info":["core","codec"],"name":"decode_first_param","preview":"","type_name":"function"},{"html_filename":"fn.decode_second_param.html","module_info":["core","codec"],"name":"decode_second_param","preview":"","type_name":"function"},{"html_filename":"primitive.u256.html","module_info":["core"],"name":"u256","preview":"256-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u64.html","module_info":["core"],"name":"u64","preview":"64-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u32.html","module_info":["core"],"name":"u32","preview":"32-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u16.html","module_info":["core"],"name":"u16","preview":"16-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.u8.html","module_info":["core"],"name":"u8","preview":"8-bit unsigned integer","type_name":"primitive"},{"html_filename":"primitive.b256.html","module_info":["core"],"name":"b256","preview":"256 bits (32 bytes), i.e. a hash","type_name":"primitive"},{"html_filename":"primitive.str.html","module_info":["core"],"name":"str","preview":"string slice","type_name":"primitive"},{"html_filename":"primitive.bool.html","module_info":["core"],"name":"bool","preview":"Boolean true or false","type_name":"primitive"},{"html_filename":"primitive.str[0].html","module_info":["core"],"name":"str[0]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[1].html","module_info":["core"],"name":"str[1]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[2].html","module_info":["core"],"name":"str[2]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[3].html","module_info":["core"],"name":"str[3]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[4].html","module_info":["core"],"name":"str[4]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[5].html","module_info":["core"],"name":"str[5]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[6].html","module_info":["core"],"name":"str[6]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[7].html","module_info":["core"],"name":"str[7]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[8].html","module_info":["core"],"name":"str[8]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[9].html","module_info":["core"],"name":"str[9]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[10].html","module_info":["core"],"name":"str[10]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[11].html","module_info":["core"],"name":"str[11]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[12].html","module_info":["core"],"name":"str[12]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[13].html","module_info":["core"],"name":"str[13]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[14].html","module_info":["core"],"name":"str[14]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[15].html","module_info":["core"],"name":"str[15]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[16].html","module_info":["core"],"name":"str[16]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[17].html","module_info":["core"],"name":"str[17]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[18].html","module_info":["core"],"name":"str[18]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[19].html","module_info":["core"],"name":"str[19]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[20].html","module_info":["core"],"name":"str[20]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[21].html","module_info":["core"],"name":"str[21]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[22].html","module_info":["core"],"name":"str[22]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[23].html","module_info":["core"],"name":"str[23]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[24].html","module_info":["core"],"name":"str[24]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[25].html","module_info":["core"],"name":"str[25]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[26].html","module_info":["core"],"name":"str[26]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[27].html","module_info":["core"],"name":"str[27]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[28].html","module_info":["core"],"name":"str[28]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[29].html","module_info":["core"],"name":"str[29]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[30].html","module_info":["core"],"name":"str[30]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[31].html","module_info":["core"],"name":"str[31]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[32].html","module_info":["core"],"name":"str[32]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[33].html","module_info":["core"],"name":"str[33]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[34].html","module_info":["core"],"name":"str[34]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[35].html","module_info":["core"],"name":"str[35]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[36].html","module_info":["core"],"name":"str[36]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[37].html","module_info":["core"],"name":"str[37]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[38].html","module_info":["core"],"name":"str[38]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[39].html","module_info":["core"],"name":"str[39]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[40].html","module_info":["core"],"name":"str[40]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[41].html","module_info":["core"],"name":"str[41]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[42].html","module_info":["core"],"name":"str[42]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[43].html","module_info":["core"],"name":"str[43]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[44].html","module_info":["core"],"name":"str[44]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[45].html","module_info":["core"],"name":"str[45]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[46].html","module_info":["core"],"name":"str[46]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[47].html","module_info":["core"],"name":"str[47]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[48].html","module_info":["core"],"name":"str[48]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[49].html","module_info":["core"],"name":"str[49]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[50].html","module_info":["core"],"name":"str[50]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[51].html","module_info":["core"],"name":"str[51]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[52].html","module_info":["core"],"name":"str[52]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[53].html","module_info":["core"],"name":"str[53]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[54].html","module_info":["core"],"name":"str[54]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[55].html","module_info":["core"],"name":"str[55]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[56].html","module_info":["core"],"name":"str[56]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[57].html","module_info":["core"],"name":"str[57]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[58].html","module_info":["core"],"name":"str[58]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[59].html","module_info":["core"],"name":"str[59]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[60].html","module_info":["core"],"name":"str[60]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[61].html","module_info":["core"],"name":"str[61]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[62].html","module_info":["core"],"name":"str[62]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[63].html","module_info":["core"],"name":"str[63]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"primitive.str[64].html","module_info":["core"],"name":"str[64]","preview":"fixed-length string","type_name":"primitive"},{"html_filename":"index.html","module_info":["core"],"name":"core","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["core","codec"],"name":"codec","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["core","ops"],"name":"ops","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["core","raw_slice"],"name":"raw_slice","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["core","storage"],"name":"storage","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["core","str"],"name":"str","preview":"","type_name":"module"}],"impl_traits":[{"html_filename":"trait.Foo.html","module_info":["impl_traits","foo"],"name":"Foo","preview":"","type_name":"trait"},{"html_filename":"trait.Baz.html","module_info":["impl_traits","foo"],"name":"Baz","preview":"","type_name":"trait"},{"html_filename":"struct.Bar.html","module_info":["impl_traits","bar"],"name":"Bar","preview":"","type_name":"struct"},{"html_filename":"index.html","module_info":["impl_traits","bar"],"name":"bar","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["impl_traits","foo"],"name":"foo","preview":"","type_name":"module"}]}; "object"==typeof exports&&"undefined"!=typeof module&&(module.exports=SEARCH_INDEX);"#]], ); assert_file_tree( doc_dir_name, project_name, vec![ - "core/primitive.str[26].html", - "core/primitive.str[54].html", - "core/primitive.u256.html", - "core/primitive.str[2].html", - "core/primitive.u8.html", + "core/ops/trait.TotalOrd.html", + "core/ops/trait.Mod.html", + "impl_traits/bar/index.html", + "impl_traits/all.html", "core/primitive.str[17].html", - "core/primitive.str[49].html", + "core/primitive.str[51].html", + "core/codec/fn.abi_decode.html", + "core/codec/struct.Buffer.html", + "core/codec/trait.AbiDecode.html", + "core/ops/trait.Divide.html", + "core/codec/fn.abi_decode_in_place.html", "core/primitive.str[34].html", - "core/primitive.str[46].html", - "core/primitive.str[15].html", - "core/primitive.str[21].html", - "core/primitive.str.html", - "core/primitive.str[24].html", - "core/primitive.str[38].html", - "core/primitive.str[47].html", - "core/primitive.str[31].html", - "core/primitive.bool.html", - "core/primitive.str[14].html", - "core/primitive.str[48].html", - "core/primitive.str[1].html", - "core/primitive.str[42].html", - "core/primitive.str[6].html", - "core/primitive.b256.html", - "core/primitive.str[5].html", - "core/primitive.str[43].html", + "core/codec/fn.decode_first_param.html", + "core/primitive.str[20].html", "core/primitive.str[4].html", - "core/primitive.str[19].html", - "core/primitive.str[25].html", - "core/primitive.str[57].html", - "core/primitive.str[56].html", + "core/primitive.str[42].html", "core/primitive.str[10].html", - "core/primitive.str[44].html", + "core/ops/trait.Subtract.html", + "core/primitive.str[28].html", + "core/primitive.u8.html", + "core/primitive.u256.html", + "core/str/fn.from_str_array.html", + "core/primitive.str[62].html", + "core/primitive.str[64].html", + "core/codec/trait.AbiEncode.html", + "core/primitive.str[8].html", + "core/primitive.str[43].html", + "core/codec/fn.decode_predicate_data_by_index.html", "core/primitive.str[37].html", - "core/primitive.str[0].html", - "core/primitive.str[53].html", - "core/primitive.str[59].html", - "core/primitive.str[22].html", - "core/primitive.str[33].html", - "core/primitive.str[27].html", - "core/primitive.str[13].html", + "core/primitive.b256.html", + "core/ops/trait.Eq.html", + "core/storage/index.html", + "core/primitive.str[58].html", + "core/primitive.str[44].html", + "core/raw_slice/index.html", "core/primitive.u16.html", - "core/primitive.str[3].html", "core/primitive.str[35].html", - "core/primitive.str[7].html", - "core/primitive.str[51].html", - "core/primitive.str[40].html", - "core/primitive.str[28].html", - "core/primitive.str[41].html", - "core/primitive.str[58].html", - "core/primitive.str[45].html", - "core/primitive.str[62].html", - "core/primitive.str[63].html", "core/primitive.str[60].html", - "core/primitive.str[50].html", - "core/primitive.str[55].html", - "core/primitive.str[8].html", - "core/primitive.str[32].html", - "core/primitive.str[23].html", - "core/primitive.str[30].html", - "core/primitive.str[61].html", - "core/primitive.str[18].html", - "core/primitive.u32.html", - "core/primitive.str[64].html", + "core/primitive.str[59].html", "core/primitive.str[39].html", - "core/primitive.str[29].html", - "core/primitive.str[11].html", - "core/primitive.str[20].html", - "core/primitive.str[9].html", - "core/primitive.str[12].html", + "core/primitive.str[49].html", + "core/primitive.str[40].html", + "core/index.html", + "search.js", + "core/ops/trait.OrdEq.html", + "core/primitive.bool.html", + "impl_traits/foo/trait.Baz.html", + "core/primitive.str.html", + "core/primitive.str[13].html", "core/primitive.u64.html", "core/primitive.str[16].html", - "core/primitive.str[36].html", - "core/primitive.str[52].html", - "core/all.html", - "core/codec/fn.abi_decode.html", - "core/codec/fn.abi_decode_in_place.html", - "core/codec/fn.contract_call.html", - "core/codec/fn.decode_predicate_data.html", - "core/codec/fn.decode_predicate_data_by_index.html", - "core/codec/fn.decode_first_param.html", - "core/codec/fn.decode_script_data.html", - "core/codec/fn.decode_second_param.html", - "core/codec/fn.encode.html", "core/codec/index.html", - "core/codec/struct.Buffer.html", - "core/codec/struct.BufferReader.html", - "core/codec/trait.AbiDecode.html", - "core/codec/trait.AbiEncode.html", - "core/index.html", - "core/ops/fn.ok_str_eq.html", + "core/primitive.str[47].html", + "core/primitive.str[57].html", + "core/ops/trait.Not.html", + "core/primitive.str[50].html", + "core/raw_slice/trait.AsRawSlice.html", + "core/primitive.str[24].html", + "core/primitive.str[56].html", "core/ops/index.html", - "core/ops/trait.Add.html", + "core/primitive.str[3].html", + "core/primitive.str[36].html", + "core/primitive.str[27].html", + "core/codec/fn.decode_script_data.html", + "impl_traits/index.html", + "core/primitive.str[12].html", + "impl_traits/foo/trait.Foo.html", + "core/primitive.str[15].html", + "core/primitive.str[29].html", + "core/primitive.str[22].html", "core/ops/trait.BitwiseAnd.html", - "core/ops/trait.BitwiseOr.html", - "core/ops/trait.BitwiseXor.html", - "core/ops/trait.Divide.html", - "core/ops/trait.Eq.html", - "core/ops/trait.Mod.html", - "core/ops/trait.Multiply.html", - "core/ops/trait.Not.html", + "core/all.html", + "core/primitive.str[11].html", "core/ops/trait.Ord.html", - "core/ops/trait.Shift.html", - "core/ops/trait.Subtract.html", - "core/raw_slice/index.html", - "core/raw_slice/trait.AsRawSlice.html", - "core/storage/index.html", - "core/storage/struct.StorageKey.html", - "core/str/fn.from_str_array.html", "core/str/index.html", - "impl_traits/all.html", - "impl_traits/bar/index.html", - "impl_traits/bar/struct.Bar.html", + "core/primitive.str[31].html", "impl_traits/foo/index.html", - "impl_traits/foo/trait.Baz.html", - "impl_traits/foo/trait.Foo.html", - "impl_traits/index.html", - "search.js", + "core/primitive.str[55].html", + "core/primitive.str[38].html", + "core/codec/struct.BufferReader.html", + "core/primitive.str[54].html", + "core/primitive.str[53].html", + "core/primitive.str[19].html", + "core/storage/struct.StorageKey.html", + "core/primitive.str[25].html", + "core/primitive.str[30].html", + "core/codec/fn.encode.html", + "core/primitive.str[26].html", + "core/primitive.str[41].html", + "core/codec/fn.decode_second_param.html", + "core/primitive.u32.html", + "core/ops/fn.ok_str_eq.html", + "core/primitive.str[1].html", + "core/primitive.str[18].html", + "core/primitive.str[33].html", + "core/primitive.str[0].html", + "core/codec/fn.decode_predicate_data.html", + "core/primitive.str[9].html", + "core/ops/trait.Shift.html", + "core/ops/trait.Multiply.html", + "core/primitive.str[32].html", + "core/primitive.str[46].html", + "core/primitive.str[7].html", + "core/primitive.str[14].html", + "core/ops/trait.Add.html", + "core/primitive.str[23].html", + "core/primitive.str[52].html", + "core/primitive.str[48].html", + "core/primitive.str[2].html", + "core/primitive.str[5].html", + "impl_traits/bar/struct.Bar.html", + "core/primitive.str[63].html", + "core/primitive.str[21].html", + "core/codec/fn.contract_call.html", + "core/ops/trait.BitwiseXor.html", + "core/primitive.str[61].html", + "core/primitive.str[45].html", + "core/ops/trait.BitwiseOr.html", + "core/primitive.str[6].html", ], ); } @@ -182,26 +176,18 @@ fn test_impl_traits_no_deps() { no_deps: true, ..Default::default() }; - let (doc_path, _) = compile_html( - &command, - &get_doc_dir, - ExperimentalFlags { - new_encoding: false, - }, - ) - .unwrap(); + let (doc_path, _) = compile_html(&command, &get_doc_dir).unwrap(); assert_index_html( &doc_path, project_name, - &expect![[ - r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

-

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"## - ]], + &expect![[r##" + Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn abi_encode(self, buffer: Buffer) -> Buffer

fn abi_decode(refmut _buffer: BufferReader) -> Self

fn foo()

something more about foo();

+

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"##]], ); assert_search_js( &doc_path, &expect![[ - r#"var SEARCH_INDEX={"impl_traits_clone":[{"html_filename":"trait.Foo.html","module_info":["impl_traits_clone","foo"],"name":"Foo","preview":"","type_name":"trait"},{"html_filename":"trait.Baz.html","module_info":["impl_traits_clone","foo"],"name":"Baz","preview":"","type_name":"trait"},{"html_filename":"struct.Bar.html","module_info":["impl_traits_clone","bar"],"name":"Bar","preview":"","type_name":"struct"}]}; + r#"var SEARCH_INDEX={"impl_traits_clone":[{"html_filename":"trait.Foo.html","module_info":["impl_traits_clone","foo"],"name":"Foo","preview":"","type_name":"trait"},{"html_filename":"trait.Baz.html","module_info":["impl_traits_clone","foo"],"name":"Baz","preview":"","type_name":"trait"},{"html_filename":"struct.Bar.html","module_info":["impl_traits_clone","bar"],"name":"Bar","preview":"","type_name":"struct"},{"html_filename":"index.html","module_info":["impl_traits_clone","bar"],"name":"bar","preview":"","type_name":"module"},{"html_filename":"index.html","module_info":["impl_traits_clone","foo"],"name":"foo","preview":"","type_name":"module"}]}; "object"==typeof exports&&"undefined"!=typeof module&&(module.exports=SEARCH_INDEX);"# ]], ); diff --git a/forc-plugins/forc-doc/tests/lib.rs b/forc-plugins/forc-doc/tests/lib.rs index 158a6c2613e..9624b656a4f 100644 --- a/forc-plugins/forc-doc/tests/lib.rs +++ b/forc-plugins/forc-doc/tests/lib.rs @@ -9,12 +9,6 @@ fn builds_lib_std_docs() { ..Default::default() }; println!("Building docs for {:?}", build_instructions.manifest_path); - let res = compile_html( - &build_instructions, - &get_doc_dir, - sway_core::ExperimentalFlags { - new_encoding: !build_instructions.no_encoding_v1, - }, - ); + let res = compile_html(&build_instructions, &get_doc_dir); assert!(res.is_ok()); } diff --git a/forc-plugins/forc-fmt/Cargo.toml b/forc-plugins/forc-fmt/Cargo.toml index 24f660bad1a..d1fdedcce41 100644 --- a/forc-plugins/forc-fmt/Cargo.toml +++ b/forc-plugins/forc-fmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-fmt" -version = "0.63.5" +version.workspace = true description = "A `forc` plugin for running the Sway code formatter." authors.workspace = true edition.workspace = true @@ -9,14 +9,14 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1" -clap = { version = "4.5.4", features = ["derive"] } -forc-pkg = { version = "0.63.5", path = "../../forc-pkg" } -forc-tracing = { version = "0.63.5", path = "../../forc-tracing" } -forc-util = { version = "0.63.5", path = "../../forc-util" } -prettydiff = "0.5" -sway-core = { version = "0.63.5", path = "../../sway-core" } -sway-utils = { version = "0.63.5", path = "../../sway-utils" } -swayfmt = { version = "0.63.5", path = "../../swayfmt" } -taplo = "0.7" -tracing = "0.1" +anyhow.workspace = true +clap = { workspace = true, features = ["derive"] } +forc-pkg.workspace = true +forc-tracing.workspace = true +forc-util.workspace = true +prettydiff.workspace = true +sway-core.workspace = true +sway-utils.workspace = true +swayfmt.workspace = true +taplo.workspace = true +tracing.workspace = true diff --git a/forc-plugins/forc-lsp/Cargo.toml b/forc-plugins/forc-lsp/Cargo.toml index 82e2e899bbd..83ed86b61ad 100644 --- a/forc-plugins/forc-lsp/Cargo.toml +++ b/forc-plugins/forc-lsp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-lsp" -version = "0.63.5" +version.workspace = true description = "A simple `forc` plugin for starting the sway language server." authors.workspace = true edition.workspace = true @@ -9,8 +9,8 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1" -clap = { version = "4.5.4", features = ["derive"] } -sway-lsp = { version = "0.63.5", path = "../../sway-lsp" } -tikv-jemallocator = "0.5" -tokio = { version = "1.8" } +anyhow.workspace = true +clap = { workspace = true, features = ["derive"] } +sway-lsp.workspace = true +tikv-jemallocator.workspace = true +tokio.workspace = true diff --git a/forc-plugins/forc-tx/Cargo.toml b/forc-plugins/forc-tx/Cargo.toml index 670778e6a07..91fee672cf3 100644 --- a/forc-plugins/forc-tx/Cargo.toml +++ b/forc-plugins/forc-tx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-tx" -version = "0.63.5" +version.workspace = true description = "A `forc` plugin for constructing transactions." authors.workspace = true edition.workspace = true @@ -16,12 +16,12 @@ name = "forc-tx" path = "src/main.rs" [dependencies] -anyhow = "1" -clap = { version = "4.5.4", features = ["derive", "env"] } -devault = "0.1" -forc-util = { version = "0.63.5", path = "../../forc-util" } -fuel-tx = { workspace = true, features = ["serde", "test-helpers", "random"] } +anyhow.workspace = true +clap = { workspace = true, features = ["derive", "env"] } +devault.workspace = true +forc-util.workspace = true +fuel-tx = { workspace = true, features = ["random", "test-helpers"] } fuel-types = { workspace = true, features = ["serde"] } -serde = "1.0" -serde_json = { version = "1" } -thiserror = "1" +serde.workspace = true +serde_json.workspace = true +thiserror.workspace = true diff --git a/forc-test/Cargo.toml b/forc-test/Cargo.toml index 4c5f9647e74..1a012d6fdc1 100644 --- a/forc-test/Cargo.toml +++ b/forc-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-test" -version = "0.63.5" +version.workspace = true description = "A library for building and running Sway unit tests within Forc packages." authors.workspace = true edition.workspace = true @@ -9,13 +9,14 @@ license.workspace = true repository.workspace = true [dependencies] -anyhow = "1" -forc-pkg = { version = "0.63.5", path = "../forc-pkg" } -fuel-abi-types = { workspace = true } +anyhow.workspace = true +forc-pkg.workspace = true +fuel-abi-types.workspace = true fuel-tx = { workspace = true, features = ["test-helpers"] } fuel-vm = { workspace = true, features = ["random", "test-helpers"] } -fuels-core = { workspace = true } -rand = "0.8" -rayon = "1.7.0" -sway-core = { version = "0.63.5", path = "../sway-core" } -sway-types = { version = "0.63.5", path = "../sway-types" } +fuels-core.workspace = true +rand.workspace = true +rayon.workspace = true +sway-core.workspace = true +sway-features.workspace = true +sway-types.workspace = true diff --git a/forc-test/src/lib.rs b/forc-test/src/lib.rs index 58394055d75..bccc4cc0209 100644 --- a/forc-test/src/lib.rs +++ b/forc-test/src/lib.rs @@ -12,7 +12,6 @@ use fuel_vm::checked_transaction::builder::TransactionBuilderExt; use fuel_vm::{self as vm}; use fuels_core::codec::ABIDecoder; use fuels_core::types::param_types::ParamType; -use pkg::manifest::build_profile::ExperimentalFlags; use pkg::TestPassCondition; use pkg::{Built, BuiltPackage}; use rand::{Rng, SeedableRng}; @@ -152,10 +151,14 @@ pub struct TestOpts { pub error_on_warnings: bool, /// Output the time elapsed over each part of the compilation process. pub time_phases: bool, + /// Profile the compilation process. + pub profile: bool, /// Output compilation metrics into file. pub metrics_outfile: Option, - /// Set of experimental flags - pub experimental: ExperimentalFlags, + /// Set of enabled experimental flags + pub experimental: Vec, + /// Set of disabled experimental flags + pub no_experimental: Vec, } /// The set of options provided for controlling logs printed for each test. @@ -452,10 +455,12 @@ impl From for pkg::BuildOpts { release: val.release, error_on_warnings: val.error_on_warnings, time_phases: val.time_phases, + profile: val.profile, metrics_outfile: val.metrics_outfile, tests: true, member_filter: Default::default(), experimental: val.experimental, + no_experimental: val.no_experimental, } } } @@ -474,10 +479,12 @@ impl TestOpts { release: self.release, error_on_warnings: self.error_on_warnings, time_phases: self.time_phases, + profile: self.profile, metrics_outfile: self.metrics_outfile, tests: true, member_filter: Default::default(), experimental: self.experimental, + no_experimental: self.no_experimental, } } } diff --git a/forc-tracing/Cargo.toml b/forc-tracing/Cargo.toml index 3a8378cf2e9..871e04df5a0 100644 --- a/forc-tracing/Cargo.toml +++ b/forc-tracing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-tracing" -version = "0.63.5" +version.workspace = true description = "Tracing utility shared between forc crates." authors.workspace = true edition.workspace = true @@ -9,9 +9,9 @@ license.workspace = true repository.workspace = true [dependencies] -ansi_term = "0.12" -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["ansi", "env-filter", "json"] } +ansiterm.workspace = true +tracing.workspace = true +tracing-subscriber = { workspace = true, features = ["ansi", "env-filter", "json"] } [dev-dependencies] -tracing-test = "0.2" \ No newline at end of file +tracing-test = "0.2" diff --git a/forc-tracing/src/lib.rs b/forc-tracing/src/lib.rs index 656cb14ca14..c331b0a8a71 100644 --- a/forc-tracing/src/lib.rs +++ b/forc-tracing/src/lib.rs @@ -1,6 +1,6 @@ //! Utility items shared between forc crates. -use ansi_term::Colour; +use ansiterm::Colour; use std::str; use std::{env, io}; use tracing::{Level, Metadata}; diff --git a/forc-util/Cargo.toml b/forc-util/Cargo.toml index f24b56b6701..b2b5cdded43 100644 --- a/forc-util/Cargo.toml +++ b/forc-util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc-util" -version = "0.63.5" +version.workspace = true description = "Utility items shared between forc crates." authors.workspace = true edition.workspace = true @@ -9,31 +9,31 @@ license.workspace = true repository.workspace = true [dependencies] -annotate-snippets = { version = "0.10.1" } -ansi_term = "0.12" -anyhow = "1" -clap = { version = "4.5.4", features = ["cargo", "derive", "env"] } -dirs = "3.0.2" -fd-lock = "4.0" -forc-tracing = { version = "0.63.5", path = "../forc-tracing" } -fuel-tx = { workspace = true, features = ["serde"], optional = true } -hex = "0.4.3" -paste = "1.0.14" -regex = "1.10.2" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.73" -serial_test = "3.0.0" -sway-core = { version = "0.63.5", path = "../sway-core" } -sway-error = { version = "0.63.5", path = "../sway-error" } -sway-types = { version = "0.63.5", path = "../sway-types" } -sway-utils = { version = "0.63.5", path = "../sway-utils" } -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = [ +annotate-snippets.workspace = true +ansiterm.workspace = true +anyhow.workspace = true +clap = { workspace = true, features = ["cargo", "derive", "env"] } +dirs.workspace = true +fd-lock.workspace = true +forc-tracing.workspace = true +fuel-tx = { workspace = true, optional = true } +hex.workspace = true +paste.workspace = true +regex.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true +serial_test.workspace = true +sway-core.workspace = true +sway-error.workspace = true +sway-types.workspace = true +sway-utils.workspace = true +tracing.workspace = true +tracing-subscriber = { workspace = true, features = [ "ansi", "env-filter", "json", ] } -unicode-xid = "0.2.2" +unicode-xid.workspace = true [features] default = ["fuel-tx"] diff --git a/forc-util/src/cli.rs b/forc-util/src/cli.rs index f8f6ed5662e..d5dc863ddcd 100644 --- a/forc-util/src/cli.rs +++ b/forc-util/src/cli.rs @@ -103,7 +103,7 @@ macro_rules! cli_examples { fn help() -> &'static str { - Box::leak(format!("{}\n{}", forc_util::ansi_term::Colour::Yellow.paint("EXAMPLES:"), examples()).into_boxed_str()) + Box::leak(format!("{}\n{}", forc_util::ansiterm::Colour::Yellow.paint("EXAMPLES:"), examples()).into_boxed_str()) } pub fn examples() -> &'static str { diff --git a/forc-util/src/lib.rs b/forc-util/src/lib.rs index a630f741023..003d50898ad 100644 --- a/forc-util/src/lib.rs +++ b/forc-util/src/lib.rs @@ -29,7 +29,7 @@ pub mod restricted; #[macro_use] pub mod cli; -pub use ansi_term; +pub use ansiterm; pub use paste; pub use regex::Regex; pub use serial_test; @@ -347,7 +347,7 @@ pub fn print_compiling(ty: Option<&TreeType>, name: &str, src: &dyn std::fmt::Di }; println_action_green( "Compiling", - &format!("{ty}{} ({src})", ansi_term::Style::new().bold().paint(name)), + &format!("{ty}{} ({src})", ansiterm::Style::new().bold().paint(name)), ); } @@ -510,7 +510,7 @@ fn format_diagnostic(diagnostic: &Diagnostic) { label: if issue.is_in_source() { None } else { - Some(issue.friendly_text()) + Some(issue.text()) }, id: None, annotation_type, @@ -532,7 +532,7 @@ fn format_diagnostic(diagnostic: &Diagnostic) { origin: Some(issue.source_path().unwrap().as_str()), fold: false, annotations: vec![SourceAnnotation { - label: issue.friendly_text(), + label: issue.text(), annotation_type, range: (start_pos, end_pos), }], @@ -594,7 +594,7 @@ fn construct_slice(labels: Vec<&Label>) -> Slice { for message in labels { annotations.push(SourceAnnotation { - label: message.friendly_text(), + label: message.text(), annotation_type: label_type_to_annotation_type(message.label_type()), range: get_annotation_range(message.span(), source_code, shift_in_bytes), }); @@ -716,43 +716,104 @@ fn construct_window<'a>( let total_lines_of_highlight = end.line - start.line; debug_assert!(total_lines_in_input >= total_lines_of_highlight); - let mut current_line = 0; - let mut lines_to_start_of_snippet = 0; - let mut calculated_start_ix = None; - let mut calculated_end_ix = None; - let mut pos = 0; - for character in input.chars() { + let mut current_line = 1usize; + + let mut chars = input.char_indices().map(|(char_offset, character)| { + let r = (current_line, char_offset); if character == '\n' { - current_line += 1 + current_line += 1; } + r + }); - if current_line + NUM_LINES_BUFFER >= start.line && calculated_start_ix.is_none() { - calculated_start_ix = Some(pos); - lines_to_start_of_snippet = current_line; - } + // Find the first char of the first line + let first_char = chars + .by_ref() + .find(|(current_line, _)| current_line + NUM_LINES_BUFFER >= start.line); - if current_line >= end.line + NUM_LINES_BUFFER && calculated_end_ix.is_none() { - calculated_end_ix = Some(pos); - } + // Find the last char of the last line + let last_char = chars + .by_ref() + .find(|(current_line, _)| *current_line > end.line + NUM_LINES_BUFFER) + .map(|x| x.1); - if calculated_start_ix.is_some() && calculated_end_ix.is_some() { - break; + // this releases the borrow of `current_line` + drop(chars); + + let (first_char_line, first_char_offset, last_char_offset) = match (first_char, last_char) { + // has first and last + (Some((first_char_line, first_char_offset)), Some(last_char_offset)) => { + (first_char_line, first_char_offset, last_char_offset) } - pos += character.len_utf8(); + // has first and no last + (Some((first_char_line, first_char_offset)), None) => { + (first_char_line, first_char_offset, input.len()) + } + // others + _ => (current_line, input.len(), input.len()), + }; + + // adjust indices to be inside the returned window + start.line = first_char_line; + *start_ix = start_ix.saturating_sub(first_char_offset); + *end_ix = end_ix.saturating_sub(first_char_offset); + + &input[first_char_offset..last_char_offset] +} + +#[test] +fn ok_construct_window() { + fn t( + start_line: usize, + start_col: usize, + end_line: usize, + end_col: usize, + start_char: usize, + end_char: usize, + input: &str, + ) -> (usize, usize, &str) { + let mut s = LineCol { + line: start_line, + col: start_col, + }; + let mut start = start_char; + let mut end = end_char; + let r = construct_window( + &mut s, + LineCol { + line: end_line, + col: end_col, + }, + &mut start, + &mut end, + input, + ); + (start, end, r) } - let calculated_start_ix = calculated_start_ix.unwrap_or(0); - let calculated_end_ix = calculated_end_ix.unwrap_or(input.len()); - let start_ix_bytes = *start_ix - std::cmp::min(calculated_start_ix, *start_ix); - let end_ix_bytes = *end_ix - std::cmp::min(calculated_start_ix, *end_ix); - // We want the start_ix and end_ix in terms of chars and not bytes, so translate. - *start_ix = input[calculated_start_ix..(calculated_start_ix + start_ix_bytes)] - .chars() - .count(); - *end_ix = input[calculated_start_ix..(calculated_start_ix + end_ix_bytes)] - .chars() - .count(); - - start.line = lines_to_start_of_snippet; - &input[calculated_start_ix..calculated_end_ix] + // Invalid Empty file + assert_eq!(t(0, 0, 0, 0, 0, 0, ""), (0, 0, "")); + + // Valid Empty File + assert_eq!(t(1, 1, 1, 1, 0, 0, ""), (0, 0, "")); + + // One line, error after the last char + assert_eq!(t(1, 7, 1, 7, 6, 6, "script"), (6, 6, "script")); + + // 01 23 45 67 89 AB CD E + let eight_lines = "1\n2\n3\n4\n5\n6\n7\n8"; + + assert_eq!(t(1, 1, 1, 1, 0, 1, eight_lines), (0, 1, "1\n2\n3\n")); + assert_eq!(t(2, 1, 2, 1, 2, 3, eight_lines), (2, 3, "1\n2\n3\n4\n")); + assert_eq!(t(3, 1, 3, 1, 4, 5, eight_lines), (4, 5, "1\n2\n3\n4\n5\n")); + assert_eq!(t(4, 1, 4, 1, 6, 7, eight_lines), (4, 5, "2\n3\n4\n5\n6\n")); + assert_eq!(t(5, 1, 5, 1, 8, 9, eight_lines), (4, 5, "3\n4\n5\n6\n7\n")); + assert_eq!(t(6, 1, 6, 1, 10, 11, eight_lines), (4, 5, "4\n5\n6\n7\n8")); + assert_eq!(t(7, 1, 7, 1, 12, 13, eight_lines), (4, 5, "5\n6\n7\n8")); + assert_eq!(t(8, 1, 8, 1, 14, 15, eight_lines), (4, 5, "6\n7\n8")); + + // Invalid lines + assert_eq!(t(9, 1, 9, 1, 14, 15, eight_lines), (2, 3, "7\n8")); + assert_eq!(t(10, 1, 10, 1, 14, 15, eight_lines), (0, 1, "8")); + assert_eq!(t(11, 1, 11, 1, 14, 15, eight_lines), (0, 0, "")); } diff --git a/forc/Cargo.toml b/forc/Cargo.toml index 665c2630c2c..b3257f1ad1f 100644 --- a/forc/Cargo.toml +++ b/forc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forc" -version = "0.63.5" +version.workspace = true description = "Fuel Orchestrator." authors.workspace = true edition.workspace = true @@ -17,41 +17,42 @@ name = "forc" path = "src/main.rs" [dependencies] -annotate-snippets = { version = "0.10.1" } -ansi_term = "0.12" -anyhow = "1.0.41" -clap = { version = "4.5.4", features = ["cargo", "derive", "env"] } -clap_complete = "4.5.2" -clap_complete_fig = "4.5.0" -forc-pkg = { version = "0.63.5", path = "../forc-pkg" } -forc-test = { version = "0.63.5", path = "../forc-test" } -forc-tracing = { version = "0.63.5", path = "../forc-tracing" } -forc-util = { version = "0.63.5", path = "../forc-util" } -fs_extra = "1.2" -fuel-asm = { workspace = true } -hex = "0.4.3" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.73" -sway-core = { version = "0.63.5", path = "../sway-core" } -sway-error = { version = "0.63.5", path = "../sway-error" } -sway-ir = { version = "0.63.5", path = "../sway-ir" } -sway-types = { version = "0.63.5", path = "../sway-types" } -sway-utils = { version = "0.63.5", path = "../sway-utils" } -term-table = "1.3" -tokio = { version = "1.8.0", features = ["macros", "rt-multi-thread"] } -toml = { version = "0.7", features = ["parse"] } -toml_edit = "0.19" -tracing = "0.1" -url = "2.2" -uwuify = { version = "^0.2", optional = true } -walkdir = "2.3" -whoami = "1.1" +annotate-snippets.workspace = true +ansiterm.workspace = true +anyhow.workspace = true +clap = { workspace = true, features = ["cargo", "derive", "env"] } +clap_complete.workspace = true +clap_complete_fig.workspace = true +forc-pkg.workspace = true +forc-test.workspace = true +forc-tracing.workspace = true +forc-util.workspace = true +fs_extra.workspace = true +fuel-asm.workspace = true +hex.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true +sway-core.workspace = true +sway-error.workspace = true +sway-features.workspace = true +sway-ir.workspace = true +sway-types.workspace = true +sway-utils.workspace = true +term-table.workspace = true +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +toml = { workspace = true, features = ["parse"] } +toml_edit.workspace = true +tracing.workspace = true +url.workspace = true +walkdir.workspace = true +whoami.workspace = true [features] default = [] test = [] util = [] -uwu = ["uwuify"] +profile = [] [dev-dependencies] completest-pty = "0.5.0" +rexpect = "0.5" diff --git a/forc/src/cli/commands/build.rs b/forc/src/cli/commands/build.rs index ae88dfebfdc..c83242d43df 100644 --- a/forc/src/cli/commands/build.rs +++ b/forc/src/cli/commands/build.rs @@ -17,13 +17,13 @@ forc_util::cli_examples! { /// - `script`, `predicate` and `contract` projects will produce their bytecode in binary format `.bin`. /// /// - `script` projects will also produce a file containing the hash of the bytecode binary -/// `-bin-hash` (using `fuel_cypto::Hasher`). +/// `-bin-hash` (using `fuel_cypto::Hasher`). /// /// - `predicate` projects will also produce a file containing the **root** hash of the bytecode binary -/// `-bin-root` (using `fuel_tx::Contract::root_from_code`). +/// `-bin-root` (using `fuel_tx::Contract::root_from_code`). /// /// - `contract` and `library` projects will also produce the public ABI in JSON format -/// `-abi.json`. +/// `-abi.json`. #[derive(Debug, Default, Parser)] #[clap(bin_name = "forc build", version, after_help = help())] pub struct Command { @@ -33,9 +33,8 @@ pub struct Command { #[clap(long)] pub tests: bool, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/check.rs b/forc/src/cli/commands/check.rs index 4d5f41e76a3..3a3406ac9e8 100644 --- a/forc/src/cli/commands/check.rs +++ b/forc/src/cli/commands/check.rs @@ -45,9 +45,8 @@ pub struct Command { #[clap(long)] pub ipfs_node: Option, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/contract_id.rs b/forc/src/cli/commands/contract_id.rs index 55848428aa8..85640937943 100644 --- a/forc/src/cli/commands/contract_id.rs +++ b/forc/src/cli/commands/contract_id.rs @@ -29,9 +29,8 @@ pub struct Command { #[clap(flatten)] pub salt: Salt, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/predicate_root.rs b/forc/src/cli/commands/predicate_root.rs index 5c9cbb6bf04..676c85e998f 100644 --- a/forc/src/cli/commands/predicate_root.rs +++ b/forc/src/cli/commands/predicate_root.rs @@ -26,9 +26,8 @@ pub struct Command { #[clap(flatten)] pub build_profile: BuildProfile, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { diff --git a/forc/src/cli/commands/test.rs b/forc/src/cli/commands/test.rs index b4dcf9c524c..685a7d4e9bb 100644 --- a/forc/src/cli/commands/test.rs +++ b/forc/src/cli/commands/test.rs @@ -1,11 +1,10 @@ use crate::cli; -use ansi_term::Colour; +use ansiterm::Colour; use clap::Parser; use forc_pkg as pkg; use forc_test::{decode_log_data, TestFilter, TestRunnerCount, TestedPackage}; use forc_tracing::println_action_green; use forc_util::{tx_utils::format_log_receipts, ForcError, ForcResult}; -use pkg::manifest::build_profile::ExperimentalFlags; use sway_core::fuel_prelude::fuel_tx::Receipt; use tracing::info; @@ -52,25 +51,23 @@ pub struct Command { /// threads available in your system. pub test_threads: Option, - /// Disable the "new encoding" feature - #[clap(long)] - pub no_encoding_v1: bool, + #[clap(flatten)] + pub experimental: sway_features::CliFields, } /// The set of options provided for controlling output of a test. #[derive(Parser, Debug, Clone)] #[clap(after_help = help())] pub struct TestPrintOpts { - #[clap(long = "pretty-print", short = 'r')] + #[clap(long = "pretty")] /// Pretty-print the logs emitted from tests. pub pretty_print: bool, /// Print `Log` and `LogData` receipts for tests. #[clap(long = "logs", short = 'l')] pub print_logs: bool, - /// Decode logs and show decoded log information in human readable format alongside the raw - /// logs. - #[clap(long = "decode", short = 'd')] - pub decode_logs: bool, + /// Print the raw logs for tests. + #[clap(long)] + pub raw_logs: bool, } pub(crate) fn exec(cmd: Command) -> ForcResult<()> { @@ -150,26 +147,26 @@ fn print_tested_pkg(pkg: &TestedPackage, test_print_opts: &TestPrintOpts) -> For ); // If logs are enabled, print them. + let logs = &test.logs; if test_print_opts.print_logs { - let logs = &test.logs; - if test_print_opts.decode_logs { - for log in logs { - if let Receipt::LogData { - rb, - data: Some(data), - .. - } = log - { - let decoded_log_data = - decode_log_data(&rb.to_string(), data, &pkg.built.program_abi)?; - let var_value = decoded_log_data.value; - info!("Decoded log value: {}, log rb: {}", var_value, rb); - } + for log in logs { + if let Receipt::LogData { + rb, + data: Some(data), + .. + } = log + { + let decoded_log_data = + decode_log_data(&rb.to_string(), data, &pkg.built.program_abi)?; + let var_value = decoded_log_data.value; + info!("Decoded log value: {}, log rb: {}", var_value, rb); } - info!("Raw logs:"); } + } + + if test_print_opts.raw_logs { let formatted_logs = format_log_receipts(logs, test_print_opts.pretty_print)?; - info!("{}", formatted_logs); + info!("Raw logs:\n{}", formatted_logs); } // If the test is failing, save the test result for printing the details later on. @@ -246,6 +243,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts { reverse_order: cmd.build.print.reverse_order, }, time_phases: cmd.build.print.time_phases, + profile: cmd.build.print.profile, metrics_outfile: cmd.build.print.metrics_outfile, minify: pkg::MinifyOpts { json_abi: cmd.build.minify.json_abi, @@ -257,9 +255,8 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts { binary_outfile: cmd.build.output.bin_file, debug_outfile: cmd.build.output.debug_file, build_target: cmd.build.build_target, - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + experimental: cmd.experimental.experimental, + no_experimental: cmd.experimental.no_experimental, } } diff --git a/forc/src/cli/shared.rs b/forc/src/cli/shared.rs index 28b38465df3..23ccdd59cb9 100644 --- a/forc/src/cli/shared.rs +++ b/forc/src/cli/shared.rs @@ -99,6 +99,9 @@ pub struct Print { /// Output the time elapsed over each part of the compilation process. #[clap(long)] pub time_phases: bool, + /// Profile the compilation process. + #[clap(long)] + pub profile: bool, /// Output build errors and warnings in reverse order. #[clap(long)] pub reverse_order: bool, diff --git a/forc/src/ops/forc_build.rs b/forc/src/ops/forc_build.rs index 49c0c27f955..2ec40cca931 100644 --- a/forc/src/ops/forc_build.rs +++ b/forc/src/ops/forc_build.rs @@ -1,7 +1,7 @@ use crate::cli::BuildCommand; use forc_pkg as pkg; use forc_util::ForcResult; -use pkg::{manifest::build_profile::ExperimentalFlags, MemberFilter}; +use pkg::MemberFilter; pub fn build(cmd: BuildCommand) -> ForcResult { let opts = opts_from_cmd(cmd); @@ -30,6 +30,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts { reverse_order: cmd.build.print.reverse_order, }, time_phases: cmd.build.print.time_phases, + profile: cmd.build.print.profile, metrics_outfile: cmd.build.print.metrics_outfile, minify: pkg::MinifyOpts { json_abi: cmd.build.minify.json_abi, @@ -43,8 +44,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts { build_target: cmd.build.build_target, tests: cmd.tests, member_filter: MemberFilter::default(), - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + experimental: cmd.experimental.experimental, + no_experimental: cmd.experimental.no_experimental, } } diff --git a/forc/src/ops/forc_check.rs b/forc/src/ops/forc_check.rs index e1419c90982..116b27ace6d 100644 --- a/forc/src/ops/forc_check.rs +++ b/forc/src/ops/forc_check.rs @@ -4,7 +4,7 @@ use forc_pkg as pkg; use forc_pkg::manifest::GenericManifestFile; use pkg::manifest::ManifestFile; use std::path::PathBuf; -use sway_core::{language::ty, Engines, ExperimentalFlags}; +use sway_core::{language::ty, Engines}; use sway_error::handler::Handler; pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option, Handler)> { @@ -16,7 +16,8 @@ pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option Result<(Option pkg::BuildOpts { reverse_order: cmd.print.reverse_order, }, time_phases: cmd.print.time_phases, + profile: cmd.print.profile, metrics_outfile: cmd.print.metrics_outfile.clone(), minify: pkg::MinifyOpts { json_abi: cmd.minify.json_abi, @@ -78,8 +78,7 @@ fn build_opts_from_cmd(cmd: &ContractIdCommand) -> pkg::BuildOpts { build_target: BuildTarget::default(), tests: false, member_filter: pkg::MemberFilter::only_contracts(), - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + experimental: cmd.experimental.experimental.clone(), + no_experimental: cmd.experimental.no_experimental.clone(), } } diff --git a/forc/src/ops/forc_predicate_root.rs b/forc/src/ops/forc_predicate_root.rs index 1381aec392e..41b7c5020a8 100644 --- a/forc/src/ops/forc_predicate_root.rs +++ b/forc/src/ops/forc_predicate_root.rs @@ -1,7 +1,6 @@ use crate::cli::PredicateRootCommand; use anyhow::Result; use forc_pkg::{self as pkg, build_with_options}; -use pkg::manifest::build_profile::ExperimentalFlags; use sway_core::BuildTarget; pub fn predicate_root(command: PredicateRootCommand) -> Result<()> { @@ -34,6 +33,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts { reverse_order: cmd.print.reverse_order, }, time_phases: cmd.print.time_phases, + profile: cmd.print.profile, metrics_outfile: cmd.print.metrics_outfile, minify: pkg::MinifyOpts { json_abi: cmd.minify.json_abi, @@ -47,8 +47,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts { build_target: BuildTarget::default(), tests: false, member_filter: pkg::MemberFilter::only_predicates(), - experimental: ExperimentalFlags { - new_encoding: !cmd.no_encoding_v1, - }, + experimental: cmd.experimental.experimental, + no_experimental: cmd.experimental.no_experimental, } } diff --git a/forc/src/ops/forc_template.rs b/forc/src/ops/forc_template.rs index 23703ea575e..0304a9d298a 100644 --- a/forc/src/ops/forc_template.rs +++ b/forc/src/ops/forc_template.rs @@ -84,7 +84,7 @@ fn edit_forc_toml(out_dir: &Path, project_name: &str, real_name: &str) -> Result let mut file = File::open(out_dir.join(constants::MANIFEST_FILE_NAME))?; let mut toml = String::new(); file.read_to_string(&mut toml)?; - let mut manifest_toml = toml.parse::()?; + let mut manifest_toml = toml.parse::()?; let mut authors = Vec::new(); let forc_toml: toml::Value = toml::de::from_str(&toml)?; @@ -144,7 +144,7 @@ fn edit_cargo_toml(out_dir: &Path, project_name: &str, real_name: &str) -> Resul } updated_authors.push(real_name); - let mut manifest_toml = toml.parse::()?; + let mut manifest_toml = toml.parse::()?; manifest_toml["package"]["authors"] = toml_edit::value(updated_authors); manifest_toml["package"]["name"] = toml_edit::value(project_name); diff --git a/forc/tests/cli_integration.rs b/forc/tests/cli_integration.rs new file mode 100644 index 00000000000..1f1248a2205 --- /dev/null +++ b/forc/tests/cli_integration.rs @@ -0,0 +1,84 @@ +use std::path::PathBuf; + +use rexpect::spawn; + +const TIMEOUT_MS: u64 = 300000; + +fn test_fixtures_path() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests") + .join("fixtures") + .canonicalize() + .unwrap() +} + +#[test] +fn test_forc_test_decoded_logs() -> Result<(), rexpect::error::Error> { + // Spawn the forc binary using cargo run + let project_dir = test_fixtures_path().join("test_contract"); + let mut process = spawn( + &format!( + "cargo run --bin forc -- test --logs --path {}", + project_dir.to_string_lossy() + ), + Some(TIMEOUT_MS), + )?; + + // Assert that the output is correct + process.exp_string(" test test_log_4")?; + process.exp_string("Decoded log value: 4, log rb: 1515152261580153489")?; + process.exp_string(" test test_log_2")?; + process.exp_string("Decoded log value: 2, log rb: 1515152261580153489")?; + + process.process.exit()?; + Ok(()) +} + +#[test] +fn test_forc_test_raw_logs() -> Result<(), rexpect::error::Error> { + // Spawn the forc binary using cargo run + let project_dir = test_fixtures_path().join("test_contract"); + let mut process = spawn( + &format!( + "cargo run --bin forc -- test --raw-logs --path {}", + project_dir.to_string_lossy() + ), + Some(TIMEOUT_MS), + )?; + + // Assert that the output is correct + process.exp_string(" test test_log_4")?; + process.exp_string("Raw logs:")?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12664,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(" test test_log_2")?; + process.exp_string("Raw logs:")?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12664,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + + process.process.exit()?; + Ok(()) +} + +#[test] +fn test_forc_test_both_logs() -> Result<(), rexpect::error::Error> { + // Spawn the forc binary using cargo run + let project_dir = test_fixtures_path().join("test_contract"); + let mut process = spawn( + &format!( + "cargo run --bin forc -- test --logs --raw-logs --path {}", + project_dir.to_string_lossy() + ), + Some(TIMEOUT_MS), + )?; + + // Assert that the output is correct + process.exp_string(" test test_log_4")?; + process.exp_string("Decoded log value: 4, log rb: 1515152261580153489")?; + process.exp_string("Raw logs:")?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12664,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(" test test_log_2")?; + process.exp_string("Decoded log value: 2, log rb: 1515152261580153489")?; + process.exp_string("Raw logs:")?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12664,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.process.exit()?; + Ok(()) +} diff --git a/forc/tests/fixtures/test_contract/.gitignore b/forc/tests/fixtures/test_contract/.gitignore new file mode 100644 index 00000000000..77d3844f58c --- /dev/null +++ b/forc/tests/fixtures/test_contract/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/forc/tests/fixtures/test_contract/Forc.lock b/forc/tests/fixtures/test_contract/Forc.lock new file mode 100644 index 00000000000..943d47b39ef --- /dev/null +++ b/forc/tests/fixtures/test_contract/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-4D4735C41181917E" + +[[package]] +name = "std" +source = "path+from-root-4D4735C41181917E" +dependencies = ["core"] + +[[package]] +name = "test_contract" +source = "member" +dependencies = ["std"] diff --git a/forc/tests/fixtures/test_contract/Forc.toml b/forc/tests/fixtures/test_contract/Forc.toml new file mode 100644 index 00000000000..4342f8dbc65 --- /dev/null +++ b/forc/tests/fixtures/test_contract/Forc.toml @@ -0,0 +1,8 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "test_contract" + +[dependencies] +std = { path = "../../../../sway-lib-std/" } diff --git a/forc-plugins/forc-client/test/data/standalone_contract_b/src/main.sw b/forc/tests/fixtures/test_contract/src/main.sw similarity index 56% rename from forc-plugins/forc-client/test/data/standalone_contract_b/src/main.sw rename to forc/tests/fixtures/test_contract/src/main.sw index 7d4a75493c6..2314fa4dc47 100644 --- a/forc-plugins/forc-client/test/data/standalone_contract_b/src/main.sw +++ b/forc/tests/fixtures/test_contract/src/main.sw @@ -9,3 +9,15 @@ impl MyContract for Contract { true } } + +#[test] +fn test_log_4() { + log(4); + assert(1 == 1) +} + +#[test] +fn test_log_2() { + log(2); + assert(1 == 1) +} diff --git a/scripts/mdbook-forc-documenter/Cargo.toml b/scripts/mdbook-forc-documenter/Cargo.toml index eae79eff1ef..8db19ab6db6 100644 --- a/scripts/mdbook-forc-documenter/Cargo.toml +++ b/scripts/mdbook-forc-documenter/Cargo.toml @@ -13,9 +13,9 @@ name = "mdbook_forc_documenter" path = "src/lib.rs" [dependencies] -anyhow = "1" -clap = { version = "4.5.4", features = ["derive"] } -mdbook = { version = "0.4", default-features = false } -semver = "1.0" -serde = "1.0" -serde_json = "1.0" +anyhow.workspace = true +clap = { workspace = true, features = ["derive"] } +mdbook.workspace = true +semver.workspace = true +serde.workspace = true +serde_json.workspace = true diff --git a/sway-ast/Cargo.toml b/sway-ast/Cargo.toml index 0d073b6ed4a..ad73333213d 100644 --- a/sway-ast/Cargo.toml +++ b/sway-ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sway-ast" -version = "0.63.5" +version.workspace = true description = "Sway's AST" authors.workspace = true edition.workspace = true @@ -9,12 +9,12 @@ license.workspace = true repository.workspace = true [dependencies] -extension-trait = "1.0.1" -num-bigint = { version = "0.4.3", features = ["serde"] } -num-traits = "0.2.14" -serde = { version = "1.0", features = ["derive"] } -sway-error = { version = "0.63.5", path = "../sway-error" } -sway-types = { version = "0.63.5", path = "../sway-types" } +extension-trait.workspace = true +num-bigint = { workspace = true, features = ["serde"] } +num-traits.workspace = true +serde = { workspace = true, features = ["derive"] } +sway-error.workspace = true +sway-types.workspace = true [lints.clippy] iter_over_hash_type = "deny" diff --git a/sway-ast/src/intrinsics.rs b/sway-ast/src/intrinsics.rs index 182d47fa3d9..30dea17436d 100644 --- a/sway-ast/src/intrinsics.rs +++ b/sway-ast/src/intrinsics.rs @@ -43,6 +43,7 @@ pub enum Intrinsic { EncodeBufferAsRawSlice, // let slice: raw_slice = __encode_buffer_as_raw_slice(buffer) Slice, // let ref_to_slice = __slice::(item: T, inclusive_start_index, exclusive_end_index) ElemAt, // let elem: &T = __elem_at::(item: T, index) + Transmute, // let dst: B = __transmute::(src) } impl fmt::Display for Intrinsic { @@ -89,6 +90,7 @@ impl fmt::Display for Intrinsic { Intrinsic::EncodeBufferAsRawSlice => "encode_buffer_as_raw_slice", Intrinsic::Slice => "slice", Intrinsic::ElemAt => "elem_at", + Intrinsic::Transmute => "transmute", }; write!(f, "{s}") } @@ -139,6 +141,7 @@ impl Intrinsic { "__encode_buffer_as_raw_slice" => EncodeBufferAsRawSlice, "__slice" => Slice, "__elem_at" => ElemAt, + "__transmute" => Transmute, _ => return None, }) } diff --git a/sway-core/Cargo.toml b/sway-core/Cargo.toml index 986a1b015b5..5e2e5d54536 100644 --- a/sway-core/Cargo.toml +++ b/sway-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sway-core" -version = "0.63.5" +version.workspace = true description = "Sway core language." authors.workspace = true edition.workspace = true @@ -9,46 +9,45 @@ license.workspace = true repository.workspace = true [dependencies] -clap = { version = "4.5.4", features = ["derive"] } -derivative = "2.2.0" -dirs = "3.0" -either = "1.9.0" -ethabi = { package = "fuel-ethabi", version = "18.0.0" } -etk-asm = { package = "fuel-etk-asm", version = "0.3.1-dev", features = [ - "backtraces", -] } -etk-ops = { package = "fuel-etk-ops", version = "0.3.1-dev" } -fuel-abi-types = { workspace = true } +clap = { workspace = true, features = ["derive"] } +derivative.workspace = true +dirs.workspace = true +either.workspace = true +ethabi.workspace = true +etk-asm = { workspace = true, features = ["backtraces"] } +etk-ops.workspace = true +fuel-abi-types.workspace = true fuel-vm = { workspace = true, features = ["serde"] } -gimli = "0.28.1" -graph-cycles = "0.1.0" -hashbrown = "0.13.1" -hex = { version = "0.4", optional = true } -im = "15.0" -indexmap = "2.0.0" -itertools = "0.10" -lazy_static = "1.4" -miden-core = "0.3.0" -object = { version = "0.32.2", features = ["write"] } -parking_lot = "0.12" -pest = "2.1.3" -pest_derive = "2.1" -petgraph = "0.6" -rustc-hash = "1.1.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.91" -sha2 = "0.9" -strum = { version = "0.24.1", features = ["derive"] } -sway-ast = { version = "0.63.5", path = "../sway-ast" } -sway-error = { version = "0.63.5", path = "../sway-error" } -sway-ir = { version = "0.63.5", path = "../sway-ir" } -sway-parse = { version = "0.63.5", path = "../sway-parse" } -sway-types = { version = "0.63.5", path = "../sway-types" } -sway-utils = { version = "0.63.5", path = "../sway-utils" } -thiserror = "1.0" -tracing = "0.1" -uint = "0.9" -vec1 = "1.8.0" +gimli.workspace = true +graph-cycles.workspace = true +hashbrown.workspace = true +hex = { workspace = true, optional = true } +im.workspace = true +indexmap.workspace = true +itertools.workspace = true +lazy_static.workspace = true +object = { workspace = true, features = ["write"] } +parking_lot.workspace = true +paste.workspace = true +pest.workspace = true +pest_derive.workspace = true +petgraph.workspace = true +rustc-hash.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true +sha2.workspace = true +strum = { workspace = true, features = ["derive"] } +sway-ast.workspace = true +sway-error.workspace = true +sway-features.workspace = true +sway-ir.workspace = true +sway-parse.workspace = true +sway-types.workspace = true +sway-utils.workspace = true +thiserror.workspace = true +tracing.workspace = true +uint.workspace = true +vec1.workspace = true [target.'cfg(not(target_os = "macos"))'.dependencies] sysinfo = "0.29.0" diff --git a/sway-core/src/abi_generation/abi_str.rs b/sway-core/src/abi_generation/abi_str.rs index 2972c9cee0e..5794906d7c9 100644 --- a/sway-core/src/abi_generation/abi_str.rs +++ b/sway-core/src/abi_generation/abi_str.rs @@ -117,6 +117,14 @@ impl TypeInfo { Numeric => "u64".into(), // u64 is the default Contract => "contract".into(), ErrorRecovery(_) => "unknown due to error".into(), + UntypedEnum(decl_id) => { + let decl = engines.pe().get_enum(decl_id); + format!("untyped enum {}", decl.name) + } + UntypedStruct(decl_id) => { + let decl = engines.pe().get_struct(decl_id); + format!("untyped struct {}", decl.name) + } Enum(decl_ref) => { let decl = decl_engine.get_enum(decl_ref); let type_params = if (ctx.abi_root_type_without_generic_type_parameters && is_root) @@ -171,7 +179,6 @@ impl TypeInfo { length.val() ) } - Storage { .. } => "contract storage".into(), RawUntypedPtr => "raw untyped ptr".into(), RawUntypedSlice => "raw untyped slice".into(), Ptr(ty) => { diff --git a/sway-core/src/abi_generation/evm_abi.rs b/sway-core/src/abi_generation/evm_abi.rs index f899e0de209..147fa387a6f 100644 --- a/sway-core/src/abi_generation/evm_abi.rs +++ b/sway-core/src/abi_generation/evm_abi.rs @@ -93,6 +93,14 @@ pub fn abi_str(type_info: &TypeInfo, engines: &Engines) -> String { Numeric => "u64".into(), // u64 is the default Contract => "contract".into(), ErrorRecovery(_) => "unknown due to error".into(), + UntypedEnum(decl_id) => { + let decl = engines.pe().get_enum(decl_id); + format!("untyped enum {}", decl.name) + } + UntypedStruct(decl_id) => { + let decl = engines.pe().get_struct(decl_id); + format!("untyped struct {}", decl.name) + } Enum(decl_ref) => { let decl = decl_engine.get_enum(decl_ref); format!("enum {}", decl.call_path.suffix) @@ -107,7 +115,6 @@ pub fn abi_str(type_info: &TypeInfo, engines: &Engines) -> String { Array(elem_ty, length) => { format!("{}[{}]", abi_str_type_arg(elem_ty, engines), length.val()) } - Storage { .. } => "contract storage".into(), RawUntypedPtr => "raw untyped ptr".into(), RawUntypedSlice => "raw untyped slice".into(), Ptr(ty) => { diff --git a/sway-core/src/abi_generation/fuel_abi.rs b/sway-core/src/abi_generation/fuel_abi.rs index 447d29341cb..7fdd704155d 100644 --- a/sway-core/src/abi_generation/fuel_abi.rs +++ b/sway-core/src/abi_generation/fuel_abi.rs @@ -181,17 +181,24 @@ pub fn generate_program_abi( configurables: Some(configurables), } } - TyProgramKind::Library { .. } => program_abi::ProgramABI { - program_type: "library".to_string(), - spec_version, - encoding_version, - metadata_types: vec![], - concrete_types: vec![], - functions: vec![], - logged_types: None, - messages_types: None, - configurables: None, - }, + TyProgramKind::Library { .. } => { + let logged_types = + generate_logged_types(handler, ctx, engines, metadata_types, concrete_types)?; + let messages_types = + generate_messages_types(handler, ctx, engines, metadata_types, concrete_types)?; + + program_abi::ProgramABI { + program_type: "library".to_string(), + spec_version, + encoding_version, + metadata_types: metadata_types.to_vec(), + concrete_types: concrete_types.to_vec(), + functions: vec![], + logged_types: Some(logged_types), + messages_types: Some(messages_types), + configurables: None, + } + } }; standardize_json_abi_types(&mut program_abi); diff --git a/sway-core/src/asm_generation/finalized_asm.rs b/sway-core/src/asm_generation/finalized_asm.rs index 9c2d3f565ab..1bb66535693 100644 --- a/sway-core/src/asm_generation/finalized_asm.rs +++ b/sway-core/src/asm_generation/finalized_asm.rs @@ -1,5 +1,4 @@ use super::instruction_set::InstructionSet; -use super::ToMidenBytecode; use super::{ fuel::{checks, data_section::DataSection}, ProgramABI, ProgramKind, @@ -20,6 +19,24 @@ use sway_types::SourceEngine; use either::Either; use std::{collections::BTreeMap, fmt}; +/// Represents an ASM set which has had register allocation, jump elimination, and optimization +/// applied to it +#[derive(Clone, serde::Serialize)] +pub struct AsmInformation { + pub bytecode_size: u64, + pub data_section: DataSectionInformation, +} + +#[derive(Default, Clone, Debug, serde::Serialize)] +pub struct DataSectionInformation { + /// The total size of the data section in bytes + pub size: u64, + /// The used size of the data section in bytes + pub used: u64, + /// The data to be put in the data section of the asm + pub value_pairs: Vec, +} + /// Represents an ASM set which has had register allocation, jump elimination, and optimization /// applied to it #[derive(Clone)] @@ -78,10 +95,6 @@ impl FinalizedAsm { }) } } - InstructionSet::MidenVM { ops } => Ok(CompiledBytecode { - bytecode: ops.to_bytecode().into(), - named_data_section_entries_offsets: Default::default(), - }), } } } @@ -553,6 +566,5 @@ pub fn check_invalid_opcodes(handler: &Handler, asm: &FinalizedAsm) -> Result<() ProgramKind::Predicate => checks::check_predicate_opcodes(handler, &ops[..]), }, InstructionSet::Evm { ops: _ } => Ok(()), - InstructionSet::MidenVM { ops: _ } => Ok(()), } } diff --git a/sway-core/src/asm_generation/from_ir.rs b/sway-core/src/asm_generation/from_ir.rs index f29354c2fca..1a0435409ff 100644 --- a/sway-core/src/asm_generation/from_ir.rs +++ b/sway-core/src/asm_generation/from_ir.rs @@ -7,7 +7,6 @@ use super::{ fuel_asm_builder::FuelAsmBuilder, register_sequencer::RegisterSequencer, }, - MidenVMAsmBuilder, }; use crate::{asm_generation::ProgramKind, BuildConfig, BuildTarget}; @@ -57,13 +56,6 @@ pub fn compile_ir_context_to_finalized_asm( build_config, EvmAsmBuilder::new(kind, ir), ), - BuildTarget::MidenVM => compile( - handler, - ir, - module, - build_config, - MidenVMAsmBuilder::new(kind, ir), - ), }?; check_invalid_opcodes(handler, &finalized_asm)?; diff --git a/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs index ea11591842b..32ef5a7f538 100644 --- a/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/abstract_instruction_set.rs @@ -30,7 +30,7 @@ impl AbstractInstructionSet { .simplify_cfg() .remove_sequential_jumps() .remove_redundant_moves() - .remove_unused_ops() + .remove_redundant_ops() } /// Removes any jumps to the subsequent line. @@ -114,11 +114,18 @@ impl AbstractInstructionSet { self } - fn remove_unused_ops(mut self) -> AbstractInstructionSet { - // Just remove NOPs for now. - self.ops.retain(|op| match &op.opcode { - Either::Left(VirtualOp::NOOP) => false, - _otherwise => true, + fn remove_redundant_ops(mut self) -> AbstractInstructionSet { + self.ops.retain(|op| { + // It is easier to think in terms of operations we want to remove + // than the operations we want to retain ;-) + #[allow(clippy::match_like_matches_macro)] + // Keep the `match` for adding more ops in the future. + let remove = match &op.opcode { + Either::Left(VirtualOp::NOOP) => true, + _ => false, + }; + + !remove }); self diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index fc218425daf..0865687f5c8 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs @@ -35,6 +35,30 @@ pub struct AllocatedAbstractInstructionSet { } impl AllocatedAbstractInstructionSet { + pub(crate) fn optimize(self) -> AllocatedAbstractInstructionSet { + self.remove_redundant_ops() + } + + fn remove_redundant_ops(mut self) -> AllocatedAbstractInstructionSet { + self.ops.retain(|op| { + // It is easier to think in terms of operations we want to remove + // than the operations we want to retain ;-) + let remove = match &op.opcode { + // `cfei i0` and `cfsi i0` pairs. + Either::Left(AllocatedOpcode::CFEI(imm)) + | Either::Left(AllocatedOpcode::CFSI(imm)) => imm.value == 0u32, + // `cfe $zero` and `cfs $zero` pairs. + Either::Left(AllocatedOpcode::CFE(reg)) + | Either::Left(AllocatedOpcode::CFS(reg)) => reg.is_zero(), + _ => false, + }; + + !remove + }); + + self + } + /// Replace each PUSHA instruction with stores of all used registers to the stack, and each /// POPA with respective loads from the stack. /// diff --git a/sway-core/src/asm_generation/fuel/analyses.rs b/sway-core/src/asm_generation/fuel/analyses.rs index cfd4cb931d6..9bdcac0d489 100644 --- a/sway-core/src/asm_generation/fuel/analyses.rs +++ b/sway-core/src/asm_generation/fuel/analyses.rs @@ -17,9 +17,9 @@ use crate::asm_lang::{ControlFlowOp, Label, Op, VirtualRegister}; /// Two tables are generated: `live_in` and `live_out`. Each row in the tables corresponds to an /// instruction in the program. /// * A virtual register is in the `live_out` table for a given instruction if it is live on any -/// of that node's out-edges +/// of that node's out-edges /// * A virtual register is in the `live_in` table for a given instruction if it is live on any -/// of that node's in-edges +/// of that node's in-edges /// /// /// Algorithm: diff --git a/sway-core/src/asm_generation/fuel/data_section.rs b/sway-core/src/asm_generation/fuel/data_section.rs index 3db12443f4f..76f3300c705 100644 --- a/sway-core/src/asm_generation/fuel/data_section.rs +++ b/sway-core/src/asm_generation/fuel/data_section.rs @@ -4,7 +4,7 @@ use std::{fmt, iter::repeat}; // An entry in the data section. It's important for the size to be correct, especially for unions // where the size could be larger than the represented value. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, serde::Serialize)] pub struct Entry { pub value: Datum, pub padding: Padding, @@ -13,7 +13,7 @@ pub struct Entry { pub name: Option, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, serde::Serialize)] pub enum Datum { Byte(u8), Word(u64), diff --git a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs index a97ff923635..0e56e87d33f 100644 --- a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs +++ b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs @@ -114,7 +114,7 @@ impl<'ir, 'eng> AsmBuilder for FuelAsmBuilder<'ir, 'eng> { self.globals_section.insert(name, size_in_bytes); let global = self.globals_section.get_by_name(name).unwrap(); - let (decode_fn_label, _) = self.func_label_map.get(decode_fn).unwrap(); + let (decode_fn_label, _) = self.func_label_map.get(&decode_fn.get()).unwrap(); let dataid = self.data_section.insert_data_value(Entry::new_byte_array( encoded_bytes.clone(), Some(name.clone()), @@ -238,9 +238,7 @@ impl<'ir, 'eng> AsmBuilder for FuelAsmBuilder<'ir, 'eng> { entries, non_entries, reg_seqr, - crate::ExperimentalFlags { - new_encoding: context.experimental.new_encoding, - }, + context.experimental, ); // Compiled dependencies will not have any content and we diff --git a/sway-core/src/asm_generation/fuel/functions.rs b/sway-core/src/asm_generation/fuel/functions.rs index a53860e4204..42577c543d6 100644 --- a/sway-core/src/asm_generation/fuel/functions.rs +++ b/sway-core/src/asm_generation/fuel/functions.rs @@ -84,49 +84,9 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> { )); } } else { - // Put NUM_ARG_REGISTERS - 1 arguments into arg registers and rest into the stack. - for (idx, arg_val) in args.iter().enumerate() { - let arg_reg = self.value_to_register(arg_val)?; - // Except for the last arg register, the others hold an argument. - if idx < compiler_constants::NUM_ARG_REGISTERS as usize - 1 { - self.cur_bytecode.push(Op::register_move( - VirtualRegister::Constant(ConstantRegister::ARG_REGS[idx]), - arg_reg, - format!("[call]: pass argument {idx}"), - self.md_mgr.val_to_span(self.context, *arg_val), - )); - } else { - // All arguments [NUM_ARG_REGISTERS - 1 ..] go into the stack. - assert!( - self.locals_size_bytes() % 8 == 0, - "The size of locals is not word aligned" - ); - let stack_offset_bytes = self.locals_size_bytes() - + (((idx as u64 + 1) - compiler_constants::NUM_ARG_REGISTERS as u64) * 8); - assert!( - stack_offset_bytes - < self.locals_size_bytes() + (self.max_num_extra_args() * 8) - ); - self.cur_bytecode.push(Op { - opcode: Either::Left(VirtualOp::SW( - VirtualRegister::Constant(ConstantRegister::LocalsBase), - arg_reg, - VirtualImmediate12::new( - // The VM multiples the offset by 8, so we divide it by 8. - stack_offset_bytes / 8, - self.md_mgr - .val_to_span(self.context, *arg_val) - .unwrap_or(Span::dummy()), - ) - .expect("Too many arguments, cannot handle."), - )), - comment: format!("[call]: pass argument {idx} via its stack slot"), - owning_span: self.md_mgr.val_to_span(self.context, *arg_val), - }); - } - } // Register ARG_REGS[NUM_ARG_REGISTERS-1] must contain LocalsBase + locals_size // so that the callee can index the stack arguments from there. + // It's also useful for us to save the arguments to the stack next. if self.locals_size_bytes() <= TWELVE_BITS { self.cur_bytecode.push(Op { opcode: Either::Left(VirtualOp::ADDI( @@ -172,6 +132,51 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> { owning_span: self.md_mgr.val_to_span(self.context, *instr_val), }); } + + // Put NUM_ARG_REGISTERS - 1 arguments into arg registers and rest into the stack. + for (idx, arg_val) in args.iter().enumerate() { + let arg_reg = self.value_to_register(arg_val)?; + // Except for the last arg register, the others hold an argument. + if idx < compiler_constants::NUM_ARG_REGISTERS as usize - 1 { + self.cur_bytecode.push(Op::register_move( + VirtualRegister::Constant(ConstantRegister::ARG_REGS[idx]), + arg_reg, + format!("[call]: pass argument {idx}"), + self.md_mgr.val_to_span(self.context, *arg_val), + )); + } else { + // All arguments [NUM_ARG_REGISTERS - 1 ..] go into the stack. + assert!( + self.locals_size_bytes() % 8 == 0, + "The size of locals is not word aligned" + ); + let stack_offset = + (idx as u64 + 1) - compiler_constants::NUM_ARG_REGISTERS as u64; + let stack_offset_bytes = self.locals_size_bytes() + (stack_offset * 8); + assert!( + stack_offset_bytes + < self.locals_size_bytes() + (self.max_num_extra_args() * 8) + ); + self.cur_bytecode.push(Op { + opcode: Either::Left(VirtualOp::SW( + VirtualRegister::Constant( + ConstantRegister::ARG_REGS + [compiler_constants::NUM_ARG_REGISTERS as usize - 1], + ), + arg_reg, + VirtualImmediate12::new( + stack_offset, + self.md_mgr + .val_to_span(self.context, *arg_val) + .unwrap_or(Span::dummy()), + ) + .expect("Too many arguments, cannot handle."), + )), + comment: format!("[call]: pass argument {idx} via its stack slot"), + owning_span: self.md_mgr.val_to_span(self.context, *arg_val), + }); + } + } } // Set a new return address. diff --git a/sway-core/src/asm_generation/fuel/programs/abstract.rs b/sway-core/src/asm_generation/fuel/programs/abstract.rs index c30f72621e7..b5a8a12e302 100644 --- a/sway-core/src/asm_generation/fuel/programs/abstract.rs +++ b/sway-core/src/asm_generation/fuel/programs/abstract.rs @@ -17,10 +17,10 @@ use crate::{ VirtualImmediate18, VirtualImmediate24, }, decl_engine::DeclRefFunction, - ExperimentalFlags, }; use either::Either; use sway_error::error::CompileError; +use sway_features::ExperimentalFeatures; /// The entry point of an abstract program. pub(crate) struct AbstractEntry { @@ -44,7 +44,7 @@ pub(crate) struct AbstractProgram { entries: Vec, non_entries: Vec, reg_seqr: RegisterSequencer, - experimental: ExperimentalFlags, + experimental: ExperimentalFeatures, } impl AbstractProgram { @@ -57,7 +57,7 @@ impl AbstractProgram { entries: Vec, non_entries: Vec, reg_seqr: RegisterSequencer, - experimental: ExperimentalFlags, + experimental: ExperimentalFeatures, ) -> Self { AbstractProgram { kind, @@ -78,7 +78,7 @@ impl AbstractProgram { && self.data_section.value_pairs.is_empty() } - /// Adds prologue, globals allocation, before entries, contract method switch, and allocates virtual register + /// Adds prologue, globals allocation, before entries, contract method switch, and allocates virtual register. pub(crate) fn into_allocated_program( mut self, fallback_fn: Option, @@ -111,21 +111,21 @@ impl AbstractProgram { }) .collect(); - // Gather all functions + // Gather all functions. let all_functions = self .entries .into_iter() .map(|entry| entry.ops) .chain(self.non_entries); - // optimise and then verify these functions. + // Optimize and then verify abstract functions. let abstract_functions = all_functions .map(|instruction_set| instruction_set.optimize(&self.data_section)) .map(AbstractInstructionSet::verify) .collect::, CompileError>>()?; // Allocate the registers for each function. - let functions = abstract_functions + let allocated_functions = abstract_functions .into_iter() .map(|abstract_instruction_set| { let allocated = abstract_instruction_set.allocate_registers()?; @@ -133,7 +133,12 @@ impl AbstractProgram { }) .collect::, CompileError>>()?; - // XXX need to verify that the stack use for each function is balanced. + // Optimize allocated functions. + // TODO: Add verification. E.g., verify that the stack use for each function is balanced. + let functions = allocated_functions + .into_iter() + .map(|instruction_set| instruction_set.optimize()) + .collect::>(); Ok(AllocatedProgram { kind: self.kind, @@ -159,13 +164,13 @@ impl AbstractProgram { /// Right now, it looks like this: /// /// WORD OP - /// 1 MOV $scratch $pc - /// - JMPF $zero i2 - /// 2 DATA_START (0-32) (in bytes, offset from $is) - /// - DATA_START (32-64) - /// 3 LW $ds $scratch 1 - /// - ADD $ds $ds $scratch - /// 4 .program_start: + /// [1] MOV $scratch $pc + /// [-] JMPF $zero i2 + /// [2] DATA_START (0-32) (in bytes, offset from $is) + /// [-] DATA_START (32-64) + /// [3] LW $ds $scratch 1 + /// [-] ADD $ds $ds $scratch + /// [4] .program_start: fn build_prologue(&mut self) -> AllocatedAbstractInstructionSet { let label = self.reg_seqr.get_label(); AllocatedAbstractInstructionSet { diff --git a/sway-core/src/asm_generation/fuel/register_allocator.rs b/sway-core/src/asm_generation/fuel/register_allocator.rs index 8e02d2d29fa..b3304563222 100644 --- a/sway-core/src/asm_generation/fuel/register_allocator.rs +++ b/sway-core/src/asm_generation/fuel/register_allocator.rs @@ -121,8 +121,8 @@ impl RegisterPool { /// add edges (v, b_1), ..., (v, b_n) for any b_i different from c. /// 3. for non-MOVE def of virtual register v with live_out virtual registers b_1, ..., b_n: /// add edges (v, b_1), ..., (v, b_n) -/// =============================================================================================== /// +/// =============================================================================================== pub(crate) fn create_interference_graph( ops: &[Op], live_out: &[BTreeSet], @@ -191,8 +191,8 @@ pub(crate) fn create_interference_graph( /// * When two registers are coalesced, a new node with a new virtual register (generated using the /// register sequencer) is created in the interference graph. /// * When a MOVE instruction is removed, the offset of each subsequent instruction has to be -/// updated, as well as the immediate values for some or all jump instructions (`ji`, `jnei`, and -/// `jnzi for now). +/// updated, as well as the immediate values for some or all jump instructions (`ji`, `jnei`, and +/// `jnzi for now). /// pub(crate) fn coalesce_registers( ops: &[Op], @@ -386,6 +386,7 @@ fn compute_def_use_points(ops: &[Op]) -> FxHashMap, /// 3. If some vertex n still has k or more neighbors, then the graph may not be k colorable. /// We still add it to the stack as is, as a potential spill. When popping, if we still /// can't colour it, then it becomes an actual spill. +/// /// =============================================================================================== /// pub(crate) fn color_interference_graph( diff --git a/sway-core/src/asm_generation/instruction_set.rs b/sway-core/src/asm_generation/instruction_set.rs index 6e5f007e305..c96c3f69df0 100644 --- a/sway-core/src/asm_generation/instruction_set.rs +++ b/sway-core/src/asm_generation/instruction_set.rs @@ -4,15 +4,8 @@ use std::fmt; /// An [InstructionSet] is produced by allocating registers on an [AbstractInstructionSet]. #[derive(Clone)] pub enum InstructionSet { - Fuel { - ops: Vec, - }, - Evm { - ops: Vec, - }, - MidenVM { - ops: Vec, - }, + Fuel { ops: Vec }, + Evm { ops: Vec }, } impl fmt::Display for InstructionSet { @@ -31,12 +24,6 @@ impl fmt::Display for InstructionSet { .map(|x| format!("{x}")) .collect::>() .join("\n"), - InstructionSet::MidenVM { ops } => { - ops.iter() - .map(|x| format!("{x}")) - .collect::>() - .join("\n") - } } ) } diff --git a/sway-core/src/asm_generation/miden_vm/miden_vm_asm_builder.rs b/sway-core/src/asm_generation/miden_vm/miden_vm_asm_builder.rs deleted file mode 100644 index 87696ca002a..00000000000 --- a/sway-core/src/asm_generation/miden_vm/miden_vm_asm_builder.rs +++ /dev/null @@ -1,705 +0,0 @@ -#![allow(dead_code)] -use std::{collections::HashMap, sync::Arc}; -mod miden_op; -use indexmap::IndexMap; -pub use miden_op::MidenAsmOp; - -use crate::{ - asm_generation::{ - asm_builder::AsmBuilder, - from_ir::StateAccessType, - fuel::data_section::DataSection, - instruction_set::InstructionSet, - miden_vm::miden_vm_asm_builder::miden_op::{MidenStackValue, Push}, - FinalizedAsm, ProgramKind, - }, - asm_lang::Label, - metadata::MetadataManager, - BuildConfig, -}; - -use sway_error::{ - error::CompileError, - handler::{ErrorEmitted, Handler}, -}; -use sway_ir::{Context, *}; -use sway_types::Span; - -pub use miden_op::DirectOp; - -#[derive(Default)] -pub struct MidenVMAsmSection { - ops: Vec, -} - -/// A procedure block is used to define a frequently-used sequence of instructions. A procedure must -/// start with a proc.