Skip to content

Commit

Permalink
Add ability to change contract name symbol for erc20 721
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk authored and acrylix committed Nov 9, 2023
1 parent 04c968c commit 91e70f4
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tokens/ERC20/ERC20Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ error InvalidInitialization();
*/
abstract contract ERC20Token is ERC20, AccessControl {

string private _tokenName;
string private _tokenSymbol;
string internal _tokenName;
string internal _tokenSymbol;
uint8 private _tokenDecimals;

address private immutable _initializer;
Expand Down
14 changes: 14 additions & 0 deletions src/tokens/ERC20/presets/minter/ERC20TokenMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ contract ERC20TokenMinter is ERC20Token, IERC20TokenMinter {
_mint(to, amount);
}

//
// Admin
//

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(DEFAULT_ADMIN_ROLE) {
_tokenName = tokenName;
_tokenSymbol = tokenSymbol;
}

//
// Views
//
Expand Down
7 changes: 7 additions & 0 deletions src/tokens/ERC20/presets/minter/IERC20TokenMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ interface IERC20TokenMinterFunctions {
* @param amount Amount of tokens to mint.
*/
function mint(address to, uint256 amount) external;

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
}

interface IERC20TokenMinterSignals {
Expand Down
4 changes: 2 additions & 2 deletions src/tokens/ERC721/ERC721Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract contract ERC721Token is ERC721AQueryable, ERC2981Controlled {
bytes32 public constant METADATA_ADMIN_ROLE = keccak256("METADATA_ADMIN_ROLE");

string private _tokenBaseURI;
string private _tokenName;
string private _tokenSymbol;
string internal _tokenName;
string internal _tokenSymbol;

address private immutable _initializer;
bool private _initialized;
Expand Down
14 changes: 14 additions & 0 deletions src/tokens/ERC721/presets/minter/ERC721TokenMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,18 @@ contract ERC721TokenMinter is ERC721Token, IERC721TokenMinter {
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
_mint(to, amount);
}

//
// Admin
//

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(METADATA_ADMIN_ROLE) {
_tokenName = tokenName;
_tokenSymbol = tokenSymbol;
}
}
9 changes: 7 additions & 2 deletions src/tokens/ERC721/presets/minter/IERC721TokenMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
pragma solidity ^0.8.17;

interface IERC721TokenMinterFunctions {

/**
* Mint tokens.
* @param to Address to mint tokens to.
* @param amount Amount of tokens to mint.
*/
function mint(address to, uint256 amount) external;

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
}

interface IERC721TokenMinterSignals {

/**
* Invalid initialization error.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/tokens/ERC721/presets/sale/ERC721Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ contract ERC721Sale is IERC721Sale, ERC721Token, WithdrawControlled, MerkleProof
emit SaleDetailsUpdated(supplyCap, cost, paymentToken, startTime, endTime, merkleRoot);
}

//
// Admin
//

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(METADATA_ADMIN_ROLE) {
_tokenName = tokenName;
_tokenSymbol = tokenSymbol;
}

//
// Views
//
Expand Down
7 changes: 7 additions & 0 deletions src/tokens/ERC721/presets/sale/IERC721Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ interface IERC721SaleFunctions {
* @return Sale details.
*/
function saleDetails() external view returns (SaleDetails memory);

/**
* Set name and symbol of token.
* @param tokenName Name of token.
* @param tokenSymbol Symbol of token.
*/
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
}

interface IERC721SaleSignals {
Expand Down

0 comments on commit 91e70f4

Please sign in to comment.