-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): allow GuardianProver set TKO allowance for TaikoL1 (#…
…16831) Co-authored-by: David <[email protected]>
- Loading branch information
1 parent
bdf05eb
commit ce7076c
Showing
5 changed files
with
31 additions
and
7 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
import "../../common/LibStrings.sol"; | ||
import "../../verifiers/IVerifier.sol"; | ||
import "../tiers/ITierProvider.sol"; | ||
|
@@ -11,7 +14,10 @@ import "./Guardians.sol"; | |
/// This prover uses itself as the verifier. | ||
/// @custom:security-contact [email protected] | ||
contract GuardianProver is IVerifier, Guardians { | ||
using SafeERC20 for IERC20; | ||
|
||
error GV_PERMISSION_DENIED(); | ||
error GV_ZERO_ADDRESS(); | ||
|
||
uint256[50] private __gap; | ||
|
||
|
@@ -36,6 +42,25 @@ contract GuardianProver is IVerifier, Guardians { | |
__Essential_init(_owner, _addressManager); | ||
} | ||
|
||
/// @notice Enables unlimited allowance for Taiko L1 contract. | ||
/// param _enable true if unlimited allowance is approved, false to set the allowance to 0. | ||
function enableTaikoTokenAllowance(bool _enable) external onlyOwner { | ||
address tko = resolve(LibStrings.B_TAIKO_TOKEN, false); | ||
address taiko = resolve(LibStrings.B_TAIKO, false); | ||
IERC20(tko).safeApprove(taiko, _enable ? type(uint256).max : 0); | ||
} | ||
|
||
/// @dev Withdraws Taiko Token to a given address. | ||
/// @param _to The recipient address. | ||
/// @param _amount The amount of Taiko token to withdraw. Use 0 for all balance. | ||
function withdrawTaikoToken(address _to, uint256 _amount) external onlyOwner { | ||
if (_to == address(0)) revert GV_ZERO_ADDRESS(); | ||
|
||
IERC20 tko = IERC20(resolve(LibStrings.B_TAIKO_TOKEN, false)); | ||
uint256 amount = _amount == 0 ? tko.balanceOf(address(this)) : _amount; | ||
tko.safeTransfer(_to, amount); | ||
} | ||
|
||
/// @dev Called by guardians to approve a guardian proof | ||
/// @param _meta The block's metadata. | ||
/// @param _tran The valid transition. | ||
|
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
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