Skip to content

Commit 97bc750

Browse files
authored
Call into EntryPoint's receive fallback via deposit() for gas savings (#16)
1 parent 553d565 commit 97bc750

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Paymaster.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ contract Paymaster is BasePaymaster {
9898
}
9999

100100
receive() external payable {
101-
deposit();
101+
(bool callSuccess, ) = payable(address(entryPoint)).call{value: msg.value}("");
102+
require(callSuccess, "Deposit failed");
102103
}
103-
}
104+
}

test/Paymaster.t.sol

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ contract PaymasterTest is Test {
123123
entrypoint.simulateValidation(userOp);
124124
}
125125

126+
function test_receive() public {
127+
assertEq(0, entrypoint.balanceOf(address(paymaster)));
128+
(bool callSuccess, ) = address(paymaster).call{value: 1 ether}("");
129+
require(callSuccess, "Receive failed");
130+
assertEq(1 ether, entrypoint.balanceOf(address(paymaster)));
131+
}
132+
126133
function createUserOp() public view returns (UserOperation memory) {
127134
UserOperation memory userOp;
128135
userOp.sender = address(account);

0 commit comments

Comments
 (0)