This is a work in progress Prettier Plugin for Refactoring Solidity 0.4.X code to 0.5.X code. This tool does the following tasks currently to refactor your soldiity 0.4.X code to work with solidity 0.5.X:
- Change pragma version to
calldatastorage keyword infront of
externalfunction complex parameters and
memoryinfront of other function's complex parameters that don't already have a defined parameter storage location.
- Rename constructor function from
- Add default function visibility of
publicto those normal functions which don't have function visibility explicitly defined.
- Add function visibility of
externalto fallback functions and all functions of any interface.
constantfunction state mutability modifier to
- Prettify your code using prettier.
npm install --save-dev prettier prettier-plugin-solidity-refactor
yarn add --dev prettier prettier-plugin-solidity-refactor
This plugin allows you to configure prettier to your needs. Command with my personal config is
./node_modules/.bin/prettier --write --tab-width 4 --print-width 140 '**/*.sol'
OR command with default config that will just print changed contracts to stdout instead of actually making chnages:
You may add the command script to your package.json file and then use
npm run scriptName to execute the command.
- It does not add
payableto addresses as it can not detect which addresses require to be payable. If you are using
addressA.transfer, please manually declare them as
address payable addressArather than
- It does not redefine expired variables. In solidity 0.4.X, variables persisted even outside their scope but in soldiity 0.5.x, you need to define them again.
- It does not fix illegal implicit conversions.
- Low level
callnow returns 2 parameters rather than 1. This plugin does not rafactor it.
None. Please report the bugs you may find.
- Add test cases.
Contributions of any kind are welcome.
NOTE: This tool is still under early testing. Please always manually verify all your contracts after using this tool.