From baadafaf7178a19c7ac32120cc468a1a24544b6d Mon Sep 17 00:00:00 2001 From: Samyak Date: Tue, 26 Mar 2019 00:17:45 +0530 Subject: [PATCH] isExecutable function to modifier --- contracts/UserWallet.sol | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contracts/UserWallet.sol b/contracts/UserWallet.sol index feeb414..71e25d3 100644 --- a/contracts/UserWallet.sol +++ b/contracts/UserWallet.sol @@ -325,9 +325,9 @@ contract InstaWallet is UserManager, UserNote { public payable note + isExecutable(_target) returns (bytes memory response) { - require(isExecutable(_target), "not-executable"); lastActivity = block.timestamp; emit LogExecute( msg.sender, @@ -359,17 +359,20 @@ contract InstaWallet 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) public view returns (bool) { + modifier isExecutable(address proxyTarget) { require(proxyTarget != address(0), "logic-proxy-address-required"); (bool isLogic, bool isDefault) = isLogicAuthorised(proxyTarget); require(isLogic, "logic-proxy-address-not-allowed"); + bool canExecute = false; if (isAuth(msg.sender)) { - return true; + canExecute = true; } else if (isManager(msg.sender) && !isDefault) { - return true; + canExecute = true; } else { - return false; + canExecute = false; } + require(canExecute, "not-executable"); + _; } } \ No newline at end of file