Skip to content

Commit 91e70f4

Browse files
ScreamingHawkacrylix
authored andcommitted
Add ability to change contract name symbol for erc20 721
1 parent 04c968c commit 91e70f4

File tree

8 files changed

+67
-6
lines changed

8 files changed

+67
-6
lines changed

src/tokens/ERC20/ERC20Token.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ error InvalidInitialization();
1313
*/
1414
abstract contract ERC20Token is ERC20, AccessControl {
1515

16-
string private _tokenName;
17-
string private _tokenSymbol;
16+
string internal _tokenName;
17+
string internal _tokenSymbol;
1818
uint8 private _tokenDecimals;
1919

2020
address private immutable _initializer;

src/tokens/ERC20/presets/minter/ERC20TokenMinter.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ contract ERC20TokenMinter is ERC20Token, IERC20TokenMinter {
5151
_mint(to, amount);
5252
}
5353

54+
//
55+
// Admin
56+
//
57+
58+
/**
59+
* Set name and symbol of token.
60+
* @param tokenName Name of token.
61+
* @param tokenSymbol Symbol of token.
62+
*/
63+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(DEFAULT_ADMIN_ROLE) {
64+
_tokenName = tokenName;
65+
_tokenSymbol = tokenSymbol;
66+
}
67+
5468
//
5569
// Views
5670
//

src/tokens/ERC20/presets/minter/IERC20TokenMinter.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ interface IERC20TokenMinterFunctions {
99
* @param amount Amount of tokens to mint.
1010
*/
1111
function mint(address to, uint256 amount) external;
12+
13+
/**
14+
* Set name and symbol of token.
15+
* @param tokenName Name of token.
16+
* @param tokenSymbol Symbol of token.
17+
*/
18+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
1219
}
1320

1421
interface IERC20TokenMinterSignals {

src/tokens/ERC721/ERC721Token.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ abstract contract ERC721Token is ERC721AQueryable, ERC2981Controlled {
1515
bytes32 public constant METADATA_ADMIN_ROLE = keccak256("METADATA_ADMIN_ROLE");
1616

1717
string private _tokenBaseURI;
18-
string private _tokenName;
19-
string private _tokenSymbol;
18+
string internal _tokenName;
19+
string internal _tokenSymbol;
2020

2121
address private immutable _initializer;
2222
bool private _initialized;

src/tokens/ERC721/presets/minter/ERC721TokenMinter.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,18 @@ contract ERC721TokenMinter is ERC721Token, IERC721TokenMinter {
5656
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
5757
_mint(to, amount);
5858
}
59+
60+
//
61+
// Admin
62+
//
63+
64+
/**
65+
* Set name and symbol of token.
66+
* @param tokenName Name of token.
67+
* @param tokenSymbol Symbol of token.
68+
*/
69+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(METADATA_ADMIN_ROLE) {
70+
_tokenName = tokenName;
71+
_tokenSymbol = tokenSymbol;
72+
}
5973
}

src/tokens/ERC721/presets/minter/IERC721TokenMinter.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
pragma solidity ^0.8.17;
33

44
interface IERC721TokenMinterFunctions {
5-
65
/**
76
* Mint tokens.
87
* @param to Address to mint tokens to.
98
* @param amount Amount of tokens to mint.
109
*/
1110
function mint(address to, uint256 amount) external;
11+
12+
/**
13+
* Set name and symbol of token.
14+
* @param tokenName Name of token.
15+
* @param tokenSymbol Symbol of token.
16+
*/
17+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
1218
}
1319

1420
interface IERC721TokenMinterSignals {
15-
1621
/**
1722
* Invalid initialization error.
1823
*/

src/tokens/ERC721/presets/sale/ERC721Sale.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ contract ERC721Sale is IERC721Sale, ERC721Token, WithdrawControlled, MerkleProof
136136
emit SaleDetailsUpdated(supplyCap, cost, paymentToken, startTime, endTime, merkleRoot);
137137
}
138138

139+
//
140+
// Admin
141+
//
142+
143+
/**
144+
* Set name and symbol of token.
145+
* @param tokenName Name of token.
146+
* @param tokenSymbol Symbol of token.
147+
*/
148+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external onlyRole(METADATA_ADMIN_ROLE) {
149+
_tokenName = tokenName;
150+
_tokenSymbol = tokenSymbol;
151+
}
152+
139153
//
140154
// Views
141155
//

src/tokens/ERC721/presets/sale/IERC721Sale.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ interface IERC721SaleFunctions {
4545
* @return Sale details.
4646
*/
4747
function saleDetails() external view returns (SaleDetails memory);
48+
49+
/**
50+
* Set name and symbol of token.
51+
* @param tokenName Name of token.
52+
* @param tokenSymbol Symbol of token.
53+
*/
54+
function setNameAndSymbol(string memory tokenName, string memory tokenSymbol) external;
4855
}
4956

5057
interface IERC721SaleSignals {

0 commit comments

Comments
 (0)