@@ -23,25 +23,24 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
2323 // STRUCTS
2424 // =============================================================
2525
26- struct ContentInfo {
27- bytes32 contentUriHash; // SHA256 of raw content URI string (for protocol uniqueness)
28- bytes32 contentSha; // SHA256 of decoded raw bytes (for storage reference)
29- string mimetype; // Full MIME type (e.g., "text/plain")
30- string mediaType; // e.g., "text", "image"
31- string mimeSubtype; // e.g., "plain", "png"
32- bool esip6;
33- }
34-
3526 struct Ethscription {
36- ContentInfo content;
27+ // Full slots
28+ bytes32 contentUriHash;
29+ bytes32 contentSha;
30+ bytes32 l1BlockHash;
31+ // Packed slot (32 bytes)
3732 address creator;
33+ uint48 createdAt;
34+ uint48 l1BlockNumber;
35+ // Dynamic
36+ string mimetype;
37+ // Packed slot (27 bytes used, 5 free)
3838 address initialOwner;
39+ uint48 ethscriptionNumber;
40+ bool esip6;
41+ // Packed slot (26 bytes used, 6 free)
3942 address previousOwner;
40- uint256 ethscriptionNumber;
41- uint256 createdAt; // Timestamp when created
42- uint64 l1BlockNumber; // L1 block number when created
43- uint64 l2BlockNumber; // L2 block number when created
44- bytes32 l1BlockHash; // L1 block hash when created
43+ uint48 l2BlockNumber;
4544 }
4645
4746 struct ProtocolParams {
@@ -56,8 +55,6 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
5655 address initialOwner;
5756 bytes content; // Raw decoded bytes (not Base64)
5857 string mimetype;
59- string mediaType;
60- string mimeSubtype;
6158 bool esip6;
6259 ProtocolParams protocolParams; // Protocol operation data (optional)
6360 }
@@ -216,22 +213,18 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
216213 bytes32 contentSha = _storeContent (params.content);
217214
218215 ethscriptions[params.transactionHash] = Ethscription ({
219- content: ContentInfo ({
220- contentUriHash: params.contentUriHash,
221- contentSha: contentSha,
222- mimetype: params.mimetype,
223- mediaType: params.mediaType,
224- mimeSubtype: params.mimeSubtype,
225- esip6: params.esip6
226- }),
216+ contentUriHash: params.contentUriHash,
217+ contentSha: contentSha,
218+ l1BlockHash: l1Block.hash (),
227219 creator: creator,
220+ createdAt: uint48 (block .timestamp ),
221+ l1BlockNumber: uint48 (l1Block.number ()),
222+ mimetype: params.mimetype,
228223 initialOwner: params.initialOwner,
229- previousOwner: creator, // Initially same as creator
230- ethscriptionNumber: totalSupply (),
231- createdAt: block .timestamp ,
232- l1BlockNumber: l1Block.number (),
233- l2BlockNumber: uint64 (block .number ),
234- l1BlockHash: l1Block.hash ()
224+ ethscriptionNumber: uint48 (totalSupply ()),
225+ esip6: params.esip6,
226+ previousOwner: creator,
227+ l2BlockNumber: uint48 (block .number )
235228 });
236229
237230 // Use ethscription number as token ID
@@ -377,7 +370,7 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
377370 /// @notice Get content for an ethscription
378371 function getEthscriptionContent (bytes32 txHash ) public view requireExists (txHash) returns (bytes memory ) {
379372 Ethscription storage etsc = ethscriptions[txHash];
380- address [] storage pointers = contentPointersBySha[etsc.content. contentSha];
373+ address [] storage pointers = contentPointersBySha[etsc.contentSha];
381374 // Empty content is valid - returns "" for empty pointers array
382375 return pointers.read ();
383376 }
@@ -388,7 +381,7 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
388381 /// @return content The content bytes
389382 function getEthscriptionWithContent (bytes32 txHash ) external view requireExists (txHash) returns (Ethscription memory ethscription , bytes memory content ) {
390383 ethscription = ethscriptions[txHash];
391- address [] storage pointers = contentPointersBySha[ethscription.content. contentSha];
384+ address [] storage pointers = contentPointersBySha[ethscription.contentSha];
392385 // Empty content is valid - returns "" for empty pointers array
393386 content = pointers.read ();
394387 }
@@ -620,8 +613,8 @@ contract Ethscriptions is ERC721EthscriptionsUpgradeable {
620613 txHash,
621614 etsc.creator,
622615 etsc.initialOwner,
623- etsc.content. contentUriHash,
624- etsc.content. contentSha,
616+ etsc.contentUriHash,
617+ etsc.contentSha,
625618 etsc.ethscriptionNumber
626619 );
627620 }
0 commit comments