transpile.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -euo pipefail -x
  3. VERSION="$(jq -r .version contracts/package.json)"
  4. DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
  5. bash "$DIRNAME/patch-apply.sh"
  6. sed -i'' -e "s/<package-version>/$VERSION/g" "contracts/package.json"
  7. git add contracts/package.json
  8. npm run clean
  9. npm run compile
  10. build_info=($(jq -r '.input.sources | keys | if any(test("^contracts/mocks/.*\\bunreachable\\b")) then empty else input_filename end' artifacts/build-info/*))
  11. build_info_num=${#build_info[@]}
  12. if [ $build_info_num -ne 1 ]; then
  13. echo "found $build_info_num relevant build info files but expected just 1"
  14. exit 1
  15. fi
  16. # -D: delete original and excluded files
  17. # -b: use this build info file
  18. # -i: use included Initializable
  19. # -x: exclude proxy-related contracts with a few exceptions
  20. # -p: emit public initializer
  21. # -n: use namespaces
  22. # -N: exclude from namespaces transformation
  23. # -q: partial transpilation using @openzeppelin/contracts as peer project
  24. npx @openzeppelin/upgrade-safe-transpiler -D \
  25. -b "$build_info" \
  26. -i contracts/proxy/utils/Initializable.sol \
  27. -x 'contracts-exposed/**/*' \
  28. -x 'contracts/proxy/**/*' \
  29. -x '!contracts/proxy/Clones.sol' \
  30. -x '!contracts/proxy/ERC1967/ERC1967Storage.sol' \
  31. -x '!contracts/proxy/ERC1967/ERC1967Utils.sol' \
  32. -x '!contracts/proxy/utils/UUPSUpgradeable.sol' \
  33. -x '!contracts/proxy/beacon/IBeacon.sol' \
  34. -p 'contracts/access/manager/AccessManager.sol' \
  35. -p 'contracts/finance/VestingWallet.sol' \
  36. -p 'contracts/governance/TimelockController.sol' \
  37. -p 'contracts/metatx/ERC2771Forwarder.sol' \
  38. -n \
  39. -N 'contracts/mocks/**/*' \
  40. -q '@openzeppelin/'
  41. # delete compilation artifacts of vanilla code
  42. npm run clean