-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: xSuperchainERC20 #275
base: sc-feat/xsuperc20
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,328 @@ | |||
// SPDX-License-Identifier: UNLICENSED | |||
pragma solidity >=0.8.4 <0.9.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XERC20
current implementation allows you to compile using a wide range of solidity versions but SuperchainERC20
is using a fixed version, in this case I think it is a good idea to use the more restrictive option to reduce compatibility errores. Use pragma solidity 0.8.25;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pragma solidity >=0.8.4 <0.9.0; | ||
|
||
import { IXERC20 } from "interfaces/L2/IXERC20.sol"; | ||
import { ERC20 } from "@solady-v0.0.245/tokens/ERC20.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
/// @title XSuperchainERC20 | ||
/// @notice A SuperchainERC20 + xERC20 implementation | ||
contract XSuperchainERC20 is SuperchainERC20, Ownable, IXERC20 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets make the contract abstract
like SuperchainERC20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string private _name; | ||
|
||
/** | ||
* @notice The symbol of the token | ||
*/ | ||
string private _symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these variables (since the contract will be abstract the override of the name()
and symbol()
functions should be done in the derived contract)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string memory __name, | ||
string memory __symbol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these params (since the contract will be abstract the override of the name()
and symbol()
functions should be done in the derived contract)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_name = __name; | ||
_symbol = __symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these assignations (since the contract will be abstract the override of the name()
and symbol()
functions should be done in the derived contract)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* @notice Returns the name of the token | ||
* | ||
* @return _name The name of the token | ||
*/ | ||
function name() public view override returns (string memory) { | ||
return _name; | ||
} | ||
|
||
/** | ||
* @notice Returns the symbol of the token | ||
* | ||
* @return _symbol The symbol of the token | ||
*/ | ||
function symbol() public view override returns (string memory) { | ||
return _symbol; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these functions (since the contract will be abstract the override of the name()
and symbol()
functions should be done in the derived contract)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
contract XSuperchainERC20Test is SuperchainERC20Test { | ||
function setUp() public override { | ||
superchainERC20 = new XSuperchainERC20("Test", "TEST", address(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the contract will be abstract a mock contract will be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param _bridge The address of the bridge we are setting the limits too | ||
*/ | ||
function setLimits(address _bridge, uint256 _mintingLimit, uint256 _burningLimit) external onlyOwner { | ||
if (_mintingLimit > (type(uint256).max / 2) || _burningLimit > (type(uint256).max / 2)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use bit shifting for this one. Just because it looks cooler 😎
if (_mintingLimit > (type(uint256).max / 2) || _burningLimit > (type(uint256).max / 2)) { | |
if (_mintingLimit > (type(uint256).max >> 1) || _burningLimit > (type(uint256).max >> 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look cooler? I think you mean saving 2 gas per tx 😎 perf(xSupERC20): optimize uint256/2 check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should add this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how that lib showed up lol. Fixed in chore: remove automate lib
No description provided.