@@ -22,7 +22,6 @@ contract TokenManager is IProtocolHandler {
2222 struct TokenInfo {
2323 address tokenContract;
2424 bytes32 deployTxHash;
25- string protocol;
2625 string tick;
2726 uint256 maxSupply;
2827 uint256 mintAmount;
@@ -133,14 +132,41 @@ contract TokenManager is IProtocolHandler {
133132 // Revert if token already exists
134133 if (token.deployTxHash != bytes32 (0 )) revert TokenAlreadyDeployed ();
135134
136- _deployToken (
137- txHash,
138- tickKey,
139- protocolName (),
140- deployOp.tick,
141- deployOp.maxSupply,
142- deployOp.mintAmount
135+ // Validate deployment parameters
136+ if (deployOp.maxSupply == 0 ) revert InvalidMaxSupply ();
137+ if (deployOp.mintAmount == 0 ) revert InvalidMintAmount ();
138+ if (deployOp.maxSupply % deployOp.mintAmount != 0 ) revert MaxSupplyNotDivisibleByMintAmount ();
139+
140+ // Deploy ERC20 clone with CREATE2 using tickKey as salt for deterministic address
141+ address tokenAddress = erc20Template.cloneDeterministic (tickKey);
142+
143+ // Initialize the clone
144+ string memory name = string .concat (protocolName (), " " , deployOp.tick);
145+ string memory symbol = LibString.upper (deployOp.tick);
146+
147+ // Initialize with max supply in 18 decimals
148+ // User maxSupply "1000000" means 1000000 * 10^18 smallest units
149+ EthscriptionsERC20 (tokenAddress).initialize (
150+ name,
151+ symbol,
152+ deployOp.maxSupply * 10 ** 18 ,
153+ txHash
143154 );
155+
156+ // Store token info
157+ tokensByTick[tickKey] = TokenInfo ({
158+ tokenContract: tokenAddress,
159+ deployTxHash: txHash,
160+ tick: deployOp.tick,
161+ maxSupply: deployOp.maxSupply,
162+ mintAmount: deployOp.mintAmount,
163+ totalMinted: 0
164+ });
165+
166+ // Map deploy hash to tick key for lookups
167+ deployToTick[txHash] = tickKey;
168+
169+ emit TokenDeployed (txHash, tokenAddress, deployOp.tick, deployOp.maxSupply, deployOp.mintAmount);
144170 }
145171
146172 /// @notice Handle mint operation
@@ -302,56 +328,4 @@ contract TokenManager is IProtocolHandler {
302328 // Use the protocol name from this handler
303329 return keccak256 (abi.encode ("erc-20 " , tick));
304330 }
305-
306- /// @notice Deploy a new token
307- /// @param deployTxHash The deployment transaction hash
308- /// @param tickKey The tick key for storage
309- /// @param protocol The protocol name
310- /// @param tick The token tick symbol
311- /// @param maxSupply The maximum supply (in user units)
312- /// @param mintAmount The amount per mint (in user units)
313- function _deployToken (
314- bytes32 deployTxHash ,
315- bytes32 tickKey ,
316- string memory protocol ,
317- string memory tick ,
318- uint256 maxSupply ,
319- uint256 mintAmount
320- ) private {
321- if (maxSupply == 0 ) revert InvalidMaxSupply ();
322- if (mintAmount == 0 ) revert InvalidMintAmount ();
323- if (maxSupply % mintAmount != 0 ) revert MaxSupplyNotDivisibleByMintAmount ();
324-
325- // Deploy ERC20 clone with CREATE2 using tickKey as salt for deterministic address
326- address tokenAddress = erc20Template.cloneDeterministic (tickKey);
327-
328- // Initialize the clone
329- string memory name = string .concat (protocol, " " , tick);
330- string memory symbol = LibString.upper (tick);
331-
332- // Initialize with max supply in 18 decimals
333- // User maxSupply "1000000" means 1000000 * 10^18 smallest units
334- EthscriptionsERC20 (tokenAddress).initialize (
335- name,
336- symbol,
337- maxSupply * 10 ** 18 ,
338- deployTxHash
339- );
340-
341- // Store token info
342- tokensByTick[tickKey] = TokenInfo ({
343- tokenContract: tokenAddress,
344- deployTxHash: deployTxHash,
345- protocol: protocol,
346- tick: tick,
347- maxSupply: maxSupply,
348- mintAmount: mintAmount,
349- totalMinted: 0
350- });
351-
352- // Map deploy hash to tick key for lookups
353- deployToTick[deployTxHash] = tickKey;
354-
355- emit TokenDeployed (deployTxHash, tokenAddress, tick, maxSupply, mintAmount);
356- }
357331}
0 commit comments