Skip to content

feat(zkgm): allow erc20 metadata update via custom authority #4276

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

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions evm/contracts/apps/ucs/03-zkgm/ZkgmERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ contract ZkgmERC20 is

struct ZkgmERC20Storage {
address minter;
string name;
string symbol;
uint8 decimals;
}

Expand Down Expand Up @@ -66,9 +68,29 @@ contract ZkgmERC20 is
__ERC20_init(_name, _symbol);
ZkgmERC20Storage storage $ = _getZkgmERC20Storage();
$.minter = _minter;
$.name = _name;
$.symbol = _symbol;
$.decimals = _decimals;
}

function name()
public
view
override(ERC20Upgradeable, IERC20Metadata)
returns (string memory)
{
return _getZkgmERC20Storage().name;
}

function symbol()
public
view
override(ERC20Upgradeable, IERC20Metadata)
returns (string memory)
{
return _getZkgmERC20Storage().symbol;
}

function decimals()
public
view
Expand All @@ -86,6 +108,17 @@ contract ZkgmERC20 is
_burn(from, amount);
}

function setMetadata(
string calldata _name,
string calldata _symbol,
uint8 _decimals
) external restricted {
ZkgmERC20Storage storage $ = _getZkgmERC20Storage();
$.name = _name;
$.symbol = _symbol;
$.decimals = _decimals;
}

modifier onlyMinter() {
if (msg.sender != _getZkgmERC20Storage().minter) {
revert ERC20Unauthorized();
Expand Down
1 change: 1 addition & 0 deletions evm/evm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ _: {
state-lens-ics23-ics23-client = "StateLensIcs23Ics23Client";
state-lens-ics23-smt-client = "StateLensIcs23SmtClient";
multicall = "Multicall";
erc20 = "ZkgmERC20";
}
)
# other various deployment scripts
Expand Down
37 changes: 36 additions & 1 deletion evm/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import "./Deployer.sol";

library LIB {
string constant MULTICALL = "lib/multicall-v2";
string constant ZKGM_ERC20 = "lib/zkgm-erc20";
string constant ZKGM_ERC20 = "lib/zkgm-erc20-v2";
}

library IBC {
Expand Down Expand Up @@ -482,6 +482,41 @@ contract DeployStateLensIcs23MptClient is UnionScript {
}
}

contract DeployZkgmERC20 is UnionScript {
using LibString for *;

address immutable deployer;
address immutable sender;

constructor() {
deployer = vm.envAddress("DEPLOYER");
sender = vm.envAddress("SENDER");
}

function getDeployer() internal view override returns (Deployer) {
return Deployer(deployer);
}

function getDeployed(
string memory salt
) internal view returns (address) {
return CREATE3.predictDeterministicAddress(
keccak256(abi.encodePacked(sender.toHexString(), "/", salt)),
deployer
);
}

function run() public {
uint256 privateKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privateKey);
ZkgmERC20 zkgmERC20 = deployZkgmERC20();
vm.stopBroadcast();

console.log("ZkgmERC20: ", address(zkgmERC20));
}
}

contract DeployUCS03 is UnionScript {
using LibString for *;

Expand Down