check-wasm.sh 951 B

123456789101112131415161718192021222324252627282930
  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. cargo build --release --target wasm32-unknown-unknown -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
  21. for CRATE_NAME in $(get_example_crate_names)
  22. do
  23. check_wasm "$CRATE_NAME"
  24. done