Skip to content

Commit

Permalink
fix: Use handled flavour for safecall and call when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
donosonaumczuk committed Jan 17, 2025
1 parent a0bb896 commit 96c48f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
11 changes: 1 addition & 10 deletions contracts/core/upgradeability/ProxyAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ contract ProxyAdmin is Ownable {
// - Cannot opt-in to auto-upgrade in the Proxy
require(selector != BeaconProxy.proxy__optInToAutoUpgrade.selector, Errors.Locked());
}
// Do the call
(bool callSucceeded, bytes memory ret) = to.safecall(value, data);
if (!callSucceeded) {
assembly {
// Equivalent to reverting with the returned error selector if the length is not zero.
let length := mload(ret)
if iszero(iszero(length)) { revert(add(ret, 32), length) }
}
}
return ret;
return to.handledsafecall(value, data);
}
}
14 changes: 5 additions & 9 deletions contracts/extensions/account/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import {ExtraStorageBased} from "contracts/core/base/ExtraStorageBased.sol";
import {MetadataBased} from "contracts/core/base/MetadataBased.sol";
import {Initializable} from "contracts/core/upgradeability/Initializable.sol";
import {Errors} from "contracts/core/types/Errors.sol";
import {CallLib} from "contracts/core/libraries/CallLib.sol";

contract Account is IAccount, Initializable, Ownable, IERC721Receiver, ExtraStorageBased, MetadataBased {
using CallLib for address;

// TODO: Think how long the timelock should be and should it be configurable
uint256 constant SPENDING_TIMELOCK = 1 hours;

Expand Down Expand Up @@ -156,16 +159,9 @@ contract Account is IAccount, Initializable, Ownable, IERC721Receiver, ExtraStor
require($storage().accountManagerPermissions[msg.sender].canTransferTokens, Errors.NotAllowed());
}
}
(bool callSucceeded, bytes memory ret) = to.call{value: value}(data);
if (!callSucceeded) {
assembly {
// Equivalent to reverting with the returned error selector if the length is not zero.
let length := mload(ret)
if iszero(iszero(length)) { revert(add(ret, 32), length) }
}
}
bytes memory returnData = to.handledcall(value, data);
emit Lens_Account_TransactionExecuted(to, value, data, msg.sender);
return ret;
return returnData;
}

receive() external payable override {}
Expand Down

0 comments on commit 96c48f6

Please sign in to comment.