Skip to content

Commit 8bad5af

Browse files
feat(zkgm): allow erc20 metadata update via custom authority
1 parent 320e4bb commit 8bad5af

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

evm/contracts/apps/ucs/03-zkgm/ZkgmERC20.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ contract ZkgmERC20 is
2626

2727
struct ZkgmERC20Storage {
2828
address minter;
29+
string name;
30+
string symbol;
2931
uint8 decimals;
3032
}
3133

@@ -66,9 +68,29 @@ contract ZkgmERC20 is
6668
__ERC20_init(_name, _symbol);
6769
ZkgmERC20Storage storage $ = _getZkgmERC20Storage();
6870
$.minter = _minter;
71+
$.name = _name;
72+
$.symbol = _symbol;
6973
$.decimals = _decimals;
7074
}
7175

76+
function name()
77+
public
78+
view
79+
override(ERC20Upgradeable, IERC20Metadata)
80+
returns (string memory)
81+
{
82+
return _getZkgmERC20Storage().name;
83+
}
84+
85+
function symbol()
86+
public
87+
view
88+
override(ERC20Upgradeable, IERC20Metadata)
89+
returns (string memory)
90+
{
91+
return _getZkgmERC20Storage().symbol;
92+
}
93+
7294
function decimals()
7395
public
7496
view
@@ -86,6 +108,17 @@ contract ZkgmERC20 is
86108
_burn(from, amount);
87109
}
88110

111+
function setMetadata(
112+
string calldata _name,
113+
string calldata _symbol,
114+
uint8 _decimals
115+
) external restricted {
116+
ZkgmERC20Storage storage $ = _getZkgmERC20Storage();
117+
$.name = _name;
118+
$.symbol = _symbol;
119+
$.decimals = _decimals;
120+
}
121+
89122
modifier onlyMinter() {
90123
if (msg.sender != _getZkgmERC20Storage().minter) {
91124
revert ERC20Unauthorized();

evm/scripts/Deploy.s.sol

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import "./Deployer.sol";
2727

2828
library LIB {
2929
string constant MULTICALL = "lib/multicall-v2";
30-
string constant ZKGM_ERC20 = "lib/zkgm-erc20";
30+
string constant ZKGM_ERC20 = "lib/zkgm-erc20-v2";
3131
}
3232

3333
library IBC {
@@ -482,6 +482,41 @@ contract DeployStateLensIcs23MptClient is UnionScript {
482482
}
483483
}
484484

485+
contract DeployZkgmERC20 is UnionScript {
486+
using LibString for *;
487+
488+
address immutable deployer;
489+
address immutable sender;
490+
491+
constructor() {
492+
deployer = vm.envAddress("DEPLOYER");
493+
sender = vm.envAddress("SENDER");
494+
}
495+
496+
function getDeployer() internal view override returns (Deployer) {
497+
return Deployer(deployer);
498+
}
499+
500+
function getDeployed(
501+
string memory salt
502+
) internal view returns (address) {
503+
return CREATE3.predictDeterministicAddress(
504+
keccak256(abi.encodePacked(sender.toHexString(), "/", salt)),
505+
deployer
506+
);
507+
}
508+
509+
function run() public {
510+
uint256 privateKey = vm.envUint("PRIVATE_KEY");
511+
512+
vm.startBroadcast(privateKey);
513+
ZkgmERC20 zkgmERC20 = deployZkgmERC20();
514+
vm.stopBroadcast();
515+
516+
console.log("ZkgmERC20: ", address(zkgmERC20));
517+
}
518+
}
519+
485520
contract DeployUCS03 is UnionScript {
486521
using LibString for *;
487522

0 commit comments

Comments
 (0)