OpenST / mosaic-contracts

Mosaic-0: Gateways and anchors on top of Ethereum to scale DApps
https://discuss.openst.org/c/mosaic
MIT License
114 stars 31 forks source link

Merge util.sol and OpenSTHelper.sol to a library contract #208

Closed abhayks1 closed 6 years ago

abhayks1 commented 6 years ago

Problem

Currently there are 2 utility files OpenSTHelper.sol and util.sol There is a code repetition for one function bytes32tobytes. util.sol

method: bytes32ToBytes Consumed By: Core.sol Type: Contract

OpenSTHelper.sol

methods: bytes32ToBytes, storageVariablePath, verifyIntentStorage Consumed By: OpenSTUtility.sol, OpenSTValue.sol, OpenSTHelperTest.sol Type: Library

Solution

Analyse the code for dependencies of both files Create a single library contract ProofLib.sol and include code from both files. Library contract name: ProofLib.sol because all 3 methods are proof related. bytes32ToBytes method is common among them. util.sol has more methods but it's not used anywhere. Preserve / mention the credit of original repo in the header. Update the test cases. Github Code

util.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/f2f3b7c0fc3e440225b339733b4bac85282d3d36/contracts/util.sol#L15 Core.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/f2f3b7c0fc3e440225b339733b4bac85282d3d36/contracts/Core.sol#L133

OpenSTHelper.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/develop/contracts/OpenSTHelper.sol OpenSTUtility.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/f2f3b7c0fc3e440225b339733b4bac85282d3d36/contracts/OpenSTUtility.sol#L311 OpenSTValue.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/f2f3b7c0fc3e440225b339733b4bac85282d3d36/contracts/OpenSTValue.sol#L452 OpenSTHelperTest.sol => https://github.com/OpenSTFoundation/openst-protocol/blob/develop/contracts/OpenSTHelperTest.sol

schemar commented 6 years ago

@abhayks1 what's the status on this issue? I assume it's closed with #211.