-
Notifications
You must be signed in to change notification settings - Fork 5
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
erc20 proxy deploy #115
erc20 proxy deploy #115
Changes from 5 commits
994939b
521ae0c
d3bc98a
df2198e
f10b6b5
ab249c2
aa247ec
c04070c
fa76d8a
c6bac08
3709448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,30 @@ import {IJBToken} from "./interfaces/IJBToken.sol"; | |
|
||
/// @notice An ERC-20 token that can be used by a project in the `JBTokens`. | ||
contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken { | ||
//*********************************************************************// | ||
// --------------------- internal stored properties ------------------ // | ||
//*********************************************************************// | ||
|
||
/// @notice The token's name. | ||
string private _name; | ||
|
||
/// @notice The token's symbol. | ||
string private _symbol; | ||
|
||
//*********************************************************************// | ||
// -------------------------- public views --------------------------- // | ||
//*********************************************************************// | ||
|
||
/// @notice The token's name. | ||
function name() public view virtual override returns (string memory) { | ||
return _name; | ||
} | ||
|
||
/// @notice The token's symbol. | ||
function symbol() public view virtual override returns (string memory) { | ||
return _symbol; | ||
} | ||
|
||
/// @notice The number of decimals included in the fixed point accounting of this token. | ||
/// @return The number of decimals. | ||
function decimals() public view override(ERC20, IJBToken) returns (uint8) { | ||
|
@@ -35,18 +55,7 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken { | |
// -------------------------- constructor ---------------------------- // | ||
//*********************************************************************// | ||
|
||
/// @param name The name of the token. | ||
/// @param symbol The symbol that the token should be represented by. | ||
/// @param owner The owner of the token. | ||
constructor( | ||
string memory name, | ||
string memory symbol, | ||
address owner | ||
) | ||
ERC20(name, symbol) | ||
ERC20Permit(name) | ||
Ownable(owner) | ||
{} | ||
constructor() Ownable(address(this)) ERC20("", "") ERC20Permit("JBToken") {} | ||
|
||
//*********************************************************************// | ||
// ---------------------- external transactions ---------------------- // | ||
|
@@ -68,6 +77,25 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken { | |
return _burn(account, amount); | ||
} | ||
|
||
//*********************************************************************// | ||
// ----------------------- public transactions ----------------------- // | ||
//*********************************************************************// | ||
|
||
/// @notice Initialized the token. | ||
/// @param name_ The name of the token. | ||
/// @param symbol_ The symbol that the token should be represented by. | ||
/// @param owner The owner of the token. | ||
function initialize(string memory name_, string memory symbol_, address owner) public override { | ||
// Stop re-initialization. | ||
if (this.owner() != address(0) || owner == address(0)) revert(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the owner calls Ownable::renounceOwnership(), then anyone can re-initialise it - rn it's ok as it should always be JBTokens the owner, but isn't a bit smelly for the long run? Why not just checking if the name/symbol are already set instead (there is no "clearNameAndSymbol()") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! |
||
|
||
_name = name_; | ||
_symbol = symbol_; | ||
|
||
// Transfer ownership to the initializer. | ||
_transferOwnership(owner); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of transferring to an external owner besides JBTokens? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. none ever. should always be JBTokens, but JBTokens will always send itself. |
||
} | ||
|
||
/// @notice required override. | ||
function nonces(address owner) public view virtual override(ERC20Permit, Nonces) returns (uint256) { | ||
return super.nonces(owner); | ||
|
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.
Shouldn't we do something like
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.
srry, projectId is removed!!
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.
Perhaps if we use DrG suggestion about using the name and/or symbol as a stop for re-initialization we can do
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 hadn't pushed up my local commits... @xBA5ED review the latest and lets see if this still makes sense. we use name, but just check for empty string.