-
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): reduce gas cost by skipping reading storage for `dele…
…gates()` (#17487) Co-authored-by: Daniel Wang <[email protected]>
- Loading branch information
Showing
1 changed file
with
10 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,13 @@ import "./TaikoTokenBase.sol"; | |
/// 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800 (token.taiko.eth) | ||
/// @custom:security-contact [email protected] | ||
contract TaikoToken is TaikoTokenBase { | ||
address private constant _TAIKO_L1 = 0x06a9Ab27c7e2255df1815E6CC0168d7755Feb19a; | ||
address private constant _ERC20_VAULT = 0x996282cA11E5DEb6B5D122CC3B9A1FcAAD4415Ab; | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
/// @param _recipient The address to receive initial token minting. | ||
|
||
function init(address _owner, address _recipient) public initializer { | ||
__Essential_init(_owner); | ||
__ERC20_init("Taiko Token", "TKO"); | ||
|
@@ -22,4 +26,10 @@ contract TaikoToken is TaikoTokenBase { | |
// Mint 1 billion tokens | ||
_mint(_recipient, 1_000_000_000 ether); | ||
} | ||
|
||
function delegates(address account) public view virtual override returns (address) { | ||
// Special checks to avoid reading from storage slots | ||
if (account == _TAIKO_L1 || account == _ERC20_VAULT) return address(0); | ||
else return super.delegates(account); | ||
} | ||
} |