transpile.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -euo pipefail -x
  3. DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
  4. bash "$DIRNAME/patch-apply.sh"
  5. npm run clean
  6. npm run compile
  7. build_info=($(jq -r '.input.sources | keys | if any(test("^contracts/mocks/.*\\bunreachable\\b")) then empty else input_filename end' artifacts/build-info/*))
  8. build_info_num=${#build_info[@]}
  9. if [ $build_info_num -ne 1 ]; then
  10. echo "found $build_info_num relevant build info files but expected just 1"
  11. exit 1
  12. fi
  13. # -D: delete original and excluded files
  14. # -b: use this build info file
  15. # -i: use included Initializable
  16. # -x: exclude proxy-related contracts with a few exceptions
  17. # -p: emit public initializer
  18. # -n: use namespaces
  19. # -N: exclude from namespaces transformation
  20. npx @openzeppelin/upgrade-safe-transpiler@latest -D \
  21. -b "$build_info" \
  22. -i contracts/proxy/utils/Initializable.sol \
  23. -x 'contracts-exposed/**/*' \
  24. -x 'contracts/proxy/**/*' \
  25. -x '!contracts/proxy/Clones.sol' \
  26. -x '!contracts/proxy/ERC1967/ERC1967Storage.sol' \
  27. -x '!contracts/proxy/ERC1967/ERC1967Utils.sol' \
  28. -x '!contracts/proxy/utils/UUPSUpgradeable.sol' \
  29. -x '!contracts/proxy/beacon/IBeacon.sol' \
  30. -p 'contracts/**/presets/**/*' \
  31. -n \
  32. -N 'contracts/mocks/**/*'
  33. # delete compilation artifacts of vanilla code
  34. npm run clean