check-wasm.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. set -e
  3. mydir=$(dirname "$0")
  4. cd "$mydir" || exit
  5. cd ..
  6. # Check contract wasm binary by crate name
  7. check_wasm () {
  8. local CONTRACT_CRATE_NAME=$1
  9. local CONTRACT_BIN_NAME="${CONTRACT_CRATE_NAME//-/_}.wasm"
  10. echo
  11. echo "Checking contract $CONTRACT_CRATE_NAME"
  12. cargo stylus check -e https://sepolia-rollup.arbitrum.io/rpc --wasm-file ./target/wasm32-unknown-unknown/release/"$CONTRACT_BIN_NAME"
  13. }
  14. # Retrieve all alphanumeric contract's crate names in `./examples` directory.
  15. get_example_crate_names () {
  16. # shellcheck disable=SC2038
  17. # NOTE: optimistically relying on the 'name = ' string at Cargo.toml file
  18. find ./examples -maxdepth 2 -type f -name "Cargo.toml" | xargs grep 'name = ' | grep -oE '".*"' | tr -d "'\""
  19. }
  20. rustup install nightly-2025-07-03
  21. rustup component add rust-src --toolchain nightly-2025-07-03
  22. cargo +nightly-2025-07-03 build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
  23. for CRATE_NAME in $(get_example_crate_names)
  24. do
  25. check_wasm "$CRATE_NAME"
  26. done