From ea51cfdee979ae692ad991790e1463a5eef129ae Mon Sep 17 00:00:00 2001 From: Sowmayjain Date: Wed, 20 Mar 2019 01:06:11 +0530 Subject: [PATCH] Code refactoring. --- contracts/AddressRegistry.sol | 17 +++++++++++------ contracts/{UserProxy.sol => UserWallet.sol} | 7 +++---- 2 files changed, 14 insertions(+), 10 deletions(-) rename contracts/{UserProxy.sol => UserWallet.sol} (97%) diff --git a/contracts/AddressRegistry.sol b/contracts/AddressRegistry.sol index 3a471c0..d529c8c 100644 --- a/contracts/AddressRegistry.sol +++ b/contracts/AddressRegistry.sol @@ -11,11 +11,6 @@ contract AddressRegistry { mapping(bytes32 => address) registry; - constructor() public { - registry[keccak256(abi.encodePacked("admin"))] = msg.sender; - registry[keccak256(abi.encodePacked("owner"))] = msg.sender; - } - modifier isAdmin() { require( msg.sender == getAddress("admin") || @@ -106,7 +101,7 @@ contract LogicRegistry is AddressRegistry { /** * @title User Wallet Registry */ -contract ProxyRegistry is LogicRegistry { +contract WalletRegistry is LogicRegistry { event Created(address indexed sender, address indexed owner, address proxy); @@ -170,4 +165,14 @@ contract ProxyRegistry is LogicRegistry { managerEnabled = false; } +} + + +contract Registry is WalletRegistry { + + constructor() public { + registry[keccak256(abi.encodePacked("admin"))] = msg.sender; + registry[keccak256(abi.encodePacked("owner"))] = msg.sender; + } + } \ No newline at end of file diff --git a/contracts/UserProxy.sol b/contracts/UserWallet.sol similarity index 97% rename from contracts/UserProxy.sol rename to contracts/UserWallet.sol index 668ab61..daf8d45 100644 --- a/contracts/UserProxy.sol +++ b/contracts/UserWallet.sol @@ -188,7 +188,7 @@ contract UserGuardian is UserAuth { /** * @dev Throws if the msg.sender is not guardian */ - function isGuardian() internal returns (bool) { + function isGuardian() internal view returns (bool) { if (msg.sender == guardians[1] || msg.sender == guardians[2] || msg.sender == guardians[3]) { return true; } else { @@ -233,7 +233,7 @@ contract UserManager is UserGuardian { /** * @dev Throws if the msg.sender is not manager */ - function isManager() internal returns (bool) { + function isManager() internal view returns (bool) { if (msg.sender == managers[1] || msg.sender == managers[2] || msg.sender == managers[3]) { return true; } else { @@ -287,7 +287,6 @@ contract UserWallet is UserManager, UserNote { /** * @dev sets the "address registry", owner's last activity, owner's active period and initial owner * @param _owner initial owner of the contract - * @param _logicRegistryAddr address registry address which have logic proxy registry */ constructor(address _owner) public { registry = msg.sender; @@ -344,7 +343,7 @@ contract UserWallet is UserManager, UserNote { * and if the sender is owner or contract itself or manager * and if manager then Throws if target is default proxy address */ - function isExecutable(address proxyTarget) internal returns (bool) { + function isExecutable(address proxyTarget) internal view returns (bool) { (bool isLogic, bool isDefault) = isLogicAuthorised(proxyTarget); require(isLogic, "logic-proxy-address-not-allowed"); if (isAuth(msg.sender)) {