@@ -13,6 +13,10 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
1313contract EthscriptionsProver {
1414 using EnumerableSet for EnumerableSet.Bytes32Set;
1515
16+ // =============================================================
17+ // STRUCTS
18+ // =============================================================
19+
1620 /// @notice Info stored when an ethscription is queued for proving
1721 struct QueuedProof {
1822 uint256 l2BlockNumber;
@@ -21,21 +25,6 @@ contract EthscriptionsProver {
2125 uint256 l1BlockNumber;
2226 }
2327
24- /// @notice Set of all ethscription transaction hashes queued for proving
25- EnumerableSet.Bytes32Set private queuedEthscriptions;
26-
27- /// @notice Mapping from ethscription tx hash to its queued proof info
28- mapping (bytes32 => QueuedProof) private queuedProofInfo;
29-
30- /// @notice L1Block contract address for access control
31- address public constant L1_BLOCK = Predeploys.L1_BLOCK_ATTRIBUTES;
32- /// @notice L2ToL1MessagePasser predeploy address on OP Stack
33- L2ToL1MessagePasser constant L2_TO_L1_MESSAGE_PASSER =
34- L2ToL1MessagePasser (Predeploys.L2_TO_L1_MESSAGE_PASSER);
35-
36- /// @notice The Ethscriptions contract (pre-deployed at known address)
37- Ethscriptions public constant ethscriptions = Ethscriptions (Predeploys.ETHSCRIPTIONS);
38-
3928 /// @notice Struct for ethscription data proof
4029 struct EthscriptionDataProof {
4130 bytes32 ethscriptionTxHash;
@@ -51,19 +40,58 @@ contract EthscriptionsProver {
5140 uint256 l2BlockNumber;
5241 uint256 l2Timestamp;
5342 }
54-
55- /// @notice Events for tracking proofs
43+
44+ // =============================================================
45+ // CONSTANTS
46+ // =============================================================
47+
48+ /// @notice L1Block contract address for access control
49+ address constant L1_BLOCK = Predeploys.L1_BLOCK_ATTRIBUTES;
50+
51+ /// @notice L2ToL1MessagePasser predeploy address on OP Stack
52+ L2ToL1MessagePasser constant L2_TO_L1_MESSAGE_PASSER =
53+ L2ToL1MessagePasser (Predeploys.L2_TO_L1_MESSAGE_PASSER);
54+
55+ /// @notice The Ethscriptions contract (pre-deployed at known address)
56+ Ethscriptions constant ethscriptions = Ethscriptions (Predeploys.ETHSCRIPTIONS);
57+
58+ // =============================================================
59+ // STATE VARIABLES
60+ // =============================================================
61+
62+ /// @notice Set of all ethscription transaction hashes queued for proving
63+ EnumerableSet.Bytes32Set private queuedEthscriptions;
64+
65+ /// @notice Mapping from ethscription tx hash to its queued proof info
66+ mapping (bytes32 => QueuedProof) private queuedProofInfo;
67+
68+ // =============================================================
69+ // CUSTOM ERRORS
70+ // =============================================================
71+
72+ error OnlyEthscriptions ();
73+ error OnlyL1Block ();
74+
75+ // =============================================================
76+ // EVENTS
77+ // =============================================================
78+
79+ /// @notice Emitted when an ethscription data proof is sent to L1
5680 event EthscriptionDataProofSent (
5781 bytes32 indexed ethscriptionTxHash ,
5882 uint256 indexed l2BlockNumber ,
5983 uint256 l2Timestamp
6084 );
6185
86+ // =============================================================
87+ // EXTERNAL FUNCTIONS
88+ // =============================================================
89+
6290 /// @notice Queue an ethscription for proving
6391 /// @dev Only callable by the Ethscriptions contract
6492 /// @param txHash The transaction hash of the ethscription
6593 function queueEthscription (bytes32 txHash ) external virtual {
66- require (msg .sender == address (ethscriptions), " Only Ethscriptions contract can queue " );
94+ if (msg .sender != address (ethscriptions)) revert OnlyEthscriptions ( );
6795
6896 // Add to the set (deduplicates automatically)
6997 if (queuedEthscriptions.add (txHash)) {
@@ -82,7 +110,7 @@ contract EthscriptionsProver {
82110 /// @notice Flush all queued proofs
83111 /// @dev Only callable by the L1Block contract at the start of each new block
84112 function flushAllProofs () external {
85- require (msg .sender == L1_BLOCK, " Only L1Block can flush " );
113+ if (msg .sender != L1_BLOCK) revert OnlyL1Block ( );
86114
87115 uint256 count = queuedEthscriptions.length ();
88116
@@ -100,13 +128,17 @@ contract EthscriptionsProver {
100128 }
101129 }
102130
131+ // =============================================================
132+ // INTERNAL FUNCTIONS
133+ // =============================================================
134+
103135 /// @notice Internal function to create and send proof for an ethscription
104136 /// @param ethscriptionTxHash The transaction hash of the ethscription
105137 /// @param proofInfo The queued proof info containing block data
106138 function _createAndSendProof (bytes32 ethscriptionTxHash , QueuedProof memory proofInfo ) internal {
107139 // Get ethscription data including previous owner
108140 Ethscriptions.Ethscription memory etsc = ethscriptions.getEthscription (ethscriptionTxHash);
109- address currentOwner = ethscriptions.currentOwner (ethscriptionTxHash);
141+ address currentOwner = ethscriptions.ownerOf (ethscriptionTxHash);
110142
111143 // Create proof struct with all ethscription data
112144 EthscriptionDataProof memory proof = EthscriptionDataProof ({
@@ -130,5 +162,4 @@ contract EthscriptionsProver {
130162
131163 emit EthscriptionDataProofSent (ethscriptionTxHash, proofInfo.l2BlockNumber, proofInfo.l2BlockTimestamp);
132164 }
133-
134165}
0 commit comments