isExecutable function to modifier

This commit is contained in:
Samyak 2019-03-26 00:17:45 +05:30
parent fa844cc2cd
commit baadafaf71

View File

@ -325,9 +325,9 @@ contract InstaWallet is UserManager, UserNote {
public public
payable payable
note note
isExecutable(_target)
returns (bytes memory response) returns (bytes memory response)
{ {
require(isExecutable(_target), "not-executable");
lastActivity = block.timestamp; lastActivity = block.timestamp;
emit LogExecute( emit LogExecute(
msg.sender, msg.sender,
@ -359,17 +359,20 @@ contract InstaWallet is UserManager, UserNote {
* and if the sender is owner or contract itself or manager * and if the sender is owner or contract itself or manager
* and if manager then Throws if target is default proxy address * and if manager then Throws if target is default proxy address
*/ */
function isExecutable(address proxyTarget) public view returns (bool) { modifier isExecutable(address proxyTarget) {
require(proxyTarget != address(0), "logic-proxy-address-required"); require(proxyTarget != address(0), "logic-proxy-address-required");
(bool isLogic, bool isDefault) = isLogicAuthorised(proxyTarget); (bool isLogic, bool isDefault) = isLogicAuthorised(proxyTarget);
require(isLogic, "logic-proxy-address-not-allowed"); require(isLogic, "logic-proxy-address-not-allowed");
bool canExecute = false;
if (isAuth(msg.sender)) { if (isAuth(msg.sender)) {
return true; canExecute = true;
} else if (isManager(msg.sender) && !isDefault) { } else if (isManager(msg.sender) && !isDefault) {
return true; canExecute = true;
} else { } else {
return false; canExecute = false;
} }
require(canExecute, "not-executable");
_;
} }
} }