-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: APACHE-2.0 | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { Paymaster } from "src/v1/Paymaster.sol"; | ||
import { BaseScript } from "../Base.s.sol"; | ||
|
||
/// @title PaymasterWithdrawAsOperator | ||
/// @notice Withdraw funds to an arbitrary address | ||
/// @dev Can only be called by the owner of the paymaster | ||
contract PaymasterWithdrawAsOperator is BaseScript { | ||
function run() public payable broadcast { | ||
address paymasterAddress = vm.envAddress("PAYMASTER"); | ||
|
||
Paymaster paymaster = Paymaster(paymasterAddress); | ||
|
||
// get the initial balance of the paymaster | ||
uint256 initialBalance = paymaster.getDeposit(); | ||
uint256 amount = vm.envOr("AMOUNT", initialBalance); | ||
|
||
// ensure we don't withdraw more than the paymaster has | ||
require(initialBalance >= amount, "Insufficient deposited funds"); | ||
|
||
// withdraw some funds to the recipient | ||
paymaster.withdrawTo(amount); | ||
|
||
// check that the withdraw was successful | ||
require(paymaster.getDeposit() == initialBalance - amount, "Withdraw failed"); | ||
} | ||
} |