Skip to content

Commit 786154c

Browse files
committed
bubble up revert message
1 parent 7a0c3b6 commit 786154c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

contracts/prebuilts/unaudited/checkout/TargetCheckout.sol

+14-3
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,28 @@ contract TargetCheckout is IPluginCheckout {
5252

5353
function _execute(UserOp memory op) internal {
5454
bool success;
55+
bytes memory response;
5556
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) {
56-
(success, ) = op.target.call{ value: op.valueToSend }(op.data);
57+
(success, response) = op.target.call{ value: op.valueToSend }(op.data);
5758
} else {
5859
if (op.valueToSend != 0 && op.approvalRequired) {
5960
IERC20(op.currency).approve(op.target, op.valueToSend);
6061
}
6162

62-
(success, ) = op.target.call(op.data);
63+
(success, response) = op.target.call(op.data);
6364
}
6465

65-
require(success, "Execution failed");
66+
if (!success) {
67+
// If there is return data, the delegate call reverted with a reason or a custom error, which we bubble up.
68+
if (response.length > 0) {
69+
assembly {
70+
let returndata_size := mload(response)
71+
revert(add(32, response), returndata_size)
72+
}
73+
} else {
74+
revert("Checkout: Execution Failed");
75+
}
76+
}
6677
}
6778

6879
function _canExecute(UserOp memory op, address caller) internal view returns (bool) {

0 commit comments

Comments
 (0)