Skip to content

Commit e546a4f

Browse files
uri-99JuArceMauroToscano
authored
feat(contract): withdraw_from_service_manager in BatcherPaymentService.sol (#1772)
Co-authored-by: JuArce <[email protected]> Co-authored-by: MauroFab <[email protected]>
1 parent 9f48e2c commit e546a4f

File tree

4 files changed

+2278
-2430
lines changed

4 files changed

+2278
-2430
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"addresses": {
3+
"batcherPaymentService": "0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650",
4+
"batcherPaymentServiceImplementation": "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0"
5+
}
6+
}

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/scripts/anvil/state/eigenlayer-deployed-anvil-state.json

Lines changed: 2245 additions & 2425 deletions
Large diffs are not rendered by default.

contracts/src/core/BatcherPaymentService.sol

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,23 @@ contract BatcherPaymentService is
7575
alignedLayerServiceManager = _alignedLayerServiceManager;
7676
batcherWallet = _batcherWallet;
7777
}
78-
78+
7979
// PAYABLE FUNCTIONS
80+
/**
81+
* @notice Fallback function to receive ETH payments
82+
* @dev This function handles two scenarios:
83+
* 1. Direct user deposits: Updates the user's balance and emits an event
84+
* 2. Batcher withdrawals from ServiceManager: Ignores balance updates since they don't apply
85+
*/
86+
8087
receive() external payable {
81-
userData[msg.sender].balance += msg.value;
82-
userData[msg.sender].unlockBlockTime = 0;
83-
emit PaymentReceived(msg.sender, msg.value);
88+
// Skip balance updates when receiving funds from ServiceManager withdrawals
89+
if (msg.sender != address(alignedLayerServiceManager)) {
90+
// Only update balances for direct user deposits
91+
userData[msg.sender].balance += msg.value;
92+
userData[msg.sender].unlockBlockTime = 0;
93+
emit PaymentReceived(msg.sender, msg.value);
94+
}
8495
}
8596

8697
// PUBLIC FUNCTIONS
@@ -178,6 +189,17 @@ contract BatcherPaymentService is
178189
emit FundsWithdrawn(msg.sender, amount);
179190
}
180191

192+
193+
function withdrawFromServiceManager(
194+
uint256 amount,
195+
address withdrawAddress
196+
) public payable onlyOwner {
197+
alignedLayerServiceManager.withdraw(amount); // reverts if InsufficientBalance
198+
// money is now in this contract
199+
// we transfer it to the withdraw address
200+
payable(withdrawAddress).transfer(amount); // non-reentrant since .transfer() has low gas limit.
201+
}
202+
181203
function pause() public onlyOwner {
182204
_pause();
183205
}

0 commit comments

Comments
 (0)